Commit 9aac2d98 authored by Dries's avatar Dries

- Bug #14609: improved the status messages and avoid empty roles being saved.

parent f9c685b6
......@@ -1455,7 +1455,13 @@ function user_admin_role($edit = array()) {
$id = arg(4);
if ($op == t('Save role')) {
db_query("UPDATE {role} SET name = '%s' WHERE rid = %d", $edit['name'], $id);
if ($edit['name']) {
db_query("UPDATE {role} SET name = '%s' WHERE rid = %d", $edit['name'], $id);
drupal_set_message(t('The changes have been saved.'));
}
else {
form_set_error('name', t('You must specify a valid role name.'));
}
}
else if ($op == t('Delete role')) {
db_query('DELETE FROM {role} WHERE rid = %d', $id);
......@@ -1475,9 +1481,17 @@ function user_admin_role($edit = array()) {
// Users with only the deleted role are put back in the authenticated users pool.
db_query('UPDATE {users_roles} SET rid = %d WHERE rid = %d', _user_authenticated_id(), $id);
drupal_set_message(t('The role has been deleted.'));
}
else if ($op == t('Add role')) {
db_query("INSERT INTO {role} (name) VALUES ('%s')", $edit['name']);
if ($edit['name']) {
db_query("INSERT INTO {role} (name) VALUES ('%s')", $edit['name']);
drupal_set_message(t('The role has been added.'));
}
else {
form_set_error('name', t('You must specify a valid role name.'));
}
}
else if ($id) {
// Display the role form.
......@@ -1566,7 +1580,6 @@ function user_configure() {
case t('Add role'):
case t('Delete role'):
case t('Save role'):
drupal_set_message(t('Your role changes were saved.'));
case 'role':
$output = user_admin_role($edit);
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment