function advpoll_voting_ranking_form_submit in Advanced Poll 6.2
Same name and namespace in other branches
- 5 modes/ranking.inc \advpoll_voting_ranking_form_submit()
- 6.3 modes/ranking.inc \advpoll_voting_ranking_form_submit()
- 6 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 697 - Handle ranking votes, e.g. choice A is preferred over choice B, which in turn is preferred over choice C.
Code
function advpoll_voting_ranking_form_submit($form, &$form_state) {
$votes = array();
$node = $form['#node'];
// Do submission specific to writeins.
if (isset($form_state['values']['writein_key'])) {
_advpoll_writeins_voting_form_submit($node, $form_state, $votes, $form_state['values']['choice'][$form_state['values']['writein_key']]);
}
foreach ($form_state['values']['choice'] as $choice => $rank) {
$vote = array();
// Ignore write-in choice that has already been taken care of.
if (!$node->writeins || !isset($form_state['values']['writein_key']) || $choice != $form_state['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;
$vote['content_type'] = 'advpoll';
$vote['content_id'] = $node->nid;
$votes[] = $vote;
}
}
}
votingapi_set_votes($votes, array());
_advpoll_vote_response($node, $form_state);
}