/** * Sends an email with a personal message and the selected * review attachements to the author. Also marks review attachments * selected by the editor as "viewable" for the author. * @param $submission Submission * @param $emailKey string An email template. * @param $request PKPRequest */ function _sendReviewMailToAuthor($submission, $emailKey, $request) { // Send personal message to author. $submitter = $submission->getUser(); import('lib.pkp.classes.mail.SubmissionMailTemplate'); $email = new SubmissionMailTemplate($submission, $emailKey, null, null, null, false); $email->setBody($this->getData('personalMessage')); $email->addRecipient($submitter->getEmail(), $submitter->getFullName()); DAORegistry::getDAO('SubmissionEmailLogDAO'); // Load constants $email->setEventType(SUBMISSION_EMAIL_EDITOR_NOTIFY_AUTHOR); $userStageAssignmentDao = DAORegistry::getDAO('UserStageAssignmentDAO'); $authorStageParticipants = $userStageAssignmentDao->getUsersBySubmissionAndStageId($submission->getId(), $submission->getStageId(), null, ROLE_ID_AUTHOR); while ($author = $authorStageParticipants->next()) { if (preg_match('{^' . quotemeta($submitter->getEmail()) . '$}', $author->getEmail())) { $email->addRecipient($author->getEmail(), $author->getFullName()); } else { $email->addCc($author->getEmail(), $author->getFullName()); } } // Get review round. $reviewRound = $this->getReviewRound(); if (is_a($reviewRound, 'ReviewRound')) { // Retrieve review indexes. $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); /* @var $reviewAssignmentDao ReviewAssignmentDAO */ $reviewIndexes = $reviewAssignmentDao->getReviewIndexesForRound($submission->getId(), $reviewRound->getId()); 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 $fileId) { // Retrieve the submission file. $submissionFile = $submissionFileDao->getLatestRevision($fileId); assert(is_a($submissionFile, 'SubmissionFile')); // Check the association information. if ($submissionFile->getAssocType() == ASSOC_TYPE_REVIEW_ASSIGNMENT) { // The review attachment has been uploaded by a reviewer. $reviewAssignmentId = $submissionFile->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($submissionFile->getFilePath(), String::enumerateAlphabetically($reviewIndex) . '-' . $submissionFile->getOriginalFileName()); // Update submission file to set viewable as true, so author // can view the file on their submission summary page. $submissionFile->setViewable(true); $submissionFileDao->updateObject($submissionFile); } } } // Send the email. if (!$this->getData('skipEmail')) { $router = $request->getRouter(); $dispatcher = $router->getDispatcher(); $paramArray = array('authorUsername' => $submitter->getUsername(), 'submissionUrl' => $dispatcher->url($request, ROUTE_PAGE, null, 'authorDashboard', 'submission', $submission->getId())); $email->assignParams($paramArray); $email->send($request); } }