You are here

function advpoll_remove_voter in Advanced Poll 7.3

Same name and namespace in other branches
  1. 5 advpoll.module \advpoll_remove_voter()
  2. 6.3 advpoll.admin.inc \advpoll_remove_voter()
  3. 6 advpoll.admin.inc \advpoll_remove_voter()
  4. 6.2 advpoll.admin.inc \advpoll_remove_voter()
  5. 7 includes/advpoll.pages.inc \advpoll_remove_voter()
  6. 7.2 includes/advpoll.pages.inc \advpoll_remove_voter()

Removes an individual voter from the electoral list.

1 string reference to 'advpoll_remove_voter'
advpoll_menu in ./advpoll.module
Implements hook_menu().

File

includes/advpoll.pages.inc, line 394
Advanced Poll Pages Include.

Code

function advpoll_remove_voter() {
  $nid = arg(1);
  $uid = arg(3);
  if (is_numeric($nid) && is_numeric($uid)) {
    if ($uid && ($node = node_load($nid))) {
      $user = db_query("\n        SELECT name\n        FROM {users}\n        WHERE uid = :uid\n      ", array(
        ':uid' => $uid,
      ))
        ->fetchField();
      if ($user) {
        db_delete('advpoll_electoral_list')
          ->condition('nid', $nid)
          ->condition('uid', $uid)
          ->execute();
        drupal_set_message(t('%user removed from the electoral list.', array(
          '%user' => $user,
        )));
      }
      else {
        drupal_set_message(t('No user found with a uid of %uid.', array(
          '%uid' => $uid,
        )));
      }
    }
  }
  drupal_goto('node/' . $node->nid . '/electoral_list');
}