You are here

function advpoll_reset_confirm_submit in Advanced Poll 5

Reset votes once the confirmation is given.

File

./advpoll.module, line 1237
Advanced Poll - a sophisticated polling module for voting, elections, and group decision-making.

Code

function advpoll_reset_confirm_submit($form_id, $form_values) {
  if ($form_values['confirm']) {
    $nid = arg(1);
    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 reset.'));
      drupal_goto('node/' . $node->nid);
    }
  }
  return '';
}