From 0858a2e0edf3ee4cace3033ede0cb202e16a1e29 Mon Sep 17 00:00:00 2001 From: Elke Date: Wed, 30 Apr 2025 15:02:01 +0200 Subject: [PATCH 1/2] Make suspendusername optional --- classes/archiveduser.php | 10 +++++++--- lang/en/tool_cleanupusers.php | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/classes/archiveduser.php b/classes/archiveduser.php index c2a4023..e65316c 100644 --- a/classes/archiveduser.php +++ b/classes/archiveduser.php @@ -211,7 +211,8 @@ public function delete_me() { } /** - * Creates an empty user with ':suspendusername + id' as username and ':suspendfirstname' as Firstname. + * Creates an empty user with optional ':suspendusername + id' as username if set, ':suspendfirstname' as Firstname + * and ':suspendlastname' as Lastname. * * @param int $id * @param int $timestamp @@ -220,8 +221,11 @@ public function delete_me() { private function give_suspended_pseudo_user($id, $timestamp) { $cloneuser = new \stdClass(); $cloneuser->id = $id; - // Usernames have to be unique therefore the id is used. - $cloneuser->username = get_config('tool_cleanupusers_settings', 'suspendusername') . $id; + $suspendusername = get_config('tool_cleanupusers_settings', 'suspendusername'); + if (!$suspendusername == '') { + // Usernames have to be unique therefore the id is used. + $cloneuser->username = $suspendusername . $id; + }; $cloneuser->firstname = get_config('tool_cleanupusers_settings', 'suspendfirstname'); $cloneuser->lastname = get_config('tool_cleanupusers_settings', 'suspendlastname'); $cloneuser->suspended = 1; diff --git a/lang/en/tool_cleanupusers.php b/lang/en/tool_cleanupusers.php index 058d974..7319543 100644 --- a/lang/en/tool_cleanupusers.php +++ b/lang/en/tool_cleanupusers.php @@ -57,7 +57,7 @@ $string['sett_suspendfirstname_description'] = 'Choose a firstname for suspended users'; $string['sett_suspendlastname_description'] = 'Choose a lastname for suspended users'; $string['sett_suspendusername'] = 'Username for suspended'; -$string['sett_suspendusername_description'] = 'Choose a username for suspended users (must be lowercase)'; +$string['sett_suspendusername_description'] = 'Choose a username for suspended users (must be lowercase), No setting leaves username unchanged.'; $string['sett_title'] = 'Configure suspended users'; $string['shouldbedelted'] = 'will be deleted in the next cron-job'; $string['showuser'] = 'Activate User'; @@ -65,7 +65,7 @@ $string['subplugintype_userstatus_plural'] = 'Returns the status of users'; $string['suspendfirstname'] = 'Anonym'; $string['suspendlastname'] = 'Anonym'; -$string['suspendusername'] = 'anonym'; +$string['suspendusername'] = ''; $string['toarchive'] = 'Manage users who will be archived'; $string['todelete'] = 'Manage users who will be deleted'; $string['usersarchived'] = 'The Users have been archived'; From d55cf12727d4b1aa5c5f9870ec5a71b3b884c76d Mon Sep 17 00:00:00 2001 From: Elke Date: Mon, 5 May 2025 13:37:32 +0200 Subject: [PATCH 2/2] Add condition to exclude active users. --- userstatus/timechecker/classes/timechecker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/userstatus/timechecker/classes/timechecker.php b/userstatus/timechecker/classes/timechecker.php index 04b9203..8125d1e 100644 --- a/userstatus/timechecker/classes/timechecker.php +++ b/userstatus/timechecker/classes/timechecker.php @@ -182,7 +182,7 @@ public function get_to_reactivate() { AND u.deleted = 0 AND tca.lastaccess >= :timelimit AND tca.username NOT IN - (SELECT username FROM {user} WHERE username IS NOT NULL)", + (SELECT username FROM {user} WHERE username IS NOT NULL AND suspended=0)", [ 'timelimit' => time() - $this->timesuspend, ]