function advpoll_voting_binary_form_submit in Advanced Poll 5
Same name and namespace in other branches
- 6.3 modes/binary.inc \advpoll_voting_binary_form_submit()
- 6 modes/binary.inc \advpoll_voting_binary_form_submit()
- 6.2 modes/binary.inc \advpoll_voting_binary_form_submit()
Registers the vote as a key for this node using votingapi_set_vote().
File
- modes/
binary.inc, line 172
Code
function advpoll_voting_binary_form_submit($form_id, $form_values) {
$votes = array();
$node = node_load($form_values['nid']);
// Do submission specific to writeins.
_advpoll_writeins_voting_form_submit($node, $form_values, $votes, 1);
if ($node->max_choices == 1) {
// Plurality voting
// Ignore write-in choice that has already been taken care of.
if (!$node->writeins || !$form_values['choice'][$form_values['writein_key']]) {
$vote->value = 1;
$vote->tag = $form_values['choice'];
$vote->value_type = 'option';
$votes[] = $vote;
}
}
else {
// Approval voting
foreach ($form_values['choice'] as $choice => $selected) {
$vote = new stdClass();
// Ignore write-in choice that has already been taken care of.
if (!$node->writeins || $choice != $form_values['writein_key']) {
$vote->value = $choice;
if ($selected) {
$vote->value_type = 'option';
$vote->tag = $choice;
$vote->value = 1;
$votes[] = $vote;
}
}
}
}
votingapi_set_vote('advpoll', $form_values['nid'], $votes);
_advpoll_vote_response($node, $form_values);
}