function poll_cancel

Same name and namespace in other branches
  1. 7.x drupal-7.x/modules/poll/poll.module \poll_cancel()

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.

Archivo

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.

Código

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