diff options
author | Neil Drumm <drumm@3064.no-reply.drupal.org> | 2006-09-23 07:43:30 +0000 |
---|---|---|
committer | Neil Drumm <drumm@3064.no-reply.drupal.org> | 2006-09-23 07:43:30 +0000 |
commit | 5406c8d9da7e8f904682753757c5898ba6a16cb1 (patch) | |
tree | 082a5258fec69e1f4b3743373085bc6b7a2a1fc9 | |
parent | 931f43f2ba9fa748ad9fa6b5a9bba7d89f17497d (diff) | |
download | brdo-5406c8d9da7e8f904682753757c5898ba6a16cb1.tar.gz brdo-5406c8d9da7e8f904682753757c5898ba6a16cb1.tar.bz2 |
#83998 by erdemkose. Remove ability to cancel votes more than once.
-rw-r--r-- | modules/poll/poll.module | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/modules/poll/poll.module b/modules/poll/poll.module index ad0728c95..4a304634d 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -442,7 +442,7 @@ function theme_poll_results($title, $results, $votes, $links, $block, $nid, $vot $output .= $results; $output .= '<div class="total">'. t('Total votes: %votes', array('%votes' => $votes)) .'</div>'; if (isset($vote) && $vote > -1 && user_access('cancel own vote')) { - $output .= drupal_get_form('poll_cancel_form', $nid, $vote); + $output .= drupal_get_form('poll_cancel_form', $nid); } $output .= '</div>'; } @@ -450,9 +450,8 @@ function theme_poll_results($title, $results, $votes, $links, $block, $nid, $vot return $output; } -function poll_cancel_form($nid, $vote) { +function poll_cancel_form($nid) { $form['#action'] = url("poll/cancel/$nid"); - $form['choice'] = array('#type' => 'hidden', '#value' => $vote); $form['submit'] = array('#type' => 'submit', '#value' => t('Cancel your vote')); return $form; } @@ -565,11 +564,7 @@ function poll_cancel(&$node) { $nid = arg(2); if ($node = node_load(array('nid' => $nid))) { - $edit = $_POST; - $choice = $edit['choice']; - $cancel = $_POST['cancel']; - - if (isset($choice) && isset($node->choice[$choice])) { + if ($node->type == 'poll' && $node->allowvotes == FALSE) { if ($user->uid) { db_query('DELETE FROM {poll_votes} WHERE nid = %d and uid = %d', $node->nid, $user->uid); } @@ -578,9 +573,9 @@ function poll_cancel(&$node) { } // Subtract from the votes. - db_query("UPDATE {poll_choices} SET chvotes = chvotes - 1 WHERE nid = %d AND chorder = %d", $node->nid, $choice); + db_query("UPDATE {poll_choices} SET chvotes = chvotes - 1 WHERE nid = %d AND chorder = %d", $node->nid, $node->vote); $node->allowvotes = TRUE; - $node->choice[$choice]['chvotes']--; + $node->choice[$node->vote]['chvotes']--; drupal_set_message(t('Your vote was canceled.')); } else { |