function advpoll_voting_ranking_form_submit in Advanced Poll 5
Same name and namespace in other branches
- 6.3 modes/ranking.inc \advpoll_voting_ranking_form_submit()
- 6 modes/ranking.inc \advpoll_voting_ranking_form_submit()
- 6.2 modes/ranking.inc \advpoll_voting_ranking_form_submit()
Implementation of the vote hook for the runoff module.
This takes care of registering the vote in runoff nodes.
File
- modes/
ranking.inc, line 626
Code
function advpoll_voting_ranking_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, $form_values['choice'][$form_values['writein_key']]);
foreach ($form_values['choice'] as $choice => $rank) {
$vote = new stdClass();
// Ignore write-in choice that has already been taken care of.
if (!$node->writeins || $choice != $form_values['writein_key']) {
$vote->value = $rank;
// A zero value indicates they didn't rank that choice.
if ($vote->value != 0) {
$vote->value_type = 'option';
$vote->tag = $choice;
$votes[] = $vote;
}
}
}
votingapi_set_vote('advpoll', $form_values['nid'], $votes);
_advpoll_vote_response($node, $form_values);
}