diff --git a/api/v1/_dois/BackendDoiController.php b/api/v1/_dois/BackendDoiController.php index 1d06d8dfcb5..ff4f7c385a1 100644 --- a/api/v1/_dois/BackendDoiController.php +++ b/api/v1/_dois/BackendDoiController.php @@ -24,6 +24,7 @@ use Illuminate\Support\Facades\Route; use Illuminate\Support\LazyCollection; use PKP\db\DAORegistry; +use PKP\userGroup\UserGroup; class BackendDoiController extends \PKP\API\v1\_dois\PKPBackendDoiController { @@ -145,9 +146,7 @@ public function editIssue(Request $illuminateRequest): JsonResponse protected function getUserGroups(int $contextId): LazyCollection { - return Repo::userGroup()->getCollector() - ->filterByContextIds([$contextId]) - ->getMany(); + return UserGroup::where('contextId', $contextId)->get(); } protected function getGenres(int $contextId): array diff --git a/api/v1/issues/IssueController.php b/api/v1/issues/IssueController.php index f0eddb9e84c..2cc29347297 100644 --- a/api/v1/issues/IssueController.php +++ b/api/v1/issues/IssueController.php @@ -36,6 +36,7 @@ use PKP\security\authorization\UserRolesRequiredPolicy; use PKP\security\Role; use PKP\submission\GenreDAO; +use PKP\userGroup\UserGroup; class IssueController extends PKPBaseController { @@ -268,9 +269,7 @@ public function get(Request $illuminateRequest): JsonResponse protected function getUserGroups(int $contextId): LazyCollection { - return Repo::userGroup()->getCollector() - ->filterByContextIds([$contextId]) - ->getMany(); + return UserGroup::where('contextId', $contextId)->get(); } protected function getGenres(int $contextId): array diff --git a/classes/search/ArticleSearch.php b/classes/search/ArticleSearch.php index 7d25044fd42..b9a48994156 100644 --- a/classes/search/ArticleSearch.php +++ b/classes/search/ArticleSearch.php @@ -28,6 +28,7 @@ use PKP\plugins\Hook; use PKP\search\SubmissionSearch; use PKP\submission\PKPSubmission; +use PKP\userGroup\UserGroup; class ArticleSearch extends SubmissionSearch { @@ -77,7 +78,7 @@ public function getSparseArray($unorderedResults, $orderBy, $orderDir, $exclude) } $i = 0; // Used to prevent ties from clobbering each other - $authorUserGroups = Repo::userGroup()->getCollector()->filterByRoleIds([\PKP\security\Role::ROLE_ID_AUTHOR])->getMany(); + $authorUserGroups = UserGroup::withRoleIds([\PKP\security\Role::ROLE_ID_AUTHOR])->get(); foreach ($unorderedResults as $submissionId => $data) { // Exclude unwanted IDs. if (in_array($submissionId, $exclude)) { diff --git a/classes/submission/Submission.php b/classes/submission/Submission.php index d908ec2208d..fc76076059c 100644 --- a/classes/submission/Submission.php +++ b/classes/submission/Submission.php @@ -26,8 +26,8 @@ use APP\facades\Repo; use APP\publication\Publication; -use PKP\facades\Locale; use PKP\submission\PKPSubmission; +use PKP\userGroup\UserGroup; class Submission extends PKPSubmission { @@ -69,7 +69,10 @@ public function _getContextLicenseFieldValue($locale, $field, $publication = nul $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': diff --git a/controllers/grid/users/subscriberSelect/SubscriberSelectGridHandler.php b/controllers/grid/users/subscriberSelect/SubscriberSelectGridHandler.php index bf7d57978df..215b8faad54 100644 --- a/controllers/grid/users/subscriberSelect/SubscriberSelectGridHandler.php +++ b/controllers/grid/users/subscriberSelect/SubscriberSelectGridHandler.php @@ -25,6 +25,7 @@ use PKP\controllers\grid\users\userSelect\UserSelectGridCellProvider; use PKP\security\authorization\ContextAccessPolicy; use PKP\security\Role; +use PKP\userGroup\UserGroup; class SubscriberSelectGridHandler extends GridHandler { @@ -71,7 +72,7 @@ public function initialize($request, $args = null) ); $this->_userGroupOptions = []; foreach ($userGroups as $userGroup) { - $this->_userGroupOptions[$userGroup->getId()] = $userGroup->getLocalizedName(); + $this->_userGroupOptions[$userGroup->id] = $userGroup->getLocalizedData('name'); } $this->setTitle('editor.submission.findAndSelectUser'); @@ -146,14 +147,12 @@ protected function loadData($request, $filter) */ public function renderFilter($request, $filterData = []) { - $context = $request->getContext(); - $userGroups = Repo::userGroup()->getCollector() - ->filterByContextIds([$context->getId()]) - ->getMany(); + $contextId = $request->getContext()->getId(); + $userGroups = UserGroup::withContextIds([$contextId])->get(); $userGroupOptions = ['' => __('grid.user.allRoles')]; foreach ($userGroups as $userGroup) { - $userGroupOptions[$userGroup->getId()] = $userGroup->getLocalizedName(); + $userGroupOptions[$userGroup->id] = $userGroup->getLocalizedData('name'); } return parent::renderFilter( diff --git a/cypress/tests/data/60-content/AmwandengaSubmission.cy.js b/cypress/tests/data/60-content/AmwandengaSubmission.cy.js index 151ef5f4bbc..b38cc86e5a1 100644 --- a/cypress/tests/data/60-content/AmwandengaSubmission.cy.js +++ b/cypress/tests/data/60-content/AmwandengaSubmission.cy.js @@ -395,7 +395,7 @@ describe('Data suite: Amwandenga', function() { it('Allow author to edit publication details', function() { cy.login('dbarnes'); cy.visit('/index.php/publicknowledge/workflow/access/' + submission.id); - cy.get('button[aria-label="Alan Mwandenga More Actions"]').click(); + cy.get('button[aria-label="Alan Mwandenga More Actions"]').scrollIntoView().should('be.visible').click(); cy.get('button:contains("Edit")').click(); cy.get('[name="canChangeMetadata"]').check(); cy.get('[id^="submitFormButton"]').contains('OK').click(); @@ -464,7 +464,7 @@ describe('Data suite: Amwandenga', function() { cy.get('button').contains('Create New Version').click(); cy.contains('Are you sure you want to create a new version?'); cy.get('div[role=dialog]:contains("Create New Version")').get('button').contains('Yes').click(); - + // Once there is 'in progress' overlay when creating new version this can be improved cy.wait(10000); diff --git a/pages/article/ArticleHandler.php b/pages/article/ArticleHandler.php index a40ad52ec32..462fd9716f3 100644 --- a/pages/article/ArticleHandler.php +++ b/pages/article/ArticleHandler.php @@ -42,6 +42,7 @@ use PKP\submission\GenreDAO; use PKP\submission\PKPSubmission; use PKP\submissionFile\SubmissionFile; +use PKP\userGroup\UserGroup; use stdClass; class ArticleHandler extends Handler @@ -286,7 +287,9 @@ public function view($args, $request) $templateMgr->assign([ 'primaryGalleys' => $primaryGalleys, 'supplementaryGalleys' => $supplementaryGalleys, - 'userGroupsById' => Repo::userGroup()->getCollector()->filterByPublicationIds([$this->publication->getId()])->getMany()->toArray() + 'userGroupsById' => UserGroup::withPublicationIds([$this->publication->getId()]) + ->get() + ->all() ]); // Citations diff --git a/pages/issue/IssueHandler.php b/pages/issue/IssueHandler.php index 8b2cd2aeca9..4ffbeda02ab 100644 --- a/pages/issue/IssueHandler.php +++ b/pages/issue/IssueHandler.php @@ -41,6 +41,7 @@ use PKP\security\Validation; use PKP\submission\GenreDAO; use PKP\submission\PKPSubmission; +use PKP\userGroup\UserGroup; class IssueHandler extends Handler { @@ -390,7 +391,10 @@ public static function _setupIssueTemplate(Request $request, Issue $issue, ?Jour $issueSubmissionsInSection[$sectionId]['articles'][] = $submission; } - $authorUserGroups = Repo::userGroup()->getCollector()->filterByRoleIds([\PKP\security\Role::ROLE_ID_AUTHOR])->filterByContextIds([$journal->getId()])->getMany()->remember(); + $authorUserGroups = UserGroup::withRoleIds([\PKP\security\Role::ROLE_ID_AUTHOR]) + ->withContextIds([$journal->getId()]) + ->get(); + $templateMgr->assign([ 'issue' => $issue, 'issueGalleys' => $issueGalleyDao->getByIssueId($issue->getId()), diff --git a/pages/search/SearchHandler.php b/pages/search/SearchHandler.php index 2010a9bff7b..335a149b5e7 100644 --- a/pages/search/SearchHandler.php +++ b/pages/search/SearchHandler.php @@ -21,6 +21,7 @@ use APP\search\ArticleSearch; use APP\security\authorization\OjsJournalMustPublishPolicy; use APP\template\TemplateManager; +use PKP\userGroup\UserGroup; class SearchHandler extends Handler { @@ -166,10 +167,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['searchJournal'] ? [$searchFilters['searchJournal']->getId()] : null) - ->getMany()->remember(), + 'authorUserGroups' => UserGroup::withRoleIds([\PKP\security\Role::ROLE_ID_AUTHOR]) + ->withContextIds($searchFilters['searchJournal'] ? [$searchFilters['searchJournal']->getId()] : null) + ->get(), 'searchResultOrderOptions' => $articleSearch->getResultSetOrderingOptions($request), 'searchResultOrderDirOptions' => $articleSearch->getResultSetOrderingDirectionOptions(), ]); diff --git a/plugins/reports/articles/ArticleReportPlugin.php b/plugins/reports/articles/ArticleReportPlugin.php index e3a419a496e..4e454bec270 100644 --- a/plugins/reports/articles/ArticleReportPlugin.php +++ b/plugins/reports/articles/ArticleReportPlugin.php @@ -28,6 +28,7 @@ use PKP\submission\SubmissionDisciplineDAO; use PKP\submission\SubmissionKeywordDAO; use PKP\submission\SubmissionSubjectDAO; +use PKP\userGroup\UserGroup; class ArticleReportPlugin extends ReportPlugin { @@ -90,15 +91,14 @@ public function display($args, $request) $submissionDisciplineDao = DAORegistry::getDAO('SubmissionDisciplineDAO'); /** @var SubmissionDisciplineDAO $submissionDisciplineDao */ $submissionAgencyDao = DAORegistry::getDAO('SubmissionAgencyDAO'); /** @var SubmissionAgencyDAO $submissionAgencyDao */ - $userGroups = Repo::userGroup()->getCollector() - ->filterByContextIds([$context->getId()]) - ->getMany() - ->toArray(); + $userGroups = UserGroup::withContextIds([$context->getId()]) + ->get() + ->all(); $editorUserGroupIds = array_map(function ($userGroup) { - return $userGroup->getId(); + return $userGroup->id; }, array_filter($userGroups, function ($userGroup) { - return in_array($userGroup->getRoleId(), [Role::ROLE_ID_MANAGER, Role::ROLE_ID_SUB_EDITOR]); + return in_array($userGroup->roleId, [Role::ROLE_ID_MANAGER, Role::ROLE_ID_SUB_EDITOR]); })); // Load the data from the database and store it in an array. diff --git a/templates/controllers/grid/settings/sections/form/sectionForm.tpl b/templates/controllers/grid/settings/sections/form/sectionForm.tpl index b1ce2ae05fd..7a60afb3c8f 100644 --- a/templates/controllers/grid/settings/sections/form/sectionForm.tpl +++ b/templates/controllers/grid/settings/sections/form/sectionForm.tpl @@ -67,8 +67,8 @@ {fbvFormSection list=true title="manager.sections.form.assignEditors"}