You are here

function user_admin_new_role_validate in Drupal 4

File

modules/user.module, line 1920
Enables the user registration and login system.

Code

function user_admin_new_role_validate($form_id, $form_values) {
  if ($form_values['name']) {
    if (drupal_valid_token($form_values['form_token'], 'user_admin_new_role', TRUE)) {
      if (db_result(db_query("SELECT COUNT(*) FROM {role} WHERE name = '%s'", $form_values['name']))) {
        form_set_error('name', t('The role name %name already exists. Please choose another role name.', array(
          '%name' => $form_values['name'],
        )));
      }
    }
    else {
      form_set_error('form_token', t('Validation error, please try again.  If this error persists, please contact the site administrator.'));
    }
  }
  else {
    form_set_error('name', t('You must specify a valid role name.'));
  }
}