/** * Save changes to the report file. * @return int the report file ID */ function execute($fileName = null) { $sectionDecisionDao =& DAORegistry::getDAO('SectionDecisionDAO'); $articleDao =& DAORegistry::getDAO('ArticleDAO'); import('classes.file.ArticleFileManager'); $articleFileManager = new ArticleFileManager($this->article->getArticleId()); $fileName = isset($fileName) ? $fileName : 'uploadReportFile'; $lastDecision = $this->article->getLastSectionDecision(); $lastDecisionDecision = $lastDecision->getDecision(); $lastDecisionType = $lastDecision->getReviewType(); // Ensure to start a new round of review when needed, and if the file to upload is correct if (($lastDecisionDecision == SUBMISSION_SECTION_DECISION_APPROVED || $lastDecisionDecision == SUBMISSION_SECTION_DECISION_EXEMPTED || $lastDecisionType == REVIEW_TYPE_SAE && ($lastDecisionDecision == SUBMISSION_SECTION_DECISION_INCOMPLETE || $lastDecisionDecision == SUBMISSION_SECTION_DECISION_RESUBMIT)) && $articleFileManager->uploadedFileExists($fileName)) { $this->fileId = $articleFileManager->uploadSAEFile($fileName); } else { $this->fileId = 0; } if ($this->fileId && $this->fileId > 0) { $sectionDecision =& new SectionDecision(); $sectionDecision->setSectionId($lastDecision->getSectionId()); $sectionDecision->setDecision(0); $sectionDecision->setDateDecided(date(Core::getCurrentDate())); $sectionDecision->setArticleId($this->article->getArticleId()); $sectionDecision->setReviewType(REVIEW_TYPE_SAE); if ($lastDecisionType == $sectionDecision->getReviewType()) { $lastRound = (int) $lastDecision->getRound(); $sectionDecision->setRound($lastRound + 1); } else { $sectionDecision->setRound(1); } $sectionDecisionDao->insertSectionDecision($sectionDecision); $articleDao->changeArticleStatus($this->article->getArticleId(), STATUS_QUEUED); } // Notifications import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $journal =& Request::getJournal(); $url = Request::url($journal->getPath(), 'sectionEditor', 'submission', array($this->article->getArticleId(), 'submissionReview')); $sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO'); $sectionEditors =& $sectionEditorsDao->getEditorsBySectionId($journal->getId(), $lastDecision->getSectionId()); foreach ($sectionEditors as $sectionEditor) { $notificationSectionEditors[] = array('id' => $sectionEditor->getId()); } foreach ($notificationSectionEditors as $userRole) { $notificationManager->createNotification($userRole['id'], 'notification.type.sae', $this->article->getProposalId(), $url, 1, NOTIFICATION_TYPE_METADATA_MODIFIED); } return $this->fileId; }