Esempio n. 1
0
 /**
  * Save changes to the supplementary file.
  * @return int the supplementary file ID
  */
 function execute($fileName = null)
 {
     import("file.PaperFileManager");
     $paperFileManager = new PaperFileManager($this->paper->getPaperId());
     $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
     $fileName = isset($fileName) ? $fileName : 'uploadSuppFile';
     if (isset($this->suppFile)) {
         $suppFile =& $this->suppFile;
         // Upload file, if file selected.
         if ($paperFileManager->uploadedFileExists($fileName)) {
             $paperFileManager->uploadSuppFile($fileName, $suppFile->getFileId());
             import('search.PaperSearchIndex');
             PaperSearchIndex::updateFileIndex($this->paper->getPaperId(), PAPER_SEARCH_SUPPLEMENTARY_FILE, $suppFile->getFileId());
         }
         // Index metadata
         PaperSearchIndex::indexSuppFileMetadata($suppFile);
         // Update existing supplementary file
         $this->setSuppFileData($suppFile);
         $suppFileDao->updateSuppFile($suppFile);
     } else {
         // Upload file, if file selected.
         if ($paperFileManager->uploadedFileExists($fileName)) {
             $fileId = $paperFileManager->uploadSuppFile($fileName);
             import('search.PaperSearchIndex');
             PaperSearchIndex::updateFileIndex($this->paper->getPaperId(), PAPER_SEARCH_SUPPLEMENTARY_FILE, $fileId);
         } else {
             $fileId = 0;
         }
         // Insert new supplementary file
         $suppFile = new SuppFile();
         $suppFile->setPaperId($this->paper->getPaperId());
         $suppFile->setFileId($fileId);
         $this->setSuppFileData($suppFile);
         $suppFileDao->insertSuppFile($suppFile);
         $this->suppFileId = $suppFile->getId();
     }
     return $this->suppFileId;
 }
 /**
  * Save changes to the supplementary file.
  * @return int the supplementary file ID
  */
 function execute()
 {
     import("file.PaperFileManager");
     $paperFileManager = new PaperFileManager($this->paperId);
     $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
     $fileName = 'uploadSuppFile';
     // edit an existing supp file, otherwise create new supp file entry
     if (isset($this->suppFile)) {
         $suppFile =& $this->suppFile;
         // Remove old file and upload new, if file is selected.
         if ($paperFileManager->uploadedFileExists($fileName)) {
             $paperFileDao =& DAORegistry::getDAO('PaperFileDAO');
             $suppFileId = $paperFileManager->uploadSuppFile($fileName, $suppFile->getFileId(), true);
             $suppFile->setFileId($suppFileId);
         }
         // Update existing supplementary file
         $this->setSuppFileData($suppFile);
         $suppFileDao->updateSuppFile($suppFile);
     } else {
         // Upload file, if file selected.
         if ($paperFileManager->uploadedFileExists($fileName)) {
             $fileId = $paperFileManager->uploadSuppFile($fileName);
         } else {
             $fileId = 0;
         }
         // Insert new supplementary file
         $suppFile = new SuppFile();
         $suppFile->setPaperId($this->paperId);
         $suppFile->setFileId($fileId);
         $this->setSuppFileData($suppFile);
         $suppFileDao->insertSuppFile($suppFile);
         $this->suppFileId = $suppFile->getId();
     }
     return $this->suppFileId;
 }