deposit() public method

Deposit the package.
public deposit ( $url, $username, $password )
$url string SWORD deposit URL
$username string SWORD deposit username (i.e. email address for DSPACE)
$password string SWORD deposit password
 /**
  * Perform SWORD deposit
  */
 function execute()
 {
     import('classes.sword.OJSSwordDeposit');
     $deposit = new OJSSwordDeposit($this->article);
     $deposit->setMetadata();
     $deposit->addEditorial();
     $deposit->createPackage();
     import('lib.pkp.classes.notification.NotificationManager');
     $notificationManager = new NotificationManager();
     $allowAuthorSpecify = $this->swordPlugin->getSetting($this->article->getJournalId(), 'allowAuthorSpecify');
     $authorDepositUrl = $this->getData('authorDepositUrl');
     if ($allowAuthorSpecify && $authorDepositUrl != '') {
         $deposit->deposit($this->getData('authorDepositUrl'), $this->getData('authorDepositUsername'), $this->getData('authorDepositPassword'));
         $notificationManager->createTrivialNotification(Locale::translate('notification.notification'), Locale::translate('plugins.generic.sword.depositComplete', array('itemTitle' => $this->article->getLocalizedTitle(), 'repositoryName' => $this->getData('authorDepositUrl'))), NOTIFICATION_TYPE_SUCCESS, null, false);
     }
     $depositableDepositPoints = $this->_getDepositableDepositPoints();
     $depositPoints = $this->getData('depositPoint');
     foreach ($depositableDepositPoints as $key => $depositPoint) {
         if (!isset($depositPoints[$key]['enabled'])) {
             continue;
         }
         if ($depositPoint['type'] == SWORD_DEPOSIT_TYPE_OPTIONAL_SELECTION) {
             $url = $depositPoints[$key]['depositPoint'];
         } else {
             // SWORD_DEPOSIT_TYPE_OPTIONAL_FIXED
             $url = $depositPoint['url'];
         }
         $deposit->deposit($url, $depositPoint['username'], $depositPoint['password']);
         $notificationManager->createTrivialNotification(Locale::translate('notification.notification'), Locale::translate('plugins.generic.sword.depositComplete', array('itemTitle' => $this->article->getLocalizedTitle(), 'repositoryName' => $depositPoint['name'])), NOTIFICATION_TYPE_SUCCESS, null, false);
     }
     $deposit->cleanup();
 }
 function deposit($url, $username, $password, $articleId, $depositEditorial, $depositGalleys)
 {
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     $publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($articleId);
     $journal =& Request::getJournal();
     $deposit = new OJSSwordDeposit($publishedArticle);
     $deposit->setMetadata();
     if ($depositGalleys) {
         $deposit->addGalleys();
     }
     if ($depositEditorial) {
         $deposit->addEditorial();
     }
     $deposit->createPackage();
     $response = $deposit->deposit($url, $username, $password);
     $deposit->cleanup();
     return $response->sac_id;
 }
Esempio n. 3
0
 /**
  * Hook registry function that is called when it's time to perform all automatic
  * deposits and notify the author of optional deposits.
  * @param $hookName string
  * @param $args array
  */
 function callbackAuthorDeposits($hookName, $args)
 {
     $sectionEditorSubmission =& $args[0];
     $request =& $this->getRequest();
     // Determine if the most recent decision was an "Accept"
     $decisions = $sectionEditorSubmission->getDecisions();
     $decisions = array_pop($decisions);
     // Rounds
     $decision = array_pop($decisions);
     $decisionConst = $decision ? $decision['decision'] : null;
     if ($decisionConst != SUBMISSION_EDITOR_DECISION_ACCEPT) {
         return false;
     }
     // The most recent decision was an "Accept"; perform auto deposits.
     $journal = $request->getJournal();
     $depositPoints = $this->getSetting($journal->getId(), 'depositPoints');
     import('classes.sword.OJSSwordDeposit');
     import('classes.notification.NotificationManager');
     $notificationManager = new NotificationManager();
     $sendDepositNotification = $this->getSetting($journal->getId(), 'allowAuthorSpecify') ? true : false;
     foreach ($depositPoints as $depositPoint) {
         $depositType = $depositPoint['type'];
         if ($depositType == SWORD_DEPOSIT_TYPE_OPTIONAL_SELECTION || $depositType == SWORD_DEPOSIT_TYPE_OPTIONAL_FIXED) {
             $sendDepositNotification = true;
         }
         if ($depositType != SWORD_DEPOSIT_TYPE_AUTOMATIC) {
             continue;
         }
         // For each automatic deposit point, perform a deposit.
         $deposit = new OJSSwordDeposit($sectionEditorSubmission);
         $deposit->setMetadata();
         $deposit->addEditorial();
         $deposit->createPackage();
         $deposit->deposit($depositPoint['url'], $depositPoint['username'], $depositPoint['password']);
         $deposit->cleanup();
         unset($deposit);
         $user = $request->getUser();
         $params = array('itemTitle' => $sectionEditorSubmission->getLocalizedTitle(), 'repositoryName' => $depositPoint['name']);
         $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SWORD_AUTO_DEPOSIT_COMPLETE, $params);
     }
     if ($sendDepositNotification) {
         $submittingUser = $sectionEditorSubmission->getUser();
         import('classes.mail.ArticleMailTemplate');
         $mail = new ArticleMailTemplate($sectionEditorSubmission, 'SWORD_DEPOSIT_NOTIFICATION', null, null, $journal, true, true);
         $mail->setReplyTo(null);
         $mail->addRecipient($submittingUser->getEmail(), $submittingUser->getFullName());
         $mail->assignParams(array('journalName' => $journal->getLocalizedName(), 'articleTitle' => $sectionEditorSubmission->getLocalizedTitle(), 'swordDepositUrl' => $request->url(null, 'sword', 'index', $sectionEditorSubmission->getId())));
         $mail->send($request);
     }
     return false;
 }