From 5af0af0b161c7bc4be7c06d1c898dbb0a806884d Mon Sep 17 00:00:00 2001 From: Taslan Graham Date: Wed, 23 Oct 2024 15:23:09 -0500 Subject: [PATCH 1/2] pkp/pkp-lib#10537 Add available editorial decisions to submission's stages data --- classes/submission/maps/Schema.php | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/classes/submission/maps/Schema.php b/classes/submission/maps/Schema.php index d27c2bbf3a..54bed79bae 100644 --- a/classes/submission/maps/Schema.php +++ b/classes/submission/maps/Schema.php @@ -14,8 +14,14 @@ namespace APP\submission\maps; use APP\core\Application; +use APP\decision\types\Decline; +use APP\decision\types\RevertDecline; +use APP\facades\Repo; use APP\submission\Submission; use Illuminate\Support\Collection; +use PKP\decision\DecisionType; +use PKP\plugins\Hook; +use PKP\security\Role; class Schema extends \PKP\submission\maps\Schema { @@ -48,4 +54,48 @@ protected function mapByProperties(array $props, Submission $submission, bool|Co return $this->withExtensions($output, $submission); } + + + /** + * Gets the Editorial decisions available to editors for a given stage of a submission + * + * This method returns decisions only for active stages. For inactive stages, it returns an empty array. + * + * @return DecisionType[] + * + * @hook Workflow::Decisions [[&$decisionTypes, $stageId]] + */ + protected function getAvailableEditorialDecisions(int $stageId, Submission $submission): array + { + $request = Application::get()->getRequest(); + $user = $request->getUser(); + $isActiveStage = $submission->getData('stageId') == $stageId; + $userHasAccessibleRoles = $user->hasRole([Role::ROLE_ID_SUB_EDITOR, Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN, Role::ROLE_ID_ASSISTANT], $request->getContext()->getId()); + $permissions = $this->checkDecisionPermissions($stageId, $submission, $user, $request->getContext()->getId()); + + /** Only the production stage is supported in OPS.*/ + if ($stageId !== WORKFLOW_STAGE_ID_PRODUCTION || !$userHasAccessibleRoles || !$isActiveStage || !$permissions['canMakeDecision']) { + return []; + } + + $isOnlyRecommending = $permissions['isOnlyRecommending']; + $decisionTypes = []; /** @var DecisionType[] $decisionTypes */ + + if ($isOnlyRecommending) { + $decisionTypes[] = Repo::decision()->getDecisionTypesMadeByRecommendingUsers($stageId); + } else { + switch ($submission->getData('status')) { + case Submission::STATUS_DECLINED: + $decisionTypes[] = new RevertDecline(); + break; + case Submission::STATUS_QUEUED: + $decisionTypes[] = new Decline(); + break; + } + } + + Hook::call('Workflow::Decisions', [&$decisionTypes, $stageId]); + + return $decisionTypes; + } } From 6ae74323d3a698b19651853c89c542768671beaf Mon Sep 17 00:00:00 2001 From: Taslan Graham Date: Sat, 26 Oct 2024 13:22:49 -0500 Subject: [PATCH 2/2] Submodule update --- lib/pkp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkp b/lib/pkp index 6882fa48c8..af501d2e3d 160000 --- a/lib/pkp +++ b/lib/pkp @@ -1 +1 @@ -Subproject commit 6882fa48c8bc68992843ab07d010bd6303f77d4d +Subproject commit af501d2e3d0bcec2b0b57986349bc1280f21b6dc