From 6d56f3557d3eba4f41d0381c6f8fc8fda036a3b4 Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 16 May 2024 16:13:31 +0200 Subject: feat: Add back searching in disabled user list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When disabled users where moved to their own endpoint we overlooked search, so adding it back. The search is done case-insensitive in uid and display name. Signed-off-by: Côme Chilliet --- apps/user_ldap/lib/User_LDAP.php | 2 +- apps/user_ldap/lib/User_Proxy.php | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'apps/user_ldap/lib') diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php index 7d5562f0ee0..6b12ef0ace3 100644 --- a/apps/user_ldap/lib/User_LDAP.php +++ b/apps/user_ldap/lib/User_LDAP.php @@ -682,7 +682,7 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I return $enabled; } - public function getDisabledUserList(?int $limit = null, int $offset = 0): array { + public function getDisabledUserList(?int $limit = null, int $offset = 0, string $search = ''): array { throw new \Exception('This is implemented directly in User_Proxy'); } } diff --git a/apps/user_ldap/lib/User_Proxy.php b/apps/user_ldap/lib/User_Proxy.php index 3df1990359a..5f17548fac7 100644 --- a/apps/user_ldap/lib/User_Proxy.php +++ b/apps/user_ldap/lib/User_Proxy.php @@ -463,11 +463,21 @@ class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP return $this->handleRequest($uid, 'setUserEnabled', [$uid, $enabled, $queryDatabaseValue, $setDatabaseValue]); } - public function getDisabledUserList(?int $limit = null, int $offset = 0): array { + public function getDisabledUserList(?int $limit = null, int $offset = 0, string $search = ''): array { + $disabledUsers = $this->deletedUsersIndex->getUsers(); + if ($search !== '') { + $disabledUsers = array_filter( + $disabledUsers, + fn (OfflineUser $user): bool => + mb_stripos($user->getOCName(), $search) !== false || + mb_stripos($user->getUID(), $search) !== false || + mb_stripos($user->getDisplayName(), $search) !== false, + ); + } return array_map( fn (OfflineUser $user) => $user->getOCName(), array_slice( - $this->deletedUsersIndex->getUsers(), + $disabledUsers, $offset, $limit ) -- cgit v1.2.3