diff --git 546518_advpoll_resultaccess.patch 546518_advpoll_resultaccess.patch index 6ff6397..38a5403 100644 --- advpoll.module +++ advpoll.module @@ -639,6 +639,13 @@ function advpoll_form_alter(&$form, $form_state, $form_id) { '#description' => t('Use a dedicated question field instead of a combined question and title field. It is recommended to rename Title field label above to "Title" if this is checked.'), '#default_value' => variable_get('advpoll_use_question_'. $node_type, ADVPOLL_USE_QUESTION), ); + $form['advpoll']['advpoll_redirect'] = array( + '#type' => 'select', + '#title' => t('Redirect after vote submission'), + '#default_value' => variable_get('advpoll_redirect_'. $node_type, 'node'), + '#options' => array('node'=>'Poll','current'=>'Current Page'), + '#description' => t('The date the poll was created is used as start date for the default duration. This setting can be overridden on the poll edit page.'), + ); } } } @@ -1124,7 +1131,8 @@ function advpoll_votes_page($node) { */ function _advpoll_can_view_results($node) { $view_results = variable_get('advpoll_view_results_'. $node->type, ADVPOLL_VIEW_RESULTS); - return user_access() || (!_advpoll_is_active($node) // Node is closed + return (user_access('inspect all votes') && !$node->voted) + || (!_advpoll_is_active($node) // Node is closed || ($node->voted && $view_results == 'aftervote') // User voted || ($view_results == 'always')); // All can view } @@ -1133,7 +1141,7 @@ function _advpoll_can_view_results($node) { * Helper function to display 'cancel vote' button if user has voted. */ function advpoll_cancel_form(&$form_state, $nid) { - $form['#action'] = url('advpoll/cancel/'. $nid); + $form['#action'] = url('advpoll/cancel/'. $nid, array('query'=>drupal_get_destination())); $form['submit'] = array('#type' => 'submit', '#value' => t('Cancel your vote')); return $form; } @@ -1418,7 +1426,21 @@ function advpoll_cancel($node) { else { drupal_set_message(t('You are not allowed to cancel an invalid choice.'), 'error'); } - drupal_goto('node/'. $node->nid); + $redirect =variable_get('advpoll_redirect_'. $node->type, 'node'); + switch($redirect) { + case 'none': + break; + case 'current': + if (isset($_REQUEST['destination'])) { + $path = url($_REQUEST['destination']); + } + break; + default: + $path = url('node/'. $node->nid); + break; + } + drupal_set_message($path); + drupal_goto($path); } /** diff --git modes/binary.inc modes/binary.inc index 054d4d5..4d2b9b7 100644 --- modes/binary.inc +++ modes/binary.inc @@ -119,9 +119,17 @@ function advpoll_voting_binary_form(&$form_state, $node, $teaser, $page, $status $login_message = t('Login to vote in this poll.', array('@login' => url('user/login', array('query' => drupal_get_destination())))); $form['message']['#value'] = isset($user->uid) ? t('You are not eligible to vote in this poll.') : $login_message; } - - $form['#action'] = url('node/'. $node->nid); - + $redirect =variable_get('advpoll_redirect_'. $node->type, 'node'); + switch($redirect) { + case 'none': + break; + case 'current': + $path = isset($_GET['q']) ? $_GET['q'] : ''; + break; + default: + $form['#action'] = url('node/'. $node->nid); + break; + } return $form; } diff --git modes/ranking.inc modes/ranking.inc index 0be7883..a435bad 100644 --- modes/ranking.inc +++ modes/ranking.inc @@ -155,7 +155,18 @@ function advpoll_voting_ranking_form(&$form_state, &$node, $teaser, $page, $stat $form['message']['#value'] = $user->uid ? t('You are not eligible to vote in this poll.') : $login_message; } - $form['#action'] = url('node/'. $node->nid); + $redirect =variable_get('advpoll_redirect_'. $node->type, 'node'); + switch($redirect) { + case 'none': + break; + case 'current': + $path = isset($_GET['q']) ? $_GET['q'] : ''; + break; + default: + $form['#action'] = url('node/'. $node->nid); + break; + } + // Set form caching because we could have multiple forms on the page. // (from poll.module). $form['#cache'] = TRUE;