You are here

function advpoll_electoral_list_form_validate in Advanced Poll 6.2

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

Validate changes to the electoral list.

File

./advpoll.module, line 953
Advanced Poll - a sophisticated polling module for voting, elections, and group decision-making.

Code

function advpoll_electoral_list_form_validate($form, &$form_state) {
  if ($form_state['values']['op'] == t('Clear electoral list')) {
    if (user_access('administer polls')) {
      db_query('DELETE FROM {advpoll_electoral_list} WHERE nid = %d', $form_state['values']['nid']);
      drupal_set_message(t('Electoral list cleared.'));
      return;
    }
  }
  $add_user = $form_state['values']['electoral_list']['add_user'];
  if ($add_user) {

    // Check that the user exists
    $result = db_query("SELECT uid FROM {users} WHERE name = '%s'", $add_user);
    if (!db_fetch_object($result)) {
      form_set_error('electoral_list][add_user', t('User %user does not exist.', array(
        '%user' => $add_user,
      )));
      return FALSE;
    }
  }
}