classes/submission/reviewer/ReviewerAction.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 // $Id$
00017 
00018 
00019 import('submission.common.Action');
00020 
00021 class ReviewerAction extends Action {
00022 
00026    function ReviewerAction() {
00027 
00028    }
00029 
00041    function confirmReview($reviewerSubmission, $decline, $send) {
00042       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00043       $userDao =& DAORegistry::getDAO('UserDAO');
00044 
00045       $reviewId = $reviewerSubmission->getReviewId();
00046 
00047       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00048       $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
00049       if (!isset($reviewer)) return true;
00050 
00051       // Only confirm the review for the reviewer if 
00052       // he has not previously done so.
00053       if ($reviewAssignment->getDateConfirmed() == null) {
00054          import('mail.PaperMailTemplate');
00055          $email = new PaperMailTemplate($reviewerSubmission, $decline?'REVIEW_DECLINE':'REVIEW_CONFIRM');
00056          // Must explicitly set sender because we may be here on an access
00057          // key, in which case the user is not technically logged in
00058          $email->setFrom($reviewer->getEmail(), $reviewer->getFullName());
00059          if (!$email->isEnabled() || ($send && !$email->hasErrors())) {
00060             HookRegistry::call('ReviewerAction::confirmReview', array(&$reviewerSubmission, &$email, $decline));
00061             if ($email->isEnabled()) {
00062                $email->setAssoc($decline?PAPER_EMAIL_REVIEW_DECLINE:PAPER_EMAIL_REVIEW_CONFIRM, PAPER_EMAIL_TYPE_REVIEW, $reviewId);
00063                $email->send();
00064             }
00065 
00066             $reviewAssignment->setDeclined($decline);
00067             $reviewAssignment->setDateConfirmed(Core::getCurrentDate());
00068             $reviewAssignment->stampModified();
00069             $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
00070 
00071             // Add log
00072             import('paper.log.PaperLog');
00073             import('paper.log.PaperEventLogEntry');
00074 
00075             $entry = new PaperEventLogEntry();
00076             $entry->setPaperId($reviewAssignment->getPaperId());
00077             $entry->setUserId($reviewer->getId());
00078             $entry->setDateLogged(Core::getCurrentDate());
00079             $entry->setEventType($decline?PAPER_LOG_REVIEW_DECLINE:PAPER_LOG_REVIEW_ACCEPT);
00080             $entry->setLogMessage($decline?'log.review.reviewDeclined':'log.review.reviewAccepted', array('reviewerName' => $reviewer->getFullName(), 'paperId' => $reviewAssignment->getPaperId(), 'stage' => $reviewAssignment->getStage()));
00081             $entry->setAssocType(LOG_TYPE_REVIEW);
00082             $entry->setAssocId($reviewAssignment->getId());
00083 
00084             PaperLog::logEventEntry($reviewAssignment->getPaperId(), $entry);
00085 
00086             return true;
00087          } else {
00088             if (!Request::getUserVar('continued')) {
00089                $reviewingTrackDirectors = $email->toAssignedTrackDirectors($reviewerSubmission->getPaperId());
00090                if (!empty($reviewingTrackDirectors)) $assignedDirectors = $email->toAssignedDirectors($reviewerSubmission->getPaperId());
00091                else $assignedDirectors = $email->toAssignedDirectors($reviewerSubmission->getPaperId());
00092                if (empty($assignedDirectors) && empty($reviewingTrackDirectors)) {
00093                   $schedConf =& Request::getSchedConf();
00094                   $email->addRecipient($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName'));
00095                   $editorialContactName = $schedConf->getSetting('contactName');
00096                } else {
00097                   if (!empty($reviewingTrackDirectors)) $editorialContact = array_shift($reviewingTrackDirectors);
00098                   else $editorialContact = array_shift($assignedDirectors);
00099                   $editorialContactName = $editorialContact->getDirectorFullName();
00100                }
00101 
00102                $email->assignParams(array(
00103                   'editorialContactName' => $editorialContactName,
00104                   'reviewerName' => $reviewer->getFullName(),
00105                   'reviewDueDate' => ($reviewAssignment->getDateDue() === null ? __('common.noDate') : strftime(Config::getVar('general', 'date_format_short'), strtotime($reviewAssignment->getDateDue())))
00106                ));
00107             }
00108             $paramArray = array('reviewId' => $reviewId);
00109             if ($decline) $paramArray['declineReview'] = 1;
00110             $email->displayEditForm(Request::url(null, null, 'reviewer', 'confirmReview'), $paramArray);
00111             return false;
00112          }
00113       }
00114       return true;
00115    }
00116 
00123    function recordRecommendation(&$reviewerSubmission, $recommendation, $send) {
00124       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00125       $userDao =& DAORegistry::getDAO('UserDAO');
00126 
00127       // Check validity of selected recommendation
00128       $reviewerRecommendationOptions =& ReviewAssignment::getReviewerRecommendationOptions();
00129       if (!isset($reviewerRecommendationOptions[$recommendation])) return true;
00130 
00131       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewerSubmission->getReviewId());
00132       $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
00133       if (!isset($reviewer)) return true;
00134 
00135       // Only record the reviewers recommendation if
00136       // no recommendation has previously been submitted.
00137       if ($reviewAssignment->getRecommendation() === null || $reviewAssignment->getRecommendation === '') {
00138          import('mail.PaperMailTemplate');
00139          $email = new PaperMailTemplate($reviewerSubmission, 'REVIEW_COMPLETE');
00140          // Must explicitly set sender because we may be here on an access
00141          // key, in which case the user is not technically logged in
00142          $email->setFrom($reviewer->getEmail(), $reviewer->getFullName());
00143 
00144          if (!$email->isEnabled() || ($send && !$email->hasErrors())) {
00145             HookRegistry::call('ReviewerAction::recordRecommendation', array(&$reviewerSubmission, &$email, $recommendation));
00146             if ($email->isEnabled()) {
00147                $email->setAssoc(PAPER_EMAIL_REVIEW_COMPLETE, PAPER_EMAIL_TYPE_REVIEW, $reviewerSubmission->getReviewId());
00148                $email->send();
00149             }
00150 
00151             $reviewAssignment->setRecommendation($recommendation);
00152             $reviewAssignment->setDateCompleted(Core::getCurrentDate());
00153             $reviewAssignment->stampModified();
00154             $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
00155 
00156             // Add log
00157             import('paper.log.PaperLog');
00158             import('paper.log.PaperEventLogEntry');
00159 
00160             $entry = new PaperEventLogEntry();
00161             $entry->setPaperId($reviewAssignment->getPaperId());
00162             $entry->setUserId($reviewer->getId());
00163             $entry->setDateLogged(Core::getCurrentDate());
00164             $entry->setEventType(PAPER_LOG_REVIEW_RECOMMENDATION);
00165             $entry->setLogMessage('log.review.reviewRecommendationSet', array('reviewerName' => $reviewer->getFullName(), 'paperId' => $reviewAssignment->getPaperId(), 'stage' => $reviewAssignment->getStage()));
00166             $entry->setAssocType(LOG_TYPE_REVIEW);
00167             $entry->setAssocId($reviewAssignment->getId());
00168 
00169             PaperLog::logEventEntry($reviewAssignment->getPaperId(), $entry);
00170          } else {
00171             if (!Request::getUserVar('continued')) {
00172                $assignedDirectors = $email->toAssignedDirectors($reviewerSubmission->getPaperId());
00173                $reviewingTrackDirectors = $email->toAssignedTrackDirectors($reviewerSubmission->getPaperId());
00174                if (empty($assignedDirectors) && empty($reviewingTrackDirectors)) {
00175                   $schedConf =& Request::getSchedConf();
00176                   $email->addRecipient($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName'));
00177                   $editorialContactName = $schedConf->getSetting('contactName');
00178                } else {
00179                   if (!empty($reviewingTrackDirectors)) $editorialContact = array_shift($reviewingTrackDirectors);
00180                   else $editorialContact = array_shift($assignedDirectors);
00181                   $editorialContactName = $editorialContact->getDirectorFullName();
00182                }
00183 
00184                $reviewerRecommendationOptions =& ReviewAssignment::getReviewerRecommendationOptions();
00185 
00186                $email->assignParams(array(
00187                   'editorialContactName' => $editorialContactName,
00188                   'reviewerName' => $reviewer->getFullName(),
00189                   'paperTitle' => strip_tags($reviewerSubmission->getLocalizedTitle()),
00190                   'recommendation' => __($reviewerRecommendationOptions[$recommendation])
00191                ));
00192             }
00193 
00194             $email->displayEditForm(Request::url(null, null, 'reviewer', 'recordRecommendation'),
00195                array('reviewId' => $reviewerSubmission->getReviewId(), 'recommendation' => $recommendation)
00196             );
00197             return false;
00198          }
00199       }
00200       return true;
00201    }
00202 
00207    function uploadReviewerVersion($reviewId) {
00208       import('file.PaperFileManager');
00209       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');     
00210       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00211 
00212       $paperFileManager = new PaperFileManager($reviewAssignment->getPaperId());
00213 
00214       // Only upload the file if the reviewer has yet to submit a recommendation
00215       if (!(($reviewAssignment->getRecommendation() === null || $reviewAssignment->getRecommendation() === '') && !$reviewAssignment->getCancelled())) return false;
00216 
00217       $fileName = 'upload';
00218       if ($paperFileManager->uploadError($fileName)) return false;
00219       if (!$paperFileManager->uploadedFileExists($fileName)) return false;
00220       HookRegistry::call('ReviewerAction::uploadReviewFile', array(&$reviewAssignment));
00221       if ($reviewAssignment->getReviewerFileId() != null) {
00222          $fileId = $paperFileManager->uploadReviewFile($fileName, $reviewAssignment->getReviewerFileId());
00223       } else {
00224          $fileId = $paperFileManager->uploadReviewFile($fileName);
00225       }
00226 
00227       if ($fileId == 0) return false;
00228 
00229       $reviewAssignment->setReviewerFileId($fileId);
00230       $reviewAssignment->stampModified();
00231       $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
00232 
00233       // Add log
00234       import('paper.log.PaperLog');
00235       import('paper.log.PaperEventLogEntry');
00236 
00237       $userDao =& DAORegistry::getDAO('UserDAO');
00238       $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
00239 
00240       $entry = new PaperEventLogEntry();
00241       $entry->setPaperId($reviewAssignment->getPaperId());
00242       $entry->setUserId($reviewer->getId());
00243       $entry->setDateLogged(Core::getCurrentDate());
00244       $entry->setEventType(PAPER_LOG_REVIEW_FILE);
00245       $entry->setLogMessage('log.review.reviewerFile');
00246       $entry->setAssocType(LOG_TYPE_REVIEW);
00247       $entry->setAssocId($reviewAssignment->getId());
00248 
00249       PaperLog::logEventEntry($reviewAssignment->getPaperId(), $entry);
00250       return true;
00251    }
00252 
00259    function deleteReviewerVersion($reviewId, $fileId, $revision = null) {
00260       import("file.PaperFileManager");
00261 
00262       $paperId = Request::getUserVar('paperId');
00263       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00264       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00265 
00266       if (!HookRegistry::call('ReviewerAction::deleteReviewerVersion', array(&$reviewAssignment, &$fileId, &$revision))) {
00267          $paperFileManager = new PaperFileManager($reviewAssignment->getPaperId());
00268          $paperFileManager->deleteFile($fileId, $revision);
00269       }
00270    }
00271 
00278    function viewPeerReviewComments(&$user, &$paper, $reviewId) {
00279       if (!HookRegistry::call('ReviewerAction::viewPeerReviewComments', array(&$user, &$paper, &$reviewId))) {
00280          import("submission.form.comment.PeerReviewCommentForm");
00281 
00282          $commentForm = new PeerReviewCommentForm($paper, $reviewId, ROLE_ID_REVIEWER);
00283 
00284          $commentForm->setUser($user);
00285          $commentForm->initData();
00286          $commentForm->setData('reviewId', $reviewId);
00287          $commentForm->display();
00288       }
00289    }
00290 
00298    function postPeerReviewComment(&$user, &$paper, $reviewId, $emailComment) {
00299       if (!HookRegistry::call('ReviewerAction::postPeerReviewComment', array(&$user, &$paper, &$reviewId, &$emailComment))) {
00300          import("submission.form.comment.PeerReviewCommentForm");
00301 
00302          $commentForm = new PeerReviewCommentForm($paper, $reviewId, ROLE_ID_REVIEWER);
00303          $commentForm->setUser($user);
00304          $commentForm->readInputData();
00305 
00306          if ($commentForm->validate()) {
00307             $commentForm->execute();
00308             
00309             // Send a notification to associated users
00310             import('notification.NotificationManager');
00311             $notificationManager = new NotificationManager();
00312             $notificationUsers = $paper->getAssociatedUserIds();
00313             foreach ($notificationUsers as $userRole) {
00314                $url = Request::url(null, null, $userRole['role'], 'submissionReview', $paper->getId(), null, 'peerReview');
00315                $notificationManager->createNotification(
00316                   $userRole['id'], 'notification.type.reviewerComment',
00317                   $paper->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_REVIEWER_COMMENT
00318                );
00319             }
00320 
00321 
00322             if ($emailComment) {
00323                $commentForm->email();
00324             }
00325 
00326          } else {
00327             $commentForm->display();
00328             return false;
00329          }
00330          return true;
00331       }
00332    }
00333    
00339    function editReviewFormResponse($reviewId, $reviewFormId) {
00340       if (!HookRegistry::call('ReviewerAction::editReviewFormResponse', array($reviewId, $reviewFormId))) {
00341          import('submission.form.ReviewFormResponseForm');
00342 
00343          $reviewForm = new ReviewFormResponseForm($reviewId, $reviewFormId);
00344          $reviewForm->initData();
00345          $reviewForm->display();
00346       }
00347    }
00348 
00354    function saveReviewFormResponse($reviewId, $reviewFormId) {
00355       if (!HookRegistry::call('ReviewerAction::saveReviewFormResponse', array($reviewId, $reviewFormId))) {
00356          import('submission.form.ReviewFormResponseForm');
00357 
00358          $reviewForm = new ReviewFormResponseForm($reviewId, $reviewFormId);
00359          $reviewForm->readInputData();
00360          if ($reviewForm->validate()) {
00361             $reviewForm->execute();
00362             
00363             // Send a notification to associated users
00364             import('notification.NotificationManager');
00365             $notificationManager = new NotificationManager();
00366             $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00367             $reviewAssignment = $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00368             $paperId = $reviewAssignment->getPaperId();
00369             $paperDao =& DAORegistry::getDAO('PaperDAO'); 
00370             $paper =& $paperDao->getPaper($paperId);
00371             $notificationUsers = $paper->getAssociatedUserIds();
00372             foreach ($notificationUsers as $userRole) {
00373                $url = Request::url(null, null, $userRole['role'], 'submissionReview', $paper->getId(), null, 'peerReview');
00374                $notificationManager->createNotification(
00375                   $userRole['id'], 'notification.type.reviewerFormComment',
00376                   $paper->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_REVIEWER_FORM_COMMENT
00377                );
00378             }
00379 
00380          } else {
00381             $reviewForm->display();
00382             return false;
00383          }
00384          return true;
00385       }
00386    }
00387 
00388    //
00389    // Misc
00390    //
00391 
00399    function downloadReviewerFile($reviewId, &$paper, $fileId, $revision = null) {
00400       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');     
00401       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00402       $conference =& Request::getConference();
00403 
00404       $canDownload = false;
00405 
00406       // Reviewers have access to:
00407       // 1) The current revision of the file to be reviewed.
00408       // 2) Any file that he uploads.
00409       // 3) Any supplementary file that is visible to reviewers.
00410       if ((!$reviewAssignment->getDateConfirmed() || $reviewAssignment->getDeclined()) && $conference->getSetting('restrictReviewerFileAccess')) {
00411          // Restrict files until review is accepted
00412       } else if ($reviewAssignment->getReviewFileId() == $fileId) {
00413          if ($revision != null) {
00414             if ($reviewAssignment->getReviewRevision() == null) $canDownload = true;
00415             else $canDownload = ($reviewAssignment->getReviewRevision() == $revision);
00416          }
00417       } else if ($reviewAssignment->getReviewerFileId() == $fileId) {
00418          $canDownload = true;
00419       } else {
00420          foreach ($reviewAssignment->getSuppFiles() as $suppFile) {
00421             if ($suppFile->getFileId() == $fileId && $suppFile->getShowReviewers()) {
00422                $canDownload = true;
00423             }
00424          }
00425       }
00426 
00427       $result = false;
00428       if (!HookRegistry::call('ReviewerAction::downloadReviewerFile', array(&$paper, &$fileId, &$revision, &$canDownload, &$result))) {
00429          if ($canDownload) {
00430             return Action::downloadFile($paper->getId(), $fileId, $revision);
00431          } else {
00432             return false;
00433          }
00434       }
00435       return $result;
00436    }
00437 
00442    function editComment ($paper, $comment, $reviewId) {
00443       if (!HookRegistry::call('ReviewerAction::editComment', array(&$paper, &$comment, &$reviewId))) {
00444          import ("submission.form.comment.EditCommentForm");
00445 
00446          $commentForm = new EditCommentForm ($paper, $comment);
00447          $commentForm->initData();
00448          $commentForm->setData('reviewId', $reviewId);
00449          $commentForm->display(array('reviewId' => $reviewId));
00450       }
00451    }
00452 }
00453 
00454 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7