Skip to content

Commit

Permalink
pkp/pkp-lib#10506 Refactor User Group 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 2d26ff5 commit 626c573
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions classes/submission/Submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@

namespace APP\submission;

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

class Submission extends PKPSubmission
{
Expand Down Expand Up @@ -67,7 +66,9 @@ 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
8 changes: 4 additions & 4 deletions pages/search/SearchHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use APP\search\PreprintSearch;
use APP\security\authorization\OpsServerMustPublishPolicy;
use APP\template\TemplateManager;
use PKP\userGroup\UserGroup;

class SearchHandler extends Handler
{
Expand Down Expand Up @@ -167,10 +168,9 @@ public function search($args, $request)
'simDocsEnabled' => true,
'results' => $results,
'error' => $error,
'authorUserGroups' => Repo::userGroup()->getCollector()
->filterByRoleIds([\PKP\security\Role::ROLE_ID_AUTHOR])
->filterByContextIds($searchFilters['searchServer'] ? [$searchFilters['searchServer']->getId()] : null)
->getMany()->remember(),
'authorUserGroups' => UserGroup::withRoleIds([\PKP\security\Role::ROLE_ID_AUTHOR])
->withContextIds($searchFilters['searchServer'] ? [$searchFilters['searchServer']->getId()] : null)
->get(),
]);
$templateMgr->display('frontend/pages/search.tpl');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
{fbvFormSection list=true title="manager.sections.form.assignEditors"}
<div>{translate key="manager.sections.form.assignEditors.description"}</div>
{foreach from=$assignableUserGroups item="assignableUserGroup"}
{assign var="role" value=$assignableUserGroup.userGroup->getLocalizedName()}
{assign var="userGroupId" value=$assignableUserGroup.userGroup->getId()}
{assign var="role" value=$assignableUserGroup.userGroup->getLocalizedData('name')}
{assign var="userGroupId" value=$assignableUserGroup.userGroup->id}
{foreach from=$assignableUserGroup.users item=$username key="id"}
{fbvElement
type="checkbox"
Expand Down

0 comments on commit 626c573

Please sign in to comment.