From e06cdc577e45b7a0522f4f32ad25b598d19b510e Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Thu, 18 Dec 2003 21:33:04 +0000
Subject: [PATCH] - Fixed bug 4667: users with the deleted role are put back in
 the authenticated   users pool.

---
 modules/user.module      | 4 ++++
 modules/user/user.module | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/modules/user.module b/modules/user.module
index 5652de8692d0..55da4b6b337c 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -1328,6 +1328,10 @@ function user_admin_role($edit = array()) {
   else if ($op == t("Delete role")) {
     db_query("DELETE FROM {role} WHERE rid = %d", $id);
     db_query("DELETE FROM {permission} WHERE rid = %d", $id);
+
+    // Users with the deleted role are put back in the authenticated users pool
+    $aid = db_result(db_query("SELECT rid FROM {role} WHERE name = 'Authenticated user'"));
+    db_query("UPDATE {users} SET rid = %d WHERE rid = %d", $aid, $id);
   }
   else if ($op == t("Add role")) {
     db_query("INSERT INTO {role} (name) VALUES ('%s')", $edit["name"]);
diff --git a/modules/user/user.module b/modules/user/user.module
index 5652de8692d0..55da4b6b337c 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -1328,6 +1328,10 @@ function user_admin_role($edit = array()) {
   else if ($op == t("Delete role")) {
     db_query("DELETE FROM {role} WHERE rid = %d", $id);
     db_query("DELETE FROM {permission} WHERE rid = %d", $id);
+
+    // Users with the deleted role are put back in the authenticated users pool
+    $aid = db_result(db_query("SELECT rid FROM {role} WHERE name = 'Authenticated user'"));
+    db_query("UPDATE {users} SET rid = %d WHERE rid = %d", $aid, $id);
   }
   else if ($op == t("Add role")) {
     db_query("INSERT INTO {role} (name) VALUES ('%s')", $edit["name"]);
-- 
GitLab