function 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 955

Code

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();
    unset($_SESSION['poll_vote'][$node->nid]);
    drupal_set_message(t('Your vote was cancelled.'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.