Open Journal Systems  3.0.0
 All Classes Namespaces Functions Variables Groups Pages
EditorDecisionHandler.inc.php
1 <?php
2 
16 import('lib.pkp.classes.controllers.modals.editorDecision.PKPEditorDecisionHandler');
17 
18 // Access decision actions constants.
19 import('classes.workflow.EditorDecisionActionsManager');
20 
21 class EditorDecisionHandler extends PKPEditorDecisionHandler {
25  function EditorDecisionHandler() {
26  parent::PKPEditorDecisionHandler();
27 
28  $this->addRoleAssignment(
29  array(ROLE_ID_SUB_EDITOR, ROLE_ID_MANAGER),
30  array_merge(array(
31  'externalReview', 'saveExternalReview',
32  'sendReviews', 'saveSendReviews',
33  'promote', 'savePromote', 'saveApproveProof'
34  ), $this->_getReviewRoundOps())
35  );
36  }
37 
38 
39  //
40  // Implement template methods from PKPHandler
41  //
45  function authorize($request, &$args, $roleAssignments) {
46  $stageId = (int) $request->getUserVar('stageId');
47  import('classes.security.authorization.OjsEditorDecisionAccessPolicy');
48  $this->addPolicy(new OjsEditorDecisionAccessPolicy($request, $args, $roleAssignments, 'submissionId', $stageId));
49 
50  return parent::authorize($request, $args, $roleAssignments);
51  }
52 
53 
54  //
55  // Public handler actions
56  //
63  function saveNewReviewRound($args, $request) {
64  // FIXME: this can probably all be managed somewhere.
65  $stageId = $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE);
66  if ($stageId == WORKFLOW_STAGE_ID_EXTERNAL_REVIEW) {
67  $redirectOp = WORKFLOW_STAGE_PATH_EXTERNAL_REVIEW;
68  } else {
69  $redirectOp = null; // Suppress scrutinizer warn
70  assert(false);
71  }
72 
73  return $this->_saveEditorDecision($args, $request, 'NewReviewRoundForm', $redirectOp, SUBMISSION_EDITOR_DECISION_RESUBMIT);
74  }
75 
81  function saveApproveProof($args, $request) {
82  $submissionFile = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION_FILE);
83  $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
84 
85  // Make sure we only alter files associated with a galley.
86  if ($submissionFile->getAssocType() !== ASSOC_TYPE_GALLEY) {
87  fatalError('The requested file is not associated with any galley.');
88  }
89  if ($submissionFile->getViewable()) {
90 
91  // No longer expose the file to readers.
92  $submissionFile->setViewable(false);
93  } else {
94 
95  // Expose the file to readers (e.g. via e-commerce).
96  $submissionFile->setViewable(true);
97 
98  // Log the approve proof event.
99  import('lib.pkp.classes.log.SubmissionLog');
100  import('classes.log.SubmissionEventLogEntry'); // constants
101  $user = $request->getUser();
102 
103  $articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
104  $galley = $articleGalleyDao->getGalleyByBestGalleyId($submissionFile->getAssocId(), $submission->getId());
105 
106  SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_PROOFS_APPROVED, 'submission.event.proofsApproved', array('formatName' => $galley->getLabel(),'name' => $user->getFullName(), 'username' => $user->getUsername()));
107  }
108 
109  $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
110  $submissionFileDao->updateObject($submissionFile);
111 
112  // update the submission's file index
113  import('classes.search.ArticleSearchIndex');
115 
116  return DAO::getDataChangedEvent($submissionFile->getId());
117  }
118 
119  //
120  // Private helper methods
121  //
126  protected function _getReviewRoundOps() {
127  return array('promoteInReview', 'savePromoteInReview', 'newReviewRound', 'saveNewReviewRound', 'sendReviewsInReview', 'saveSendReviewsInReview', 'importPeerReviews');
128  }
129 
130  protected function _saveGeneralPromote($args, $request) {
131  // Redirect to the next workflow page after
132  // promoting the submission.
133  $decision = (int)$request->getUserVar('decision');
134 
135  $redirectOp = null;
136 
137  if ($decision == SUBMISSION_EDITOR_DECISION_ACCEPT) {
138  $redirectOp = WORKFLOW_STAGE_PATH_EDITING;
139  } elseif ($decision == SUBMISSION_EDITOR_DECISION_EXTERNAL_REVIEW) {
140  $redirectOp = WORKFLOW_STAGE_PATH_EXTERNAL_REVIEW;
141  } elseif ($decision == SUBMISSION_EDITOR_DECISION_SEND_TO_PRODUCTION) {
142  $redirectOp = WORKFLOW_STAGE_PATH_PRODUCTION;
143  }
144 
145  // Make sure user has access to the workflow stage.
146  $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
147  $redirectWorkflowStage = $userGroupDao->getIdFromPath($redirectOp);
148  $userAccessibleWorkflowStages = $this->getAuthorizedContextObject(ASSOC_TYPE_ACCESSIBLE_WORKFLOW_STAGES);
149  if (!array_key_exists($redirectWorkflowStage, $userAccessibleWorkflowStages)) {
150  $redirectOp = null;
151  }
152 
153  return $this->_saveEditorDecision($args, $request, 'PromoteForm', $redirectOp);
154  }
155 
161  protected function _getNotificationTypeByEditorDecision($decision) {
162  switch ($decision) {
163  case SUBMISSION_EDITOR_DECISION_ACCEPT:
164  return NOTIFICATION_TYPE_EDITOR_DECISION_ACCEPT;
165  case SUBMISSION_EDITOR_DECISION_EXTERNAL_REVIEW:
166  return NOTIFICATION_TYPE_EDITOR_DECISION_EXTERNAL_REVIEW;
167  case SUBMISSION_EDITOR_DECISION_PENDING_REVISIONS:
168  return NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS;
169  case SUBMISSION_EDITOR_DECISION_RESUBMIT:
170  return NOTIFICATION_TYPE_EDITOR_DECISION_RESUBMIT;
171  case SUBMISSION_EDITOR_DECISION_DECLINE:
172  return NOTIFICATION_TYPE_EDITOR_DECISION_DECLINE;
173  case SUBMISSION_EDITOR_DECISION_SEND_TO_PRODUCTION:
174  return NOTIFICATION_TYPE_EDITOR_DECISION_SEND_TO_PRODUCTION;
175  default:
176  assert(false);
177  return null;
178  }
179  }
180 
185  protected function _getReviewStages() {
186  return array(WORKFLOW_STAGE_ID_INTERNAL_REVIEW, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW);
187  }
188 
192  protected function _getReviewNotificationTypes() {
193  return array(NOTIFICATION_TYPE_PENDING_EXTERNAL_REVISIONS);
194  }
195 
201  protected function _resolveEditorDecisionForm($formName) {
202  switch($formName) {
203  case 'InitiateExternalReviewForm':
204  return "controllers.modals.editorDecision.form.$formName";
205  default:
206  return parent::_resolveEditorDecisionForm($formName);
207  }
208  }
209 }
210 
211 ?>
static & getDAO($name, $dbconn=null)
addPolicy($authorizationPolicy, $addToTop=false)
authorize($request, &$args, $roleAssignments)
Class to control access to OJS&#39;s submission workflow stage components.
addRoleAssignment($roleIds, $operations)
static getDataChangedEvent($elementId=null, $parentElementId=null)
Definition: DAO.inc.php:606
static logEvent($request, $submission, $eventType, $messageKey, $params=array())
& getAuthorizedContextObject($assocType)
Handle requests for editors to make a decision.