Skip to content

Commit

Permalink
pkp/pkp-lib#10537 Add available editorial decisions to submission's s…
Browse files Browse the repository at this point in the history
…tages data
  • Loading branch information
taslangraham committed Oct 24, 2024
1 parent b66cbb5 commit 348dc0a
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions classes/submission/maps/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
namespace APP\submission\maps;

use APP\core\Application;
use APP\decision\types\Decline;
use APP\decision\types\RevertDecline;
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
{
Expand Down Expand Up @@ -48,4 +53,32 @@ protected function mapByProperties(array $props, Submission $submission, bool|Co

return $this->withExtensions($output, $submission);
}



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());

if (!$userHasAccessibleRoles || !$isActiveStage || !$permissions['canMakeDecision'] || $stageId !== WORKFLOW_STAGE_ID_PRODUCTION/** Only the production stage is supported in OPS.*/) {
return [];
}


$decisionTypes = []; /** @var DecisionType[] $decisionTypes */

if ($submission->getData('status') === Submission::STATUS_DECLINED) {
$decisionTypes[] = new RevertDecline();
} elseif ($submission->getData('status') === Submission::STATUS_QUEUED) {
$decisionTypes[] = new Decline();
}

Hook::call('Workflow::Decisions', [&$decisionTypes, $stageId]);

return $decisionTypes;
}
}

0 comments on commit 348dc0a

Please sign in to comment.