Skip to content

Commit

Permalink
pkp#10506 Fix call to a removed User Group Collector
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy-1 committed Nov 27, 2024
1 parent 78ddb16 commit 3095bbc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 5 additions & 5 deletions classes/security/authorization/UserRolesRequiredPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use APP\core\Application;
use APP\core\Request;
use APP\facades\Repo;
use PKP\userGroup\UserGroup;

class UserRolesRequiredPolicy extends AuthorizationPolicy
{
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions classes/user/form/RolesForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 3095bbc

Please sign in to comment.