Skip to content

Commit

Permalink
pkp#7495 Additional submission mapping, added temporarly to pass e2e …
Browse files Browse the repository at this point in the history
…tests
  • Loading branch information
jardakotesovec committed Oct 2, 2024
1 parent 32a44a9 commit 166de4d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions classes/submission/maps/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,17 @@ public function getPropertyStages(Submission $submission): array
$currentUserAssignedRoles = [];
$stageAssignmentsOverview = [];
if ($currentUser) {
// FIXME - $stageAssignments are just temporarly added until https://github.com/pkp/pkp-lib/issues/10480 is ready
$currentRoles = array_map(
function (Role $role) {
return $role->getId();
},
$currentUser->getRoles($this->context->getId())
);
// Replaces StageAssignmentDAO::getBySubmissionAndUserIdAndStageId
$stageAssignments = StageAssignment::withSubmissionIds([$submission->getId()])
->withUserId($currentUser->getId() ?? 0)
->withStageIds([$stageId])
->get();

foreach ($stageAssignments as $stageAssignment) {
Expand All @@ -544,6 +552,7 @@ public function getPropertyStages(Submission $submission): array
->withStageIds([$stageId])
->get();

// FIXME - $stageAssignments are just temporarly added until https://github.com/pkp/pkp-lib/issues/10480 is ready
foreach ($stageAssignments as $stageAssignment) {
$userGroup = Repo::userGroup()->get($stageAssignment->userGroupId);
$stageAssignmentsOverview[] = [
Expand All @@ -555,7 +564,13 @@ public function getPropertyStages(Submission $submission): array
}
}
$stage['currentUserAssignedRoles'] = array_values(array_unique($currentUserAssignedRoles));
// FIXME - $stageAssignments are just temporarly added until https://github.com/pkp/pkp-lib/issues/10480 is ready
$stage['stageAssignments'] = $stageAssignmentsOverview;
if(!$stage['currentUserAssignedRoles']) {
if(in_array(Role::ROLE_ID_MANAGER, $currentRoles)) {
$stage['currentUserAssignedRoles'][] = Role::ROLE_ID_MANAGER;
}
}
// Stage-specific statuses
switch ($stageId) {
case WORKFLOW_STAGE_ID_SUBMISSION:
Expand Down

0 comments on commit 166de4d

Please sign in to comment.