diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2024-02-29 11:29:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-29 11:29:05 +0100 |
commit | d692b2a94bdaf030a0b647c9e31a53fda827cd5b (patch) | |
tree | c8e81c6721c123c3837fe5a58a462996130154d6 /apps | |
parent | f7470ab973d9dc3c979accd95985d71cf80653fa (diff) | |
parent | a23cf50d5e629d21c8c08494668b6c721684d920 (diff) | |
download | nextcloud-server-d692b2a94bdaf030a0b647c9e31a53fda827cd5b.tar.gz nextcloud-server-d692b2a94bdaf030a0b647c9e31a53fda827cd5b.zip |
Merge pull request #43817 from nextcloud/backport/42706/stable28
Diffstat (limited to 'apps')
-rw-r--r-- | apps/settings/lib/AppInfo/Application.php | 4 | ||||
-rw-r--r-- | apps/settings/lib/Controller/UsersController.php | 11 | ||||
-rw-r--r-- | apps/settings/tests/Controller/UsersControllerTest.php | 6 |
3 files changed, 8 insertions, 13 deletions
diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index 820ee4f98ac..0e89d0f989f 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -128,10 +128,6 @@ class Application extends App implements IBootstrap { /** * Core class wrappers */ - /** FIXME: Remove once OC_User is non-static and mockable */ - $context->registerService('isAdmin', function () { - return \OC_User::isAdminUser(\OC_User::getUser()); - }); /** FIXME: Remove once OC_SubAdmin is non-static and mockable */ $context->registerService('isSubAdmin', function () { $userObject = \OC::$server->getUserSession()->getUser(); diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php index 3c6ee1806f0..f80b45c2b40 100644 --- a/apps/settings/lib/Controller/UsersController.php +++ b/apps/settings/lib/Controller/UsersController.php @@ -83,8 +83,6 @@ class UsersController extends Controller { private $userSession; /** @var IConfig */ private $config; - /** @var bool */ - private $isAdmin; /** @var IL10N */ private $l10n; /** @var IMailer */ @@ -114,7 +112,6 @@ class UsersController extends Controller { IGroupManager $groupManager, IUserSession $userSession, IConfig $config, - bool $isAdmin, IL10N $l10n, IMailer $mailer, IFactory $l10nFactory, @@ -131,7 +128,6 @@ class UsersController extends Controller { $this->groupManager = $groupManager; $this->userSession = $userSession; $this->config = $config; - $this->isAdmin = $isAdmin; $this->l10n = $l10n; $this->mailer = $mailer; $this->l10nFactory = $l10nFactory; @@ -168,6 +164,7 @@ class UsersController extends Controller { public function usersList(): TemplateResponse { $user = $this->userSession->getUser(); $uid = $user->getUID(); + $isAdmin = $this->groupManager->isAdmin($uid); \OC::$server->getNavigationManager()->setActiveEntry('core_users'); @@ -192,7 +189,7 @@ class UsersController extends Controller { /* GROUPS */ $groupsInfo = new \OC\Group\MetaData( $uid, - $this->isAdmin, + $isAdmin, $this->groupManager, $this->userSession ); @@ -210,7 +207,7 @@ class UsersController extends Controller { $userCount = 0; if (!$isLDAPUsed) { - if ($this->isAdmin) { + if ($isAdmin) { $disabledUsers = $this->userManager->countDisabledUsers(); $userCount = array_reduce($this->userManager->countUsers(), function ($v, $w) { return $v + (int)$w; @@ -265,7 +262,7 @@ class UsersController extends Controller { // groups $serverData['groups'] = array_merge_recursive($adminGroup, [$disabledUsersGroup], $groups); // Various data - $serverData['isAdmin'] = $this->isAdmin; + $serverData['isAdmin'] = $isAdmin; $serverData['sortGroups'] = $sortGroupsBy; $serverData['quotaPreset'] = $quotaPreset; $serverData['allowUnlimitedQuota'] = $allowUnlimitedQuota; diff --git a/apps/settings/tests/Controller/UsersControllerTest.php b/apps/settings/tests/Controller/UsersControllerTest.php index eddb290212a..bbd795bdd6c 100644 --- a/apps/settings/tests/Controller/UsersControllerTest.php +++ b/apps/settings/tests/Controller/UsersControllerTest.php @@ -137,6 +137,10 @@ class UsersControllerTest extends \Test\TestCase { * @return UsersController | \PHPUnit\Framework\MockObject\MockObject */ protected function getController($isAdmin = false, $mockedMethods = []) { + $this->groupManager->expects($this->any()) + ->method('isAdmin') + ->willReturn($isAdmin); + if (empty($mockedMethods)) { return new UsersController( 'settings', @@ -145,7 +149,6 @@ class UsersControllerTest extends \Test\TestCase { $this->groupManager, $this->userSession, $this->config, - $isAdmin, $this->l, $this->mailer, $this->l10nFactory, @@ -167,7 +170,6 @@ class UsersControllerTest extends \Test\TestCase { $this->groupManager, $this->userSession, $this->config, - $isAdmin, $this->l, $this->mailer, $this->l10nFactory, |