Пример #1
0
 /**
  * Release draft study.
  * @param $study DataverseStudy
  * @return boolean Study released
  */
 function releaseStudy($study)
 {
     import('classes.notification.NotificationManager');
     $notificationManager = new NotificationManager();
     $journal =& Request::getJournal();
     $user =& Request::getUser();
     // Dataverse released?
     $dvReleased = $this->dataverseIsReleased($journal->getId());
     if (!$dvReleased) {
         // Try to release Dataverse via API
         $dvReleased = $this->releaseDataverse($journal->getId());
     }
     // If release via API has failed or is not supported, notify JMs
     if (!$dvReleased) {
         $request =& Application::getRequest();
         $roleDao =& DAORegistry::getDAO('RoleDAO');
         $journalManagers =& $roleDao->getUsersByRoleId(ROLE_ID_JOURNAL_MANAGER, $journal->getId());
         while ($journalManagers && !$journalManagers->eof()) {
             $journalManager =& $journalManagers->next();
             $notification = $notificationManager->createNotification($request, $journalManager->getId(), NOTIFICATION_TYPE_DATAVERSE_UNRELEASED, $journal->getId(), ASSOC_TYPE_JOURNAL, $journal->getId(), NOTIFICATION_LEVEL_NORMAL);
             $notificationManager->sendNotificationEmail($request, $notification);
             unset($journalManager);
         }
         // end notifying JMs
         // In API v1.1, publishing datasets in unpublished datverses is not supported.
         if (version_compare($this->getSetting($journal->getId(), 'apiVersion'), '1.1', '>=')) {
             $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR);
             return $dvReleased;
         }
     }
     // Attempt to release/publish the study/dataset.
     $client = $this->_initSwordClient();
     $response = $client->completeIncompleteDeposit($study->getEditUri(), $this->getSetting($journal->getId(), 'username'), $this->getSetting($journal->getId(), 'password'), '');
     // on behalf of
     $studyReleased = $response->sac_status == DATAVERSE_PLUGIN_HTTP_STATUS_OK;
     if ($studyReleased) {
         // Retrieve deposit receipt & store updated data citation
         $depositReceipt = $client->retrieveDepositReceipt($study->getEditUri(), $this->getSetting($journal->getId(), 'username'), $this->getSetting($journal->getId(), 'password'), '');
         if ($depositReceipt->sac_status == DATAVERSE_PLUGIN_HTTP_STATUS_OK) {
             $study->setDataCitation($depositReceipt->sac_dcterms['bibliographicCitation'][0]);
             $dataverseStudyDao =& DAORegistry::getDAO('DataverseStudyDAO');
             $dataverseStudyDao->updateStudy($study);
         }
         // Include citation & link to study in notification
         $params = array('dataCitation' => $this->_formatDataCitation($study->getDataCitation(), $study->getPersistentUri()));
         $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_DATAVERSE_STUDY_RELEASED, $params);
     } else {
         $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR);
     }
     return $studyReleased;
 }
Пример #2
0
 /**
  * Release draft study.
  * @param DataverseStudy $study
  * @return boolean Study released
  */
 function releaseStudy(&$study)
 {
     $journal =& Request::getJournal();
     $user =& Request::getUser();
     $client = $this->_initSwordClient();
     $response = $client->completeIncompleteDeposit($study->getEditUri(), $this->getSetting($journal->getId(), 'username'), $this->getSetting($journal->getId(), 'password'), '');
     // on behalf of
     $studyReleased = $response->sac_status == DATAVERSE_PLUGIN_HTTP_STATUS_OK;
     // Notify on success or failure. Provide citation & link to study.
     import('classes.notification.NotificationManager');
     $notificationManager = new NotificationManager();
     if ($studyReleased) {
         $params = array('dataCitation' => $this->_formatDataCitation($study->getDataCitation(), $study->getPersistentUri()));
         $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_DATAVERSE_STUDY_RELEASED, $params);
     } else {
         $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR);
     }
     // Whether the study was released or not, notify JMs by email if Dataverse
     // has not yet been released. Released studies are not accessible until
     // the Dataverse has been released.
     if (!$this->dataverseIsReleased()) {
         $request =& Application::getRequest();
         $roleDao =& DAORegistry::getDAO('RoleDAO');
         $journalManagers =& $roleDao->getUsersByRoleId(ROLE_ID_JOURNAL_MANAGER, $journal->getId());
         while ($journalManagers && !$journalManagers->eof()) {
             $journalManager =& $journalManagers->next();
             $notification = $notificationManager->createNotification($request, $journalManager->getId(), NOTIFICATION_TYPE_DATAVERSE_UNRELEASED, $journal->getId(), ASSOC_TYPE_JOURNAL, $journal->getId(), NOTIFICATION_LEVEL_NORMAL);
             $notificationManager->sendNotificationEmail($request, $notification);
             unset($journalManager);
         }
         // end notifying JMs
     }
     // end if (study not released)
     return $studyReleased;
 }