You are here

function advpoll_ranking_cancel_vote_submit in Advanced Poll 7.3

Submit function for cancelling a vote.

1 string reference to 'advpoll_ranking_cancel_vote_submit'
advpoll_ranking_cancel_form in advpoll_ranking/advpoll_ranking.module
Form element for canceling votes.

File

advpoll_ranking/advpoll_ranking.module, line 900

Code

function advpoll_ranking_cancel_vote_submit($form, &$form_state) {
  global $user;
  if ($user->uid) {
    $nid = $form['#nid'];
    $criteria = array();
    $criteria['entity_id'] = $nid;
    $criteria['entity_type'] = 'node';
    $criteria['uid'] = $user->uid;
    votingapi_delete_votes(votingapi_select_votes($criteria));
    $node = node_load($nid);
    if (advpoll_user_eligibility($node)) {

      // print out voting form
      $data = advpoll_get_data($node);
      if ($data->behavior == 'borda' || $data->behavior == 'runoff') {
        $update_form = drupal_get_form('advpoll_ranking_choice_form', $data, $node);
      }
      else {
        $update_form = drupal_get_form('advpoll_draggable_form', $data, $node);
      }
      return drupal_render($update_form);
    }
  }
  return '';
}