Example #1
0
 /**
  * Reminds a reviewer about a review assignment.
  * @param $trackDirectorSubmission object
  * @param $reviewId int
  * @return boolean true iff no error was encountered
  */
 function remindReviewer($trackDirectorSubmission, $reviewId, $send = false)
 {
     $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
     $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $conference =& Request::getConference();
     $schedConf =& Request::getSchedConf();
     $user =& Request::getUser();
     $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
     $reviewerAccessKeysEnabled = $schedConf->getSetting('reviewerAccessKeysEnabled');
     // If we're using access keys, disable the address fields
     // for this message. (Prevents security issue: track director
     // could CC or BCC someone else, or change the reviewer address,
     // in order to get the access key.)
     $preventAddressChanges = $reviewerAccessKeysEnabled;
     import('mail.PaperMailTemplate');
     $email = new PaperMailTemplate($trackDirectorSubmission, $reviewerAccessKeysEnabled ? 'REVIEW_REMIND_ONECLICK' : 'REVIEW_REMIND');
     if ($preventAddressChanges) {
         $email->setAddressFieldsEnabled(false);
     }
     if ($send && !$email->hasErrors()) {
         HookRegistry::call('TrackDirectorAction::remindReviewer', array(&$trackDirectorSubmission, &$reviewAssignment, &$email));
         $email->setAssoc(PAPER_EMAIL_REVIEW_REMIND, PAPER_EMAIL_TYPE_REVIEW, $reviewId);
         $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
         if ($reviewerAccessKeysEnabled) {
             import('security.AccessKeyManager');
             import('pages.reviewer.ReviewerHandler');
             $accessKeyManager = new AccessKeyManager();
             // Key lifetime is the typical review period plus four weeks
             if ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_ABSOLUTE) {
                 // Get number of days from now until review deadline date
                 $reviewDeadlineDate = strtotime($schedConf->getSetting('numWeeksPerReviewAbsolute'));
                 $daysDiff = ($reviewDeadlineDate - strtotime(date("Y-m-d"))) / (60 * 60 * 24);
                 $keyLifetime = (round($daysDiff / 7) + 4) * 7;
             } elseif ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_RELATIVE) {
                 $keyLifetime = ((int) $schedConf->getSetting('numWeeksPerReviewRelative') + 4) * 7;
             }
             $email->addPrivateParam('ACCESS_KEY', $accessKeyManager->createKey('ReviewerContext', $reviewer->getId(), $reviewId, $keyLifetime));
         }
         if ($preventAddressChanges) {
             // Ensure that this messages goes to the reviewer, and the reviewer ONLY.
             $email->clearAllRecipients();
             $email->addRecipient($reviewer->getEmail(), $reviewer->getFullName());
         }
         $email->send();
         $reviewAssignment->setDateReminded(Core::getCurrentDate());
         $reviewAssignment->setReminderWasAutomatic(0);
         $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
         return true;
     } elseif ($reviewAssignment->getPaperId() == $trackDirectorSubmission->getPaperId()) {
         $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
         if (!Request::getUserVar('continued')) {
             if (!isset($reviewer)) {
                 return true;
             }
             $email->addRecipient($reviewer->getEmail(), $reviewer->getFullName());
             $submissionUrl = Request::url(null, null, 'reviewer', 'submission', $reviewId, $reviewerAccessKeysEnabled ? array('key' => 'ACCESS_KEY') : array());
             //
             // FIXME: Assign correct values!
             //
             $paramArray = array('reviewerName' => $reviewer->getFullName(), 'reviewerUsername' => $reviewer->getUsername(), 'reviewerPassword' => $reviewer->getPassword(), 'reviewDueDate' => strftime(Config::getVar('general', 'date_format_short'), strtotime($reviewAssignment->getDateDue())), 'editorialContactSignature' => $user->getContactSignature(), 'passwordResetUrl' => Request::url(null, null, 'login', 'resetPassword', $reviewer->getUsername(), array('confirm' => Validation::generatePasswordResetHash($reviewer->getId()))), 'submissionReviewUrl' => $submissionUrl);
             $email->assignParams($paramArray);
         }
         $email->displayEditForm(Request::url(null, null, null, 'remindReviewer', 'send'), array('reviewerId' => $reviewer->getId(), 'paperId' => $trackDirectorSubmission->getPaperId(), 'reviewId' => $reviewId));
         return false;
     }
     return true;
 }