function advpoll_electoral_list_form_validate in Advanced Poll 7.3
Same name and namespace in other branches
- 5 advpoll.module \advpoll_electoral_list_form_validate()
- 6.3 advpoll.module \advpoll_electoral_list_form_validate()
- 6 advpoll.module \advpoll_electoral_list_form_validate()
- 6.2 advpoll.module \advpoll_electoral_list_form_validate()
- 7 includes/advpoll.pages.inc \advpoll_electoral_list_form_validate()
- 7.2 includes/advpoll.pages.inc \advpoll_electoral_list_form_validate()
Validate changes to the electoral list.
File
- includes/
advpoll.pages.inc, line 363 - Advanced Poll Pages Include.
Code
function advpoll_electoral_list_form_validate($form, &$form_state) {
if ($form_state['values']['op'] == t('Clear electoral list')) {
if (user_access('administer polls')) {
$nid = $form_state['values']['nid'];
$items_deleted = db_delete('advpoll_electoral_list')
->condition('nid', $nid)
->execute();
drupal_set_message(t('@items cleared from the Electoral list.', array(
'@items' => $items_deleted,
)));
return;
}
}
$add_user = $form_state['values']['electoral_list']['add_user'];
if ($add_user) {
// Check that the user exists.
$result = db_query("\n SELECT uid\n FROM {users}\n WHERE name = :name\n ", array(
':name' => $add_user,
));
if (!$result) {
form_set_error('electoral_list][add_user', t('User %user does not exist.', array(
'%user' => $add_user,
)));
return FALSE;
}
}
}