/**
  * Save review assignment
  * @param $args array
  * @param $request PKPRequest
  */
 function execute($args, &$request)
 {
     $userDao =& DAORegistry::getDAO('UserDAO');
     $monographDao =& DAORegistry::getDAO('MonographDAO');
     $reviewAssignment =& $this->getReviewAssignment();
     $reviewerId = $reviewAssignment->getReviewerId();
     $reviewer =& $userDao->getUser($reviewerId);
     $monograph =& $monographDao->getMonograph($reviewAssignment->getSubmissionId());
     import('classes.mail.MonographMailTemplate');
     $email = new MonographMailTemplate($monograph, 'REVIEW_REMIND');
     $email->addRecipient($reviewer->getEmail(), $reviewer->getFullName());
     $email->setBody($this->getData('message'));
     $email->send();
 }
 /**
  * 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);
 }
 /**
  * Assign user to copyedit the selected files
  * @see Form::execute()
  */
 function execute()
 {
     $userDao =& DAORegistry::getDAO('UserDAO');
     /* @var $userDao UserDAO */
     $signoffDao =& DAORegistry::getDAO('SignoffDAO');
     /* @var $signoffDao SignoffDAO */
     $monograph =& $this->getMonograph();
     if ($this->getData('selected-listbuilder-files-galleyfileslistbuilder')) {
         $selectedFiles = $this->getData('selected-listbuilder-files-galleyfileslistbuilder');
     } else {
         $selectedFiles = array();
     }
     // Split the selected user value; index 0 is the user id, index 1 is the user groupID
     $userIdAndGroup = explode('-', $this->getData('userId'));
     // Build galley signoff for each file
     foreach ($selectedFiles as $selectedFileId) {
         $signoff =& $signoffDao->build('SIGNOFF_COPYEDITING', ASSOC_TYPE_MONOGRAPH_FILE, $selectedFileId, $userIdAndGroup[0], WORKFLOW_STAGE_ID_EDITING, $userIdAndGroup[1]);
         /* @var $signoff Signoff */
         // Set the date notified
         $signoff->setDateNotified(Core::getCurrentDate());
         // Set the date response due (stored as date underway in signoffs table)
         $dueDateParts = explode('-', $this->getData('responseDueDate'));
         $signoff->setDateUnderway(date('Y-m-d H:i:s', mktime(0, 0, 0, $dueDateParts[0], $dueDateParts[1], $dueDateParts[2])));
         $signoffDao->updateObject($signoff);
     }
     // Send the message to the user
     import('classes.mail.MonographMailTemplate');
     $email = new MonographMailTemplate($monograph);
     $email->setBody($this->getData('personalMessage'));
     $user =& $userDao->getUser($userIdAndGroup[0]);
     $email->addRecipient($user->getEmail(), $user->getFullName());
     $email->setAssoc(MONOGRAPH_EMAIL_COPYEDIT_NOTIFY_AUTHOR, MONOGRAPH_EMAIL_TYPE_COPYEDIT, MONOGRAPH_EMAIL_COPYEDIT_NOTIFY_AUTHOR);
     $email->send();
 }
 /**
  * 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();
 }