Esempio n. 1
0
 /**
  * Save changes to the supplementary file.
  * @return int the supplementary file ID
  */
 function execute($fileName = null)
 {
     import("file.ArticleFileManager");
     $articleFileManager =& new ArticleFileManager($this->article->getArticleId());
     $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
     $fileName = isset($fileName) ? $fileName : 'uploadSuppFile';
     if (isset($this->suppFile)) {
         $suppFile =& $this->suppFile;
         // Upload file, if file selected.
         if ($articleFileManager->uploadedFileExists($fileName)) {
             $articleFileManager->uploadSuppFile($fileName, $suppFile->getFileId());
             import('search.ArticleSearchIndex');
             ArticleSearchIndex::updateFileIndex($this->article->getArticleId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $suppFile->getFileId());
         }
         // Index metadata
         ArticleSearchIndex::indexSuppFileMetadata($suppFile);
         // Update existing supplementary file
         $this->setSuppFileData($suppFile);
         $suppFileDao->updateSuppFile($suppFile);
     } else {
         // Upload file, if file selected.
         if ($articleFileManager->uploadedFileExists($fileName)) {
             $fileId = $articleFileManager->uploadSuppFile($fileName);
             import('search.ArticleSearchIndex');
             ArticleSearchIndex::updateFileIndex($this->article->getArticleId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $fileId);
         } else {
             $fileId = 0;
         }
         // Insert new supplementary file
         $suppFile =& new SuppFile();
         $suppFile->setArticleId($this->article->getArticleId());
         $suppFile->setFileId($fileId);
         $this->setSuppFileData($suppFile);
         $suppFileDao->insertSuppFile($suppFile);
         $this->suppFileId = $suppFile->getSuppFileId();
     }
     return $this->suppFileId;
 }
Esempio n. 2
0
 /**
  * Save changes to the supplementary file.
  * @return int the supplementary file ID
  */
 function execute($fileName = null, $createRemote = false)
 {
     import('classes.file.ArticleFileManager');
     $articleFileManager = new ArticleFileManager($this->article->getId());
     $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
     $fileName = isset($fileName) ? $fileName : 'uploadSuppFile';
     if (isset($this->suppFile)) {
         parent::execute();
         // Upload file, if file selected.
         if ($articleFileManager->uploadedFileExists($fileName)) {
             $fileId = $this->suppFile->getFileId();
             if ($fileId != 0) {
                 $articleFileManager->uploadSuppFile($fileName, $fileId);
             } else {
                 $fileId = $articleFileManager->uploadSuppFile($fileName);
                 $this->suppFile->setFileId($fileId);
             }
             import('classes.search.ArticleSearchIndex');
             ArticleSearchIndex::updateFileIndex($this->article->getId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $fileId);
         }
         // Index metadata
         ArticleSearchIndex::indexSuppFileMetadata($this->suppFile);
         // Update existing supplementary file
         $this->setSuppFileData($this->suppFile);
         if ($this->getData('remoteURL')) {
             $this->suppFile->setRemoteURL($this->getData('remoteURL'));
         }
         $suppFileDao->updateSuppFile($this->suppFile);
     } else {
         // Upload file, if file selected.
         if ($articleFileManager->uploadedFileExists($fileName)) {
             $fileId = $articleFileManager->uploadSuppFile($fileName);
             import('classes.search.ArticleSearchIndex');
             ArticleSearchIndex::updateFileIndex($this->article->getId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $fileId);
         } else {
             $fileId = 0;
         }
         // Insert new supplementary file
         $this->suppFile = new SuppFile();
         $this->suppFile->setArticleId($this->article->getId());
         $this->suppFile->setFileId($fileId);
         if ($createRemote) {
             $this->suppFile->setRemoteURL(__('common.remoteURL'));
         }
         parent::execute();
         $this->setSuppFileData($this->suppFile);
         $suppFileDao->insertSuppFile($this->suppFile);
         $this->suppFileId = $this->suppFile->getId();
     }
     return $this->suppFileId;
 }
Esempio n. 3
0
 /**
  * Index all article files (supplementary and galley).
  * @param $article Article
  */
 function indexArticleFiles(&$article)
 {
     // Index supplementary files
     $fileDao =& DAORegistry::getDAO('SuppFileDAO');
     $files =& $fileDao->getSuppFilesByArticle($article->getId());
     foreach ($files as $file) {
         if ($file->getFileId()) {
             ArticleSearchIndex::updateFileIndex($article->getId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $file->getFileId());
         }
         ArticleSearchIndex::indexSuppFileMetadata($file);
     }
     unset($files);
     // Index galley files
     $fileDao =& DAORegistry::getDAO('ArticleGalleyDAO');
     $files =& $fileDao->getGalleysByArticle($article->getId());
     foreach ($files as $file) {
         if ($file->getFileId()) {
             ArticleSearchIndex::updateFileIndex($article->getId(), ARTICLE_SEARCH_GALLEY_FILE, $file->getFileId());
         }
     }
 }
Esempio n. 4
0
 /**
  * Save changes to the supplementary file.
  * @return int the supplementary file ID
  */
 function execute($fileName = null)
 {
     import('classes.file.ArticleFileManager');
     $articleFileManager = new ArticleFileManager($this->article->getArticleId());
     $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
     $fileName = isset($fileName) ? $fileName : 'uploadSuppFile';
     if (isset($this->suppFile)) {
         $suppFile =& $this->suppFile;
         // Upload file, if file selected.
         if ($articleFileManager->uploadedFileExists($fileName)) {
             $articleFileManager->uploadSuppFile($fileName, $suppFile->getFileId());
             import('classes.search.ArticleSearchIndex');
             ArticleSearchIndex::updateFileIndex($this->article->getArticleId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $suppFile->getFileId());
         }
         // Index metadata
         ArticleSearchIndex::indexSuppFileMetadata($suppFile);
         // Update existing supplementary file
         $this->setSuppFileData($suppFile);
         $suppFileDao->updateSuppFile($suppFile);
     } else {
         // Upload file, if file selected.
         if ($articleFileManager->uploadedFileExists($fileName)) {
             $fileId = $articleFileManager->uploadSuppFile($fileName);
             import('classes.search.ArticleSearchIndex');
             ArticleSearchIndex::updateFileIndex($this->article->getArticleId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $fileId);
             // Insert new supplementary file
             $suppFile = new SuppFile();
             $suppFile->setArticleId($this->article->getArticleId());
             $suppFile->setFileId($fileId);
             $this->setSuppFileData($suppFile);
             $suppFileDao->insertSuppFile($suppFile);
             $this->suppFileId = $suppFile->getId();
         } else {
             $fileId = 0;
         }
     }
     // 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(), $this->article->getSectionId());
     foreach ($sectionEditors as $sectionEditor) {
         $notificationSectionEditors[] = array('id' => $sectionEditor->getId());
     }
     if ($suppFile->getData('type') == 'Raw Data File') {
         $message = 'notification.type.rawDataSubmitted';
     }
     if ($suppFile->getData('type') == 'Other Supplementary Research Output') {
         $message = 'notification.type.otherSuppResearchOutput';
     }
     if ($suppFile->getData('type') == 'Progress Report') {
         $message = 'notification.type.progressReport';
     }
     if ($suppFile->getData('type') == 'Completion Report') {
         $message = 'notification.type.completionReport';
     }
     if ($suppFile->getData('type') == 'Extension Request') {
         $message = 'notification.type.extensionRequest';
     }
     if ($this->getData('type') == "Supp File") {
         $message = 'notification.type.suppFile';
     }
     if (isset($message)) {
         foreach ($notificationSectionEditors as $userRole) {
             $notificationManager->createNotification($userRole['id'], $message, $this->article->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_SUPP_FILE_MODIFIED);
         }
     }
     return $this->suppFileId;
 }