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  // Retrieve the authorized submission.
65  $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
66  // FIXME: this can probably all be managed somewhere.
67  $stageId = $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE);
68  if ($stageId == WORKFLOW_STAGE_ID_EXTERNAL_REVIEW) {
69  $redirectOp = WORKFLOW_STAGE_PATH_EXTERNAL_REVIEW;
70  } else {
71  assert(false);
72  }
73 
74  return $this->_saveEditorDecision($args, $request, 'NewReviewRoundForm', $redirectOp, SUBMISSION_EDITOR_DECISION_RESUBMIT);
75  }
76 
82  function saveApproveProof($args, $request) {
83  $submissionFile = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION_FILE);
84  $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
85 
86  // Make sure we only alter files associated with a galley.
87  if ($submissionFile->getAssocType() !== ASSOC_TYPE_GALLEY) {
88  fatalError('The requested file is not associated with any galley.');
89  }
90  if ($submissionFile->getViewable()) {
91 
92  // No longer expose the file to readers.
93  $submissionFile->setViewable(false);
94  } else {
95 
96  // Expose the file to readers (e.g. via e-commerce).
97  $submissionFile->setViewable(true);
98 
99  // Log the approve proof event.
100  import('lib.pkp.classes.log.SubmissionLog');
101  import('classes.log.SubmissionEventLogEntry'); // constants
102  $user = $request->getUser();
103 
104  $articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
105  $galley = $articleGalleyDao->getGalleyByBestGalleyId($submissionFile->getAssocId(), $submission->getId());
106 
107  SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_PROOFS_APPROVED, 'submission.event.proofsApproved', array('formatName' => $galley->getLabel(),'name' => $user->getFullName(), 'username' => $user->getUsername()));
108  }
109 
110  $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
111  $submissionFileDao->updateObject($submissionFile);
112 
113  // update the submission's file index
114  import('classes.search.ArticleSearchIndex');
116 
117  return DAO::getDataChangedEvent($submissionFile->getId());
118  }
119 
120  //
121  // Private helper methods
122  //
127  protected function _getReviewRoundOps() {
128  return array('promoteInReview', 'savePromoteInReview', 'newReviewRound', 'saveNewReviewRound', 'sendReviewsInReview', 'saveSendReviewsInReview', 'importPeerReviews');
129  }
130 
131  protected function _saveGeneralPromote($args, $request) {
132  // Redirect to the next workflow page after
133  // promoting the submission.
134  $decision = (int)$request->getUserVar('decision');
135 
136  $redirectOp = null;
137 
138  if ($decision == SUBMISSION_EDITOR_DECISION_ACCEPT) {
139  $redirectOp = WORKFLOW_STAGE_PATH_EDITING;
140  } elseif ($decision == SUBMISSION_EDITOR_DECISION_EXTERNAL_REVIEW) {
141  $redirectOp = WORKFLOW_STAGE_PATH_EXTERNAL_REVIEW;
142  } elseif ($decision == SUBMISSION_EDITOR_DECISION_SEND_TO_PRODUCTION) {
143  $redirectOp = WORKFLOW_STAGE_PATH_PRODUCTION;
144  }
145 
146  // Make sure user has access to the workflow stage.
147  $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
148  $redirectWorkflowStage = $userGroupDao->getIdFromPath($redirectOp);
149  $userAccessibleWorkflowStages = $this->getAuthorizedContextObject(ASSOC_TYPE_ACCESSIBLE_WORKFLOW_STAGES);
150  if (!array_key_exists($redirectWorkflowStage, $userAccessibleWorkflowStages)) {
151  $redirectOp = null;
152  }
153 
154  return $this->_saveEditorDecision($args, $request, 'PromoteForm', $redirectOp);
155  }
156 
162  protected function _getNotificationTypeByEditorDecision($decision) {
163  switch ($decision) {
164  case SUBMISSION_EDITOR_DECISION_ACCEPT:
165  return NOTIFICATION_TYPE_EDITOR_DECISION_ACCEPT;
166  case SUBMISSION_EDITOR_DECISION_EXTERNAL_REVIEW:
167  return NOTIFICATION_TYPE_EDITOR_DECISION_EXTERNAL_REVIEW;
168  case SUBMISSION_EDITOR_DECISION_PENDING_REVISIONS:
169  return NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS;
170  case SUBMISSION_EDITOR_DECISION_RESUBMIT:
171  return NOTIFICATION_TYPE_EDITOR_DECISION_RESUBMIT;
172  case SUBMISSION_EDITOR_DECISION_DECLINE:
173  return NOTIFICATION_TYPE_EDITOR_DECISION_DECLINE;
174  case SUBMISSION_EDITOR_DECISION_SEND_TO_PRODUCTION:
175  return NOTIFICATION_TYPE_EDITOR_DECISION_SEND_TO_PRODUCTION;
176  default:
177  assert(false);
178  return null;
179  }
180  }
181 
186  protected function _getReviewStages() {
187  return array(WORKFLOW_STAGE_ID_INTERNAL_REVIEW, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW);
188  }
189 
193  protected function _getReviewNotificationTypes() {
194  return array(NOTIFICATION_TYPE_PENDING_EXTERNAL_REVISIONS);
195  }
196 
202  protected function _resolveEditorDecisionForm($formName) {
203  switch($formName) {
204  case 'InitiateExternalReviewForm':
205  return "controllers.modals.editorDecision.form.$formName";
206  default:
207  return parent::_resolveEditorDecisionForm($formName);
208  }
209  }
210 }
211 
212 ?>
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.