/**
  * 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)) {
         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->getArticleId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $fileId);
         }
         // Index metadata
         ArticleSearchIndex::indexSuppFileMetadata($this->suppFile);
         // Update existing supplementary file
         $this->setSuppFileData($this->suppFile);
         $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->getArticleId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $fileId);
         } else {
             $fileId = 0;
         }
         // Insert new supplementary file
         $this->suppFile = new SuppFile();
         $this->suppFile->setArticleId($this->article->getArticleId());
         $this->suppFile->setFileId($fileId);
         parent::execute();
         $this->setSuppFileData($this->suppFile);
         $suppFileDao->insertSuppFile($this->suppFile);
         $this->suppFileId = $this->suppFile->getId();
     }
     return $this->suppFileId;
 }
 /**
  * Save changes to the supplementary file.
  * @return int the supplementary file ID
  */
 function execute()
 {
     import('classes.file.ArticleFileManager');
     $articleFileManager = new ArticleFileManager($this->articleId);
     $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 ($articleFileManager->uploadedFileExists($fileName)) {
             $articleFileDao =& DAORegistry::getDAO('ArticleFileDAO');
             $suppFileId = $articleFileManager->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 ($articleFileManager->uploadedFileExists($fileName)) {
             $fileId = $articleFileManager->uploadSuppFile($fileName);
             // Insert new supplementary file
             $suppFile = new SuppFile();
             $suppFile->setArticleId($this->articleId);
             $suppFile->setFileId($fileId);
             $this->setSuppFileData($suppFile);
             $suppFileDao->insertSuppFile($suppFile);
             $this->suppFileId = $suppFile->getId();
         } else {
             $fileId = 0;
         }
     }
     return $this->suppFileId;
 }
Beispiel #3
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';
     import('classes.search.ArticleSearchIndex');
     $articleSearchIndex = new ArticleSearchIndex();
     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);
             }
             $articleSearchIndex->articleFileChanged($this->article->getId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $fileId);
         }
         // 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);
             $articleSearchIndex->articleFileChanged($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();
     }
     // Index updated metadata.
     $articleSearchIndex->suppFileMetadataChanged($this->suppFile);
     $articleSearchIndex->articleChangesFinished();
     return $this->suppFileId;
 }
 /**
  * Hook callback: handle suppfile form execution for completed submissions
  * @see Form::execute()
  */
 function suppFileFormExecute($hookName, $args)
 {
     $form =& $args[0];
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $article =& $form->article;
     // Notify on successful study updates or errors
     import('classes.notification.NotificationManager');
     $notificationManager = new NotificationManager();
     $user =& Request::getUser();
     // Dataset metadata: fields stored with article metadata, but provided in suppfile
     // form, at point of data deposit, to support data publishing
     $article->setData('studyDescription', $form->getData('studyDescription'), $form->getFormLocale());
     $article->setData('externalDataCitation', $form->getData('externalDataCitation'), $form->getFormLocale());
     $articleDao->updateArticle($article);
     // Form executed for completed submissions. Draft studies are created on
     // submission completion. A study may or may not exist for this submission.
     switch ($form->getData('publishData')) {
         case 'none':
             // Supplementary file: do not deposit.
             if ($form->suppFile->getId()) {
                 // Suppfile exists & may previously have been flagged for deposit /
                 // deposited in Dataverse
                 $dvFileDao =& DAORegistry::getDAO('DataverseFileDAO');
                 $dvFile =& $dvFileDao->getDataverseFileBySuppFileId($form->suppFile->getId(), $article->getId());
                 if (isset($dvFile)) {
                     // Remove file from pending deposit (if submission is incomplete) or
                     // dataset previously deposited
                     $fileDeleted = $this->deleteFile($dvFile);
                     if ($fileDeleted) {
                         $dvFileDao->deleteDataverseFile($dvFile);
                     }
                     // Deleting a file may affect study cataloguing information
                     $dvStudyDao =& DAORegistry::getDAO('DataverseStudyDAO');
                     $study =& $dvStudyDao->getStudyBySubmissionId($article->getId());
                     if (isset($study)) {
                         $this->replaceStudyMetadata($article, $study);
                     }
                     // Notify
                     $notificationManager->createTrivialNotification($user->getId(), $fileDeleted ? NOTIFICATION_TYPE_DATAVERSE_STUDY_UPDATED : NOTIFICATION_TYPE_ERROR);
                 }
             }
             break;
         case 'dataverse':
             // Deposit file. Create a study, if submission doesn't have one already.
             $dvStudyDao =& DAORegistry::getDAO('DataverseStudyDAO');
             $study =& $dvStudyDao->getStudyBySubmissionId($article->getId());
             if (!$study) {
                 $study = $this->createStudy($article);
             }
             if (!$study) {
                 // If study is not created, warn & exit
                 $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR);
                 return false;
             }
             if (!$form->suppFile->getId()) {
                 // Suppfile is new, but inserted in db after hook is called. Handle
                 // insertion here & prevent duplicates in handleSuppFileInsertion() callback
                 $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
                 $form->setSuppFileData($form->suppFile);
                 $suppFileDao->insertSuppFile($form->suppFile);
                 $form->suppFileId = $form->suppFile->getId();
                 $form->suppFile =& $suppFileDao->getSuppFile($form->suppFileId, $article->getId());
                 // Add suppfile to study.
                 $deposited = $this->depositFiles($study, array($form->suppFile));
                 // File-level metadata may need to be added to study.
                 $this->replaceStudyMetadata($article, $study);
                 // & notify:
                 $notificationManager->createTrivialNotification($user->getId(), $deposited ? NOTIFICATION_TYPE_DATAVERSE_STUDY_UPDATED : NOTIFICATION_TYPE_ERROR);
             } else {
                 // Suppfile exists, and uploaded file may be new or a replacement
                 // (form validator requires file upload if Dataverse option selected).
                 // Hook is called before suppfile object is updated with details of
                 // uploaded file, so refresh suppfile object here.
                 import('classes.file.ArticleFileManager');
                 $fileName = 'uploadSuppFile';
                 $articleFileManager = new ArticleFileManager($article->getId());
                 if ($articleFileManager->uploadedFileExists($fileName)) {
                     $fileId = $form->suppFile->getFileId();
                     if ($fileId != 0) {
                         $articleFileManager->uploadSuppFile($fileName, $fileId);
                     } else {
                         $fileId = $articleFileManager->uploadSuppFile($fileName);
                         $form->suppFile->setFileId($fileId);
                     }
                 }
                 // Store form metadata. It may be used to update study cataloguing information.
                 $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
                 $form->suppFile =& $suppFileDao->getSuppFile($form->suppFileId, $article->getId());
                 $form->setSuppFileData($form->suppFile);
                 $suppFileDao->updateSuppFile($form->suppFile);
                 // The uploaded file may be new, or it may replace a previously-deposited
                 // file. If it's a replacement, delete the existing file from Dataverse:
                 // this prevents orphaned files on the Dataverse side, and filename collisions
                 // described in https://redmine.hmdc.harvard.edu/issues/3301
                 $dvFileDao =& DAORegistry::getDAO('DataverseFileDAO');
                 $dvFile =& $dvFileDao->getDataverseFileBySuppFileId($form->suppFileId, $article->getId());
                 if (isset($dvFile)) {
                     $this->deleteFile($dvFile);
                     $dvFileDao->deleteDataverseFile($dvFile);
                 }
                 // Add uploaded suppfile to study.
                 $deposited = $this->depositFiles($study, array($form->suppFile));
                 // File-level metadata may need to be added to study.
                 $this->replaceStudyMetadata($article, $study);
                 // & notify:
                 $notificationManager->createTrivialNotification($user->getId(), $deposited ? NOTIFICATION_TYPE_DATAVERSE_STUDY_UPDATED : NOTIFICATION_TYPE_ERROR);
             }
             break;
         default:
             // Unknown option
             assert(false);
     }
     return false;
 }
 /**
  * Hook callback: handle suppfile form execution for completed submissions
  * @see Form::execute()
  */
 function suppFileFormExecute($hookName, $args)
 {
     $form =& $args[0];
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $article =& $form->article;
     // External data citation: field is article metadata, but provided in
     // suppfile form as well, at point of data file deposit, to help support
     // data publishing decisions
     $article->setData('externalDataCitation', $form->getData('externalDataCitation'), $form->getFormLocale());
     $articleDao->updateArticle($article);
     // Form executed for completed submissions. Draft studies are created on
     // submission completion. A study may or may not exist for this submission.
     $dvStudyDao =& DAORegistry::getDAO('DataverseStudyDAO');
     $dvFileDao =& DAORegistry::getDAO('DataverseFileDAO');
     switch ($form->getData('publishData')) {
         case 'none':
             // Supplementary file: do not deposit.
             if (!$form->suppFile->getId()) {
                 return false;
             }
             // New suppfile: not in Dataverse
             $dvFile =& $dvFileDao->getDataverseFileBySuppFileId($form->suppFile->getId(), $article->getId());
             if (!isset($dvFile)) {
                 return false;
             }
             // Edited suppfile, but not in Dataverse
             // Remove the file from Dataverse
             $this->deleteFile($dvFile);
             // Deleting a file may affect study cataloguing information
             $study =& $dvStudyDao->getStudyBySubmissionId($article->getId());
             $this->updateStudy($article, $study);
             break;
         case 'dataverse':
             // Deposit file. If needed, insert/update suppfile on behalf of form
             $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
             if (!$form->suppFile->getId()) {
                 // Suppfile is new, but inserted in db after hook is called. Handle
                 // insertion here & prevent duplicates in handleSuppFileInsertion() callback
                 $form->setSuppFileData($form->suppFile);
                 $suppFileDao->insertSuppFile($form->suppFile);
                 $form->suppFileId = $form->suppFile->getId();
                 $form->suppFile =& $suppFileDao->getSuppFile($form->suppFileId, $article->getId());
             } else {
                 // Suppfile exists, but uploaded file may be new, replaced, or non-existent.
                 // Hook called before suppfile object updated with details of uploaded file,
                 // so refresh suppfile object here.
                 import('classes.file.ArticleFileManager');
                 $fileName = 'uploadSuppFile';
                 $articleFileManager = new ArticleFileManager($article->getId());
                 if ($articleFileManager->uploadedFileExists($fileName)) {
                     $fileId = $form->suppFile->getFileId();
                     if ($fileId != 0) {
                         $articleFileManager->uploadSuppFile($fileName, $fileId);
                     } else {
                         $fileId = $articleFileManager->uploadSuppFile($fileName);
                         $form->suppFile->setFileId($fileId);
                     }
                 }
                 // Store form metadata. It may be used to update study cataloguing information.
                 $form->suppFile =& $suppFileDao->getSuppFile($form->suppFileId, $article->getId());
                 $form->setSuppFileData($form->suppFile);
                 $suppFileDao->updateSuppFile($form->suppFile);
             }
             // If, at this point, there is no file id, there is nothing to deposit
             if (!$form->suppFile->getFileId()) {
                 return false;
             }
             $user =& Request::getUser();
             import('classes.notification.NotificationManager');
             $notificationManager = new NotificationManager();
             // Study may not exist, if this is the first file deposited
             $study =& $dvStudyDao->getStudyBySubmissionId($article->getId());
             if (!isset($study)) {
                 $study =& $this->createStudy($article);
                 $notificationManager->createTrivialNotification($user->getId(), isset($study) ? NOTIFICATION_TYPE_DATAVERSE_STUDY_CREATED : NOTIFICATION_TYPE_ERROR);
             }
             if (!isset($study)) {
                 return false;
             }
             // File already in Dataverse?
             $dvFile =& $dvFileDao->getDataverseFileBySuppFileId($form->suppFile->getId(), $article->getId());
             if (isset($dvFile)) {
                 // File is already in Dataverse. Update study with suppfile metadata.
                 $studyUpdated = $this->updateStudy($article, $study);
                 $notificationManager->createTrivialNotification($user->getId(), $studyUpdated ? NOTIFICATION_TYPE_DATAVERSE_STUDY_UPDATED : NOTIFICATION_TYPE_ERROR);
             } else {
                 // Add file to study
                 $fileAdded = $this->addFileToStudy($study, $form->suppFile);
                 $notificationManager->createTrivialNotification($user->getId(), $fileAdded ? NOTIFICATION_TYPE_DATAVERSE_FILE_ADDED : NOTIFICATION_TYPE_ERROR);
             }
             break;
     }
     return false;
 }
Beispiel #6
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;
 }
Beispiel #7
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 = 'uploadSuppFile';
     // 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;
     }
     // Save article settings (withdrawReason and withdrawComments)
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $article =& $this->article;
     $article->setWithdrawReason($this->getData('withdrawReason'), null);
     if ($article->getWithdrawReason('en_US') == "2") {
         $article->setWithdrawReason($this->getData('otherReason'), null);
     }
     $article->setWithdrawComments($this->getData('withdrawComments'), null);
     // Save the article
     $articleDao->updateArticle($article);
     return $this->suppFileId;
 }