classes/submission/trackDirector/TrackDirectorAction.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 import('submission.common.Action');
00017 
00018 class TrackDirectorAction extends Action {
00019 
00023    function TrackDirectorAction() {
00024       parent::Action();
00025    }
00026 
00036    function changeTrack(&$trackDirectorSubmission, $trackId) {
00037       if (!HookRegistry::call('TrackDirectorAction::changeTrack', array(&$trackDirectorSubmission, $trackId))) {
00038          $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00039          $trackDirectorSubmission->setTrackId((int) $trackId);
00040          $trackDirectorSubmissionDao->updateTrackDirectorSubmission($trackDirectorSubmission);
00041       }
00042    }
00043 
00049    function changeSessionType(&$trackDirectorSubmission, $sessionType) {
00050       if (!HookRegistry::call('TrackDirectorAction::changeSessionType', array(&$trackDirectorSubmission, $sessionType))) {
00051          $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00052          $trackDirectorSubmission->setData('sessionType', (int) $sessionType);
00053          $trackDirectorSubmissionDao->updateTrackDirectorSubmission($trackDirectorSubmission);
00054       }
00055    }
00056 
00063    function recordDecision($trackDirectorSubmission, $decision, $stage) {
00064       $editAssignments =& $trackDirectorSubmission->getEditAssignments();
00065       if (empty($editAssignments)) return;
00066 
00067       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00068       $user =& Request::getUser();
00069       $directorDecision = array(
00070          'editDecisionId' => null,
00071          'directorId' => $user->getId(),
00072          'decision' => $decision,
00073          'dateDecided' => date(Core::getCurrentDate())
00074       );
00075 
00076       if (!HookRegistry::call('TrackDirectorAction::recordDecision', array(&$trackDirectorSubmission, $directorDecision))) {
00077          if ($decision == SUBMISSION_DIRECTOR_DECISION_DECLINE) {
00078             $trackDirectorSubmission->setStatus(STATUS_DECLINED);
00079             $trackDirectorSubmission->stampStatusModified();
00080          } else {
00081             $trackDirectorSubmission->setStatus(STATUS_QUEUED);      
00082             $trackDirectorSubmission->stampStatusModified();
00083          }
00084 
00085          $trackDirectorSubmission->addDecision($directorDecision, $stage);
00086          $decisions = TrackDirectorSubmission::getDirectorDecisionOptions();
00087          // Add log
00088          import('paper.log.PaperLog');
00089          import('paper.log.PaperEventLogEntry');
00090          AppLocale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON, LOCALE_COMPONENT_OCS_DIRECTOR));
00091          PaperLog::logEvent(
00092             $trackDirectorSubmission->getPaperId(),
00093             PAPER_LOG_DIRECTOR_DECISION,
00094             LOG_TYPE_DIRECTOR,
00095             $user->getId(),
00096             'log.director.decision',
00097             array(
00098                'directorName' => $user->getFullName(),
00099                'paperId' => $trackDirectorSubmission->getPaperId(),
00100                'decision' => __($decisions[$decision]),
00101                'round' => ($stage == REVIEW_STAGE_ABSTRACT?'submission.abstractReview':'submission.paperReview')
00102             )
00103          );
00104       }
00105 
00106       if($decision == SUBMISSION_DIRECTOR_DECISION_ACCEPT || $decision == SUBMISSION_DIRECTOR_DECISION_INVITE) {
00107          // completeReview will take care of updating the
00108          // submission with the new decision.
00109          TrackDirectorAction::completeReview($trackDirectorSubmission);
00110       } else {
00111          // Insert the new decision.
00112          $trackDirectorSubmissionDao->updateTrackDirectorSubmission($trackDirectorSubmission);
00113       }
00114    }
00115 
00124    function completeReview($trackDirectorSubmission) {
00125       $schedConf =& Request::getSchedConf();
00126 
00127       if($trackDirectorSubmission->getReviewMode() == REVIEW_MODE_BOTH_SEQUENTIAL) {
00128          // two-stage submission; paper required
00129          // The submission is incomplete, and needs the author to submit
00130          // more materials (potentially for another stage of reviews)
00131 
00132          if($trackDirectorSubmission->getCurrentStage() == REVIEW_STAGE_ABSTRACT) {
00133 
00134             // We've just completed reviewing the abstract. Prepare for presentation
00135             // review process.
00136             $trackDirectorSubmission->setCurrentStage(REVIEW_STAGE_PRESENTATION);
00137 
00138             // The paper itself needs to be collected. Flag it so the author
00139             // may complete it.
00140             $trackDirectorSubmission->setSubmissionProgress(2);
00141 
00142             // TODO: notify the author the submission must be completed.
00143             // Q: should the director be given this option explicitly?
00144 
00145             // Now, reassign all reviewers that submitted a review for the last
00146             // stage of reviews.
00147             foreach ($trackDirectorSubmission->getReviewAssignments(REVIEW_STAGE_ABSTRACT) as $reviewAssignment) {
00148                if ($reviewAssignment->getRecommendation() !== null && $reviewAssignment->getRecommendation() !== '') {
00149                   // This reviewer submitted a review; reassign them
00150                   TrackDirectorAction::addReviewer($trackDirectorSubmission, $reviewAssignment->getReviewerId(), REVIEW_STAGE_PRESENTATION);
00151                }
00152             }
00153          }
00154       }
00155 
00156       $trackDirectorSubmissionDao =& DAORegistry::getDao('TrackDirectorSubmissionDAO');
00157       $trackDirectorSubmissionDao->updateTrackDirectorSubmission($trackDirectorSubmission);
00158       $trackDirectorSubmission->stampStatusModified();
00159 
00160       // Commit the paper changes
00161       $paperDao =& DAORegistry::getDao('PaperDAO');
00162       $paperDao->updatePaper($trackDirectorSubmission);
00163    }
00164 
00171    function addReviewer($trackDirectorSubmission, $reviewerId, $stage) {
00172       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00173       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00174       $userDao =& DAORegistry::getDAO('UserDAO');
00175       $user =& Request::getUser();
00176 
00177       $reviewer =& $userDao->getUser($reviewerId);
00178 
00179       // Check to see if the requested reviewer is not already
00180       // assigned to review this paper.
00181       if ($stage == null) {
00182          $stage = $trackDirectorSubmission->getCurrentStage();
00183       }
00184 
00185       $assigned = $trackDirectorSubmissionDao->reviewerExists($trackDirectorSubmission->getPaperId(), $reviewerId, $stage);
00186 
00187       // Only add the reviewer if he has not already
00188       // been assigned to review this paper.
00189       if (!$assigned && isset($reviewer) && !HookRegistry::call('TrackDirectorAction::addReviewer', array(&$trackDirectorSubmission, $reviewerId))) {
00190          $reviewAssignment = new ReviewAssignment();
00191          $reviewAssignment->setReviewerId($reviewerId);
00192          $reviewAssignment->setDateAssigned(Core::getCurrentDate());
00193          $reviewAssignment->setStage($stage);
00194 
00195          // Assign review form automatically if needed
00196          $schedConfId = $trackDirectorSubmission->getSchedConfId();
00197          $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00198          $schedConf =& $schedConfDao->getSchedConf($schedConfId);
00199          $conferenceId = $schedConf->getConferenceId();
00200          $trackDao =& DAORegistry::getDAO('TrackDAO');
00201          $reviewFormDao =& DAORegistry::getDAO('ReviewFormDAO');
00202 
00203          $trackId = $trackDirectorSubmission->getTrackId();
00204          $track =& $trackDao->getTrack($trackId, $conferenceId);
00205          if ($track && ($reviewFormId = (int) $track->getReviewFormId())) {
00206             if ($reviewFormDao->reviewFormExists($reviewFormId, ASSOC_TYPE_CONFERENCE, $conferenceId)) {
00207                $reviewAssignment->setReviewFormId($reviewFormId);
00208             }
00209          }
00210 
00211          $trackDirectorSubmission->addReviewAssignment($reviewAssignment);
00212          $trackDirectorSubmissionDao->updateTrackDirectorSubmission($trackDirectorSubmission);
00213 
00214          $reviewAssignment = $reviewAssignmentDao->getReviewAssignment($trackDirectorSubmission->getPaperId(), $reviewerId, $stage);
00215 
00216          $schedConf =& Request::getSchedConf();
00217          if ($schedConf->getSetting('reviewDeadlineType') != null) {
00218             $dueDateSet = true;
00219             if ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_ABSOLUTE) {
00220                $reviewDeadlineDate = $schedConf->getSetting('numWeeksPerReviewAbsolute');
00221                $reviewDueDate = strftime(Config::getVar('general', 'date_format_short'), $reviewDeadlineDate);
00222                TrackDirectorAction::setDueDate($trackDirectorSubmission->getPaperId(), $reviewAssignment->getId(), $reviewDueDate, null, false);
00223             } elseif ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_RELATIVE) {
00224                TrackDirectorAction::setDueDate($trackDirectorSubmission->getPaperId(), $reviewAssignment->getId(), null, $schedConf->getSetting('numWeeksPerReviewRelative'), false);
00225             } else {
00226                $dueDateSet = false;
00227             }
00228             if ($dueDateSet) {
00229                $reviewAssignment = $reviewAssignmentDao->getReviewAssignment($trackDirectorSubmission->getPaperId(), $reviewerId, $stage);
00230                $trackDirectorSubmission->updateReviewAssignment($reviewAssignment);
00231                $trackDirectorSubmissionDao->updateTrackDirectorSubmission($trackDirectorSubmission);
00232             }
00233          }
00234 
00235          // Add log
00236          import('paper.log.PaperLog');
00237          import('paper.log.PaperEventLogEntry');
00238          PaperLog::logEvent($trackDirectorSubmission->getPaperId(), PAPER_LOG_REVIEW_ASSIGN, LOG_TYPE_REVIEW, $reviewAssignment->getId(), 'log.review.reviewerAssigned', array('reviewerName' => $reviewer->getFullName(), 'paperId' => $trackDirectorSubmission->getPaperId(), 'stage' => $stage));
00239       }
00240    }
00241 
00247    function clearReview($trackDirectorSubmission, $reviewId) {
00248       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00249       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00250       $userDao =& DAORegistry::getDAO('UserDAO');
00251       $user =& Request::getUser();
00252 
00253       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00254 
00255       if (isset($reviewAssignment) && $reviewAssignment->getPaperId() == $trackDirectorSubmission->getPaperId() && !HookRegistry::call('TrackDirectorAction::clearReview', array(&$trackDirectorSubmission, $reviewAssignment))) {
00256          $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
00257          if (!isset($reviewer)) return false;
00258          $trackDirectorSubmission->removeReviewAssignment($reviewId);
00259          $trackDirectorSubmissionDao->updateTrackDirectorSubmission($trackDirectorSubmission);
00260 
00261          // Add log
00262          import('paper.log.PaperLog');
00263          import('paper.log.PaperEventLogEntry');
00264          PaperLog::logEvent($trackDirectorSubmission->getPaperId(), PAPER_LOG_REVIEW_CLEAR, LOG_TYPE_REVIEW, $reviewAssignment->getId(), 'log.review.reviewCleared', array('reviewerName' => $reviewer->getFullName(), 'paperId' => $trackDirectorSubmission->getPaperId(), 'stage' => $reviewAssignment->getStage()));
00265       }     
00266    }
00267 
00274    function notifyReviewer($trackDirectorSubmission, $reviewId, $send = false) {
00275       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00276       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00277       $userDao =& DAORegistry::getDAO('UserDAO');
00278 
00279       $conference =& Request::getConference();
00280       $schedConf =& Request::getSchedConf();
00281       $user =& Request::getUser();
00282 
00283       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00284 
00285       $reviewerAccessKeysEnabled = $schedConf->getSetting('reviewerAccessKeysEnabled');
00286 
00287       // If we're using access keys, disable the address fields
00288       // for this message. (Prevents security issue: track director
00289       // could CC or BCC someone else, or change the reviewer address,
00290       // in order to get the access key.)
00291       $preventAddressChanges = $reviewerAccessKeysEnabled;
00292 
00293       import('mail.PaperMailTemplate');
00294 
00295       $email = new PaperMailTemplate($trackDirectorSubmission, $reviewerAccessKeysEnabled?'REVIEW_REQUEST_ONECLICK':'REVIEW_REQUEST');
00296 
00297       if ($preventAddressChanges) {
00298          $email->setAddressFieldsEnabled(false);
00299       }
00300 
00301       if ($reviewAssignment->getPaperId() == $trackDirectorSubmission->getPaperId()) {
00302          $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
00303          if (!isset($reviewer)) return true;
00304 
00305          if (!$email->isEnabled() || ($send && !$email->hasErrors())) {
00306             HookRegistry::call('TrackDirectorAction::notifyReviewer', array(&$trackDirectorSubmission, &$reviewAssignment, &$email));
00307             if ($email->isEnabled()) {
00308                $email->setAssoc(PAPER_EMAIL_REVIEW_NOTIFY_REVIEWER, PAPER_EMAIL_TYPE_REVIEW, $reviewId);
00309                if ($reviewerAccessKeysEnabled) {
00310                   import('security.AccessKeyManager');
00311                   import('pages.reviewer.ReviewerHandler');
00312                   $accessKeyManager = new AccessKeyManager();
00313 
00314                   // Key lifetime is the typical review period plus four weeks
00315                   if ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_ABSOLUTE) {
00316                      // Get number of days from now until review deadline date
00317                      $reviewDeadlineDate = $schedConf->getSetting('numWeeksPerReviewAbsolute');
00318                      $daysDiff = ($reviewDeadlineDate - strtotime(date("Y-m-d"))) / (60 * 60 * 24);
00319                      $keyLifetime = (round($daysDiff / 7) + 4) * 7;
00320                   } elseif ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_RELATIVE) {
00321                      $keyLifetime = ((int) $schedConf->getSetting('numWeeksPerReviewRelative') + 4) * 7;
00322                   }
00323 
00324                   $email->addPrivateParam('ACCESS_KEY', $accessKeyManager->createKey('ReviewerContext', $reviewer->getId(), $reviewId, $keyLifetime));
00325                }
00326 
00327                if ($preventAddressChanges) {
00328                   // Ensure that this messages goes to the reviewer, and the reviewer ONLY.
00329                   $email->clearAllRecipients();
00330                   $email->addRecipient($reviewer->getEmail(), $reviewer->getFullName());
00331                }
00332                $email->send();
00333             }
00334 
00335             $reviewAssignment->setDateNotified(Core::getCurrentDate());
00336             $reviewAssignment->setCancelled(0);
00337             $reviewAssignment->stampModified();
00338             $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
00339             return true;
00340          } else {
00341             if (!Request::getUserVar('continued')) {
00342                $weekLaterDate = strftime(Config::getVar('general', 'date_format_short'), strtotime('+1 week'));
00343 
00344                if ($reviewAssignment->getDateDue() != null) {
00345                   $reviewDueDate = strftime(Config::getVar('general', 'date_format_short'), strtotime($reviewAssignment->getDateDue()));
00346                } else {
00347                   if ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_ABSOLUTE) {
00348                      $reviewDeadlineDate = $schedConf->getSetting('numWeeksPerReviewAbsolute');
00349                      $reviewDueDate = strftime(Config::getVar('general', 'date_format_short'), $reviewDeadlineDate);
00350                   } elseif ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_RELATIVE) {
00351                      $numWeeks = max((int) $schedConf->getSetting('numWeeksPerReviewRelative'), 2);
00352                      $reviewDueDate = strftime(Config::getVar('general', 'date_format_short'), strtotime('+' . $numWeeks . ' week'));
00353                   }
00354                   
00355                }
00356 
00357                $submissionUrl = Request::url(null, null, 'reviewer', 'submission', $reviewId, $reviewerAccessKeysEnabled?array('key' => 'ACCESS_KEY'):array());
00358 
00359                $paramArray = array(
00360                   'reviewerName' => $reviewer->getFullName(),
00361                   'weekLaterDate' => $weekLaterDate,
00362                   'reviewDueDate' => $reviewDueDate,
00363                   'reviewerUsername' => $reviewer->getUsername(),
00364                   'reviewerPassword' => $reviewer->getPassword(),
00365                   'editorialContactSignature' => $user->getContactSignature(),
00366                   'reviewGuidelines' => $schedConf->getLocalizedSetting('reviewGuidelines'),
00367                   'submissionReviewUrl' => $submissionUrl,
00368                   'passwordResetUrl' => Request::url(null, null, 'login', 'resetPassword', $reviewer->getUsername(), array('confirm' => Validation::generatePasswordResetHash($reviewer->getId())))
00369                );
00370                $email->assignParams($paramArray);
00371                $email->addRecipient($reviewer->getEmail(), $reviewer->getFullName());
00372             }
00373             $email->displayEditForm(Request::url(null, null, null, 'notifyReviewer'), array('reviewId' => $reviewId, 'paperId' => $trackDirectorSubmission->getPaperId()));
00374             return false;
00375          }
00376       }
00377       return true;
00378    }
00379 
00386    function cancelReview($trackDirectorSubmission, $reviewId, $send = false) {
00387       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00388       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00389       $userDao =& DAORegistry::getDAO('UserDAO');
00390 
00391       $conference =& Request::getConference();
00392       $user =& Request::getUser();
00393 
00394       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00395       $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
00396       if (!isset($reviewer)) return true;
00397 
00398       if ($reviewAssignment->getPaperId() == $trackDirectorSubmission->getPaperId()) {
00399          // Only cancel the review if it is currently not cancelled but has previously
00400          // been initiated, and has not been completed.
00401          if ($reviewAssignment->getDateNotified() != null && !$reviewAssignment->getCancelled() && ($reviewAssignment->getDateCompleted() == null || $reviewAssignment->getDeclined())) {
00402             import('mail.PaperMailTemplate');
00403             $email = new PaperMailTemplate($trackDirectorSubmission, 'REVIEW_CANCEL');
00404 
00405             if (!$email->isEnabled() || ($send && !$email->hasErrors())) {
00406                HookRegistry::call('TrackDirectorAction::cancelReview', array(&$trackDirectorSubmission, &$reviewAssignment, &$email));
00407                if ($email->isEnabled()) {
00408                   $email->setAssoc(PAPER_EMAIL_REVIEW_CANCEL, PAPER_EMAIL_TYPE_REVIEW, $reviewId);
00409                   $email->send();
00410                }
00411 
00412                $reviewAssignment->setCancelled(1);
00413                $reviewAssignment->setDateCompleted(Core::getCurrentDate());
00414                $reviewAssignment->stampModified();
00415 
00416                $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
00417 
00418                // Add log
00419                import('paper.log.PaperLog');
00420                import('paper.log.PaperEventLogEntry');
00421                PaperLog::logEvent($trackDirectorSubmission->getPaperId(), PAPER_LOG_REVIEW_CANCEL, LOG_TYPE_REVIEW, $reviewAssignment->getId(), 'log.review.reviewCancelled', array('reviewerName' => $reviewer->getFullName(), 'paperId' => $trackDirectorSubmission->getPaperId(), 'stage' => $reviewAssignment->getStage()));
00422             } else {
00423                if (!Request::getUserVar('continued')) {
00424                   $email->addRecipient($reviewer->getEmail(), $reviewer->getFullName());
00425 
00426                   $paramArray = array(
00427                      'reviewerName' => $reviewer->getFullName(),
00428                      'reviewerUsername' => $reviewer->getUsername(),
00429                      'reviewerPassword' => $reviewer->getPassword(),
00430                      'editorialContactSignature' => $user->getContactSignature()
00431                   );
00432                   $email->assignParams($paramArray);
00433                }
00434                $email->displayEditForm(Request::url(null, null, null, 'cancelReview', 'send'), array('reviewId' => $reviewId, 'paperId' => $trackDirectorSubmission->getPaperId()));
00435                return false;
00436             }
00437          }           
00438       }
00439       return true;
00440    }
00441 
00448    function remindReviewer($trackDirectorSubmission, $reviewId, $send = false) {
00449       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00450       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00451       $userDao =& DAORegistry::getDAO('UserDAO');
00452 
00453       $conference =& Request::getConference();
00454       $schedConf =& Request::getSchedConf();
00455       $user =& Request::getUser();
00456       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00457       $reviewerAccessKeysEnabled = $schedConf->getSetting('reviewerAccessKeysEnabled');
00458 
00459       // If we're using access keys, disable the address fields
00460       // for this message. (Prevents security issue: track director
00461       // could CC or BCC someone else, or change the reviewer address,
00462       // in order to get the access key.)
00463       $preventAddressChanges = $reviewerAccessKeysEnabled;
00464 
00465       import('mail.PaperMailTemplate');
00466       $email = new PaperMailTemplate($trackDirectorSubmission, $reviewerAccessKeysEnabled?'REVIEW_REMIND_ONECLICK':'REVIEW_REMIND');
00467 
00468       if ($preventAddressChanges) {
00469          $email->setAddressFieldsEnabled(false);
00470       }
00471 
00472       if ($send && !$email->hasErrors()) {
00473          HookRegistry::call('TrackDirectorAction::remindReviewer', array(&$trackDirectorSubmission, &$reviewAssignment, &$email));
00474          $email->setAssoc(PAPER_EMAIL_REVIEW_REMIND, PAPER_EMAIL_TYPE_REVIEW, $reviewId);
00475 
00476          $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
00477 
00478          if ($reviewerAccessKeysEnabled) {
00479             import('security.AccessKeyManager');
00480             import('pages.reviewer.ReviewerHandler');
00481             $accessKeyManager = new AccessKeyManager();
00482 
00483             // Key lifetime is the typical review period plus four weeks
00484             if ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_ABSOLUTE) {
00485                // Get number of days from now until review deadline date
00486                $reviewDeadlineDate = $schedConf->getSetting('numWeeksPerReviewAbsolute');
00487                $daysDiff = ($reviewDeadlineDate - strtotime(date("Y-m-d"))) / (60 * 60 * 24);
00488                $keyLifetime = (round($daysDiff / 7) + 4) * 7;
00489             } elseif ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_RELATIVE) {
00490                $keyLifetime = ((int) $schedConf->getSetting('numWeeksPerReviewRelative') + 4) * 7;
00491             }
00492             $email->addPrivateParam('ACCESS_KEY', $accessKeyManager->createKey('ReviewerContext', $reviewer->getId(), $reviewId, $keyLifetime));
00493          }
00494 
00495          if ($preventAddressChanges) {
00496             // Ensure that this messages goes to the reviewer, and the reviewer ONLY.
00497             $email->clearAllRecipients();
00498             $email->addRecipient($reviewer->getEmail(), $reviewer->getFullName());
00499          }
00500 
00501          $email->send();
00502 
00503          $reviewAssignment->setDateReminded(Core::getCurrentDate());
00504          $reviewAssignment->setReminderWasAutomatic(0);
00505          $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
00506          return true;
00507       } elseif ($reviewAssignment->getPaperId() == $trackDirectorSubmission->getPaperId()) {
00508          $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
00509 
00510          if (!Request::getUserVar('continued')) {
00511             if (!isset($reviewer)) return true;
00512             $email->addRecipient($reviewer->getEmail(), $reviewer->getFullName());
00513 
00514             $submissionUrl = Request::url(null, null, 'reviewer', 'submission', $reviewId, $reviewerAccessKeysEnabled?array('key' => 'ACCESS_KEY'):array());
00515 
00516             // Format the review due date
00517             $reviewDueDate = strtotime($reviewAssignment->getDateDue());
00518             $dateFormatShort = Config::getVar('general', 'date_format_short');
00519             if ($reviewDueDate === -1 || $reviewDueDate === false) {
00520                // Use something human-readable if unspecified.
00521                $reviewDueDate = '_____';
00522             } else {
00523                $reviewDueDate = strftime($dateFormatShort, $reviewDueDate);
00524             }
00525 
00526             $paramArray = array(
00527                'reviewerName' => $reviewer->getFullName(),
00528                'reviewerUsername' => $reviewer->getUsername(),
00529                'reviewerPassword' => $reviewer->getPassword(),
00530                'reviewDueDate' => $reviewDueDate,
00531                'editorialContactSignature' => $user->getContactSignature(),
00532                'passwordResetUrl' => Request::url(null, null, 'login', 'resetPassword', $reviewer->getUsername(), array('confirm' => Validation::generatePasswordResetHash($reviewer->getId()))),
00533                'submissionReviewUrl' => $submissionUrl
00534             );
00535             $email->assignParams($paramArray);
00536 
00537          }
00538          $email->displayEditForm(
00539             Request::url(null, null, null, 'remindReviewer', 'send'),
00540             array(
00541                'reviewerId' => $reviewer->getId(),
00542                'paperId' => $trackDirectorSubmission->getPaperId(),
00543                'reviewId' => $reviewId
00544             )
00545          );
00546          return false;
00547       }
00548       return true;
00549    }
00550 
00557    function thankReviewer($trackDirectorSubmission, $reviewId, $send = false) {
00558       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00559       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00560       $userDao =& DAORegistry::getDAO('UserDAO');
00561 
00562       $conference =& Request::getConference();
00563       $user =& Request::getUser();
00564 
00565       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00566 
00567       import('mail.PaperMailTemplate');
00568       $email = new PaperMailTemplate($trackDirectorSubmission, 'REVIEW_ACK');
00569 
00570       if ($reviewAssignment->getPaperId() == $trackDirectorSubmission->getPaperId()) {
00571          $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
00572          if (!isset($reviewer)) return true;
00573 
00574          if (!$email->isEnabled() || ($send && !$email->hasErrors())) {
00575             HookRegistry::call('TrackDirectorAction::thankReviewer', array(&$trackDirectorSubmission, &$reviewAssignment, &$email));
00576             if ($email->isEnabled()) {
00577                $email->setAssoc(PAPER_EMAIL_REVIEW_THANK_REVIEWER, PAPER_EMAIL_TYPE_REVIEW, $reviewId);
00578                $email->send();
00579             }
00580 
00581             $reviewAssignment->setDateAcknowledged(Core::getCurrentDate());
00582             $reviewAssignment->stampModified();
00583             $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
00584          } else {
00585             if (!Request::getUserVar('continued')) {
00586                $email->addRecipient($reviewer->getEmail(), $reviewer->getFullName());
00587 
00588                $paramArray = array(
00589                   'reviewerName' => $reviewer->getFullName(),
00590                   'editorialContactSignature' => $user->getContactSignature()
00591                );
00592                $email->assignParams($paramArray);
00593             }
00594             $email->displayEditForm(Request::url(null, null, null, 'thankReviewer', 'send'), array('reviewId' => $reviewId, 'paperId' => $trackDirectorSubmission->getPaperId()));
00595             return false;
00596          }
00597       }
00598       return true;
00599    }
00600 
00607    function rateReviewer($paperId, $reviewId, $quality = null) {
00608       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00609       $userDao =& DAORegistry::getDAO('UserDAO');
00610       $user =& Request::getUser();
00611 
00612       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00613       $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
00614       if (!isset($reviewer)) return false;
00615 
00616       if ($reviewAssignment->getPaperId() == $paperId && !HookRegistry::call('TrackDirectorAction::rateReviewer', array(&$reviewAssignment, &$reviewer, &$quality))) {
00617          // Ensure that the value for quality
00618          // is between 1 and 5.
00619          if ($quality != null && ($quality >= 1 && $quality <= 5)) {
00620             $reviewAssignment->setQuality($quality);
00621          }
00622 
00623          $reviewAssignment->setDateRated(Core::getCurrentDate());
00624          $reviewAssignment->stampModified();
00625 
00626          $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
00627 
00628          // Add log
00629          import('paper.log.PaperLog');
00630          import('paper.log.PaperEventLogEntry');
00631          PaperLog::logEvent($paperId, PAPER_LOG_REVIEW_RATE, LOG_TYPE_REVIEW, $reviewAssignment->getId(), 'log.review.reviewerRated', array('reviewerName' => $reviewer->getFullName(), 'paperId' => $paperId, 'stage' => $reviewAssignment->getStage()));
00632       }
00633    }
00634 
00641    function makeReviewerFileViewable($paperId, $reviewId, $fileId, $revision, $viewable = false) {
00642       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00643       $paperFileDao =& DAORegistry::getDAO('PaperFileDAO');
00644 
00645       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00646       $paperFile =& $paperFileDao->getPaperFile($fileId, $revision);
00647 
00648       if ($reviewAssignment->getPaperId() == $paperId && $reviewAssignment->getReviewerFileId() == $fileId && !HookRegistry::call('TrackDirectorAction::makeReviewerFileViewable', array(&$reviewAssignment, &$paperFile, &$viewable))) {
00649          $paperFile->setViewable($viewable);
00650          $paperFileDao->updatePaperFile($paperFile);           
00651       }
00652    }
00653 
00662    function setDueDate($paperId, $reviewId, $dueDate = null, $numWeeks = null, $logChange = true) {
00663       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00664       $userDao =& DAORegistry::getDAO('UserDAO');
00665       $user =& Request::getUser();
00666 
00667       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00668       $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
00669       if (!isset($reviewer)) return false;
00670 
00671       if ($reviewAssignment->getPaperId() == $paperId && !HookRegistry::call('TrackDirectorAction::setDueDate', array(&$reviewAssignment, &$reviewer, &$dueDate, &$numWeeks))) {
00672          $today = getDate();
00673          $todayTimestamp = mktime(0, 0, 0, $today['mon'], $today['mday'], $today['year']);
00674          if ($dueDate != null) {
00675             $dueDateParts = explode('-', $dueDate);
00676 
00677             // Ensure that the specified due date is today or after today's date.
00678             if ($todayTimestamp <= strtotime($dueDate)) {
00679                $reviewAssignment->setDateDue(date('Y-m-d H:i:s', mktime(0, 0, 0, $dueDateParts[1], $dueDateParts[2], $dueDateParts[0])));
00680             } else {
00681                $reviewAssignment->setDateDue(date('Y-m-d H:i:s', $todayTimestamp));
00682             }
00683          } else {
00684             // Add the equivilant of $numWeeks weeks, measured in seconds, to $todaysTimestamp.
00685             $newDueDateTimestamp = $todayTimestamp + ($numWeeks * 7 * 24 * 60 * 60);
00686 
00687             $reviewAssignment->setDateDue(date('Y-m-d H:i:s', $newDueDateTimestamp));
00688          }
00689 
00690          $reviewAssignment->stampModified();
00691          $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
00692 
00693          if ($logChange) {
00694             // Add log
00695             import('paper.log.PaperLog');
00696             import('paper.log.PaperEventLogEntry');
00697             PaperLog::logEvent(
00698                $paperId,
00699                PAPER_LOG_REVIEW_SET_DUE_DATE,
00700                LOG_TYPE_REVIEW,
00701                $reviewAssignment->getId(),
00702                'log.review.reviewDueDateSet',
00703                array(
00704                   'reviewerName' => $reviewer->getFullName(),
00705                   'dueDate' => strftime(Config::getVar('general', 'date_format_short'), strtotime($reviewAssignment->getDateDue())),
00706                   'paperId' => $paperId,
00707                   'stage' => $reviewAssignment->getStage()
00708                )
00709             );
00710          } // $logChange
00711       }
00712    }
00713 
00719    function unsuitableSubmission($trackDirectorSubmission, $send = false) {
00720       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00721       $userDao =& DAORegistry::getDAO('UserDAO');
00722 
00723       $conference =& Request::getConference();
00724       $schedConf =& Request::getSchedConf();
00725       $user =& Request::getUser();
00726 
00727       $author =& $userDao->getUser($trackDirectorSubmission->getUserId());
00728       if (!isset($author)) return true;
00729 
00730       import('mail.PaperMailTemplate');
00731       $email = new PaperMailTemplate($trackDirectorSubmission, 'SUBMISSION_UNSUITABLE');
00732 
00733       if (!$email->isEnabled() || ($send && !$email->hasErrors())) {
00734          HookRegistry::call('TrackDirectorAction::unsuitableSubmission', array(&$trackDirectorSubmission, &$author, &$email));
00735          if ($email->isEnabled()) {
00736             $email->setAssoc(PAPER_EMAIL_DIRECTOR_NOTIFY_AUTHOR_UNSUITABLE, PAPER_EMAIL_TYPE_DIRECTOR, $user->getId());
00737             $email->send();
00738          }
00739          TrackDirectorAction::archiveSubmission($trackDirectorSubmission);
00740          return true;
00741       } else {
00742          if (!Request::getUserVar('continued')) {
00743             $paramArray = array(
00744                'editorialContactSignature' => $user->getContactSignature(),
00745                'authorName' => $author->getFullName(),
00746                'locationCity' => $schedConf->getSetting('locationCity')
00747             );
00748             $email->assignParams($paramArray);
00749             $email->addRecipient($author->getEmail(), $author->getFullName());
00750          }
00751          $email->displayEditForm(Request::url(null, null, null, 'unsuitableSubmission'), array('paperId' => $trackDirectorSubmission->getPaperId()));
00752          return false;
00753       }
00754    }
00755 
00763    function setReviewerRecommendation($paperId, $reviewId, $recommendation, $acceptOption) {
00764       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00765       $userDao =& DAORegistry::getDAO('UserDAO');
00766       $user =& Request::getUser();
00767 
00768       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00769       $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId(), true);
00770 
00771       if ($reviewAssignment->getPaperId() == $paperId && !HookRegistry::call('TrackDirectorAction::setReviewerRecommendation', array(&$reviewAssignment, &$reviewer, &$recommendation, &$acceptOption))) {
00772          $reviewAssignment->setRecommendation($recommendation);
00773 
00774          $nowDate = Core::getCurrentDate();
00775          if (!$reviewAssignment->getDateConfirmed()) {
00776             $reviewAssignment->setDateConfirmed($nowDate);
00777          }
00778          $reviewAssignment->setDateCompleted($nowDate);
00779          $reviewAssignment->stampModified();
00780 
00781          $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
00782 
00783          // Add log
00784          import('paper.log.PaperLog');
00785          import('paper.log.PaperEventLogEntry');
00786          PaperLog::logEvent($paperId, PAPER_LOG_REVIEW_RECOMMENDATION_BY_PROXY, LOG_TYPE_REVIEW, $reviewAssignment->getId(), 'log.review.reviewRecommendationSetByProxy', array('directorName' => $user->getFullName(), 'reviewerName' => $reviewer->getFullName(), 'paperId' => $paperId, 'stage' => $reviewAssignment->getStage()));
00787       }
00788    }   
00789 
00795    function clearReviewForm($trackDirectorSubmission, $reviewId) {
00796       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00797       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00798 
00799       if (HookRegistry::call('TrackDirectorAction::clearReviewForm', array(&$trackDirectorSubmission, &$reviewAssignment, &$reviewId))) return $reviewId;
00800 
00801       if (isset($reviewAssignment) && $reviewAssignment->getPaperId() == $trackDirectorSubmission->getPaperId()) {
00802          $reviewFormResponseDao =& DAORegistry::getDAO('ReviewFormResponseDAO');
00803          $responses = $reviewFormResponseDao->getReviewReviewFormResponseValues($reviewId);
00804          if (!empty($responses)) {
00805             $reviewFormResponseDao->deleteByReviewId($reviewId);
00806          }
00807          $reviewAssignment->setReviewFormId(null);
00808          $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
00809       }
00810    }
00811 
00818    function addReviewForm($trackDirectorSubmission, $reviewId, $reviewFormId) {
00819       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00820       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00821 
00822       if (HookRegistry::call('TrackDirectorAction::addReviewForm', array(&$trackDirectorSubmission, &$reviewAssignment, &$reviewId, &$reviewFormId))) return $reviewFormId;
00823 
00824       if (isset($reviewAssignment) && $reviewAssignment->getPaperId() == $trackDirectorSubmission->getPaperId()) {
00825          // Only add the review form if it has not already
00826          // been assigned to the review.
00827          if ($reviewAssignment->getReviewFormId() != $reviewFormId) {
00828             $reviewFormResponseDao =& DAORegistry::getDAO('ReviewFormResponseDAO');
00829             $responses = $reviewFormResponseDao->getReviewReviewFormResponseValues($reviewId);
00830             if (!empty($responses)) {
00831                $reviewFormResponseDao->deleteByReviewId($reviewId);
00832             }
00833             $reviewAssignment->setReviewFormId($reviewFormId);
00834             $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
00835          }
00836       }
00837    }
00838 
00844    function viewReviewFormResponse($trackDirectorSubmission, $reviewId) {
00845       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00846       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00847 
00848       if (HookRegistry::call('TrackDirectorAction::viewReviewFormResponse', array(&$trackDirectorSubmission, &$reviewAssignment, &$reviewId))) return $reviewId;
00849 
00850       if (isset($reviewAssignment) && $reviewAssignment->getPaperId() == $trackDirectorSubmission->getPaperId()) {
00851          $reviewFormId = $reviewAssignment->getReviewFormId();
00852          if ($reviewFormId != null) {
00853             import('submission.form.ReviewFormResponseForm');
00854             $reviewForm = new ReviewFormResponseForm($reviewId, $reviewFormId);
00855             $reviewForm->initData();
00856             $reviewForm->display();
00857          }
00858       }
00859    }
00860 
00869    function setEditingFile($trackDirectorSubmission, $fileId, $revision, $createGalley = false) {
00870       import('file.PaperFileManager');
00871       $paperFileManager = new PaperFileManager($trackDirectorSubmission->getPaperId());
00872       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00873       $paperFileDao =& DAORegistry::getDAO('PaperFileDAO');
00874       $user =& Request::getUser();
00875 
00876       if (!HookRegistry::call('TrackDirectorAction::setEditingFile', array(&$trackDirectorSubmission, &$fileId, &$revision))) {
00877          // Copy the file from the director decision file folder to the layout folder
00878          $newFileId = $paperFileManager->copyToLayoutFile($fileId, $revision);
00879 
00880          $trackDirectorSubmission->setLayoutFileId($newFileId);
00881          $trackDirectorSubmissionDao->updateTrackDirectorSubmission($trackDirectorSubmission);
00882 
00883          if ($createGalley) {
00884             $paperGalleyDao =& DAORegistry::getDAO('PaperGalleyDAO');
00885             $galleys =& $paperGalleyDao->getGalleysByPaper($trackDirectorSubmission->getPaperId());
00886             if (empty($galleys)) {
00887                $layoutFile =& $paperFileDao->getPaperFile($newFileId, $revision);
00888                $fileType = $layoutFile->getFileType();
00889                $fileId = $paperFileManager->copyPublicFile($layoutFile->getFilePath(), $fileType);
00890                if (strstr($fileType, 'html')) {
00891                   $galley = new PaperHTMLGalley();
00892                } else {
00893                   $galley = new PaperGalley();
00894                }
00895                $galley->setPaperId($trackDirectorSubmission->getPaperId());
00896                $galley->setLocale(AppLocale::getLocale());
00897                $galley->setFileId($fileId);
00898                if ($galley->isHTMLGalley()) {
00899                   $galley->setLabel('HTML');
00900                } elseif (strstr($fileType, 'pdf')) {
00901                   $galley->setLabel('PDF');
00902                } else if (strstr($fileType, 'postscript')) {
00903                   $galley->setLabel('Postscript');
00904                } else if (strstr($fileType, 'xml')) {
00905                   $galley->setLabel('XML');
00906                } else {
00907                   $galley->setLabel(__('common.untitled'));
00908                }
00909                $paperGalleyDao->insertGalley($galley);
00910             }
00911          }
00912 
00913          // Add log
00914          import('paper.log.PaperLog');
00915          import('paper.log.PaperEventLogEntry');
00916          PaperLog::logEvent($trackDirectorSubmission->getPaperId(), PAPER_LOG_LAYOUT_SET_FILE, LOG_TYPE_FILE, $trackDirectorSubmission->getLayoutFileId(), 'log.layout.layoutFileSet', array('directorName' => $user->getFullName(), 'paperId' => $trackDirectorSubmission->getPaperId()));
00917       }
00918    }
00919 
00924    function uploadReviewVersion($trackDirectorSubmission) {
00925       import('file.PaperFileManager');
00926       $paperFileManager = new PaperFileManager($trackDirectorSubmission->getPaperId());
00927       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00928 
00929       $fileName = 'upload';
00930       if ($paperFileManager->uploadError($fileName)) return false;
00931       if (!$paperFileManager->uploadedFileExists($fileName)) return false;
00932       if (HookRegistry::call('TrackDirectorAction::uploadReviewVersion', array(&$trackDirectorSubmission))) return true;
00933 
00934       if ($trackDirectorSubmission->getReviewFileId() != null) {
00935          $reviewFileId = $paperFileManager->uploadReviewFile($fileName, $trackDirectorSubmission->getReviewFileId());
00936          // Increment the review revision.
00937          $trackDirectorSubmission->setReviewRevision($trackDirectorSubmission->getReviewRevision()+1);
00938       } else {
00939          $reviewFileId = $paperFileManager->uploadReviewFile($fileName);
00940          $trackDirectorSubmission->setReviewRevision(1);
00941       }
00942       $directorFileId = $paperFileManager->copyToDirectorFile($reviewFileId, $trackDirectorSubmission->getReviewRevision(), $trackDirectorSubmission->getDirectorFileId());
00943 
00944       if ($reviewFileId != 0 && isset($directorFileId) && $directorFileId != 0) {
00945          $trackDirectorSubmission->setReviewFileId($reviewFileId);
00946          $trackDirectorSubmission->setDirectorFileId($directorFileId);
00947 
00948          $trackDirectorSubmissionDao->updateTrackDirectorSubmission($trackDirectorSubmission);
00949       }
00950       return true;
00951    }
00952 
00957    function uploadDirectorVersion($trackDirectorSubmission) {
00958       import('file.PaperFileManager');
00959       $paperFileManager = new PaperFileManager($trackDirectorSubmission->getPaperId());
00960       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00961       $user =& Request::getUser();
00962 
00963       $fileName = 'upload';
00964       if ($paperFileManager->uploadError($fileName)) return false;
00965       if ($paperFileManager->uploadedFileExists($fileName) && !HookRegistry::call('TrackDirectorAction::uploadDirectorVersion', array(&$trackDirectorSubmission))) {
00966          if ($trackDirectorSubmission->getDirectorFileId() != null) {
00967             $fileId = $paperFileManager->uploadDirectorDecisionFile($fileName, $trackDirectorSubmission->getDirectorFileId());
00968          } else {
00969             $fileId = $paperFileManager->uploadDirectorDecisionFile($fileName);
00970          }
00971       }
00972 
00973       if (isset($fileId) && $fileId != 0) {
00974          $trackDirectorSubmission->setDirectorFileId($fileId);
00975          $trackDirectorSubmissionDao->updateTrackDirectorSubmission($trackDirectorSubmission);
00976 
00977          // Add log
00978          import('paper.log.PaperLog');
00979          import('paper.log.PaperEventLogEntry');
00980          PaperLog::logEvent($trackDirectorSubmission->getPaperId(), PAPER_LOG_DIRECTOR_FILE, LOG_TYPE_DIRECTOR, $trackDirectorSubmission->getDirectorFileId(), 'log.director.directorFile');
00981       }
00982    }
00983 
00991    function completePaper($trackDirectorSubmission, $complete) {
00992       import('file.PaperFileManager');
00993       $paperFileManager = new PaperFileManager($trackDirectorSubmission->getPaperId());
00994       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00995       $user =& Request::getUser();
00996 
00997       import('paper.log.PaperLog');
00998       import('paper.log.PaperEventLogEntry');
00999 
01000       if ($complete) { // Publish the paper.
01001          $trackDirectorSubmission->setStatus(STATUS_PUBLISHED);
01002          $trackDirectorSubmissionDao->updateTrackDirectorSubmission($trackDirectorSubmission);
01003 
01004          // Add a published paper object
01005          $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO');
01006          if(($publishedPaper = $publishedPaperDao->getPublishedPaperByPaperId($trackDirectorSubmission->getPaperId())) == null) {
01007             $schedConfId = $trackDirectorSubmission->getSchedConfId();
01008 
01009             $publishedPaper = new PublishedPaper();
01010             $publishedPaper->setPaperId($trackDirectorSubmission->getPaperId());
01011             $publishedPaper->setSchedConfId($schedConfId);
01012             $publishedPaper->setDatePublished(Core::getCurrentDate());
01013             $publishedPaper->setSeq(REALLY_BIG_NUMBER);
01014             $publishedPaper->setViews(0);
01015 
01016             $publishedPaperDao->insertPublishedPaper($publishedPaper);
01017 
01018             // Resequence the published papers.
01019             $publishedPaperDao->resequencePublishedPapers($trackDirectorSubmission->getTrackId(), $schedConfId);
01020          }
01021 
01022          // Add log
01023          PaperLog::logEvent($trackDirectorSubmission->getPaperId(), PAPER_LOG_DIRECTOR_PUBLISH, LOG_TYPE_DIRECTOR, $trackDirectorSubmission->getDirectorFileId(), 'log.director.publish');
01024 
01025       } else { // Un-publish the paper.
01026 
01027          $trackDirectorSubmission->setStatus(STATUS_QUEUED);
01028          $trackDirectorSubmissionDao->updateTrackDirectorSubmission($trackDirectorSubmission);
01029 
01030          // Add log
01031          PaperLog::logEvent($trackDirectorSubmission->getPaperId(), PAPER_LOG_DIRECTOR_UNPUBLISH, LOG_TYPE_DIRECTOR, $trackDirectorSubmission->getDirectorFileId(), 'log.director.unpublish');
01032       }
01033    }
01034 
01039    function archiveSubmission($trackDirectorSubmission) {
01040       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
01041       $user =& Request::getUser();
01042 
01043       if (HookRegistry::call('TrackDirectorAction::archiveSubmission', array(&$trackDirectorSubmission))) return;
01044 
01045       $trackDirectorSubmission->setStatus(STATUS_ARCHIVED);
01046       $trackDirectorSubmission->stampStatusModified();
01047       $trackDirectorSubmission->stampDateToArchive();
01048 
01049       $trackDirectorSubmissionDao->updateTrackDirectorSubmission($trackDirectorSubmission);
01050 
01051       // Add log
01052       import('paper.log.PaperLog');
01053       import('paper.log.PaperEventLogEntry');
01054       PaperLog::logEvent($trackDirectorSubmission->getPaperId(), PAPER_LOG_DIRECTOR_ARCHIVE, LOG_TYPE_DIRECTOR, $trackDirectorSubmission->getPaperId(), 'log.director.archived', array('paperId' => $trackDirectorSubmission->getPaperId()));
01055    }
01056 
01061    function restoreToQueue($trackDirectorSubmission) {
01062       if (HookRegistry::call('TrackDirectorAction::restoreToQueue', array(&$trackDirectorSubmission))) return;
01063 
01064       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
01065 
01066       // Determine which queue to return the paper to: the
01067       // scheduling queue or the editing queue.
01068       $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO');
01069       $publishedPaper =& $publishedPaperDao->getPublishedPaperByPaperId($trackDirectorSubmission->getPaperId());
01070       if ($publishedPaper) {
01071          $trackDirectorSubmission->setStatus(STATUS_PUBLISHED);
01072       } else {
01073          $trackDirectorSubmission->setStatus(STATUS_QUEUED);
01074       }
01075       unset($publishedPaper);
01076 
01077       $trackDirectorSubmission->stampStatusModified();
01078 
01079       $trackDirectorSubmissionDao->updateTrackDirectorSubmission($trackDirectorSubmission);
01080 
01081       // Add log
01082       import('paper.log.PaperLog');
01083       import('paper.log.PaperEventLogEntry');
01084       PaperLog::logEvent($trackDirectorSubmission->getPaperId(), PAPER_LOG_DIRECTOR_RESTORE, LOG_TYPE_DIRECTOR, $trackDirectorSubmission->getPaperId(), 'log.director.restored', array('paperId' => $trackDirectorSubmission->getPaperId()));
01085    }
01086 
01087    //
01088    // Layout Editing
01089    //
01090 
01097    function orderGalley($paper, $galleyId, $direction) {
01098       $galleyDao =& DAORegistry::getDAO('PaperGalleyDAO');
01099       $galley =& $galleyDao->getGalley($galleyId, $paper->getId());
01100       if (isset($galley)) {
01101          $galley->setSequence($galley->getSequence() + ($direction == 'u' ? -1.5 : 1.5));
01102          $galleyDao->updateGalley($galley);
01103          $galleyDao->resequenceGalleys($paper->getId());
01104       }
01105    }
01106 
01112    function deleteGalley($paper, $galleyId) {
01113 import('file.PaperFileManager');
01114 
01115       $galleyDao =& DAORegistry::getDAO('PaperGalleyDAO');
01116       $galley =& $galleyDao->getGalley($galleyId, $paper->getId());
01117 
01118       if (isset($galley) && !HookRegistry::call('TrackDirectorAction::deleteGalley', array(&$paper, &$galley))) {
01119          $paperFileManager = new PaperFileManager($paper->getId());
01120 
01121          if ($galley->getFileId()) {
01122             $paperFileManager->deleteFile($galley->getFileId());
01123             import('search.PaperSearchIndex');
01124             PaperSearchIndex::deleteTextIndex($paper->getId(), PAPER_SEARCH_GALLEY_FILE, $galley->getFileId());
01125          }
01126          if ($galley->isHTMLGalley()) {
01127             if ($galley->getStyleFileId()) {
01128                $paperFileManager->deleteFile($galley->getStyleFileId());
01129             }
01130             foreach ($galley->getImageFiles() as $image) {
01131                $paperFileManager->deleteFile($image->getFileId());
01132             }
01133          }
01134          $galleyDao->deleteGalley($galley);
01135       }
01136    }
01137 
01144    function orderSuppFile($paper, $suppFileId, $direction) {
01145       $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
01146       $suppFile =& $suppFileDao->getSuppFile($suppFileId, $paper->getId());
01147       if (isset($suppFile)) {
01148          $suppFile->setSequence($suppFile->getSequence() + ($direction == 'u' ? -1.5 : 1.5));
01149          $suppFileDao->updateSuppFile($suppFile);
01150          $suppFileDao->resequenceSuppFiles($paper->getId());
01151       }
01152    }
01153 
01159    function deleteSuppFile($paper, $suppFileId) {
01160       import('file.PaperFileManager');
01161 
01162       $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
01163 
01164       $suppFile =& $suppFileDao->getSuppFile($suppFileId, $paper->getId());
01165       if (isset($suppFile) && !HookRegistry::call('TrackDirectorAction::deleteSuppFile', array(&$paper, &$suppFile))) {
01166          if ($suppFile->getFileId()) {
01167             $paperFileManager = new PaperFileManager($paper->getId());
01168             $paperFileManager->deleteFile($suppFile->getFileId());
01169             import('search.PaperSearchIndex');
01170             PaperSearchIndex::deleteTextIndex($paper->getId(), PAPER_SEARCH_SUPPLEMENTARY_FILE, $suppFile->getFileId());
01171          }
01172          $suppFileDao->deleteSuppFile($suppFile);
01173       }
01174    }
01175 
01182    function deletePaperFile($submission, $fileId, $revision) {
01183       import('file.PaperFileManager');
01184       $file =& $submission->getDirectorFile();
01185 
01186       if (isset($file) && $file->getFileId() == $fileId && !HookRegistry::call('TrackDirectorAction::deletePaperFile', array(&$submission, &$fileId, &$revision))) {
01187          $paperFileManager = new PaperFileManager($submission->getPaperId());
01188          $paperFileManager->deleteFile($fileId, $revision);
01189       }
01190    }
01191 
01198    function deletePaperImage($submission, $fileId, $revision) {
01199       import('file.PaperFileManager');
01200       $paperGalleyDao =& DAORegistry::getDAO('PaperGalleyDAO');
01201       if (HookRegistry::call('TrackDirectorAction::deletePaperImage', array(&$submission, &$fileId, &$revision))) return;
01202       foreach ($submission->getGalleys() as $galley) {
01203          $images =& $paperGalleyDao->getGalleyImages($galley->getId());
01204          foreach ($images as $imageFile) {
01205             if ($imageFile->getPaperId() == $submission->getPaperId() && $fileId == $imageFile->getFileId() && $imageFile->getRevision() == $revision) {
01206                $paperFileManager = new PaperFileManager($submission->getPaperId());
01207                $paperFileManager->deleteFile($imageFile->getFileId(), $imageFile->getRevision());
01208             }
01209          }
01210          unset($images);
01211       }
01212    }
01213 
01218    function addSubmissionNote($paperId) {
01219       import('file.PaperFileManager');
01220 
01221       $paperNoteDao =& DAORegistry::getDAO('PaperNoteDAO');
01222       $user =& Request::getUser();
01223 
01224       $paperNote = new PaperNote();
01225       $paperNote->setPaperId($paperId);
01226       $paperNote->setUserId($user->getId());
01227       $paperNote->setDateCreated(Core::getCurrentDate());
01228       $paperNote->setDateModified(Core::getCurrentDate());
01229       $paperNote->setTitle(Request::getUserVar('title'));
01230       $paperNote->setNote(Request::getUserVar('note'));
01231 
01232       if (!HookRegistry::call('TrackDirectorAction::addSubmissionNote', array(&$paperId, &$paperNote))) {
01233          $paperFileManager = new PaperFileManager($paperId);
01234          if ($paperFileManager->uploadedFileExists('upload')) {
01235             if ($paperFileManager->uploadError('upload')) return false;
01236             $fileId = $paperFileManager->uploadSubmissionNoteFile('upload');
01237          } else {
01238             $fileId = 0;
01239          }
01240 
01241          $paperNote->setFileId($fileId);
01242 
01243          $paperNoteDao->insertPaperNote($paperNote);
01244       }
01245    }
01246 
01251    function removeSubmissionNote($paperId) {
01252       $noteId = Request::getUserVar('noteId');
01253       $fileId = Request::getUserVar('fileId');
01254 
01255       if (HookRegistry::call('TrackDirectorAction::removeSubmissionNote', array(&$paperId, &$noteId, &$fileId))) return;
01256 
01257       // if there is an attached file, remove it as well
01258       if ($fileId) {
01259          import('file.PaperFileManager');
01260          $paperFileManager = new PaperFileManager($paperId);
01261          $paperFileManager->deleteFile($fileId);
01262       }
01263 
01264       $paperNoteDao =& DAORegistry::getDAO('PaperNoteDAO');
01265       $paperNoteDao->deletePaperNoteById($noteId);
01266    }
01267 
01272    function updateSubmissionNote($paperId) {
01273       import('file.PaperFileManager');
01274 
01275       $paperNoteDao =& DAORegistry::getDAO('PaperNoteDAO');
01276       $user =& Request::getUser();
01277 
01278       $paperNote = new PaperNote();
01279       $paperNote->setNoteId(Request::getUserVar('noteId'));
01280       $paperNote->setPaperId($paperId);
01281       $paperNote->setUserId($user->getId());
01282       $paperNote->setDateModified(Core::getCurrentDate());
01283       $paperNote->setTitle(Request::getUserVar('title'));
01284       $paperNote->setNote(Request::getUserVar('note'));
01285       $paperNote->setFileId(Request::getUserVar('fileId'));
01286 
01287       if (HookRegistry::call('TrackDirectorAction::updateSubmissionNote', array(&$paperId, &$paperNote))) return;
01288 
01289       $paperFileManager = new PaperFileManager($paperId);
01290 
01291       if ($paperFileManager->uploadError('upload')) return false;
01292       // if there is a new file being uploaded
01293       if ($paperFileManager->uploadedFileExists('upload')) {
01294          // Attach the new file to the note, overwriting existing file if necessary
01295          $fileId = $paperFileManager->uploadSubmissionNoteFile('upload', $paperNote->getFileId(), true);
01296          $paperNote->setFileId($fileId);
01297 
01298       } else {
01299          if (Request::getUserVar('removeUploadedFile')) {
01300             $paperFileManager = new PaperFileManager($paperId);
01301             $paperFileManager->deleteFile($paperNote->getFileId());
01302             $paperNote->setFileId(0);
01303          }
01304       }
01305 
01306       $paperNoteDao->updatePaperNote($paperNote);
01307    }
01308 
01313    function clearAllSubmissionNotes($paperId) {
01314       if (HookRegistry::call('TrackDirectorAction::clearAllSubmissionNotes', array(&$paperId))) return;
01315 
01316       import('file.PaperFileManager');
01317 
01318       $paperNoteDao =& DAORegistry::getDAO('PaperNoteDAO');
01319 
01320       $fileIds = $paperNoteDao->getAllPaperNoteFileIds($paperId);
01321 
01322       if (!empty($fileIds)) {
01323          $paperFileDao =& DAORegistry::getDAO('PaperFileDAO');
01324          $paperFileManager = new PaperFileManager($paperId);
01325 
01326          foreach ($fileIds as $fileId) {
01327             $paperFileManager->deleteFile($fileId);
01328          }        
01329       }
01330 
01331       $paperNoteDao->clearAllPaperNotes($paperId);
01332 
01333    }
01334 
01335    //
01336    // Comments
01337    //
01338 
01344    function viewPeerReviewComments(&$paper, $reviewId) {
01345       if (HookRegistry::call('TrackDirectorAction::viewPeerReviewComments', array(&$paper, &$reviewId))) return;
01346 
01347       import('submission.form.comment.PeerReviewCommentForm');
01348 
01349       $commentForm = new PeerReviewCommentForm($paper, $reviewId, Validation::isDirector()?ROLE_ID_DIRECTOR:ROLE_ID_TRACK_DIRECTOR);
01350       $commentForm->initData();
01351       $commentForm->display();
01352    }
01353 
01360    function postPeerReviewComment(&$paper, $reviewId, $emailComment) {
01361       if (HookRegistry::call('TrackDirectorAction::postPeerReviewComment', array(&$paper, &$reviewId, &$emailComment))) return;
01362 
01363       import('submission.form.comment.PeerReviewCommentForm');
01364 
01365       $commentForm = new PeerReviewCommentForm($paper, $reviewId, Validation::isDirector()?ROLE_ID_DIRECTOR:ROLE_ID_TRACK_DIRECTOR);
01366       $commentForm->readInputData();
01367 
01368       if ($commentForm->validate()) {
01369          $commentForm->execute();
01370          
01371          // Send a notification to associated users
01372          import('notification.NotificationManager');
01373          $notificationManager = new NotificationManager();
01374          $notificationUsers = $paper->getAssociatedUserIds();
01375          foreach ($notificationUsers as $userRole) {
01376             $url = Request::url(null, null, $userRole['role'], 'submissionReview', $paper->getId(), null, 'peerReview');
01377             $notificationManager->createNotification(
01378                $userRole['id'], 'notification.type.reviewerComment',
01379                $paper->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_REVIEWER_COMMENT
01380             );
01381          }
01382 
01383          if ($emailComment) {
01384             $commentForm->email();
01385          }
01386 
01387       } else {
01388          $commentForm->display();
01389          return false;
01390       }
01391       return true;
01392    }
01393 
01398    function viewDirectorDecisionComments($paper) {
01399       if (HookRegistry::call('TrackDirectorAction::viewDirectorDecisionComments', array(&$paper))) return;
01400 
01401       import('submission.form.comment.DirectorDecisionCommentForm');
01402 
01403       $commentForm = new DirectorDecisionCommentForm($paper, Validation::isDirector()?ROLE_ID_DIRECTOR:ROLE_ID_TRACK_DIRECTOR);
01404       $commentForm->initData();
01405       $commentForm->display();
01406    }
01407 
01413    function postDirectorDecisionComment($paper, $emailComment) {
01414       if (HookRegistry::call('TrackDirectorAction::postDirectorDecisionComment', array(&$paper, &$emailComment))) return;
01415 
01416       import('submission.form.comment.DirectorDecisionCommentForm');
01417 
01418       $commentForm = new DirectorDecisionCommentForm($paper, Validation::isDirector()?ROLE_ID_DIRECTOR:ROLE_ID_TRACK_DIRECTOR);
01419       $commentForm->readInputData();
01420 
01421       if ($commentForm->validate()) {
01422          $commentForm->execute();
01423 
01424          // Send a notification to associated users
01425          import('notification.NotificationManager');
01426          $notificationManager = new NotificationManager();
01427          $notificationUsers = $paper->getAssociatedUserIds(true, false);
01428          foreach ($notificationUsers as $userRole) {
01429             $url = Request::url(null, null, $userRole['role'], 'submissionReview', $paper->getId(), null, 'directorDecision');
01430             $notificationManager->createNotification(
01431                $userRole['id'], 'notification.type.directorDecisionComment',
01432                $paper->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_DIRECTOR_DECISION_COMMENT
01433             );
01434          }
01435             
01436          if ($emailComment) {
01437             $commentForm->email();
01438          }
01439       } else {
01440          $commentForm->display();
01441          return false;
01442       }
01443       return true;
01444    }
01445 
01451    function emailDirectorDecisionComment($trackDirectorSubmission, $send) {
01452       $userDao =& DAORegistry::getDAO('UserDAO');
01453       $paperCommentDao =& DAORegistry::getDAO('PaperCommentDAO');
01454       $conference =& Request::getConference();
01455       $schedConf =& Request::getSchedConf();
01456 
01457       $templateName = null;
01458       $reviewMode = $trackDirectorSubmission->getReviewMode();
01459       $stages = $trackDirectorSubmission->getDecisions();
01460       if (is_array($stages)) {
01461          $isAbstract = array_pop(array_keys($stages)) == REVIEW_STAGE_ABSTRACT;
01462       }
01463       if (isset($stages) && is_array($stages)) {
01464          $decisions = array_pop($stages);
01465          // If this round has no decision, revert to prior round
01466          if (empty($decisions)) $decisions = array_pop($stages);
01467       }
01468       if (isset($decisions) && is_array($decisions)) $lastDecision = array_pop($decisions);
01469       if (isset($lastDecision) && is_array($lastDecision)) switch ($lastDecision['decision']) {
01470          case SUBMISSION_DIRECTOR_DECISION_INVITE:
01471             $templateName = ($reviewMode==REVIEW_MODE_BOTH_SEQUENTIAL?'SUBMISSION_PAPER_INVITE':'SUBMISSION_ABSTRACT_ACCEPT');
01472             break;
01473          case SUBMISSION_DIRECTOR_DECISION_ACCEPT:
01474             $templateName = 'SUBMISSION_PAPER_ACCEPT';
01475             break;
01476          case SUBMISSION_DIRECTOR_DECISION_PENDING_REVISIONS:
01477             $templateName = $isAbstract?'SUBMISSION_ABSTRACT_REVISE':'SUBMISSION_PAPER_REVISE';
01478             break;
01479          case SUBMISSION_DIRECTOR_DECISION_DECLINE:
01480             $templateName = $isAbstract?'SUBMISSION_ABSTRACT_DECLINE':'SUBMISSION_PAPER_DECLINE';
01481             break;
01482       }
01483 
01484       $user =& Request::getUser();
01485       import('mail.PaperMailTemplate');
01486       $email = new PaperMailTemplate($trackDirectorSubmission, $templateName);
01487 
01488       if ($send && !$email->hasErrors()) {
01489          HookRegistry::call('TrackDirectorAction::emailDirectorDecisionComment', array(&$trackDirectorSubmission, &$send));
01490          $email->send();
01491 
01492          $paperComment = new PaperComment();
01493          $paperComment->setCommentType(COMMENT_TYPE_DIRECTOR_DECISION);
01494          $paperComment->setRoleId(Validation::isDirector()?ROLE_ID_DIRECTOR:ROLE_ID_TRACK_DIRECTOR);
01495          $paperComment->setPaperId($trackDirectorSubmission->getPaperId());
01496          $paperComment->setAuthorId($trackDirectorSubmission->getUserId());
01497          $paperComment->setCommentTitle($email->getSubject());
01498          $paperComment->setComments($email->getBody());
01499          $paperComment->setDatePosted(Core::getCurrentDate());
01500          $paperComment->setViewable(true);
01501          $paperComment->setAssocId($trackDirectorSubmission->getPaperId());
01502          $paperCommentDao->insertPaperComment($paperComment);
01503 
01504          return true;
01505       } else {
01506          if (!Request::getUserVar('continued')) {
01507             $authorUser =& $userDao->getUser($trackDirectorSubmission->getUserId());
01508             $authorEmail = $authorUser->getEmail();
01509             $email->addRecipient($authorEmail, $authorUser->getFullName());
01510             if ($schedConf->getSetting('notifyAllAuthorsOnDecision')) foreach ($trackDirectorSubmission->getAuthors() as $author) {
01511                if ($author->getEmail() != $authorEmail) {
01512                   $email->addCc ($author->getEmail(), $author->getFullName());
01513                }
01514             }
01515             $email->assignParams(array(
01516                'conferenceDate' => strftime(Config::getVar('general', 'date_format_short'), $schedConf->getSetting('startDate')),
01517                'authorName' => $authorUser->getFullName(),
01518                'conferenceTitle' => $conference->getConferenceTitle(),
01519                'editorialContactSignature' => $user->getContactSignature(),
01520                'locationCity' => $schedConf->getSetting('locationCity'),
01521                'paperTitle' => $trackDirectorSubmission->getLocalizedTitle()
01522             ));
01523          } elseif (Request::getUserVar('importPeerReviews')) {
01524             $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
01525             $hasBody = false;
01526             for ($stage = $trackDirectorSubmission->getCurrentStage(); $stage == REVIEW_STAGE_ABSTRACT || $stage == REVIEW_STAGE_PRESENTATION; $stage--) {
01527                $reviewAssignments =& $reviewAssignmentDao->getReviewAssignmentsByPaperId($trackDirectorSubmission->getPaperId(), $stage);
01528                $reviewIndexes =& $reviewAssignmentDao->getReviewIndexesForStage($trackDirectorSubmission->getPaperId(), $stage);
01529 
01530                $body = '';
01531                foreach ($reviewAssignments as $reviewAssignment) {
01532                   // If the reviewer has completed the assignment, then import the review.
01533                   if ($reviewAssignment->getDateCompleted() != null && !$reviewAssignment->getCancelled()) {
01534                      // Get the comments associated with this review assignment
01535                      $paperComments =& $paperCommentDao->getPaperComments($trackDirectorSubmission->getPaperId(), COMMENT_TYPE_PEER_REVIEW, $reviewAssignment->getId());
01536                      
01537                      if ($paperComments) {
01538                         $body .= "------------------------------------------------------\n";
01539                         $body .= __('submission.comments.importPeerReviews.reviewerLetter', array('reviewerLetter' => chr(ord('A') + $reviewIndexes[$reviewAssignment->getId()]))) . "\n";
01540                         if (is_array($paperComments)) {
01541                            foreach ($paperComments as $comment) {
01542                               // If the comment is viewable by the author, then add the comment.
01543                               if ($comment->getViewable()) {
01544                                  $body .= String::html2utf(
01545                                     strip_tags(
01546                                        str_replace(array('<p>', '<br>', '<br/>'), array("\n", "\n", "\n"), $comment->getComments())
01547                                     )
01548                                  ) . "\n\n";
01549                                  $hasBody = true;
01550                               }
01551                            }
01552                         }
01553                         $body .= "------------------------------------------------------\n\n";
01554                      } 
01555                      if ($reviewFormId = $reviewAssignment->getReviewFormId()){
01556                         $reviewId = $reviewAssignment->getId();
01557                         
01558                         $reviewFormResponseDao =& DAORegistry::getDAO('ReviewFormResponseDAO');
01559                         $reviewFormElementDao =& DAORegistry::getDAO('ReviewFormElementDAO');
01560                         $reviewFormElements =& $reviewFormElementDao->getReviewFormElements($reviewFormId);
01561                         if (!$paperComments) {
01562                            $body .= "------------------------------------------------------\n";
01563                            $body .= __('submission.comments.importPeerReviews.reviewerLetter', array('reviewerLetter' => chr(ord('A') + $reviewIndexes[$reviewAssignment->getId()]))) . "\n\n";
01564                         }
01565                         foreach ($reviewFormElements as $reviewFormElement) if ($reviewFormElement->getIncluded()) {
01566                            $body .= strip_tags($reviewFormElement->getLocalizedQuestion()) . ": \n";
01567                            $reviewFormResponse = $reviewFormResponseDao->getReviewFormResponse($reviewId, $reviewFormElement->getId());
01568          
01569                            if ($reviewFormResponse) {
01570                               $possibleResponses = $reviewFormElement->getLocalizedPossibleResponses();
01571                               if (in_array($reviewFormElement->getElementType(), $reviewFormElement->getMultipleResponsesElementTypes())) {
01572                                  if ($reviewFormElement->getElementType() == REVIEW_FORM_ELEMENT_TYPE_CHECKBOXES) {
01573                                     foreach ($reviewFormResponse->getValue() as $value) {
01574                                        $body .= "\t" . String::html2utf(strip_tags($possibleResponses[$value-1]['content'])) . "\n";
01575                                     }
01576                                  } else {
01577                                     $body .= "\t" . String::html2utf(strip_tags($possibleResponses[$reviewFormResponse->getValue()-1]['content'])) . "\n";
01578                                  }
01579                                  $body .= "\n";
01580                               } else {
01581                                  $body .= "\t" . String::html2utf(strip_tags($reviewFormResponse->getValue())) . "\n\n";
01582                               }
01583                            }
01584                         }
01585                         $body .= "------------------------------------------------------\n\n";
01586                         $hasBody = true;
01587                      }
01588                   } // if
01589                } // foreach
01590                if ($hasBody) {
01591                   $oldBody = $email->getBody();
01592                   if (!empty($oldBody)) $oldBody .= "\n";
01593                   $email->setBody($oldBody . $body);
01594                   break;
01595                }
01596             } // foreach
01597          }
01598 
01599          $email->displayEditForm(Request::url(null, null, null, 'emailDirectorDecisionComment', 'send'), array('paperId' => $trackDirectorSubmission->getPaperId()), 'submission/comment/directorDecisionEmail.tpl', array('isADirector' => true));
01600 
01601          return false;
01602       }
01603    }
01604 
01612    function blindCcReviewsToReviewers($paper, $send = false, $inhibitExistingEmail = false) {
01613       $commentDao =& DAORegistry::getDAO('PaperCommentDAO');
01614       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
01615       $userDao =& DAORegistry::getDAO('UserDAO');
01616       $conference =& Request::getConference();
01617 
01618       $comments =& $commentDao->getPaperComments($paper->getId(), COMMENT_TYPE_DIRECTOR_DECISION);
01619       $reviewAssignments =& $reviewAssignmentDao->getReviewAssignmentsByPaperId($paper->getId(), $paper->getCurrentStage());
01620 
01621       $commentsText = "";
01622       foreach ($comments as $comment) {
01623          $commentsText .= String::html2utf(strip_tags($comment->getComments())) . "\n\n";
01624       }
01625 
01626       $user =& Request::getUser();
01627       import('mail.PaperMailTemplate');
01628       $email = new PaperMailTemplate($paper, 'SUBMISSION_DECISION_REVIEWERS', null, null, null, null, true, true);
01629 
01630       if ($send && !$email->hasErrors() && !$inhibitExistingEmail) {
01631          HookRegistry::call('TrackDirectorAction::blindCcReviewsToReviewers', array(&$paper, &$reviewAssignments, &$email));
01632          $email->send();
01633          return true;
01634       } else {
01635          if ($inhibitExistingEmail || !Request::getUserVar('continued')) {
01636             $email->clearRecipients();
01637             foreach ($reviewAssignments as $reviewAssignment) {
01638                if ($reviewAssignment->getDateCompleted() != null && !$reviewAssignment->getCancelled()) {
01639                   $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
01640 
01641                   if (isset($reviewer)) $email->addBcc($reviewer->getEmail(), $reviewer->getFullName());
01642                }
01643             }
01644 
01645             $paramArray = array(
01646                'comments' => $commentsText,
01647                'editorialContactSignature' => $user->getContactSignature()
01648             );
01649             $email->assignParams($paramArray);
01650          }
01651 
01652          $email->displayEditForm(Request::url(null, null, null, 'blindCcReviewsToReviewers'), array('paperId' => $paper->getId()));
01653          return false;
01654       }
01655    }
01656 
01661    function confirmReviewForReviewer($reviewId) {
01662       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
01663       $userDao =& DAORegistry::getDAO('UserDAO');
01664       $user =& Request::getUser();
01665 
01666       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
01667       $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId(), true);
01668 
01669       if (HookRegistry::call('TrackDirectorAction::confirmReviewForReviewer', array(&$reviewAssignment, &$reviewer))) return;
01670 
01671       // Only confirm the review for the reviewer if 
01672       // he has not previously done so.
01673       if ($reviewAssignment->getDateConfirmed() == null) {
01674          $reviewAssignment->setDeclined(0);
01675          $reviewAssignment->setDateConfirmed(Core::getCurrentDate());
01676          $reviewAssignment->stampModified();
01677          $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
01678 
01679          // Add log
01680          import('paper.log.PaperLog');
01681          import('paper.log.PaperEventLogEntry');
01682 
01683          $entry = new PaperEventLogEntry();
01684          $entry->setPaperId($reviewAssignment->getPaperId());
01685          $entry->setUserId($user->getId());
01686          $entry->setDateLogged(Core::getCurrentDate());
01687          $entry->setEventType(PAPER_LOG_REVIEW_ACCEPT_BY_PROXY);
01688          $entry->setLogMessage('log.review.reviewAcceptedByProxy', array('reviewerName' => $reviewer->getFullName(), 'paperId' => $reviewAssignment->getPaperId(), 'stage' => $reviewAssignment->getStage(), 'userName' => $user->getFullName()));
01689          $entry->setAssocType(LOG_TYPE_REVIEW);
01690          $entry->setAssocId($reviewAssignment->getId());
01691 
01692          PaperLog::logEventEntry($reviewAssignment->getPaperId(), $entry);
01693       }
01694    }
01695 
01700    function uploadReviewForReviewer($reviewId) {
01701       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
01702       $userDao =& DAORegistry::getDAO('UserDAO');
01703       $user =& Request::getUser();
01704 
01705       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
01706       $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId(), true);
01707 
01708       if (HookRegistry::call('TrackDirectorAction::uploadReviewForReviewer', array(&$reviewAssignment, &$reviewer))) return;
01709 
01710       // Upload the review file.
01711       import('file.PaperFileManager');
01712       $paperFileManager = new PaperFileManager($reviewAssignment->getPaperId());
01713       // Only upload the file if the reviewer has yet to submit a recommendation
01714       if (($reviewAssignment->getRecommendation() === null || $reviewAssignment->getRecommendation() === '') && !$reviewAssignment->getCancelled()) {
01715          $fileName = 'upload';
01716          if ($paperFileManager->uploadError($fileName)) return false;
01717          if ($paperFileManager->uploadedFileExists($fileName)) {
01718             if ($reviewAssignment->getReviewerFileId() != null) {
01719                $fileId = $paperFileManager->uploadReviewFile($fileName, $reviewAssignment->getReviewerFileId());
01720             } else {
01721                $fileId = $paperFileManager->uploadReviewFile($fileName);
01722             }
01723          }
01724       }
01725 
01726       if (isset($fileId) && $fileId != 0) {
01727          // Only confirm the review for the reviewer if 
01728          // he has not previously done so.
01729          if ($reviewAssignment->getDateConfirmed() == null) {
01730             $reviewAssignment->setDeclined(0);
01731             $reviewAssignment->setDateConfirmed(Core::getCurrentDate());
01732          }
01733 
01734          $reviewAssignment->setReviewerFileId($fileId);
01735          $reviewAssignment->stampModified();
01736          $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
01737 
01738          // Add log
01739          import('paper.log.PaperLog');
01740          import('paper.log.PaperEventLogEntry');
01741 
01742          $entry = new PaperEventLogEntry();
01743          $entry->setPaperId($reviewAssignment->getPaperId());
01744          $entry->setUserId($user->getId());
01745          $entry->setDateLogged(Core::getCurrentDate());
01746          $entry->setEventType(PAPER_LOG_REVIEW_FILE_BY_PROXY);
01747          $entry->setLogMessage('log.review.reviewFileByProxy', array('reviewerName' => $reviewer->getFullName(), 'paperId' => $reviewAssignment->getPaperId(), 'stage' => $reviewAssignment->getStage(), 'userName' => $user->getFullName()));
01748          $entry->setAssocType(LOG_TYPE_REVIEW);
01749          $entry->setAssocId($reviewAssignment->getId());
01750 
01751          PaperLog::logEventEntry($reviewAssignment->getPaperId(), $entry);
01752       }
01753    }
01754 
01760    function updateCommentsStatus($submission, $commentsStatus) {
01761       if (HookRegistry::call('TrackDirectorAction::updateCommentsStatus', array(&$submission, &$commentsStatus))) return;
01762 
01763       $submissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
01764       $submission->setCommentsStatus($commentsStatus); // FIXME validate this?
01765       $submissionDao->updateTrackDirectorSubmission($submission);
01766    }
01767 
01774    function submissionBreadcrumb($paperId, $parentPage, $track) {
01775       $breadcrumb = array();
01776       if ($paperId) {
01777          $breadcrumb[] = array(Request::url(null, null, $track, 'submission', $paperId), "#$paperId", true);
01778       }
01779 
01780       if ($parentPage) {
01781          switch($parentPage) {
01782             case 'summary':
01783                $parent = array(Request::url(null, null, $track, 'submission', $paperId), 'submission.summary');
01784                break;
01785             case 'review':
01786                $parent = array(Request::url(null, null, $track, 'submissionReview', $paperId), 'submission.review');
01787                break;
01788             case 'history':
01789                $parent = array(Request::url(null, null, $track, 'submissionHistory', $paperId), 'submission.history');
01790                break;
01791          }
01792          if ($track != 'director' && $track != 'trackDirector') {
01793             $parent[0] = Request::url(null, null, $track, 'submission', $paperId);
01794          }
01795          if (isset($parent)) $breadcrumb[] = $parent;
01796       }
01797       return $breadcrumb;
01798    }
01799 
01800 }
01801 
01802 ?>

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