function advpoll_clear_votes_confirm_form_submit in Advanced Poll 6
Same name and namespace in other branches
- 6.3 advpoll.module \advpoll_clear_votes_confirm_form_submit()
- 6.2 advpoll.module \advpoll_clear_votes_confirm_form_submit()
- 7.3 includes/advpoll.pages.inc \advpoll_clear_votes_confirm_form_submit()
- 7 includes/advpoll.pages.inc \advpoll_clear_votes_confirm_form_submit()
- 7.2 includes/advpoll.pages.inc \advpoll_clear_votes_confirm_form_submit()
Process advpoll_clear_votes_confirm form submissions.
Update the choices added or removed when editing a node Clear all votes once the confirmation is given.
File
- ./
advpoll.module, line 1172 - Advanced Poll - a sophisticated polling module for voting, elections, and group decision-making.
Code
function advpoll_clear_votes_confirm_form_submit($form, &$form_state) {
if ($form_state['values']['confirm']) {
$nid = $form['#nid'];
if ($node = node_load($nid)) {
// Delete any votes for the poll.
db_query("DELETE FROM {votingapi_vote} WHERE content_type = 'advpoll' AND content_id = %d", $node->nid);
// Delete any write-in choices.
db_query('DELETE FROM {advpoll_choices} WHERE writein = 1 AND nid = %d', $node->nid);
votingapi_recalculate_results('advpoll', $node->nid);
drupal_set_message(t('Votes have been cleared.'));
watchdog('content', 'Cleared all poll votes (%num_votes).', array(
'%num_votes' => $node->votes,
), WATCHDOG_NOTICE, l(t('view'), 'node/' . $node->nid));
}
$form_state['redirect'] = 'node/' . $node->nid;
}
}