/**
  * Save changes to submission.
  * @param $args array
  * @param $request PKPRequest
  * @return int the submission ID
  */
 function execute($args, $request)
 {
     parent::execute($args, $request);
     // handle category assignment.
     ListbuilderHandler::unpack($request, $this->getData('categories'));
     $submissionDao = Application::getSubmissionDAO();
     $submission = $submissionDao->getById($this->submissionId);
     // Send author notification email
     import('classes.mail.MonographMailTemplate');
     $mail = new MonographMailTemplate($submission, 'SUBMISSION_ACK', null, null, null, false);
     $authorMail = new MonographMailTemplate($submission, 'SUBMISSION_ACK_NOT_USER', null, null, null, false);
     $context = $request->getContext();
     $router = $request->getRouter();
     if ($mail->isEnabled()) {
         // submission ack emails should be from the contact.
         $mail->setReplyTo($this->context->getSetting('contactEmail'), $this->context->getSetting('contactName'));
         $authorMail->setReplyTo($this->context->getSetting('contactEmail'), $this->context->getSetting('contactName'));
         $user = $request->getUser();
         $primaryAuthor = $submission->getPrimaryAuthor();
         if (!isset($primaryAuthor)) {
             $authors = $submission->getAuthors();
             $primaryAuthor = $authors[0];
         }
         $mail->addRecipient($user->getEmail(), $user->getFullName());
         if ($user->getEmail() != $primaryAuthor->getEmail()) {
             $authorMail->addRecipient($primaryAuthor->getEmail(), $primaryAuthor->getFullName());
         }
         if ($context->getSetting('copySubmissionAckPrimaryContact')) {
             $authorMail->addBcc($context->getSetting('contactEmail'), $context->getSetting('contactName'));
         }
         if ($copyAddress = $context->getSetting('copySubmissionAckAddress')) {
             $authorMail->addBcc($copyAddress);
         }
         $assignedAuthors = $submission->getAuthors();
         foreach ($assignedAuthors as $author) {
             $authorEmail = $author->getEmail();
             // only add the author email if they have not already been added as the primary author
             // or user creating the submission.
             if ($authorEmail != $primaryAuthor->getEmail() && $authorEmail != $user->getEmail()) {
                 $authorMail->addRecipient($author->getEmail(), $author->getFullName());
             }
         }
         $mail->bccAssignedSeriesEditors($submission->getId(), WORKFLOW_STAGE_ID_SUBMISSION);
         $mail->assignParams(array('authorName' => $user->getFullName(), 'authorUsername' => $user->getUsername(), 'editorialContactSignature' => $context->getSetting('contactName') . "\n" . $context->getLocalizedName(), 'submissionUrl' => $router->url($request, null, 'authorDashboard', 'submission', $submission->getId())));
         $authorMail->assignParams(array('submitterName' => $user->getFullName(), 'editorialContactSignature' => $context->getSetting('contactName') . "\n" . $context->getLocalizedName()));
         $mail->send($request);
         $recipients = $authorMail->getRecipients();
         if (!empty($recipients)) {
             $authorMail->send($request);
         }
     }
     // Log submission.
     import('lib.pkp.classes.log.SubmissionLog');
     import('classes.log.SubmissionEventLogEntry');
     // constants
     SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_SUBMISSION_SUBMIT, 'submission.event.submissionSubmitted');
     return $this->submissionId;
 }
Exemple #2
0
 /**
  * Initialize form data with the author name and the monograph id.
  * @param $args array
  * @param $request PKPRequest
  */
 function initData($args, &$request)
 {
     $press =& $request->getPress();
     $monograph =& $this->getMonograph();
     $submitter = $monograph->getUser();
     import('classes.mail.MonographMailTemplate');
     $email = new MonographMailTemplate($monograph, 'EDITOR_DECISION_ACCEPT');
     $paramArray = array('authorName' => $submitter->getFullName(), 'pressName' => $press->getLocalizedName(), 'monographTitle' => $monograph->getLocalizedTitle(), 'editorialContactSignature' => $submitter->getContactSignature());
     $email->assignParams($paramArray);
     $actionLabels = array(SUBMISSION_EDITOR_DECISION_EXTERNAL_REVIEW => 'editor.monograph.decision.externalReview', SUBMISSION_EDITOR_DECISION_ACCEPT => 'editor.monograph.decision.accept');
     $this->_data = array('monographId' => $monograph->getId(), 'decision' => $this->getDecision(), 'authorName' => $monograph->getAuthorString(), 'personalMessage' => $email->getBody(), 'actionLabel' => $actionLabels[$this->getDecision()]);
     return parent::initData($args, $request);
 }
 /**
  * Records whether or not the reviewer accepts the review assignment.
  * @param $reviewerSubmission object
  * @param $decline boolean
  * @param $send boolean
  */
 function confirmReview($request, $reviewerSubmission, $decline, $send)
 {
     $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $reviewId = $reviewerSubmission->getReviewId();
     $reviewAssignment =& $reviewAssignmentDao->getById($reviewId);
     $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
     if (!isset($reviewer)) {
         return true;
     }
     // Only confirm the review for the reviewer if
     // he has not previously done so.
     if ($reviewAssignment->getDateConfirmed() == null) {
         import('classes.mail.MonographMailTemplate');
         $email = new MonographMailTemplate($reviewerSubmission, $decline ? 'REVIEW_DECLINE' : 'REVIEW_CONFIRM');
         // Must explicitly set sender because we may be here on an access
         // key, in which case the user is not technically logged in
         $email->setFrom($reviewer->getEmail(), $reviewer->getFullName());
         if (!$email->isEnabled() || $send && !$email->hasErrors()) {
             HookRegistry::call('ReviewerAction::confirmReview', array(&$request, &$reviewerSubmission, &$email, $decline));
             if ($email->isEnabled()) {
                 $email->setEventType($decline ? MONOGRAPH_EMAIL_REVIEW_DECLINE : MONOGRAPH_EMAIL_REVIEW_CONFIRM);
                 $email->send($request);
             }
             $reviewAssignment->setDeclined($decline);
             $reviewAssignment->setDateConfirmed(Core::getCurrentDate());
             $reviewAssignment->stampModified();
             $reviewAssignmentDao->updateObject($reviewAssignment);
             // Add log
             import('classes.log.MonographLog');
             import('classes.log.MonographEventLogEntry');
             $entry = new MonographEventLogEntry();
             $entry->setMonographId($reviewAssignment->getSubmissionId());
             $entry->setUserId($reviewer->getId());
             $entry->setDateLogged(Core::getCurrentDate());
             $entry->setEventType($decline ? MONOGRAPH_LOG_REVIEW_DECLINE : MONOGRAPH_LOG_REVIEW_ACCEPT);
             MonographLog::logEvent($request, $reviewerSubmission, $decline ? MONOGRAPH_LOG_REVIEW_DECLINE : MONOGRAPH_LOG_REVIEW_ACCEPT, $decline ? 'log.review.reviewDeclined' : 'log.review.reviewAccepted', array('reviewerName' => $reviewer->getFullName(), 'monographId' => $reviewAssignment->getSubmissionId(), 'round' => $reviewAssignment->getRound()));
             return true;
         } else {
             if (!$request->getUserVar('continued')) {
                 $assignedEditors = $email->ccAssignedEditors($reviewerSubmission->getId());
                 $reviewingSeriesEditors = $email->toAssignedReviewingSeriesEditors($reviewerSubmission->getId());
                 if (empty($assignedEditors) && empty($reviewingSeriesEditors)) {
                     $press =& $request->getPress();
                     $email->addRecipient($press->getSetting('contactEmail'), $press->getSetting('contactName'));
                     $editorialContactName = $press->getSetting('contactName');
                 } else {
                     if (!empty($reviewingSeriesEditors)) {
                         $editorialContact = array_shift($reviewingSeriesEditors);
                     } else {
                         $editorialContact = array_shift($assignedEditors);
                     }
                     $editorialContactName = $editorialContact->getEditorFullName();
                 }
                 // Format the review due date
                 $reviewDueDate = strtotime($reviewAssignment->getDateDue());
                 $dateFormatShort = Config::getVar('general', 'date_format_short');
                 if ($reviewDueDate == -1) {
                     $reviewDueDate = $dateFormatShort;
                 } else {
                     $reviewDueDate = strftime($dateFormatShort, $reviewDueDate);
                 }
                 $email->assignParams(array('editorialContactName' => $editorialContactName, 'reviewerName' => $reviewer->getFullName(), 'reviewDueDate' => $reviewDueDate));
             }
             $paramArray = array('reviewId' => $reviewId);
             if ($decline) {
                 $paramArray['declineReview'] = 1;
             }
             $email->displayEditForm($request->url(null, 'reviewer', 'confirmReview'), $paramArray);
             return false;
         }
     }
     return true;
 }
 /**
  * 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();
 }
 /**
  * Register a new user.
  * @return userId int
  */
 function execute(&$request)
 {
     $user =& $request->getUser();
     $monographDao =& DAORegistry::getDAO('MonographDAO');
     $router =& $request->getRouter();
     $dispatcher =& $router->getDispatcher();
     $paramArray = array('sender' => $user->getFullName(), 'monographDetailsUrl' => $dispatcher->url($request, ROUTE_PAGE, null, 'workflow', 'submission', $this->itemId), 'message' => $this->getData('message'));
     switch ($this->itemType) {
         case ASSOC_TYPE_MONOGRAPH_FILE:
             $emailTemplate = 'NOTIFY_FILE';
             $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
             /* @var $submissionFileDao SubmissionFileDAO */
             $monographFile =& $submissionFileDao->getLatestRevision($this->itemId);
             $monographId = $monographFile->getMonographId();
             $paramArray['fileName'] = $monographFile->getLocalizedName();
             break;
         default:
             $emailTemplate = 'NOTIFY_SUBMISSION';
             $monographId = $this->itemId;
             break;
     }
     import('classes.mail.MonographMailTemplate');
     $email = new MonographMailTemplate($monographDao->getMonograph($monographId), $emailTemplate);
     $email->assignParams($paramArray);
     $userDao =& DAORegistry::getDAO('UserDAO');
     foreach ($this->getData('selected-listbuilder-users-notifyuserslistbuilder') as $recipientId) {
         $user =& $userDao->getUser($recipientId);
         $email->addRecipient($user->getEmail(), $user->getFullName());
     }
     $email->send();
 }
 /**
  * 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();
 }
 /**
  * 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);
 }
 /**
  * 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();
 }