Exemplo n.º 1
0
 /**
  * Upload the annotated version of a paper.
  * @param $reviewId int
  */
 function uploadReviewerVersion($reviewId)
 {
     import('file.PaperFileManager');
     $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
     $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
     $paperFileManager = new PaperFileManager($reviewAssignment->getPaperId());
     // Only upload the file if the reviewer has yet to submit a recommendation
     if (!(($reviewAssignment->getRecommendation() === null || $reviewAssignment->getRecommendation() === '') && !$reviewAssignment->getCancelled())) {
         return false;
     }
     $fileName = 'upload';
     if ($paperFileManager->uploadError($fileName)) {
         return false;
     }
     if (!$paperFileManager->uploadedFileExists($fileName)) {
         return false;
     }
     HookRegistry::call('ReviewerAction::uploadReviewFile', array(&$reviewAssignment));
     if ($reviewAssignment->getReviewerFileId() != null) {
         $fileId = $paperFileManager->uploadReviewFile($fileName, $reviewAssignment->getReviewerFileId());
     } else {
         $fileId = $paperFileManager->uploadReviewFile($fileName);
     }
     if ($fileId == 0) {
         return false;
     }
     $reviewAssignment->setReviewerFileId($fileId);
     $reviewAssignment->stampModified();
     $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
     // Add log
     import('paper.log.PaperLog');
     import('paper.log.PaperEventLogEntry');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
     $entry = new PaperEventLogEntry();
     $entry->setPaperId($reviewAssignment->getPaperId());
     $entry->setUserId($reviewer->getId());
     $entry->setDateLogged(Core::getCurrentDate());
     $entry->setEventType(PAPER_LOG_REVIEW_FILE);
     $entry->setLogMessage('log.review.reviewerFile');
     $entry->setAssocType(LOG_TYPE_REVIEW);
     $entry->setAssocId($reviewAssignment->getId());
     PaperLog::logEventEntry($reviewAssignment->getPaperId(), $entry);
     return true;
 }
Exemplo n.º 2
0
 /**
  * Upload a review on behalf of its reviewer.
  * @param $reviewId int
  */
 function uploadReviewForReviewer($reviewId)
 {
     $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $user =& Request::getUser();
     $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
     $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId(), true);
     if (HookRegistry::call('TrackDirectorAction::uploadReviewForReviewer', array(&$reviewAssignment, &$reviewer))) {
         return;
     }
     // Upload the review file.
     import('file.PaperFileManager');
     $paperFileManager = new PaperFileManager($reviewAssignment->getPaperId());
     // Only upload the file if the reviewer has yet to submit a recommendation
     if (($reviewAssignment->getRecommendation() === null || $reviewAssignment->getRecommendation() === '') && !$reviewAssignment->getCancelled()) {
         $fileName = 'upload';
         if ($paperFileManager->uploadError($fileName)) {
             return false;
         }
         if ($paperFileManager->uploadedFileExists($fileName)) {
             if ($reviewAssignment->getReviewerFileId() != null) {
                 $fileId = $paperFileManager->uploadReviewFile($fileName, $reviewAssignment->getReviewerFileId());
             } else {
                 $fileId = $paperFileManager->uploadReviewFile($fileName);
             }
         }
     }
     if (isset($fileId) && $fileId != 0) {
         // Only confirm the review for the reviewer if
         // he has not previously done so.
         if ($reviewAssignment->getDateConfirmed() == null) {
             $reviewAssignment->setDeclined(0);
             $reviewAssignment->setDateConfirmed(Core::getCurrentDate());
         }
         $reviewAssignment->setReviewerFileId($fileId);
         $reviewAssignment->stampModified();
         $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
         // Add log
         import('paper.log.PaperLog');
         import('paper.log.PaperEventLogEntry');
         $entry = new PaperEventLogEntry();
         $entry->setPaperId($reviewAssignment->getPaperId());
         $entry->setUserId($user->getId());
         $entry->setDateLogged(Core::getCurrentDate());
         $entry->setEventType(PAPER_LOG_REVIEW_FILE_BY_PROXY);
         $entry->setLogMessage('log.review.reviewFileByProxy', array('reviewerName' => $reviewer->getFullName(), 'paperId' => $reviewAssignment->getPaperId(), 'stage' => $reviewAssignment->getStage(), 'userName' => $user->getFullName()));
         $entry->setAssocType(LOG_TYPE_REVIEW);
         $entry->setAssocId($reviewAssignment->getId());
         PaperLog::logEventEntry($reviewAssignment->getPaperId(), $entry);
     }
 }