You are here

function user_admin_role_submit in Drupal 5

Same name and namespace in other branches
  1. 6 modules/user/user.admin.inc \user_admin_role_submit()
  2. 7 modules/user/user.admin.inc \user_admin_role_submit()

File

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

Code

function user_admin_role_submit($form_id, $form_values) {
  if ($form_values['op'] == t('Save role')) {
    db_query("UPDATE {role} SET name = '%s' WHERE rid = %d", $form_values['name'], $form_values['rid']);
    drupal_set_message(t('The role has been renamed.'));
  }
  else {
    if ($form_values['op'] == t('Delete role')) {
      db_query('DELETE FROM {role} WHERE rid = %d', $form_values['rid']);
      db_query('DELETE FROM {permission} WHERE rid = %d', $form_values['rid']);

      // Update the users who have this role set:
      db_query('DELETE FROM {users_roles} WHERE rid = %d', $form_values['rid']);
      drupal_set_message(t('The role has been deleted.'));
    }
    else {
      if ($form_values['op'] == t('Add role')) {
        db_query("INSERT INTO {role} (name) VALUES ('%s')", $form_values['name']);
        drupal_set_message(t('The role has been added.'));
      }
    }
  }
  return 'admin/user/roles';
}