/** * Save changes to article. */ function execute() { $articleDao =& DAORegistry::getDAO('ArticleDAO'); $signoffDao =& DAORegistry::getDAO('SignoffDAO'); $sectionDao =& DAORegistry::getDAO('SectionDAO'); $ercReviewersDao =& DAORegistry::getDAO('ErcReviewersDAO'); $institutionDao =& DAORegistry::getDAO('InstitutionDAO'); $journal = Request::getJournal(); $user = Request::getUser(); // Update article $article =& $this->article; if ($article->getDateSubmitted() == null) { $year = substr(Core::getCurrentDate(), 0, 4); $countyear = $articleDao->getSubmissionsForYearCount($year) + 1; $pSponsor = $article->getArticlePrimarySponsor(); $institution = $institutionDao->getInstitutionById($pSponsor->getInstitutionId()); $article->setProposalId($year . '-' . $countyear . '-' . $institution->getInstitutionAcronym()); } if ($this->getData('commentsToEditor') != '') { $article->setCommentsToEditor($this->getData('commentsToEditor')); } $article->setDateSubmitted(Core::getCurrentDate()); $article->setSubmissionProgress(0); $article->stampStatusModified(); $articleDao->updateArticle($article); // Designate this as the review version by default. $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $authorSubmission =& $authorSubmissionDao->getAuthorSubmission($article->getId()); AuthorAction::designateReviewVersion($authorSubmission, true); unset($authorSubmission); $copyeditInitialSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $article->getId()); $copyeditAuthorSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_AUTHOR', ASSOC_TYPE_ARTICLE, $article->getId()); $copyeditFinalSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $article->getId()); $copyeditInitialSignoff->setUserId(0); $copyeditAuthorSignoff->setUserId($user->getId()); $copyeditFinalSignoff->setUserId(0); $signoffDao->updateObject($copyeditInitialSignoff); $signoffDao->updateObject($copyeditAuthorSignoff); $signoffDao->updateObject($copyeditFinalSignoff); $layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $article->getId()); $layoutSignoff->setUserId(0); $signoffDao->updateObject($layoutSignoff); $proofAuthorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_AUTHOR', ASSOC_TYPE_ARTICLE, $article->getId()); $proofProofreaderSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $article->getId()); $proofLayoutEditorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $article->getId()); $proofAuthorSignoff->setUserId($user->getId()); $proofProofreaderSignoff->setUserId(0); $proofLayoutEditorSignoff->setUserId(0); $signoffDao->updateObject($proofAuthorSignoff); $signoffDao->updateObject($proofProofreaderSignoff); $signoffDao->updateObject($proofLayoutEditorSignoff); $sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO'); $sectionEditors =& $sectionEditorsDao->getEditorsBySectionId($journal->getId(), $article->getSectionId()); $user =& Request::getUser(); // Update search index import('classes.search.ArticleSearchIndex'); ArticleSearchIndex::indexArticleMetadata($article); ArticleSearchIndex::indexArticleFiles($article); // Send author notification email import('classes.mail.ArticleMailTemplate'); $mail = new ArticleMailTemplate($article, null, 'SUBMISSION_ACK', null, null, null, false); foreach ($sectionEditors as $sectionEditor) { // If one of the secretary is the chair of the committee, send from the chair, if not, take the last secretary in the array $from = $mail->getFrom(); if ($ercReviewersDao->isErcReviewer($journal->getId(), $sectionEditor->getId(), REVIEWER_CHAIR)) { $mail->setFrom($sectionEditor->getEmail(), $sectionEditor->getFullName()); } elseif ($from['email'] == $user->getEmail()) { $mail->setFrom($sectionEditor->getEmail(), $sectionEditor->getFullName()); } $mail->addBcc($sectionEditor->getEmail(), $sectionEditor->getFullName()); unset($sectionEditor); } if ($mail->isEnabled()) { $mail->addRecipient($user->getEmail(), $user->getFullName()); if ($journal->getSetting('copySubmissionAckSpecified')) { $copyAddress = $journal->getSetting('copySubmissionAckAddress'); if (!empty($copyAddress)) { $mail->addBcc($copyAddress); } } $section = $sectionDao->getSection($article->getSectionId()); $mail->assignParams(array('authorName' => $user->getFullName(), 'authorUsername' => $user->getUsername(), 'address' => $sectionDao->getSettingValue($article->getSectionId(), 'address'), 'bankAccount' => $sectionDao->getSettingValue($article->getSectionId(), 'bankAccount'), 'proposalId' => $article->getProposalId(), 'submissionUrl' => Request::url(null, 'author', 'submission', $article->getId()))); $mail->send(); } // Send a regular notification to section editors $lastDecision = $article->getLastSectionDecision(); switch ($lastDecision->getReviewType()) { case REVIEW_TYPE_INITIAL: if ($lastDecision->getRound() == 1) { $message = 'notification.type.articleSubmitted.initialReview'; } else { $message = 'notification.type.articleReSubmitted.initialReview'; } break; case REVIEW_TYPE_PR: if ($lastDecision->getRound() == 1) { $message = 'notification.type.articleSubmitted.continuingReview'; } else { $message = 'notification.type.articleReSubmitted.continuingReview'; } break; case REVIEW_TYPE_AMENDMENT: if ($lastDecision->getRound() == 1) { $message = 'notification.type.articleSubmitted.PAAmendmentReview'; } else { $message = 'notification.type.articleReSubmitted.PAAmendmentReview'; } break; case REVIEW_TYPE_SAE: if ($lastDecision->getRound() == 1) { $message = 'notification.type.articleSubmitted.SAE'; } else { $message = 'notification.type.articleReSubmitted.SAE'; } break; case REVIEW_TYPE_FR: if ($lastDecision->getRound() == 1) { $message = 'notification.type.articleSubmitted.EOS'; } else { $message = 'notification.type.articleReSubmitted.EOS'; } break; } import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $url = Request::url($journal->getPath(), 'sectionEditor', 'submission', array($article->getId(), 'submissionReview')); foreach ($sectionEditors as $sectionEditor) { $notificationManager->createNotification($sectionEditor->getId(), $message, $article->getProposalId(), $url, 1, NOTIFICATION_TYPE_ARTICLE_SUBMITTED); } import('classes.article.log.ArticleLog'); import('classes.article.log.ArticleEventLogEntry'); if ($lastDecision->getRound() == 1) { $message = 'log.author.submitted'; } else { $message = 'log.author.resubmitted'; } ArticleLog::logEvent($this->articleId, ARTICLE_LOG_ARTICLE_SUBMIT, ARTICLE_LOG_TYPE_AUTHOR, $user->getId(), $message, array('submissionId' => $article->getProposalId(), 'authorName' => $user->getFullName(), 'reviewType' => Locale::translate($lastDecision->getReviewTypeKey()))); return $this->articleId; }