diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-05-16 16:13:31 +0200 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-05-23 09:08:31 +0200 |
commit | 6d56f3557d3eba4f41d0381c6f8fc8fda036a3b4 (patch) | |
tree | 92a5389dd0f90945b8429104e34550540be83fd1 /lib | |
parent | 474cbda59a4c5c4a225918724a871451a0f49a7f (diff) | |
download | nextcloud-server-6d56f3557d3eba4f41d0381c6f8fc8fda036a3b4.tar.gz nextcloud-server-6d56f3557d3eba4f41d0381c6f8fc8fda036a3b4.zip |
feat: Add back searching in disabled user list
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 <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/User/Manager.php | 12 | ||||
-rw-r--r-- | lib/public/IUserManager.php | 3 | ||||
-rw-r--r-- | lib/public/User/Backend/IProvideEnabledStateBackend.php | 3 |
3 files changed, 14 insertions, 4 deletions
diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php index c7611da382d..8234f505a47 100644 --- a/lib/private/User/Manager.php +++ b/lib/private/User/Manager.php @@ -333,7 +333,7 @@ class Manager extends PublicEmitter implements IUserManager { /** * @return IUser[] */ - public function getDisabledUsers(?int $limit = null, int $offset = 0): array { + public function getDisabledUsers(?int $limit = null, int $offset = 0, string $search = ''): array { $users = $this->config->getUsersForUserValue('core', 'enabled', 'false'); $users = array_combine( $users, @@ -342,6 +342,14 @@ class Manager extends PublicEmitter implements IUserManager { $users ) ); + if ($search !== '') { + $users = array_filter( + $users, + fn (IUser $user): bool => + mb_stripos($user->getUID(), $search) !== false || + mb_stripos($user->getDisplayName(), $search) !== false, + ); + } $tempLimit = ($limit === null ? null : $limit + $offset); foreach ($this->backends as $backend) { @@ -349,7 +357,7 @@ class Manager extends PublicEmitter implements IUserManager { break; } if ($backend instanceof IProvideEnabledStateBackend) { - $backendUsers = $backend->getDisabledUserList(($tempLimit === null ? null : $tempLimit - count($users))); + $backendUsers = $backend->getDisabledUserList(($tempLimit === null ? null : $tempLimit - count($users)), 0, $search); foreach ($backendUsers as $uid) { $users[$uid] = new LazyUser($uid, $this, null, $backend); } diff --git a/lib/public/IUserManager.php b/lib/public/IUserManager.php index 0a94c5ad928..94ab487d318 100644 --- a/lib/public/IUserManager.php +++ b/lib/public/IUserManager.php @@ -142,8 +142,9 @@ interface IUserManager { /** * @return IUser[] * @since 28.0.0 + * @since 30.0.0 $search parameter added */ - public function getDisabledUsers(?int $limit = null, int $offset = 0): array; + public function getDisabledUsers(?int $limit = null, int $offset = 0, string $search = ''): array; /** * Search known users (from phonebook sync) by displayName diff --git a/lib/public/User/Backend/IProvideEnabledStateBackend.php b/lib/public/User/Backend/IProvideEnabledStateBackend.php index f12d99fd1a6..3fd517048fb 100644 --- a/lib/public/User/Backend/IProvideEnabledStateBackend.php +++ b/lib/public/User/Backend/IProvideEnabledStateBackend.php @@ -49,8 +49,9 @@ interface IProvideEnabledStateBackend { * Get the list of disabled users, to merge with the ones disabled in database * * @since 28.0.0 + * @since 30.0.0 $search parameter added * * @return string[] */ - public function getDisabledUserList(?int $limit = null, int $offset = 0): array; + public function getDisabledUserList(?int $limit = null, int $offset = 0, string $search = ''): array; } |