diff --git a/pages/workflow/PKPWorkflowHandler.inc.php b/pages/workflow/PKPWorkflowHandler.inc.php index aff4cd293ad..cd1d6bfe5af 100644 --- a/pages/workflow/PKPWorkflowHandler.inc.php +++ b/pages/workflow/PKPWorkflowHandler.inc.php @@ -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; @@ -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 @@ -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 @@ -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, diff --git a/templates/workflow/editorialLinkActions.tpl b/templates/workflow/editorialLinkActions.tpl index 285df7f2fc0..0fd81ce1fea 100644 --- a/templates/workflow/editorialLinkActions.tpl +++ b/templates/workflow/editorialLinkActions.tpl @@ -31,7 +31,7 @@ {/foreach} {/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)}
{translate key="editor.submission.decision.noDecisionsAvailable"}