Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
PromoteForm.inc.php
1 <?php
2 
16 import('lib.pkp.controllers.modals.editorDecision.form.EditorDecisionWithEmailForm');
17 
18 // Access decision actions constants.
19 import('classes.workflow.EditorDecisionActionsManager');
20 
22 
30  function PromoteForm(&$seriesEditorSubmission, $decision, $stageId, $reviewRound = null) {
31  if (!in_array($decision, $this->_getDecisions())) {
32  fatalError('Invalid decision!');
33  }
34 
35  $this->setSaveFormOperation('savePromote');
36 
37  parent::EditorDecisionWithEmailForm(
38  $seriesEditorSubmission, $decision, $stageId,
39  'controllers/modals/editorDecision/form/promoteForm.tpl',
40  $reviewRound
41  );
42  }
43 
44 
45  //
46  // Implement protected template methods from Form
47  //
51  function initData($args, $request) {
53 
54  $seriesEditorSubmission = $this->getSubmission();
55  $this->setData('stageId', $this->getStageId());
56 
57  return parent::initData($args, $request, $actionLabels);
58  }
59 
63  function execute($args, $request) {
64  // Retrieve the submission.
65  $seriesEditorSubmission = $this->getSubmission();
66 
67  // Get this form decision actions labels.
69 
70  // Record the decision.
71  $reviewRound = $this->getReviewRound();
72  $decision = $this->getDecision();
73  import('lib.pkp.classes.submission.action.EditorAction');
74  $editorAction = new EditorAction();
75  $editorAction->recordDecision($request, $seriesEditorSubmission, $decision, $actionLabels, $reviewRound);
76 
77  // Identify email key and status of round.
78  import('lib.pkp.classes.file.SubmissionFileManager');
79  $submissionFileManager = new SubmissionFileManager($seriesEditorSubmission->getContextId(), $seriesEditorSubmission->getId());
80  switch ($decision) {
81  case SUBMISSION_EDITOR_DECISION_ACCEPT:
82  $emailKey = 'EDITOR_DECISION_ACCEPT';
83  $status = REVIEW_ROUND_STATUS_ACCEPTED;
84 
85  $this->_updateReviewRoundStatus($seriesEditorSubmission, $status, $reviewRound);
86 
87  // Move to the editing stage.
88  $editorAction->incrementWorkflowStage($seriesEditorSubmission, WORKFLOW_STAGE_ID_EDITING, $request);
89 
90  // Bring in the SUBMISSION_FILE_* constants.
91  import('lib.pkp.classes.submission.SubmissionFile');
92  // Bring in the Manager (we need it).
93  import('lib.pkp.classes.file.SubmissionFileManager');
94 
95  $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */
96 
97  $selectedFiles = $this->getData('selectedFiles');
98  if(is_array($selectedFiles)) {
99  foreach ($selectedFiles as $fileId) {
100  $revisionNumber = $submissionFileDao->getLatestRevisionNumber($fileId);
101  $submissionFileManager->copyFileToFileStage($fileId, $revisionNumber, SUBMISSION_FILE_FINAL, null, true);
102  }
103  }
104 
105  // Send email to the author.
106  $this->_sendReviewMailToAuthor($seriesEditorSubmission, $emailKey, $request);
107  break;
108 
109  case SUBMISSION_EDITOR_DECISION_EXTERNAL_REVIEW:
110  $emailKey = 'EDITOR_DECISION_SEND_TO_EXTERNAL';
111  $status = REVIEW_ROUND_STATUS_SENT_TO_EXTERNAL;
112 
113  $this->_updateReviewRoundStatus($seriesEditorSubmission, $status, $reviewRound);
114 
115  // Move to the external review stage.
116  $editorAction->incrementWorkflowStage($seriesEditorSubmission, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW, $request);
117 
118  // Create an initial external review round.
119  $this->_initiateReviewRound($seriesEditorSubmission, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW, $request, REVIEW_ROUND_STATUS_PENDING_REVIEWERS);
120 
121  // Send email to the author.
122  $this->_sendReviewMailToAuthor($seriesEditorSubmission, $emailKey, $request);
123  break;
124  case SUBMISSION_EDITOR_DECISION_SEND_TO_PRODUCTION:
125  $emailKey = 'EDITOR_DECISION_SEND_TO_PRODUCTION';
126  // FIXME: this is copy-pasted from above, save the FILE_GALLEY.
127 
128  // Move to the editing stage.
129  $editorAction->incrementWorkflowStage($seriesEditorSubmission, WORKFLOW_STAGE_ID_PRODUCTION, $request);
130 
131  // Bring in the SUBMISSION_FILE_* constants.
132  import('lib.pkp.classes.submission.SubmissionFile');
133  // Bring in the Manager (we need it).
134  import('lib.pkp.classes.file.SubmissionFileManager');
135 
136  // Move the revisions to the next stage
137  $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */
138 
139  $selectedFiles = $this->getData('selectedFiles');
140  if(is_array($selectedFiles)) {
141  foreach ($selectedFiles as $fileId) {
142  $revisionNumber = $submissionFileDao->getLatestRevisionNumber($fileId);
143  $submissionFileManager->copyFileToFileStage($fileId, $revisionNumber, SUBMISSION_FILE_PRODUCTION_READY);
144  }
145  }
146  // Send email to the author.
147  $this->_sendReviewMailToAuthor($seriesEditorSubmission, $emailKey, $request);
148  break;
149  default:
150  fatalError('Unsupported decision!');
151  }
152  }
153 
154  //
155  // Private functions
156  //
161  function _getDecisions() {
162  return array(
163  SUBMISSION_EDITOR_DECISION_EXTERNAL_REVIEW,
164  SUBMISSION_EDITOR_DECISION_ACCEPT,
165  SUBMISSION_EDITOR_DECISION_SEND_TO_PRODUCTION
166  );
167  }
168 }
169 
170 ?>
static & getDAO($name, $dbconn=null)
PromoteForm(&$seriesEditorSubmission, $decision, $stageId, $reviewRound=null)
setData($key, $value)
Definition: Form.inc.php:219
Form for promoting a submission (to external review or editing)
initData($args, $request)
getData($key)
Definition: Form.inc.php:210
_initiateReviewRound($submission, $stageId, $request, $status=null)
Base class for the editor decision forms.
_updateReviewRoundStatus($submission, $status, $reviewRound=null)
_sendReviewMailToAuthor($submission, $emailKey, $request)
Editor actions.
execute($args, $request)