Beispiel #1
0
 /**
  * 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_PR || $lastDecisionType == REVIEW_TYPE_FR) && ($lastDecisionDecision == SUBMISSION_SECTION_DECISION_INCOMPLETE || $lastDecisionDecision == SUBMISSION_SECTION_DECISION_RESUBMIT)) && $articleFileManager->uploadedFileExists($fileName)) {
         $this->fileId = $articleFileManager->uploadReportFile($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());
         if ($this->getData('type') == 'progress') {
             $sectionDecision->setReviewType(REVIEW_TYPE_PR);
         } else {
             $sectionDecision->setReviewType(REVIEW_TYPE_FR);
         }
         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', 'submissionReview', array($this->article->getArticleId()));
     $sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO');
     $sectionEditors =& $sectionEditorsDao->getEditorsBySectionId($journal->getId(), $lastDecision->getSectionId());
     foreach ($sectionEditors as $sectionEditor) {
         $notificationSectionEditors[] = array('id' => $sectionEditor->getId());
     }
     if ($this->getData('type') == 'progress') {
         $message = 'notification.type.progressReport';
     } else {
         $message = 'notification.type.completionReport';
     }
     if (isset($message)) {
         foreach ($notificationSectionEditors as $userRole) {
             $notificationManager->createNotification($userRole['id'], $message, $this->article->getProposalId(), $url, 1, NOTIFICATION_TYPE_SUPP_FILE_MODIFIED);
         }
     }
     return $this->fileId;
 }