Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#10480 Add stage assignment related data to submission schema #10523

Merged
merged 12 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions api/v1/_submissions/PKPBackendSubmissionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
use PKP\submission\PKPSubmission;
use PKP\userGroup\UserGroup;


abstract class PKPBackendSubmissionsController extends PKPBaseController
{
use AnonymizeData;
Expand Down Expand Up @@ -204,14 +203,15 @@ public function getMany(Request $illuminateRequest): JsonResponse
}
}

$userRoles = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES);

/**
* FIXME: Clean up before release pkp/pkp-lib#7495.
* In new submission lists this endpoint is dedicated to retrieve all submissions only by admins and managers
*/
if (!Config::getVar('features', 'enable_new_submission_listing')) {

// Anyone not a manager or site admin can only access their assigned submissions
$userRoles = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES);
$canAccessUnassignedSubmission = !empty(array_intersect([Role::ROLE_ID_SITE_ADMIN, Role::ROLE_ID_MANAGER], $userRoles));
Hook::run('API::_submissions::params', [$collector, $illuminateRequest]);
if (!$canAccessUnassignedSubmission) {
Expand All @@ -238,7 +238,7 @@ public function getMany(Request $illuminateRequest): JsonResponse

return response()->json([
'itemsMax' => $collector->getCount(),
'items' => Repo::submission()->getSchemaMap()->mapManyToSubmissionsList($submissions, $userGroups, $genres)->values(),
'items' => Repo::submission()->getSchemaMap()->mapManyToSubmissionsList($submissions, $userGroups, $genres, $userRoles)->values(),
], Response::HTTP_OK);
}

Expand Down Expand Up @@ -276,6 +276,7 @@ public function assigned(Request $illuminateRequest): JsonResponse
$submissions,
$userGroups,
$genres,
$this->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES),
$this->anonymizeReviews($submissions)
)->values(),
], Response::HTTP_OK);
Expand Down Expand Up @@ -343,7 +344,12 @@ public function reviews(Request $illuminateRequest): JsonResponse

return response()->json([
'itemsMax' => $collector->getCount(),
'items' => Repo::submission()->getSchemaMap()->mapManyToSubmissionsList($submissions, $userGroups, $genres)->values(),
'items' => Repo::submission()->getSchemaMap()->mapManyToSubmissionsList(
$submissions,
$userGroups,
$genres,
$this->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES)
)->values(),
], Response::HTTP_OK);
}

Expand Down
22 changes: 15 additions & 7 deletions api/v1/submissions/PKPSubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ protected function getSubmissionCollector(array $queryParams): Collector
break;
case 'isUnassigned':
$collector->filterByisUnassigned(true);
break;
break;
}
}

Expand All @@ -532,7 +532,7 @@ public function get(Request $illuminateRequest): JsonResponse
$submission = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_SUBMISSION);

$userGroups = UserGroup::withContextIds($submission->getData('contextId'))->cursor();

$userRoles = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES);

// Anonymize sensitive review assignment data if user is a reviewer or author assigned to the article and review isn't open
$reviewAssignments = Repo::reviewAssignment()->getCollector()->filterBySubmissionIds([$submission->getId()])->getMany()->remember();
Expand All @@ -547,8 +547,10 @@ public function get(Request $illuminateRequest): JsonResponse
$submission,
$userGroups,
$genres,
$userRoles,
$reviewAssignments,
null,
null,
!$anonymizeReviews || $anonymizeReviews->isEmpty() ? false : $anonymizeReviews
), Response::HTTP_OK);
}
Expand Down Expand Up @@ -680,7 +682,9 @@ public function add(Request $illuminateRequest): JsonResponse
$userGroups = $userGroups->lazy();
}

return response()->json(Repo::submission()->getSchemaMap()->map($submission, $userGroups, $genres), Response::HTTP_OK);
$userRoles = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES);

return response()->json(Repo::submission()->getSchemaMap()->map($submission, $userGroups, $genres, $userRoles), Response::HTTP_OK);
}

/**
Expand Down Expand Up @@ -716,8 +720,9 @@ public function edit(Request $illuminateRequest): JsonResponse
/** @var GenreDAO $genreDao */
$genreDao = DAORegistry::getDAO('GenreDAO');
$genres = $genreDao->getByContextId($submission->getData('contextId'))->toArray();
$userRoles = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES);

return response()->json(Repo::submission()->getSchemaMap()->map($submission, $userGroups, $genres), Response::HTTP_OK);
return response()->json(Repo::submission()->getSchemaMap()->map($submission, $userGroups, $genres, $userRoles), Response::HTTP_OK);
}

/**
Expand Down Expand Up @@ -768,8 +773,9 @@ public function saveForLater(Request $illuminateRequest): JsonResponse
/** @var GenreDAO $genreDao */
$genreDao = DAORegistry::getDAO('GenreDAO');
$genres = $genreDao->getByContextId($submission->getData('contextId'))->toArray();
$userRoles = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES);

return response()->json(Repo::submission()->getSchemaMap()->map($submission, $userGroups, $genres), Response::HTTP_OK);
return response()->json(Repo::submission()->getSchemaMap()->map($submission, $userGroups, $genres, $userRoles), Response::HTTP_OK);
}

/**
Expand Down Expand Up @@ -848,6 +854,7 @@ public function submit(Request $illuminateRequest): JsonResponse
/** @var GenreDAO $genreDao */
$genreDao = DAORegistry::getDAO('GenreDAO');
$genres = $genreDao->getByContextId($submission->getData('contextId'))->toArray();
$userRoles = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES);

$notificationManager = new NotificationManager();
$notificationManager->updateNotification(
Expand All @@ -858,7 +865,7 @@ public function submit(Request $illuminateRequest): JsonResponse
$submission->getId()
);

return response()->json(Repo::submission()->getSchemaMap()->map($submission, $userGroups, $genres), Response::HTTP_OK);
return response()->json(Repo::submission()->getSchemaMap()->map($submission, $userGroups, $genres, $userRoles), Response::HTTP_OK);
}

/**
Expand All @@ -880,8 +887,9 @@ public function delete(Request $illuminateRequest): JsonResponse
/** @var GenreDAO $genreDao */
$genreDao = DAORegistry::getDAO('GenreDAO');
$genres = $genreDao->getByContextId($submission->getData('contextId'))->toArray();
$userRoles = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES);

$submissionProps = Repo::submission()->getSchemaMap()->map($submission, $userGroups, $genres);
$submissionProps = Repo::submission()->getSchemaMap()->map($submission, $userGroups, $genres, $userRoles);

Repo::submission()->delete($submission);

Expand Down
1 change: 0 additions & 1 deletion classes/stageAssignment/StageAssignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use PKP\user\User;
use PKP\userGroup\relationships\UserGroupStage;
use PKP\userGroup\UserGroup;

Expand Down
2 changes: 1 addition & 1 deletion classes/submission/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ protected function mapDashboardViews(Collection $types, Context $context, User $
case DashboardView::TYPE_REVIEWS_SUBMITTED:
$collector = Repo::submission()->getCollector()
->filterByContextIds([$context->getId()])
->filterByAwaitingReviews(true)
->filterByReviewsSubmitted(true)
->filterByStatus([PKPSubmission::STATUS_QUEUED]);
return new DashboardView(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this fix for #10765 (comment) ? :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I've made it a long time ago)

$key,
Expand Down
Loading