You are here

function user_admin_role_validate in Drupal 6

Same name and namespace in other branches
  1. 5 modules/user/user.module \user_admin_role_validate()
  2. 7 modules/user/user.admin.inc \user_admin_role_validate()
1 string reference to 'user_admin_role_validate'
user_admin_role in modules/user/user.admin.inc
Menu callback: administer roles.

File

modules/user/user.admin.inc, line 683
Admin page callback file for the user module.

Code

function user_admin_role_validate($form, &$form_state) {
  if ($form_state['values']['name']) {
    if ($form_state['values']['op'] == t('Save role')) {
      if (db_result(db_query("SELECT COUNT(*) FROM {role} WHERE name = '%s' AND rid != %d", $form_state['values']['name'], $form_state['values']['rid']))) {
        form_set_error('name', t('The role name %name already exists. Please choose another role name.', array(
          '%name' => $form_state['values']['name'],
        )));
      }
    }
    else {
      if ($form_state['values']['op'] == t('Add role')) {
        if (db_result(db_query("SELECT COUNT(*) FROM {role} WHERE name = '%s'", $form_state['values']['name']))) {
          form_set_error('name', t('The role name %name already exists. Please choose another role name.', array(
            '%name' => $form_state['values']['name'],
          )));
        }
      }
    }
  }
  else {
    form_set_error('name', t('You must specify a valid role name.'));
  }
}