diff options
author | Louis Chemineau <louis@chmn.me> | 2024-07-11 12:09:39 +0200 |
---|---|---|
committer | Louis Chemineau <louis@chmn.me> | 2024-07-22 17:17:35 +0200 |
commit | dff881544920f426b984f91b7bc8dece1f351342 (patch) | |
tree | 9ebce4597dad2cd0fe817257f76348f28805c2ba /apps/settings/lib/Controller/UsersController.php | |
parent | 1af827fdb39dd182743853e17cf5493a8b4637d2 (diff) | |
download | nextcloud-server-dff881544920f426b984f91b7bc8dece1f351342.tar.gz nextcloud-server-dff881544920f426b984f91b7bc8dece1f351342.zip |
feat(users): Add support for admin delegation for users and groups management
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'apps/settings/lib/Controller/UsersController.php')
-rw-r--r-- | apps/settings/lib/Controller/UsersController.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php index 999f883bad8..1e934cdf43c 100644 --- a/apps/settings/lib/Controller/UsersController.php +++ b/apps/settings/lib/Controller/UsersController.php @@ -19,12 +19,14 @@ use OC\Security\IdentityProof\Manager; use OC\User\Manager as UserManager; use OCA\Settings\BackgroundJobs\VerifyUserData; use OCA\Settings\Events\BeforeTemplateRenderedEvent; +use OCA\Settings\Settings\Admin\Users; use OCA\User_LDAP\User_Proxy; use OCP\Accounts\IAccount; use OCP\Accounts\IAccountManager; use OCP\Accounts\PropertyDoesNotExistException; use OCP\App\IAppManager; use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting; use OCP\AppFramework\Http\Attribute\OpenAPI; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\JSONResponse; @@ -93,6 +95,7 @@ class UsersController extends Controller { $user = $this->userSession->getUser(); $uid = $user->getUID(); $isAdmin = $this->groupManager->isAdmin($uid); + $isDelegatedAdmin = $this->groupManager->isDelegatedAdmin($uid); \OC::$server->getNavigationManager()->setActiveEntry('core_users'); @@ -118,6 +121,7 @@ class UsersController extends Controller { $groupsInfo = new \OC\Group\MetaData( $uid, $isAdmin, + $isDelegatedAdmin, $this->groupManager, $this->userSession ); @@ -135,7 +139,7 @@ class UsersController extends Controller { $userCount = 0; if (!$isLDAPUsed) { - if ($isAdmin) { + if ($isAdmin || $isDelegatedAdmin) { $disabledUsers = $this->userManager->countDisabledUsers(); $userCount = array_reduce($this->userManager->countUsers(), function ($v, $w) { return $v + (int)$w; @@ -200,7 +204,8 @@ class UsersController extends Controller { // groups $serverData['groups'] = array_merge_recursive($adminGroup, [$recentUsersGroup, $disabledUsersGroup], $groups); // Various data - $serverData['isAdmin'] = $isAdmin; + $serverData['isAdmin'] = $isAdmin || $isDelegatedAdmin; + $serverData['isDelegatedAdmin'] = $isDelegatedAdmin; $serverData['sortGroups'] = $forceSortGroupByName ? \OC\Group\MetaData::SORT_GROUPNAME : (int)$this->config->getAppValue('core', 'group.sortBy', (string)\OC\Group\MetaData::SORT_USERCOUNT); @@ -232,6 +237,7 @@ class UsersController extends Controller { * * @return JSONResponse */ + #[AuthorizedAdminSetting(settings:Users::class)] public function setPreference(string $key, string $value): JSONResponse { $allowed = ['newUser.sendEmail', 'group.sortBy']; if (!in_array($key, $allowed, true)) { |