classes/tasks/ReviewReminder.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 // $Id$
00017 
00018 
00019 import('scheduledTask.ScheduledTask');
00020 
00021 class ReviewReminder extends ScheduledTask {
00022 
00026    function ReviewReminder() {
00027       $this->ScheduledTask();
00028    }
00029 
00030    function sendReminder ($reviewAssignment, $paper, $conference, $schedConf) {
00031       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00032       $userDao =& DAORegistry::getDAO('UserDAO');
00033       $reviewId = $reviewAssignment->getId();
00034 
00035       $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
00036       if (!isset($reviewer)) return false;
00037 
00038       import('mail.PaperMailTemplate');
00039 
00040       $reviewerAccessKeysEnabled = $schedConf->getSetting('reviewerAccessKeysEnabled');
00041 
00042       $email = new PaperMailTemplate($paper, $reviewerAccessKeysEnabled?'REVIEW_REMIND_AUTO_ONECLICK':'REVIEW_REMIND_AUTO', $conference->getPrimaryLocale(), false, $conference, $schedConf);
00043       $email->setConference($conference);
00044       $email->setSchedConf($schedConf);
00045 
00046       $contactEmail = $schedConf->getSetting('contactEmail') ? $schedConf->getSetting('contactEmail') : $conference->getSetting('contactEmail');
00047       $contactName = $schedConf->getSetting('contactName') ? $schedConf->getSetting('contactName') : $conference->getSetting('contactName');
00048       $email->setFrom($contactEmail, $contactName);
00049 
00050       $email->addRecipient($reviewer->getEmail(), $reviewer->getFullName());
00051       $email->setAssoc(PAPER_EMAIL_REVIEW_REMIND, PAPER_EMAIL_TYPE_REVIEW, $reviewId);
00052 
00053       $email->setSubject($email->getSubject($conference->getPrimaryLocale()));
00054       $email->setBody($email->getBody($conference->getPrimaryLocale()));
00055 
00056       $urlParams = array();
00057       if ($reviewerAccessKeysEnabled) {
00058          import('security.AccessKeyManager');
00059          $accessKeyManager = new AccessKeyManager();
00060 
00061          // Key lifetime is the typical review period plus four weeks
00062          if ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_ABSOLUTE) {
00063             // Get number of days from now until review deadline date
00064             $reviewDeadlineDate = $schedConf->getSetting('numWeeksPerReviewAbsolute');
00065             $daysDiff = ($reviewDeadlineDate - strtotime(date("Y-m-d"))) / (60 * 60 * 24);
00066             $keyLifetime = (round($daysDiff / 7) + 4) * 7;
00067          } elseif ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_RELATIVE) {
00068             $keyLifetime = ((int) $schedConf->getSetting('numWeeksPerReviewRelative') + 4) * 7;
00069          }
00070          $urlParams['key'] = $accessKeyManager->createKey('ReviewerContext', $reviewer->getId(), $reviewId, $keyLifetime);
00071       }
00072       $submissionReviewUrl = Request::url($conference->getPath(), $schedConf->getPath(), 'reviewer', 'submission', $reviewId, $urlParams);
00073 
00074       // Format the review due date
00075       $reviewDueDate = strtotime($reviewAssignment->getDateDue());
00076       $dateFormatShort = Config::getVar('general', 'date_format_short');
00077       if ($reviewDueDate === -1 || $reviewDueDate === false) {
00078          // Use something human-readable if unspecified.
00079          $reviewDueDate = '_____';
00080       } else {
00081          $reviewDueDate = strftime($dateFormatShort, $reviewDueDate);
00082       }
00083 
00084       $paramArray = array(
00085          'reviewerName' => $reviewer->getFullName(),
00086          'reviewerUsername' => $reviewer->getUsername(),
00087          'conferenceUrl' => $conference->getUrl(),
00088          'schedConfUrl' => $schedConf->getUrl(),
00089          'reviewerPassword' => $reviewer->getPassword(),
00090          'reviewDueDate' => $reviewDueDate,
00091          'weekLaterDate' => strftime(Config::getVar('general', 'date_format_short'), strtotime('+1 week')),
00092          'editorialContactSignature' => $contactName . "\n" . $schedConf->getFullTitle(),
00093          'passwordResetUrl' => Request::url($conference->getPath(), $schedConf->getPath(), 'login', 'resetPassword', $reviewer->getUsername(), array('confirm' => Validation::generatePasswordResetHash($reviewer->getId()))),
00094          'submissionReviewUrl' => $submissionReviewUrl
00095       );
00096       $email->assignParams($paramArray);
00097 
00098       $email->send();
00099 
00100       $reviewAssignment->setDateReminded(Core::getCurrentDate());
00101       $reviewAssignment->setReminderWasAutomatic(1);
00102       $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
00103 
00104    }
00105 
00106    function execute() {
00107       $paper = null;
00108       $conference = null;
00109       $schedConf = null;
00110 
00111       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00112       $paperDao =& DAORegistry::getDAO('PaperDAO');
00113       $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
00114       $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00115 
00116       $incompleteAssignments =& $reviewAssignmentDao->getIncompleteReviewAssignments();
00117       foreach ($incompleteAssignments as $reviewAssignment) {
00118          // Fetch the Paper and the Sched Conf if necessary.
00119          if ($paper == null || $paper->getId() != $reviewAssignment->getPaperId()) {
00120             $paper =& $paperDao->getPaper($reviewAssignment->getPaperId());
00121             if ($schedConf == null || $schedConf->getId() != $paper->getSchedConfId()) {
00122                $schedConf =& $schedConfDao->getSchedConf($paper->getSchedConfId());
00123 
00124                $inviteReminderEnabled = $schedConf->getSetting('remindForInvite');
00125                $submitReminderEnabled = $schedConf->getSetting('remindForSubmit');
00126                $inviteReminderDays = $schedConf->getSetting('numDaysBeforeInviteReminder');
00127                $submitReminderDays = $schedConf->getSetting('numDaysBeforeSubmitReminder');
00128             }
00129          }
00130 
00131          // $paper, $schedConf, $...ReminderEnabled, $...ReminderDays, and $reviewAssignment
00132          // are initialized by this point. $conference is NOT necessarily correct.
00133          $shouldRemind = false;
00134          if ($inviteReminderEnabled==1 && $reviewAssignment->getDateConfirmed() == null) {
00135             $checkDate = strtotime($reviewAssignment->getDateNotified());
00136             if (time() - $checkDate > 60 * 60 * 24 * $inviteReminderDays) {
00137                $shouldRemind = true;
00138             }
00139          }
00140          if ($submitReminderEnabled==1 && $reviewAssignment->getDateDue() != null) {
00141             $checkDate = strtotime($reviewAssignment->getDateDue());
00142             if (time() - $checkDate > 60 * 60 * 24 * $submitReminderDays) {
00143                $shouldRemind = true;
00144             }
00145          }
00146 
00147          if ($reviewAssignment->getDateReminded() !== null) {
00148             $shouldRemind = false;
00149          }
00150 
00151          if ($shouldRemind) {
00152             // We may still have to look up the conference.
00153             if(!$conference || $schedConf->getConferenceId() != $conference->getId()) {
00154                $conference =& $conferenceDao->getConference($schedConf->getConferenceId());
00155             }
00156             $this->sendReminder ($reviewAssignment, $paper, $conference, $schedConf);
00157          }
00158       }
00159    }
00160 }
00161 
00162 ?>

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