function poll_cancel

7.x poll.module poll_cancel($form, &$form_state)
6.x poll.module poll_cancel($form, &$form_state)

Submit callback for poll_cancel_form

1 string reference to 'poll_cancel'
poll_cancel_form in drupal-6.x/modules/poll/poll.module
Builds the cancel form for a poll.

File

drupal-6.x/modules/poll/poll.module, line 759
Enables your site to capture votes on different topics in the form of multiple choice questions.

Code

function poll_cancel($form, &$form_state) {
  $node = node_load($form['#nid']);
  global $user;

  if ($user->uid) {
    db_query('DELETE FROM {poll_votes} WHERE nid = %d and uid = %d', $node->nid, $user->uid);
  }
  else {
    db_query("DELETE FROM {poll_votes} WHERE nid = %d and hostname = '%s'", $node->nid, ip_address());
  }

  // Subtract from the votes.
  db_query("UPDATE {poll_choices} SET chvotes = chvotes - 1 WHERE nid = %d AND chorder = %d", $node->nid, $node->vote);
}