Skip to content

Commit

Permalink
pkp/pkp-lib#10506 Update usage for porting UserGroup to Eloquent
Browse files Browse the repository at this point in the history
  • Loading branch information
Hafsa-Naeem committed Oct 28, 2024
1 parent ed5a0a7 commit 2e5a05b
Show file tree
Hide file tree
Showing 12 changed files with 631 additions and 33 deletions.
5 changes: 2 additions & 3 deletions api/v1/_dois/BackendDoiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions api/v1/issues/IssueController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -268,9 +269,8 @@ 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
Expand Down
4 changes: 3 additions & 1 deletion classes/search/ArticleSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use PKP\plugins\Hook;
use PKP\search\SubmissionSearch;
use PKP\submission\PKPSubmission;
use PKP\userGroup\UserGroup;

class ArticleSearch extends SubmissionSearch
{
Expand Down Expand Up @@ -77,7 +78,8 @@ 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::where('roleId', \PKP\security\Role::ROLE_ID_AUTHOR)->get();

foreach ($unorderedResults as $submissionId => $data) {
// Exclude unwanted IDs.
if (in_array($submissionId, $exclude)) {
Expand Down
3 changes: 2 additions & 1 deletion classes/submission/Submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use APP\publication\Publication;
use PKP\facades\Locale;
use PKP\submission\PKPSubmission;
use PKP\userGroup\UserGroup;

class Submission extends PKPSubmission
{
Expand Down Expand Up @@ -69,7 +70,7 @@ 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::where('roleId', \PKP\security\Role::ROLE_ID_AUTHOR)->where('contextId', $context->getId())->get();
$fieldValue = [$context->getPrimaryLocale() => $publication->getAuthorString($authorUserGroups)];
break;
case 'context':
Expand Down
Loading

0 comments on commit 2e5a05b

Please sign in to comment.