Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
EditorDecisionForm.inc.php
1 <?php
2 
16 import('lib.pkp.classes.form.Form');
17 
18 // Define review round and review stage id constants.
19 import('lib.pkp.classes.submission.reviewRound.ReviewRound');
20 
21 class EditorDecisionForm extends Form {
23  var $_submission;
24 
26  var $_stageId;
27 
29  var $_reviewRound;
30 
33 
34 
42  function EditorDecisionForm($submission, $decision, $stageId, $template, $reviewRound = null) {
43  parent::Form($template);
44  $this->_submission = $submission;
45  $this->_stageId = $stageId;
46  $this->_reviewRound = $reviewRound;
47  $this->_decision = $decision;
48 
49  // Validation checks for this form
50  $this->addCheck(new FormValidatorPost($this));
51  }
52 
53  //
54  // Getters and Setters
55  //
60  function getDecision() {
61  return $this->_decision;
62  }
63 
68  function getSubmission() {
69  return $this->_submission;
70  }
71 
76  function getStageId() {
77  return $this->_stageId;
78  }
79 
84  function getReviewRound() {
85  return $this->_reviewRound;
86  }
87 
88  //
89  // Overridden template methods from Form
90  //
94  function readInputData() {
95  $this->readUserVars(array('selectedFiles'));
96  parent::initData();
97  }
98 
99 
103  function fetch($request) {
104  $submission = $this->getSubmission();
105 
106  $reviewRound = $this->getReviewRound();
107  if (is_a($reviewRound, 'ReviewRound')) {
108  $this->setData('reviewRoundId', $reviewRound->getId());
109  }
110 
111  $this->setData('stageId', $this->getStageId());
112 
113  // Set the submission.
114  $templateMgr = TemplateManager::getManager($request);
115  $templateMgr->assign('submissionId', $submission->getId());
116  $templateMgr->assign('submission', $submission);
117 
118  // Set the decision related data.
120  $templateMgr->assign('decisionData', $stageDecisions[$this->getDecision()]);
121 
122  return parent::fetch($request);
123  }
124 
125 
126  //
127  // Private helper methods
128  //
138  function _initiateReviewRound($submission, $stageId, $request, $status = null) {
139 
140  // If we already have review round for this stage,
141  // we create a new round after the last one.
142  $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /* @var $reviewRoundDao ReviewRoundDAO */
143  $lastReviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($submission->getId(), $stageId);
144  if ($lastReviewRound) {
145  $newRound = $lastReviewRound->getRound() + 1;
146  } else {
147  // If we don't have any review round, we create the first one.
148  $newRound = 1;
149  }
151  // Create a new review round.
152  $reviewRound = $reviewRoundDao->build($submission->getId(), $stageId, $newRound, $status);
153 
154  // Check for a notification already in place for the current review round.
155  $notificationDao = DAORegistry::getDAO('NotificationDAO');
156  $notificationFactory = $notificationDao->getByAssoc(
157  ASSOC_TYPE_REVIEW_ROUND,
158  $reviewRound->getId(),
159  null,
160  NOTIFICATION_TYPE_REVIEW_ROUND_STATUS,
161  $submission->getContextId()
162  );
163 
164  // Create round status notification if there is no notification already.
165  if ($notificationFactory->wasEmpty()) {
166  $notificationMgr = new NotificationManager();
167  $notificationMgr->createNotification(
168  $request,
169  null,
170  NOTIFICATION_TYPE_REVIEW_ROUND_STATUS,
171  $submission->getContextId(),
172  ASSOC_TYPE_REVIEW_ROUND,
173  $reviewRound->getId(),
174  NOTIFICATION_LEVEL_NORMAL
175  );
176  }
177 
178  // Add the selected files to the new round.
179  $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */
180 
181  // Bring in the SUBMISSION_FILE_* constants.
182  import('lib.pkp.classes.submission.SubmissionFile');
183  // Bring in the Manager (we need it).
184  import('lib.pkp.classes.file.SubmissionFileManager');
185  $submissionFileManager = new SubmissionFileManager($submission->getContextId(), $submission->getId());
186  foreach (array('selectedFiles', 'selectedAttachments') as $userVar) {
187  $selectedFiles = $this->getData($userVar);
188  if(is_array($selectedFiles)) {
189  foreach ($selectedFiles as $fileId) {
190  // Retrieve the file last revision number.
191  $revisionNumber = $submissionFileDao->getLatestRevisionNumber($fileId);
192  list($newFileId, $newRevision) = $submissionFileManager->copyFileToFileStage($fileId, $revisionNumber, SUBMISSION_FILE_REVIEW_FILE, null, true);
193  $submissionFileDao->assignRevisionToReviewRound($newFileId, $newRevision, $reviewRound);
194  }
195  }
196  }
197 
198  return $newRound;
199  }
200 }
201 
202 ?>
static & getDAO($name, $dbconn=null)
addCheck($formValidator)
Definition: Form.inc.php:396
setData($key, $value)
Definition: Form.inc.php:219
Base class for the editor decision forms.
Form validation check to make sure the form is POSTed.
readUserVars($vars)
Definition: Form.inc.php:364
Class defining basic operations for handling HTML forms.
Definition: Form.inc.php:47
getData($key)
Definition: Form.inc.php:210
_initiateReviewRound($submission, $stageId, $request, $status=null)
EditorDecisionForm($submission, $decision, $stageId, $template, $reviewRound=null)