From 189ccc2d722bdfb16a96432f709d18438c80c29e Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Thu, 29 Jun 2023 16:15:12 +0200 Subject: [PATCH] Add method to list disabled users to IProvideEnabledStateBackend MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/user_ldap/lib/User_LDAP.php | 4 ++++ apps/user_ldap/lib/User_Proxy.php | 12 ++++++++++++ .../User/Backend/IProvideEnabledStateBackend.php | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php index d4a851bd7aa..f9ae6bbee66 100644 --- a/apps/user_ldap/lib/User_LDAP.php +++ b/apps/user_ldap/lib/User_LDAP.php @@ -681,4 +681,8 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I $setDatabaseValue($enabled); return $enabled; } + + public function getDisabledUserList(int $offset = 0, ?int $limit = null): 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 e0f1bb2d522..0449c89bd24 100644 --- a/apps/user_ldap/lib/User_Proxy.php +++ b/apps/user_ldap/lib/User_Proxy.php @@ -32,6 +32,7 @@ namespace OCA\User_LDAP; use OCA\User_LDAP\User\DeletedUsersIndex; +use OCA\User_LDAP\User\OfflineUser; use OCA\User_LDAP\User\User; use OCP\IConfig; use OCP\IUserBackend; @@ -461,4 +462,15 @@ class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): bool { return $this->handleRequest($uid, 'setUserEnabled', [$uid, $enabled, $queryDatabaseValue, $setDatabaseValue]); } + + public function getDisabledUserList(int $offset = 0, ?int $limit = null): array { + return array_map( + fn (OfflineUser $user) => $user->getOCName(), + array_slice( + $this->deletedUsersIndex->getUsers(), + $offset, + $limit + ) + ); + } } diff --git a/lib/public/User/Backend/IProvideEnabledStateBackend.php b/lib/public/User/Backend/IProvideEnabledStateBackend.php index 8a4755ffbef..d03beacd7b8 100644 --- a/lib/public/User/Backend/IProvideEnabledStateBackend.php +++ b/lib/public/User/Backend/IProvideEnabledStateBackend.php @@ -44,4 +44,13 @@ interface IProvideEnabledStateBackend { * @param callable(bool):void $setDatabaseValue A callable to set the enabled state in the database. */ public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): bool; + + /** + * Get the list of disabled users, to merge with the ones disabled in database + * + * @since 28.0.0 + * + * @return string[] + */ + public function getDisabledUserList(int $offset = 0, ?int $limit = null): array; } -- 2.39.5