Skip to content

Commit

Permalink
pkp/pkp-lib#10506 User Group refactoring to Eloquent Model
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy-1 committed Dec 14, 2024
1 parent 1187580 commit 883f65d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 6 additions & 2 deletions classes/submission/Submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

namespace APP\submission;

use APP\facades\Repo;
use APP\publication\Publication;
use PKP\submission\PKPSubmission;
use PKP\userGroup\UserGroup;

class Submission extends PKPSubmission
{
Expand Down Expand Up @@ -67,7 +67,11 @@ public function _getContextLicenseFieldValue($locale, $field, $publication = nul
if (!$publication) {
$publication = $this->getCurrentPublication();
}
$authorUserGroups = Repo::userGroup()->getCollector()->filterByRoleIds([\PKP\security\Role::ROLE_ID_AUTHOR])->filterByContextIds([$context->getId()])->getMany();

$authorUserGroups = UserGroup::withRoleIds([\PKP\security\Role::ROLE_ID_AUTHOR])
->withContextIds([$context->getId()])
->get();

$fieldValue = [$context->getPrimaryLocale() => $publication->getAuthorString($authorUserGroups)];
break;
case 'context':
Expand Down
9 changes: 4 additions & 5 deletions pages/search/SearchHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
namespace APP\pages\search;

use APP\core\Request;
use APP\facades\Repo;
use APP\handler\Handler;
use APP\search\MonographSearch;
use APP\template\TemplateManager;
use PKP\userGroup\UserGroup;

class SearchHandler extends Handler
{
Expand Down Expand Up @@ -57,10 +57,9 @@ public function search($args, $request)
$templateMgr->assign([
'results' => $monographSearch->retrieveResults($request, $press, [null => $query], $error, null, null, $rangeInfo),
'searchQuery' => $query,
'authorUserGroups' => Repo::userGroup()->getCollector()
->filterByRoleIds([\PKP\security\Role::ROLE_ID_AUTHOR])
->filterByContextIds($press ? [$press->getId()] : null)
->getMany()->remember(),
'authorUserGroups' => UserGroup::withRoleIds([\PKP\security\Role::ROLE_ID_AUTHOR])
->withContextIds($press ? [$press->getId()] : null)
->get(),
]);

// Display
Expand Down

0 comments on commit 883f65d

Please sign in to comment.