From 0bc8342ddea2b7a54c2ad126f96afb17ef81c373 Mon Sep 17 00:00:00 2001 From: Vitalii Bezsheiko Date: Wed, 27 Nov 2024 13:26:24 +0200 Subject: [PATCH] pkp/pkp-lib#10506 Fix call to a removed User Group Collector --- .../security/authorization/UserRolesRequiredPolicy.php | 10 +++++----- classes/user/form/RolesForm.php | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/classes/security/authorization/UserRolesRequiredPolicy.php b/classes/security/authorization/UserRolesRequiredPolicy.php index 8f5acf5e032..ec4497cd503 100644 --- a/classes/security/authorization/UserRolesRequiredPolicy.php +++ b/classes/security/authorization/UserRolesRequiredPolicy.php @@ -18,7 +18,7 @@ use APP\core\Application; use APP\core\Request; -use APP\facades\Repo; +use PKP\userGroup\UserGroup; class UserRolesRequiredPolicy extends AuthorizationPolicy { @@ -53,10 +53,10 @@ public function effect() } $context = $request->getRouter()->getContext($request); - $userGroups = Repo::userGroup()->getCollector() - ->filterByUserIds([$user->getId()]) - ->filterByContextIds($context ? [$context->getId(), Application::SITE_CONTEXT_ID] : [Application::SITE_CONTEXT_ID]) - ->getMany()->toArray(); + $userGroups = UserGroup::withUserIds([$user->getId()]) + ->withContextIds($context ? [$context->getId(), Application::SITE_CONTEXT_ID] : [Application::SITE_CONTEXT_ID]) + ->get() + ->toArray(); $roleIds = array_map(fn ($userGroup) => $userGroup->getRoleId(), $userGroups); $this->addAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES, $roleIds); diff --git a/classes/user/form/RolesForm.php b/classes/user/form/RolesForm.php index 0a8520d3e43..7f5752b4165 100644 --- a/classes/user/form/RolesForm.php +++ b/classes/user/form/RolesForm.php @@ -17,7 +17,6 @@ namespace PKP\user\form; use APP\core\Application; -use APP\facades\Repo; use APP\template\TemplateManager; use PKP\user\InterestManager; use PKP\user\User; @@ -46,7 +45,6 @@ public function fetch($request, $template = null, $display = false) $userGroupIds = UserGroup::getIdsByUserId($request->getUser()->getId()); - $templateMgr->assign('userGroupIds', $userGroupIds); $userFormHelper = new UserFormHelper();