Open Journal Systems  2.4.3
 All Classes Namespaces Functions Variables Groups Pages
ReviewerAction.inc.php
1 <?php
2 
16 import('classes.submission.common.Action');
17 
18 class ReviewerAction extends Action {
19 
23  function ReviewerAction() {
24  }
25 
38  function confirmReview($reviewerSubmission, $decline, $send, $request) {
39  $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
40  $userDao =& DAORegistry::getDAO('UserDAO');
41 
42  $reviewId = $reviewerSubmission->getReviewId();
43 
44  $reviewAssignment =& $reviewAssignmentDao->getById($reviewId);
45  $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
46  if (!isset($reviewer)) return true;
47 
48  // Only confirm the review for the reviewer if
49  // he has not previously done so.
50  if ($reviewAssignment->getDateConfirmed() == null) {
51  import('classes.mail.ArticleMailTemplate');
52  $email = new ArticleMailTemplate($reviewerSubmission, $decline?'REVIEW_DECLINE':'REVIEW_CONFIRM');
53  // Must explicitly set sender because we may be here on an access
54  // key, in which case the user is not technically logged in
55  $email->setFrom($reviewer->getEmail(), $reviewer->getFullName());
56  if (!$email->isEnabled() || ($send && !$email->hasErrors())) {
57  HookRegistry::call('ReviewerAction::confirmReview', array(&$reviewerSubmission, &$email, $decline));
58  if ($email->isEnabled()) {
59  $email->send($request);
60  }
61 
62  $reviewAssignment->setDateReminded(null);
63  $reviewAssignment->setReminderWasAutomatic(null);
64  $reviewAssignment->setDeclined($decline);
65  $reviewAssignment->setDateConfirmed(Core::getCurrentDate());
66  $reviewAssignment->stampModified();
67  $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
68 
69  // Add log
70  import('classes.article.log.ArticleLog');
71  ArticleLog::logEvent($request, $reviewerSubmission, $decline?ARTICLE_LOG_REVIEW_DECLINE:ARTICLE_LOG_REVIEW_ACCEPT, $decline?'log.review.reviewDeclined':'log.review.reviewAccepted', array('reviewerName' => $reviewer->getFullName(), 'articleId' => $reviewAssignment->getSubmissionId(), 'round' => $reviewAssignment->getRound(), 'reviewId' => $reviewAssignment->getId()));
72  return true;
73  } else {
74  if (!$request->getUserVar('continued')) {
75  $assignedEditors = $email->ccAssignedEditors($reviewerSubmission->getId());
76  $reviewingSectionEditors = $email->toAssignedReviewingSectionEditors($reviewerSubmission->getId());
77  if (empty($assignedEditors) && empty($reviewingSectionEditors)) {
78  $journal =& $request->getJournal();
79  $email->addRecipient($journal->getSetting('contactEmail'), $journal->getSetting('contactName'));
80  $editorialContactName = $journal->getSetting('contactName');
81  } else {
82  if (!empty($reviewingSectionEditors)) $editorialContact = array_shift($reviewingSectionEditors);
83  else $editorialContact = array_shift($assignedEditors);
84  $editorialContactName = $editorialContact->getEditorFullName();
85  }
86  $email->promoteCcsIfNoRecipients();
87 
88  // Format the review due date
89  $reviewDueDate = strtotime($reviewAssignment->getDateDue());
90  $dateFormatShort = Config::getVar('general', 'date_format_short');
91  if ($reviewDueDate == -1) $reviewDueDate = $dateFormatShort; // Default to something human-readable if no date specified
92  else $reviewDueDate = strftime($dateFormatShort, $reviewDueDate);
93 
94  $email->assignParams(array(
95  'editorialContactName' => $editorialContactName,
96  'reviewerName' => $reviewer->getFullName(),
97  'reviewDueDate' => $reviewDueDate
98  ));
99  }
100  $paramArray = array('reviewId' => $reviewId);
101  if ($decline) $paramArray['declineReview'] = 1;
102  $email->displayEditForm($request->url(null, 'reviewer', 'confirmReview'), $paramArray);
103  return false;
104  }
105  }
106  return true;
107  }
108 
116  function recordRecommendation(&$reviewerSubmission, $recommendation, $send, $request) {
117  $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
118  $userDao =& DAORegistry::getDAO('UserDAO');
119 
120  // Check validity of selected recommendation
121  $reviewerRecommendationOptions =& ReviewAssignment::getReviewerRecommendationOptions();
122  if (!isset($reviewerRecommendationOptions[$recommendation])) return true;
123 
124  $reviewAssignment =& $reviewAssignmentDao->getById($reviewerSubmission->getReviewId());
125  $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
126  if (!isset($reviewer)) return true;
127 
128  // Only record the reviewers recommendation if
129  // no recommendation has previously been submitted.
130  if ($reviewAssignment->getRecommendation() === null || $reviewAssignment->getRecommendation === '') {
131  import('classes.mail.ArticleMailTemplate');
132  $email = new ArticleMailTemplate($reviewerSubmission, 'REVIEW_COMPLETE');
133  // Must explicitly set sender because we may be here on an access
134  // key, in which case the user is not technically logged in
135  $email->setFrom($reviewer->getEmail(), $reviewer->getFullName());
136 
137  if (!$email->isEnabled() || ($send && !$email->hasErrors())) {
138  HookRegistry::call('ReviewerAction::recordRecommendation', array(&$reviewerSubmission, &$email, $recommendation));
139  if ($email->isEnabled()) {
140  $email->send($request);
141  }
142 
143  $reviewAssignment->setRecommendation($recommendation);
144  $reviewAssignment->setDateCompleted(Core::getCurrentDate());
145  $reviewAssignment->stampModified();
146  $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
147 
148  // Add log
149  import('classes.article.log.ArticleLog');
150  ArticleLog::logEvent($request, $reviewerSubmission, ARTICLE_LOG_REVIEW_RECOMMENDATION, 'log.review.reviewRecommendationSet', array('reviewerName' => $reviewer->getFullName(), 'articleId' => $reviewAssignment->getSubmissionId(), 'round' => $reviewAssignment->getRound(), 'reviewId' => $reviewAssignment->getId()));
151  } else {
152  if (!$request->getUserVar('continued')) {
153  $assignedEditors = $email->ccAssignedEditors($reviewerSubmission->getId());
154  $reviewingSectionEditors = $email->toAssignedReviewingSectionEditors($reviewerSubmission->getId());
155  if (empty($assignedEditors) && empty($reviewingSectionEditors)) {
156  $journal =& Request::getJournal();
157  $email->addRecipient($journal->getSetting('contactEmail'), $journal->getSetting('contactName'));
158  $editorialContactName = $journal->getSetting('contactName');
159  } else {
160  if (!empty($reviewingSectionEditors)) $editorialContact = array_shift($reviewingSectionEditors);
161  else $editorialContact = array_shift($assignedEditors);
162  $editorialContactName = $editorialContact->getEditorFullName();
163  }
164 
165  $reviewerRecommendationOptions =& ReviewAssignment::getReviewerRecommendationOptions();
166 
167  $email->assignParams(array(
168  'editorialContactName' => $editorialContactName,
169  'reviewerName' => $reviewer->getFullName(),
170  'articleTitle' => strip_tags($reviewerSubmission->getLocalizedTitle()),
171  'recommendation' => __($reviewerRecommendationOptions[$recommendation])
172  ));
173  }
174 
175  $email->displayEditForm($request->url(null, 'reviewer', 'recordRecommendation'),
176  array('reviewId' => $reviewerSubmission->getReviewId(), 'recommendation' => $recommendation)
177  );
178  return false;
179  }
180  }
181  return true;
182  }
183 
190  function uploadReviewerVersion($reviewId, $reviewerSubmission, $request) {
191  import('classes.file.ArticleFileManager');
192  $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
193  $reviewAssignment =& $reviewAssignmentDao->getById($reviewId);
194 
195  $articleFileManager = new ArticleFileManager($reviewAssignment->getSubmissionId());
196 
197  // Only upload the file if the reviewer has yet to submit a recommendation
198  // and if review forms are not used
199  if (($reviewAssignment->getRecommendation() === null || $reviewAssignment->getRecommendation() === '') && !$reviewAssignment->getCancelled()) {
200  $fileName = 'upload';
201  if ($articleFileManager->uploadedFileExists($fileName)) {
202  HookRegistry::call('ReviewerAction::uploadReviewFile', array(&$reviewAssignment));
203  if ($reviewAssignment->getReviewerFileId() != null) {
204  $fileId = $articleFileManager->uploadReviewFile($fileName, $reviewAssignment->getReviewerFileId());
205  } else {
206  $fileId = $articleFileManager->uploadReviewFile($fileName);
207  }
208  }
209  }
210 
211  if (isset($fileId) && $fileId != 0) {
212  $reviewAssignment->setReviewerFileId($fileId);
213  $reviewAssignment->stampModified();
214  $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
215 
216  $userDao =& DAORegistry::getDAO('UserDAO');
217  $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
218 
219  // Add log
220  import('classes.article.log.ArticleLog');
221  ArticleLog::logEvent($request, $reviewerSubmission, ARTICLE_LOG_REVIEW_FILE, 'log.review.reviewerFile', array('reviewId' => $reviewAssignment->getId()));
222  }
223  }
224 
231  function deleteReviewerVersion($reviewId, $fileId, $revision = null) {
232  import('classes.file.ArticleFileManager');
233 
234  $articleId = Request::getUserVar('articleId');
235  $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
236  $reviewAssignment =& $reviewAssignmentDao->getById($reviewId);
237 
238  if (!HookRegistry::call('ReviewerAction::deleteReviewerVersion', array(&$reviewAssignment, &$fileId, &$revision))) {
239  $articleFileManager = new ArticleFileManager($reviewAssignment->getSubmissionId());
240  $articleFileManager->deleteFile($fileId, $revision);
241  }
242  }
243 
250  function viewPeerReviewComments(&$user, &$article, $reviewId) {
251  if (!HookRegistry::call('ReviewerAction::viewPeerReviewComments', array(&$user, &$article, &$reviewId))) {
252  import('classes.submission.form.comment.PeerReviewCommentForm');
253 
254  $commentForm = new PeerReviewCommentForm($article, $reviewId, ROLE_ID_REVIEWER);
255  $commentForm->setUser($user);
256  $commentForm->initData();
257  $commentForm->setData('reviewId', $reviewId);
258  $commentForm->display();
259  }
260  }
261 
270  function postPeerReviewComment(&$user, &$article, $reviewId, $emailComment, $request) {
271  if (!HookRegistry::call('ReviewerAction::postPeerReviewComment', array(&$user, &$article, &$reviewId, &$emailComment))) {
272  import('classes.submission.form.comment.PeerReviewCommentForm');
273 
274  $commentForm = new PeerReviewCommentForm($article, $reviewId, ROLE_ID_REVIEWER);
275  $commentForm->setUser($user);
276  $commentForm->readInputData();
277 
278  if ($commentForm->validate()) {
279  $commentForm->execute();
280 
281  // Send a notification to associated users
282  import('classes.notification.NotificationManager');
283  $notificationManager = new NotificationManager();
284  $notificationUsers = $article->getAssociatedUserIds(false, false);
285  foreach ($notificationUsers as $userRole) {
286  $notificationManager->createNotification(
287  $request, $userRole['id'], NOTIFICATION_TYPE_REVIEWER_COMMENT,
288  $article->getJournalId(), ASSOC_TYPE_ARTICLE, $article->getId()
289  );
290  }
291 
292  if ($emailComment) {
293  $commentForm->email($request);
294  }
295 
296  } else {
297  $commentForm->display();
298  return false;
299  }
300  return true;
301  }
302  }
303 
309  function editReviewFormResponse($reviewId, $reviewFormId) {
310  if (!HookRegistry::call('ReviewerAction::editReviewFormResponse', array($reviewId, $reviewFormId))) {
311  import('classes.submission.form.ReviewFormResponseForm');
312 
313  $reviewForm = new ReviewFormResponseForm($reviewId, $reviewFormId);
314  $reviewForm->initData();
315  $reviewForm->display();
316  }
317  }
318 
325  function saveReviewFormResponse($reviewId, $reviewFormId, $request) {
326  if (!HookRegistry::call('ReviewerAction::saveReviewFormResponse', array($reviewId, $reviewFormId))) {
327  import('classes.submission.form.ReviewFormResponseForm');
328 
329  $reviewForm = new ReviewFormResponseForm($reviewId, $reviewFormId);
330  $reviewForm->readInputData();
331  if ($reviewForm->validate()) {
332  $reviewForm->execute();
333 
334  // Send a notification to associated users
335  import('classes.notification.NotificationManager');
336  $notificationManager = new NotificationManager();
337  $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
338  $reviewAssignment = $reviewAssignmentDao->getById($reviewId);
339  $articleId = $reviewAssignment->getSubmissionId();
340  $articleDao =& DAORegistry::getDAO('ArticleDAO');
341  $article =& $articleDao->getArticle($articleId);
342  $notificationUsers = $article->getAssociatedUserIds(false, false);
343  foreach ($notificationUsers as $userRole) {
344  $notificationManager->createNotification(
345  $request, $userRole['id'], NOTIFICATION_TYPE_REVIEWER_FORM_COMMENT,
346  $article->getJournalId(), ASSOC_TYPE_ARTICLE, $article->getId()
347  );
348  }
349 
350  } else {
351  $reviewForm->display();
352  return false;
353  }
354  return true;
355  }
356  }
357 
358  //
359  // Misc
360  //
361 
369  function downloadReviewerFile($reviewId, $article, $fileId, $revision = null) {
370  $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
371  $reviewAssignment =& $reviewAssignmentDao->getById($reviewId);
372  $journal =& Request::getJournal();
373 
374  $canDownload = false;
375 
376  // Reviewers have access to:
377  // 1) The current revision of the file to be reviewed.
378  // 2) Any file that he uploads.
379  // 3) Any supplementary file that is visible to reviewers.
380  if ((!$reviewAssignment->getDateConfirmed() || $reviewAssignment->getDeclined()) && $journal->getSetting('restrictReviewerFileAccess')) {
381  // Restrict files until review is accepted
382  } else if ($reviewAssignment->getReviewFileId() == $fileId) {
383  if ($revision != null) {
384  $canDownload = ($reviewAssignment->getReviewRevision() == $revision);
385  }
386  } else if ($reviewAssignment->getReviewerFileId() == $fileId) {
387  $canDownload = true;
388  } else {
389  foreach ($reviewAssignment->getSuppFiles() as $suppFile) {
390  if ($suppFile->getFileId() == $fileId && $suppFile->getShowReviewers()) {
391  $canDownload = true;
392  }
393  }
394  }
395 
396  $result = false;
397  if (!HookRegistry::call('ReviewerAction::downloadReviewerFile', array(&$article, &$fileId, &$revision, &$canDownload, &$result))) {
398  if ($canDownload) {
399  return Action::downloadFile($article->getId(), $fileId, $revision);
400  } else {
401  return false;
402  }
403  }
404  return $result;
405  }
406 
411  function editComment ($article, $comment, $reviewId) {
412  if (!HookRegistry::call('ReviewerAction::editComment', array(&$article, &$comment, &$reviewId))) {
413  import ('classes.submission.form.comment.EditCommentForm');
414 
415  $commentForm = new EditCommentForm ($article, $comment);
416  $commentForm->initData();
417  $commentForm->setData('reviewId', $reviewId);
418  $commentForm->display(array('reviewId' => $reviewId));
419  }
420  }
421 }
422 
423 ?>
Peer review form response form.
logEvent(&$request, &$article, $eventType, $messageKey, $params=array())
downloadFile($articleId, $fileId, $revision=null)
Definition: Action.inc.php:180
ReviewerAction class.
Subclass of MailTemplate for sending emails related to articles.
recordRecommendation(&$reviewerSubmission, $recommendation, $send, $request)
& getJournal()
Definition: Request.inc.php:42
confirmReview($reviewerSubmission, $decline, $send, $request)
Edit comment form.
getCurrentDate($ts=null)
Definition: Core.inc.php:94
deleteFile($fileId, $revision=null)
viewPeerReviewComments(&$user, &$article, $reviewId)
Application-specific submission actions.
Definition: Action.inc.php:44
saveReviewFormResponse($reviewId, $reviewFormId, $request)
editReviewFormResponse($reviewId, $reviewFormId)
editComment($article, $comment, $reviewId)
deleteReviewerVersion($reviewId, $fileId, $revision=null)
getVar($section, $key, $default=null)
Definition: Config.inc.php:34
downloadReviewerFile($reviewId, $article, $fileId, $revision=null)
& getDAO($name, $dbconn=null)
Class defining operations for article file management.
call($hookName, $args=null)
postPeerReviewComment(&$user, &$article, $reviewId, $emailComment, $request)
uploadReviewerVersion($reviewId, $reviewerSubmission, $request)