You are here

function permissions_by_term_validate in Permissions by Term 7

Same name and namespace in other branches
  1. 8.2 permissions_by_term.module \permissions_by_term_validate()
  2. 8 permissions_by_term.module \permissions_by_term_validate()

Validation handler for permissions_by_term_form_alter().

1 string reference to 'permissions_by_term_validate'
permissions_by_term_form_taxonomy_form_term_alter in ./permissions_by_term.module
Implements hook_form_FORM_ID_alter().

File

./permissions_by_term.module, line 209
Allows access to terms in a vocabulary to be limited by user or role.

Code

function permissions_by_term_validate($form, &$form_state) {
  if (!empty($form_state['values']['access']['user'])) {
    $allowed_users = drupal_explode_tags($form_state['values']['access']['user']);
    foreach ($allowed_users as $name) {
      $user = db_query("SELECT u.name FROM {users} u WHERE u.name = :uname", array(
        ':uname' => $name,
      ))
        ->fetchCol();
      if (empty($user)) {
        form_set_error('access][user', t('The user %user_name does not exist.', array(
          '%user_name' => $name,
        )));
      }
    }
  }
}