poll_cancel

Versions
5
poll_cancel(&$node)
6 – 7
poll_cancel($form, &$form_state)

Submit callback for poll_cancel_form().

Code

modules/poll/poll.module, line 869

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

  db_delete('poll_vote')
    ->condition('nid', $node->nid)
    ->condition($user->uid ? 'uid' : 'hostname', $user->uid ? $user->uid : ip_address())
    ->execute();

  // Subtract from the votes.
  db_update('poll_choice')
    ->expression('chvotes', 'chvotes - 1')
    ->condition('chid', $node->vote)
    ->execute();

  drupal_set_message(t('Your vote was cancelled.'));
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.