Open Journal Systems  3.0.0
 All Data Structures 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 
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('lib.pkp.classes.security.authorization.EditorDecisionAccessPolicy');
48  $this->addPolicy(new EditorDecisionAccessPolicy($request, $args, $roleAssignments, 'submissionId', $stageId));
49  return parent::authorize($request, $args, $roleAssignments);
50  }
51 
52 
53  //
54  // Public handler actions
55  //
62  function saveNewReviewRound($args, $request) {
63  // FIXME: this can probably all be managed somewhere.
64  $stageId = $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE);
65  if ($stageId == WORKFLOW_STAGE_ID_EXTERNAL_REVIEW) {
66  $redirectOp = WORKFLOW_STAGE_PATH_EXTERNAL_REVIEW;
67  } else {
68  $redirectOp = null; // Suppress scrutinizer warn
69  assert(false);
70  }
71 
72  return $this->_saveEditorDecision($args, $request, 'NewReviewRoundForm', $redirectOp, SUBMISSION_EDITOR_DECISION_RESUBMIT);
73  }
74 
80  function saveApproveProof($args, $request) {
81  $submissionFile = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION_FILE);
82  $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
83 
84  // Make sure we only alter files associated with a galley.
85  if ($submissionFile->getAssocType() !== ASSOC_TYPE_GALLEY) {
86  fatalError('The requested file is not associated with any galley.');
87  }
88  if ($submissionFile->getViewable()) {
89 
90  // No longer expose the file to readers.
91  $submissionFile->setViewable(false);
92  } else {
93 
94  // Expose the file to readers (e.g. via e-commerce).
95  $submissionFile->setViewable(true);
96 
97  // Log the approve proof event.
98  import('lib.pkp.classes.log.SubmissionLog');
99  import('classes.log.SubmissionEventLogEntry'); // constants
100  $user = $request->getUser();
101 
102  $articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
103  $galley = $articleGalleyDao->getByBestGalleyId($submissionFile->getAssocId(), $submission->getId());
104 
105  SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_PROOFS_APPROVED, 'submission.event.proofsApproved', array('formatName' => $galley->getLabel(),'name' => $user->getFullName(), 'username' => $user->getUsername()));
106  }
107 
108  $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
109  $submissionFileDao->updateObject($submissionFile);
110 
111  // update the submission's file index
112  import('classes.search.ArticleSearchIndex');
113  ArticleSearchIndex::submissionFilesChanged($submission);
114 
115  return DAO::getDataChangedEvent($submissionFile->getId());
116  }
117 
118  //
119  // Private helper methods
120  //
125  protected function _getReviewRoundOps() {
126  return array('promoteInReview', 'savePromoteInReview', 'newReviewRound', 'saveNewReviewRound', 'sendReviewsInReview', 'saveSendReviewsInReview', 'importPeerReviews');
127  }
128 
129  protected function _saveGeneralPromote($args, $request) {
130  // Redirect to the next workflow page after
131  // promoting the submission.
132  $decision = (int)$request->getUserVar('decision');
133 
134  $redirectOp = null;
135 
136  if ($decision == SUBMISSION_EDITOR_DECISION_ACCEPT) {
137  $redirectOp = WORKFLOW_STAGE_PATH_EDITING;
138  } elseif ($decision == SUBMISSION_EDITOR_DECISION_EXTERNAL_REVIEW) {
139  $redirectOp = WORKFLOW_STAGE_PATH_EXTERNAL_REVIEW;
140  } elseif ($decision == SUBMISSION_EDITOR_DECISION_SEND_TO_PRODUCTION) {
141  $redirectOp = WORKFLOW_STAGE_PATH_PRODUCTION;
142  }
143 
144  // Make sure user has access to the workflow stage.
145  import('lib.pkp.classes.workflow.WorkflowStageDAO');
146  $redirectWorkflowStage = WorkflowStageDAO::getIdFromPath($redirectOp);
147  $userAccessibleWorkflowStages = $this->getAuthorizedContextObject(ASSOC_TYPE_ACCESSIBLE_WORKFLOW_STAGES);
148  if (!array_key_exists($redirectWorkflowStage, $userAccessibleWorkflowStages)) {
149  $redirectOp = null;
150  }
151 
152  return $this->_saveEditorDecision($args, $request, 'PromoteForm', $redirectOp);
153  }
154 
160  protected function _getNotificationTypeByEditorDecision($decision) {
161  switch ($decision) {
162  case SUBMISSION_EDITOR_DECISION_ACCEPT:
163  return NOTIFICATION_TYPE_EDITOR_DECISION_ACCEPT;
164  case SUBMISSION_EDITOR_DECISION_EXTERNAL_REVIEW:
165  return NOTIFICATION_TYPE_EDITOR_DECISION_EXTERNAL_REVIEW;
166  case SUBMISSION_EDITOR_DECISION_PENDING_REVISIONS:
167  return NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS;
168  case SUBMISSION_EDITOR_DECISION_RESUBMIT:
169  return NOTIFICATION_TYPE_EDITOR_DECISION_RESUBMIT;
170  case SUBMISSION_EDITOR_DECISION_DECLINE:
171  return NOTIFICATION_TYPE_EDITOR_DECISION_DECLINE;
172  case SUBMISSION_EDITOR_DECISION_SEND_TO_PRODUCTION:
173  return NOTIFICATION_TYPE_EDITOR_DECISION_SEND_TO_PRODUCTION;
174  default:
175  assert(false);
176  return null;
177  }
178  }
179 
184  protected function _getReviewStages() {
185  return array(WORKFLOW_STAGE_ID_INTERNAL_REVIEW, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW);
186  }
187 
191  protected function _getReviewNotificationTypes() {
192  return array(NOTIFICATION_TYPE_PENDING_EXTERNAL_REVISIONS);
193  }
194 
200  protected function _resolveEditorDecisionForm($formName) {
201  switch($formName) {
202  case 'InitiateExternalReviewForm':
203  return "controllers.modals.editorDecision.form.$formName";
204  default:
205  return parent::_resolveEditorDecisionForm($formName);
206  }
207  }
208 }
209 
210 ?>
static & getDAO($name, $dbconn=null)
addPolicy($authorizationPolicy, $addToTop=false)
authorize($request, &$args, $roleAssignments)
Class to control access to submission workflow stage components.
static getIdFromPath($stagePath)
addRoleAssignment($roleIds, $operations)
_saveEditorDecision($args, $request, $formName, $redirectOp=null, $decision=null)
static logEvent($request, $submission, $eventType, $messageKey, $params=array())
static getDataChangedEvent($elementId=null, $parentElementId=null, $content= '')
Definition: DAO.inc.php:633
& getAuthorizedContextObject($assocType)
Handle requests for editors to make a decision.