Commit 2ddb81af authored by drumm's avatar drumm

#66697 by hunmonk, simplify user role deletion.

parent a73303a8
......@@ -1824,18 +1824,8 @@ function user_admin_role() {
else if ($op == t('Delete role')) {
db_query('DELETE FROM {role} WHERE rid = %d', $id);
db_query('DELETE FROM {permission} WHERE rid = %d', $id);
// Update the users who have this role set:
$result = db_query('SELECT DISTINCT(ur1.uid) FROM {users_roles} ur1 LEFT JOIN {users_roles} ur2 ON ur2.uid = ur1.uid WHERE ur1.rid = %d AND ur2.rid != ur1.rid', $id);
$uid = array();
while ($u = db_fetch_object($result)) {
$uid[] = $u->uid;
}
if ($uid) {
db_query('DELETE FROM {users_roles} WHERE rid = %d AND uid IN (%s)', $id, implode(', ', $uid));
}
db_query('DELETE FROM {users_roles} WHERE rid = %d', $id);
drupal_set_message(t('The role has been deleted.'));
drupal_goto('admin/access/roles');
......
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