/**
  * Sends an email with a personal message and the selected
  * review attachements to the author. Also updates the status
  * of the current review round and marks review attachments
  * selected by the editor as "viewable" for the author.
  * @param $seriesEditorSubmission SeriesEditorSubmission
  * @param $status integer One of the REVIEW_ROUND_STATUS_* constants.
  * @param $emailKey string An email template.
  */
 function _sendReviewMailToAuthor(&$seriesEditorSubmission, $status, $emailKey)
 {
     // Retrieve the current review round and update it with the new status.
     $reviewRoundDao =& DAORegistry::getDAO('ReviewRoundDAO');
     /* @var $reviewRoundDao ReviewRoundDAO */
     $currentReviewRound =& $reviewRoundDao->build($seriesEditorSubmission->getId(), $seriesEditorSubmission->getCurrentReviewType(), $seriesEditorSubmission->getCurrentRound());
     $currentReviewRound->setStatus($status);
     $reviewRoundDao->updateObject($currentReviewRound);
     // Send personal message to author.
     $submitter =& $seriesEditorSubmission->getUser();
     import('classes.mail.MonographMailTemplate');
     $email = new MonographMailTemplate($seriesEditorSubmission, $emailKey);
     $email->setBody($this->getData('personalMessage'));
     $email->addRecipient($submitter->getEmail(), $submitter->getFullName());
     $email->setEventType(MONOGRAPH_EMAIL_EDITOR_NOTIFY_AUTHOR);
     // Retrieve review indexes.
     $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
     /* @var $reviewAssignmentDao ReviewAssignmentDAO */
     $reviewIndexes =& $reviewAssignmentDao->getReviewIndexesForRound($seriesEditorSubmission->getId(), $seriesEditorSubmission->getCurrentRound());
     assert(is_array($reviewIndexes));
     // Add a review index for review attachments not associated with
     // a review assignment (i.e. attachments uploaded by the editor).
     $lastIndex = end($reviewIndexes);
     $reviewIndexes[-1] = $lastIndex + 1;
     // Attach the selected reviewer attachments to the email.
     $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
     /* @var $submissionFileDao SubmissionFileDAO */
     $selectedAttachments = $this->getData('selectedAttachments');
     if (is_array($selectedAttachments)) {
         foreach ($selectedAttachments as $attachmentId) {
             // Split the attachment into file id and file revision.
             $attachment = explode('-', $attachmentId);
             assert(count($attachment) == 2);
             // Retrieve the monograph file.
             $monographFile =& $submissionFileDao->getRevision($attachment[0], $attachment[1]);
             assert(is_a($monographFile, 'MonographFile'));
             // Check the association information.
             if ($monographFile->getAssocType() == ASSOC_TYPE_REVIEW_ASSIGNMENT) {
                 // The review attachment has been uploaded by a reviewer.
                 $reviewAssignmentId = $monographFile->getAssocId();
                 assert(is_numeric($reviewAssignmentId));
             } else {
                 // The review attachment has been uploaded by the editor.
                 $reviewAssignmentId = -1;
             }
             // Identify the corresponding review index.
             assert(isset($reviewIndexes[$reviewAssignmentId]));
             $reviewIndex = $reviewIndexes[$reviewAssignmentId];
             assert(!is_null($reviewIndex));
             // Add the attachment to the email.
             $email->addAttachment($monographFile->getFilePath(), String::enumerateAlphabetically($reviewIndex) . '-' . $monographFile->getOriginalFileName());
             // Update monograph file to set viewable as true, so author
             // can view the file on their submission summary page.
             $monographFile->setViewable(true);
             $submissionFileDao->updateObject($monographFile);
         }
     }
     // Send the email.
     $email->send($request);
 }
Example #2
0
 /**
  * Save review assignment
  * @param $args array
  * @param $request PKPRequest
  * @see Form::execute()
  */
 function execute($args, &$request)
 {
     $decision = $this->getDecision();
     $monograph =& $this->getMonograph();
     $seriesEditorSubmissionDao =& DAORegistry::getDAO('SeriesEditorSubmissionDAO');
     $seriesEditorSubmission =& $seriesEditorSubmissionDao->getSeriesEditorSubmission($monograph->getId());
     import('classes.submission.seriesEditor.SeriesEditorAction');
     $seriesEditorAction =& new SeriesEditorAction();
     switch ($decision) {
         case SUBMISSION_EDITOR_DECISION_PENDING_REVISIONS:
             // 1. Record the decision
             $seriesEditorAction->recordDecision($seriesEditorSubmission, SUBMISSION_EDITOR_DECISION_DECLINE);
             // 2. select email key
             $emailKey = 'SUBMISSION_UNSUITABLE';
             // 3. Set status of round
             $status = REVIEW_ROUND_STATUS_REVISIONS_REQUESTED;
             break;
         case SUBMISSION_EDITOR_DECISION_RESUBMIT:
             // 1. Record the decision
             $seriesEditorAction->recordDecision($seriesEditorSubmission, SUBMISSION_EDITOR_DECISION_RESUBMIT);
             // 2.  Set status of round
             $status = REVIEW_ROUND_STATUS_RESUBMITTED;
             // 3.  Select email key
             $emailKey = 'EDITOR_DECISION_RESUBMIT';
             break;
         case SUBMISSION_EDITOR_DECISION_DECLINE:
             // 1. Record the decision
             $seriesEditorAction->recordDecision($seriesEditorSubmission, SUBMISSION_EDITOR_DECISION_DECLINE);
             // 2. select email key
             $emailKey = 'SUBMISSION_UNSUITABLE';
             // 3. Set status of round
             $status = REVIEW_ROUND_STATUS_DECLINED;
             break;
         default:
             // only support the three decisions above
             assert(false);
     }
     $reviewRoundDao =& DAORegistry::getDAO('ReviewRoundDAO');
     $currentReviewRound =& $reviewRoundDao->build($monograph->getId(), $seriesEditorSubmission->getCurrentReviewType(), $seriesEditorSubmission->getCurrentRound());
     $currentReviewRound->setStatus($status);
     $reviewRoundDao->updateObject($currentReviewRound);
     // n. Send Personal message to author
     $submitter = $seriesEditorSubmission->getUser();
     import('classes.mail.MonographMailTemplate');
     $email = new MonographMailTemplate($seriesEditorSubmission, $emailKey);
     $email->setBody($this->getData('personalMessage'));
     $email->addRecipient($submitter->getEmail(), $submitter->getFullName());
     $email->setAssoc(MONOGRAPH_EMAIL_EDITOR_NOTIFY_AUTHOR, MONOGRAPH_EMAIL_TYPE_EDITOR, $currentReviewRound->getRound());
     // Attach the selected reviewer attachments
     $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
     /* @var $submissionFileDao SubmissionFileDAO */
     $selectedAttachments = $this->getData('selectedAttachments') ? $this->getData('selectedAttachments') : array();
     $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
     $reviewIndexes =& $reviewAssignmentDao->getReviewIndexesForRound($seriesEditorSubmission->getId(), $seriesEditorSubmission->getCurrentRound());
     assert(is_array($reviewIndexes));
     if (is_array($selectedAttachments)) {
         foreach ($selectedAttachments as $attachmentId) {
             $monographFile =& $submissionFileDao->getLatestRevision($attachmentId);
             assert(is_a($monographFile, 'MonographFile'));
             $fileName = $monographFile->getOriginalFileName();
             $reviewAssignmentId = $monographFile->getAssocId();
             assert($monographFile->getAssocType == ASSOC_TYPE_REVIEW_ASSIGNMENT);
             assert(is_numeric($reviewAssignmentId));
             $reviewIndex = $reviewIndexes[$reviewAssignmentId];
             assert(!is_null($reviewIndex));
             $email->addAttachment($monographFile->getFilePath(), String::enumerateAlphabetically($reviewIndex) . '-' . $monographFile->getOriginalFileName());
             // Update monograph to set viewable as true, so author can view the file on their submission summary page
             $monographFile->setViewable(true);
             $submissionFileDao->updateObject($monographFile);
         }
     }
     $email->send();
 }