function user_admin_role_validate in Drupal 5
Same name and namespace in other branches
- 6 modules/user/user.admin.inc \user_admin_role_validate()
- 7 modules/user/user.admin.inc \user_admin_role_validate()
File
- modules/
user/ user.module, line 1977 - Enables the user registration and login system.
Code
function user_admin_role_validate($form_id, $form_values) {
if ($form_values['name']) {
if ($form_values['op'] == t('Save role')) {
if (db_result(db_query("SELECT COUNT(*) FROM {role} WHERE name = '%s' AND rid != %d", $form_values['name'], $form_values['rid']))) {
form_set_error('name', t('The role name %name already exists. Please choose another role name.', array(
'%name' => $form_values['name'],
)));
}
}
else {
if ($form_values['op'] == t('Add role')) {
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('name', t('You must specify a valid role name.'));
}
}