Skip to content

Commit

Permalink
#3039 editor actions for all managers and sub-editors
Browse files Browse the repository at this point in the history
  • Loading branch information
bozana committed Nov 29, 2017
1 parent a543f6c commit 00e1b4d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 33 deletions.
84 changes: 52 additions & 32 deletions pages/workflow/PKPWorkflowHandler.inc.php
Expand Up @@ -221,6 +221,23 @@ function editorDecisionActions($args, $request) {
}
}

// If user is not assigned to the submission,
// see if the user is manager or sub-editor, and
// if the group is recommendOnly
if (!$recommendOnly && !$makeDecision) {
$userGroupDao = DAORegistry::getDAO('UserGroupDAO');
$userGroups = $userGroupDao->getByUserId($user->getId(), $request->getContext()->getId());
while ($userGroup = $userGroups->next()) {
if (in_array($userGroup->getRoleId(), array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR))) {
if (!$userGroup->getRecommendOnly()) {
$makeDecision = true;
} else {
$recommendOnly = true;
}
}
}
}

import('lib.pkp.classes.linkAction.request.AjaxModal');
$editorActions = array();
$lastRecommendation = $allRecommendations = null;
Expand All @@ -229,43 +246,41 @@ function editorDecisionActions($args, $request) {
$editDecisionDao = DAORegistry::getDAO('EditDecisionDAO');
$recommendationOptions = EditorDecisionActionsManager::getRecommendationOptions($stageId);
// If this is a review stage and the user has "recommend only role"
if (($stageId == WORKFLOW_STAGE_ID_EXTERNAL_REVIEW || $stageId == WORKFLOW_STAGE_ID_INTERNAL_REVIEW) && $recommendOnly) {
// Get the made editorial decisions from the current user
$editorDecisions = $editDecisionDao->getEditorDecisions($submission->getId(), $stageId, $reviewRound->getRound(), $user->getId());
// Get the last recommendation
foreach ($editorDecisions as $editorDecision) {
if (array_key_exists($editorDecision['decision'], $recommendationOptions)) {
if ($lastRecommendation) {
if ($editorDecision['dateDecided'] >= $lastRecommendation['dateDecided']) {
if (($stageId == WORKFLOW_STAGE_ID_EXTERNAL_REVIEW || $stageId == WORKFLOW_STAGE_ID_INTERNAL_REVIEW)) {
if ($recommendOnly) {
// Get the made editorial decisions from the current user
$editorDecisions = $editDecisionDao->getEditorDecisions($submission->getId(), $stageId, $reviewRound->getRound(), $user->getId());
// Get the last recommendation
foreach ($editorDecisions as $editorDecision) {
if (array_key_exists($editorDecision['decision'], $recommendationOptions)) {
if ($lastRecommendation) {
if ($editorDecision['dateDecided'] >= $lastRecommendation['dateDecided']) {
$lastRecommendation = $editorDecision;
}
} else {
$lastRecommendation = $editorDecision;
}
} else {
$lastRecommendation = $editorDecision;
}
}
}
if ($lastRecommendation) {
$lastRecommendation = __($recommendationOptions[$lastRecommendation['decision']]);
}
// Add the recommend link action.
$editorActions[] =
new LinkAction(
'recommendation',
new AjaxModal(
$dispatcher->url(
$request, ROUTE_COMPONENT, null,
'modals.editorDecision.EditorDecisionHandler',
'sendRecommendation', null, $actionArgs
if ($lastRecommendation) {
$lastRecommendation = __($recommendationOptions[$lastRecommendation['decision']]);
}
// Add the recommend link action.
$editorActions[] =
new LinkAction(
'recommendation',
new AjaxModal(
$dispatcher->url(
$request, ROUTE_COMPONENT, null,
'modals.editorDecision.EditorDecisionHandler',
'sendRecommendation', null, $actionArgs
),
$lastRecommendation ? __('editor.submission.changeRecommendation') : __('editor.submission.makeRecommendation'),
'review_recommendation'
),
$lastRecommendation ? __('editor.submission.changeRecommendation') : __('editor.submission.makeRecommendation'),
'review_recommendation'
),
$lastRecommendation ? __('editor.submission.changeRecommendation') : __('editor.submission.makeRecommendation')
);
}
// If this is not a review stage or the user can make decision
if (!($stageId == WORKFLOW_STAGE_ID_EXTERNAL_REVIEW || $stageId == WORKFLOW_STAGE_ID_INTERNAL_REVIEW) || $makeDecision) {
if ($makeDecision) { // It is a review stage
$lastRecommendation ? __('editor.submission.changeRecommendation') : __('editor.submission.makeRecommendation')
);
} elseif ($makeDecision) {
// Get the made editorial decisions from all users
$editorDecisions = $editDecisionDao->getEditorDecisions($submission->getId(), $stageId, $reviewRound->getRound());
// Get all recommendations
Expand All @@ -287,6 +302,10 @@ function editorDecisionActions($args, $request) {
$i++;
}
}
}
// In non-review stages, the user have to be able to make decisions,
// in order for editor actions to be displayed/available
if ($makeDecision) {
// Get the possible editor decisions for this stage
$decisions = EditorDecisionActionsManager::getStageDecisions($request->getContext(), $stageId);
// Iterate through the editor decisions and create a link action
Expand Down Expand Up @@ -316,6 +335,7 @@ function editorDecisionActions($args, $request) {
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign(array(
'editorActions' => $editorActions,
'editorsAssigned' => count($editorsStageAssignments) > 0,
'stageId' => $stageId,
'lastRecommendation' => $lastRecommendation,
'allRecommendations' => $allRecommendations,
Expand Down
2 changes: 1 addition & 1 deletion templates/workflow/editorialLinkActions.tpl
Expand Up @@ -31,7 +31,7 @@
{/foreach}
</ul>
{/if}
{elseif array_intersect(array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR), (array)$userRoles)}
{elseif !$editorsAssigned && array_intersect(array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR), (array)$userRoles)}
<div class="pkp_no_workflow_decisions">
{translate key="editor.submission.decision.noDecisionsAvailable"}
</div>
Expand Down

0 comments on commit 00e1b4d

Please sign in to comment.