You are here

function poll_cancel in Drupal 6

Same name and namespace in other branches
  1. 5 modules/poll/poll.module \poll_cancel()
  2. 7 modules/poll/poll.module \poll_cancel()

Submit callback for poll_cancel_form

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

File

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);
}