You are here

function user_admin_edit_role_submit in Drupal 4

File

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

Code

function user_admin_edit_role_submit($form_id, $form_values) {
  $op = isset($_POST['op']) ? $_POST['op'] : '';
  if ($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 ($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.'));
    }
  }
  return 'admin/access/roles';
}