Exemple #1
0
 function sendReminder($reviewAssignment, $paper, $conference, $schedConf)
 {
     $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO');
     $userDao = DAORegistry::getDAO('UserDAO');
     $reviewId = $reviewAssignment->getId();
     $reviewer =& $userDao->getById($reviewAssignment->getReviewerId());
     if (!isset($reviewer)) {
         return false;
     }
     import('classes.mail.PaperMailTemplate');
     $reviewerAccessKeysEnabled = $schedConf->getSetting('reviewerAccessKeysEnabled');
     $email = new PaperMailTemplate($paper, $reviewerAccessKeysEnabled ? 'REVIEW_REMIND_AUTO_ONECLICK' : 'REVIEW_REMIND_AUTO', $conference->getPrimaryLocale(), false, $conference, $schedConf);
     $email->setConference($conference);
     $email->setSchedConf($schedConf);
     $contactEmail = $schedConf->getSetting('contactEmail') ? $schedConf->getSetting('contactEmail') : $conference->getSetting('contactEmail');
     $contactName = $schedConf->getSetting('contactName') ? $schedConf->getSetting('contactName') : $conference->getSetting('contactName');
     $email->setFrom($contactEmail, $contactName);
     $email->addRecipient($reviewer->getEmail(), $reviewer->getFullName());
     $email->setAssoc(PAPER_EMAIL_REVIEW_REMIND, PAPER_EMAIL_TYPE_REVIEW, $reviewId);
     $email->setSubject($email->getSubject($conference->getPrimaryLocale()));
     $email->setBody($email->getBody($conference->getPrimaryLocale()));
     $urlParams = array();
     if ($reviewerAccessKeysEnabled) {
         import('lib.pkp.classes.security.AccessKeyManager');
         $accessKeyManager = new AccessKeyManager();
         // Key lifetime is the typical review period plus four weeks
         if ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_ABSOLUTE) {
             // Get number of days from now until review deadline date
             $reviewDeadlineDate = $schedConf->getSetting('numWeeksPerReviewAbsolute');
             $daysDiff = ($reviewDeadlineDate - strtotime(date("Y-m-d"))) / (60 * 60 * 24);
             $keyLifetime = (round($daysDiff / 7) + 4) * 7;
         } elseif ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_RELATIVE) {
             $keyLifetime = ((int) $schedConf->getSetting('numWeeksPerReviewRelative') + 4) * 7;
         }
         $urlParams['key'] = $accessKeyManager->createKey('ReviewerContext', $reviewer->getId(), $reviewId, $keyLifetime);
     }
     $submissionReviewUrl = Request::url($conference->getPath(), $schedConf->getPath(), 'reviewer', 'submission', $reviewId, $urlParams);
     // Format the review due date
     $reviewDueDate = strtotime($reviewAssignment->getDateDue());
     $dateFormatShort = Config::getVar('general', 'date_format_short');
     if ($reviewDueDate === -1 || $reviewDueDate === false) {
         // Use something human-readable if unspecified.
         $reviewDueDate = '_____';
     } else {
         $reviewDueDate = strftime($dateFormatShort, $reviewDueDate);
     }
     $paramArray = array('reviewerName' => $reviewer->getFullName(), 'reviewerUsername' => $reviewer->getUsername(), 'conferenceUrl' => Request::url($conference->getPath()), 'schedConfUrl' => Request::url($conference->getPath(), $schedConf->getPath()), 'reviewerPassword' => $reviewer->getPassword(), 'reviewDueDate' => $reviewDueDate, 'weekLaterDate' => strftime(Config::getVar('general', 'date_format_short'), strtotime('+1 week')), 'editorialContactSignature' => $contactName . "\n" . $schedConf->getLocalizedName(), 'passwordResetUrl' => Request::url($conference->getPath(), $schedConf->getPath(), 'login', 'resetPassword', $reviewer->getUsername(), array('confirm' => Validation::generatePasswordResetHash($reviewer->getId()))), 'submissionReviewUrl' => $submissionReviewUrl);
     $email->assignParams($paramArray);
     $email->send();
     $reviewAssignment->setDateReminded(Core::getCurrentDate());
     $reviewAssignment->setReminderWasAutomatic(1);
     $reviewAssignmentDao->updateObject($reviewAssignment);
 }
Exemple #2
0
 /**
  * Email director decision comment.
  * @param $authorSubmission object
  * @param $send boolean
  */
 function emailDirectorDecisionComment($authorSubmission, $send)
 {
     $userDao =& DAORegistry::getDAO('UserDAO');
     $conference =& Request::getConference();
     $schedConf =& Request::getSchedConf();
     $user =& Request::getUser();
     import('mail.PaperMailTemplate');
     $email = new PaperMailTemplate($authorSubmission);
     $editAssignments = $authorSubmission->getEditAssignments();
     $directors = array();
     foreach ($editAssignments as $editAssignment) {
         array_push($directors, $userDao->getUser($editAssignment->getDirectorId()));
     }
     if ($send && !$email->hasErrors()) {
         HookRegistry::call('AuthorAction::emailDirectorDecisionComment', array(&$authorSubmission, &$email));
         $email->send();
         $paperCommentDao =& DAORegistry::getDAO('PaperCommentDAO');
         $paperComment = new PaperComment();
         $paperComment->setCommentType(COMMENT_TYPE_DIRECTOR_DECISION);
         $paperComment->setRoleId(ROLE_ID_AUTHOR);
         $paperComment->setPaperId($authorSubmission->getPaperId());
         $paperComment->setAuthorId($authorSubmission->getUserId());
         $paperComment->setCommentTitle($email->getSubject());
         $paperComment->setComments($email->getBody());
         $paperComment->setDatePosted(Core::getCurrentDate());
         $paperComment->setViewable(true);
         $paperComment->setAssocId($authorSubmission->getPaperId());
         $paperCommentDao->insertPaperComment($paperComment);
         return true;
     } else {
         if (!Request::getUserVar('continued')) {
             $email->setSubject($authorSubmission->getLocalizedTitle());
             if (!empty($directors)) {
                 foreach ($directors as $director) {
                     $email->addRecipient($director->getEmail(), $director->getFullName());
                 }
             } else {
                 $email->addRecipient($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName'));
             }
         }
         $email->displayEditForm(Request::url(null, null, null, 'emailDirectorDecisionComment', 'send'), array('paperId' => $authorSubmission->getPaperId()), 'submission/comment/directorDecisionEmail.tpl');
         return false;
     }
 }
 /**
  * Email director decision comment.
  * @param $trackDirectorSubmission object
  * @param $send boolean
  */
 function emailDirectorDecisionComment($trackDirectorSubmission, $send)
 {
     $userDao =& DAORegistry::getDAO('UserDAO');
     $paperCommentDao =& DAORegistry::getDAO('PaperCommentDAO');
     $conference =& Request::getConference();
     $schedConf =& Request::getSchedConf();
     $templateName = null;
     $reviewMode = $trackDirectorSubmission->getReviewMode();
     $stages = $trackDirectorSubmission->getDecisions();
     if (is_array($stages)) {
         $isAbstract = array_pop(array_keys($stages)) == REVIEW_STAGE_ABSTRACT;
     }
     if (isset($stages) && is_array($stages)) {
         $decisions = array_pop($stages);
         // If this round has no decision, revert to prior round
         if (empty($decisions)) {
             $decisions = array_pop($stages);
         }
     }
     if (isset($decisions) && is_array($decisions)) {
         $lastDecision = array_pop($decisions);
     }
     if (isset($lastDecision) && is_array($lastDecision)) {
         switch ($lastDecision['decision']) {
             case SUBMISSION_DIRECTOR_DECISION_INVITE:
                 $templateName = $reviewMode == REVIEW_MODE_BOTH_SEQUENTIAL ? 'SUBMISSION_PAPER_INVITE' : 'SUBMISSION_ABSTRACT_ACCEPT';
                 break;
             case SUBMISSION_DIRECTOR_DECISION_ACCEPT:
                 $templateName = 'SUBMISSION_PAPER_ACCEPT';
                 break;
             case SUBMISSION_DIRECTOR_DECISION_PENDING_REVISIONS:
                 $templateName = $isAbstract ? 'SUBMISSION_ABSTRACT_REVISE' : 'SUBMISSION_PAPER_REVISE';
                 break;
             case SUBMISSION_DIRECTOR_DECISION_DECLINE:
                 $templateName = $isAbstract ? 'SUBMISSION_ABSTRACT_DECLINE' : 'SUBMISSION_PAPER_DECLINE';
                 break;
         }
     }
     $user =& Request::getUser();
     import('mail.PaperMailTemplate');
     $email = new PaperMailTemplate($trackDirectorSubmission, $templateName);
     if ($send && !$email->hasErrors()) {
         HookRegistry::call('TrackDirectorAction::emailDirectorDecisionComment', array(&$trackDirectorSubmission, &$send));
         $email->send();
         $paperComment = new PaperComment();
         $paperComment->setCommentType(COMMENT_TYPE_DIRECTOR_DECISION);
         $paperComment->setRoleId(Validation::isDirector() ? ROLE_ID_DIRECTOR : ROLE_ID_TRACK_DIRECTOR);
         $paperComment->setPaperId($trackDirectorSubmission->getPaperId());
         $paperComment->setAuthorId($trackDirectorSubmission->getUserId());
         $paperComment->setCommentTitle($email->getSubject());
         $paperComment->setComments($email->getBody());
         $paperComment->setDatePosted(Core::getCurrentDate());
         $paperComment->setViewable(true);
         $paperComment->setAssocId($trackDirectorSubmission->getPaperId());
         $paperCommentDao->insertPaperComment($paperComment);
         return true;
     } else {
         if (!Request::getUserVar('continued')) {
             $authorUser =& $userDao->getUser($trackDirectorSubmission->getUserId());
             $authorEmail = $authorUser->getEmail();
             $email->addRecipient($authorEmail, $authorUser->getFullName());
             if ($schedConf->getSetting('notifyAllAuthorsOnDecision')) {
                 foreach ($trackDirectorSubmission->getAuthors() as $author) {
                     if ($author->getEmail() != $authorEmail) {
                         $email->addCc($author->getEmail(), $author->getFullName());
                     }
                 }
             }
             $email->assignParams(array('conferenceDate' => strftime(Config::getVar('general', 'date_format_short'), $schedConf->getSetting('startDate')), 'authorName' => $authorUser->getFullName(), 'conferenceTitle' => $conference->getConferenceTitle(), 'editorialContactSignature' => $user->getContactSignature(), 'locationCity' => $schedConf->getSetting('locationCity'), 'paperTitle' => $trackDirectorSubmission->getLocalizedTitle()));
         } elseif (Request::getUserVar('importPeerReviews')) {
             $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
             $hasBody = false;
             for ($stage = $trackDirectorSubmission->getCurrentStage(); $stage == REVIEW_STAGE_ABSTRACT || $stage == REVIEW_STAGE_PRESENTATION; $stage--) {
                 $reviewAssignments =& $reviewAssignmentDao->getReviewAssignmentsByPaperId($trackDirectorSubmission->getPaperId(), $stage);
                 $reviewIndexes =& $reviewAssignmentDao->getReviewIndexesForStage($trackDirectorSubmission->getPaperId(), $stage);
                 $body = '';
                 foreach ($reviewAssignments as $reviewAssignment) {
                     // If the reviewer has completed the assignment, then import the review.
                     if ($reviewAssignment->getDateCompleted() != null && !$reviewAssignment->getCancelled()) {
                         // Get the comments associated with this review assignment
                         $paperComments =& $paperCommentDao->getPaperComments($trackDirectorSubmission->getPaperId(), COMMENT_TYPE_PEER_REVIEW, $reviewAssignment->getId());
                         if ($paperComments) {
                             $body .= "------------------------------------------------------\n";
                             $body .= Locale::translate('submission.comments.importPeerReviews.reviewerLetter', array('reviewerLetter' => chr(ord('A') + $reviewIndexes[$reviewAssignment->getId()]))) . "\n";
                             if (is_array($paperComments)) {
                                 foreach ($paperComments as $comment) {
                                     // If the comment is viewable by the author, then add the comment.
                                     if ($comment->getViewable()) {
                                         $body .= String::html2utf(strip_tags(str_replace(array('<p>', '<br>', '<br/>'), array("\n", "\n", "\n"), $comment->getComments()))) . "\n\n";
                                         $hasBody = true;
                                     }
                                 }
                             }
                             $body .= "------------------------------------------------------\n\n";
                         }
                         if ($reviewFormId = $reviewAssignment->getReviewFormId()) {
                             $reviewId = $reviewAssignment->getId();
                             $reviewFormResponseDao =& DAORegistry::getDAO('ReviewFormResponseDAO');
                             $reviewFormElementDao =& DAORegistry::getDAO('ReviewFormElementDAO');
                             $reviewFormElements =& $reviewFormElementDao->getReviewFormElements($reviewFormId);
                             if (!$paperComments) {
                                 $body .= "------------------------------------------------------\n";
                                 $body .= Locale::translate('submission.comments.importPeerReviews.reviewerLetter', array('reviewerLetter' => chr(ord('A') + $reviewIndexes[$reviewAssignment->getId()]))) . "\n\n";
                             }
                             foreach ($reviewFormElements as $reviewFormElement) {
                                 if ($reviewFormElement->getIncluded()) {
                                     $body .= strip_tags($reviewFormElement->getLocalizedQuestion()) . ": \n";
                                     $reviewFormResponse = $reviewFormResponseDao->getReviewFormResponse($reviewId, $reviewFormElement->getId());
                                     if ($reviewFormResponse) {
                                         $possibleResponses = $reviewFormElement->getLocalizedPossibleResponses();
                                         if (in_array($reviewFormElement->getElementType(), $reviewFormElement->getMultipleResponsesElementTypes())) {
                                             if ($reviewFormElement->getElementType() == REVIEW_FORM_ELEMENT_TYPE_CHECKBOXES) {
                                                 foreach ($reviewFormResponse->getValue() as $value) {
                                                     $body .= "\t" . String::html2utf(strip_tags($possibleResponses[$value - 1]['content'])) . "\n";
                                                 }
                                             } else {
                                                 $body .= "\t" . String::html2utf(strip_tags($possibleResponses[$reviewFormResponse->getValue() - 1]['content'])) . "\n";
                                             }
                                             $body .= "\n";
                                         } else {
                                             $body .= "\t" . String::html2utf(strip_tags($reviewFormResponse->getValue())) . "\n\n";
                                         }
                                     }
                                 }
                             }
                             $body .= "------------------------------------------------------\n\n";
                             $hasBody = true;
                         }
                     }
                     // if
                 }
                 // foreach
                 if ($hasBody) {
                     $oldBody = $email->getBody();
                     if (!empty($oldBody)) {
                         $oldBody .= "\n";
                     }
                     $email->setBody($oldBody . $body);
                     break;
                 }
             }
             // foreach
         }
         $email->displayEditForm(Request::url(null, null, null, 'emailDirectorDecisionComment', 'send'), array('paperId' => $trackDirectorSubmission->getPaperId()), 'submission/comment/directorDecisionEmail.tpl', array('isADirector' => true));
         return false;
     }
 }
 /**
  * Email director decision comment.
  * @param $authorSubmission object
  * @param $send boolean
  */
 function emailDirector($authorSubmission, $send, $director)
 {
     $userDao =& DAORegistry::getDAO('UserDAO');
     $conference =& Request::getConference();
     $schedConf =& Request::getSchedConf();
     $user =& Request::getUser();
     import('mail.PaperMailTemplate');
     $templateName = 'AUTHOR_EMAIL_DIRECTOR';
     $email = new PaperMailTemplate($authorSubmission, $templateName);
     $editAssignments = $authorSubmission->getEditAssignments();
     $directors = array($director);
     if ($send && !$email->hasErrors()) {
         HookRegistry::call('AuthorAction::emailDirector', array(&$authorSubmission, &$email));
         $email->send();
         $paperCommentDao =& DAORegistry::getDAO('PaperCommentDAO');
         $paperComment = new PaperComment();
         $paperComment->setCommentType(COMMENT_TYPE_DIRECTOR_DECISION);
         $paperComment->setRoleId(ROLE_ID_AUTHOR);
         $paperComment->setPaperId($authorSubmission->getPaperId());
         $paperComment->setAuthorId($authorSubmission->getUserId());
         $paperComment->setCommentTitle($email->getSubject());
         $paperComment->setComments($email->getBody());
         $paperComment->setDatePosted(Core::getCurrentDate());
         $paperComment->setViewable(true);
         $paperComment->setAssocId($authorSubmission->getPaperId());
         $paperCommentDao->insertPaperComment($paperComment);
         return true;
     } else {
         if (!Request::getUserVar('continued')) {
             //$subject = $authorSubmission->getLocalizedTitle();
             $subject = $email->getSubject();
             //$subject = "[" . $schedConf->getLocalizedAcronym() . "] " . $subject;
             $email->setSubject($subject);
             if (!empty($directors)) {
                 foreach ($directors as $director) {
                     $email->addRecipient($director->getEmail(), $director->getFullName());
                 }
             } else {
                 $email->addRecipient($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName'));
             }
             //--------------------------
             $authorUser =& $userDao->getUser($authorSubmission->getUserId());
             //$submissionUrl = $submissionUrl . '?u=' . $authorUser->getUserId();
             $authorEmail = $authorUser->getEmail();
             $email->addRecipient($authorEmail, $authorUser->getFullName());
             if ($schedConf->getSetting('notifyAllAuthorsOnDecision')) {
                 foreach ($authorSubmission->getAuthors() as $author) {
                     if ($author->getEmail() != $authorEmail) {
                         $email->addCc($author->getEmail(), $author->getFullName());
                     }
                 }
             }
             $submissionUrl = Request::url(null, null, 'director', 'submissionReview', $authorSubmission->getPaperId());
             $email->assignParams(array('contactName' => $director->getFullName(), 'conferenceDate' => strftime(Config::getVar('general', 'date_format_short'), $schedConf->getSetting('startDate')), 'authorName' => $authorUser->getFullName(), 'conferenceTitle' => $conference->getConferenceTitle(), 'editorialContactSignature' => $user->getContactSignature(), 'locationCity' => $schedConf->getSetting('locationCity'), 'paperTitle' => $authorSubmission->getLocalizedTitle(), 'submissionUrl' => $submissionUrl));
             // ---------------------------
         }
         $email->displayEditForm(Request::url(null, null, null, 'emailDirectorDecisionComment', 'send'), array('paperId' => $authorSubmission->getPaperId()), 'submission/comment/directorDecisionEmail.tpl', array('isADirector' => false, 'templateName' => $templateName));
         return false;
     }
 }