fetch() public method

public fetch ( $request )
コード例 #1
0
ファイル: IssueGridHandler.inc.php プロジェクト: pkp/ojs
 /**
  * Publish issue
  * @param $args array
  * @param $request Request
  */
 function publishIssue($args, $request)
 {
     $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
     $issueId = $issue->getId();
     $journal = $request->getJournal();
     $journalId = $journal->getId();
     $articleSearchIndex = null;
     if (!$issue->getPublished()) {
         $confirmationText = __('editor.issues.confirmPublish');
         import('controllers.grid.pubIds.form.AssignPublicIdentifiersForm');
         $formTemplate = $this->getAssignPublicIdentifiersFormTemplate();
         $assignPublicIdentifiersForm = new AssignPublicIdentifiersForm($formTemplate, $issue, true, $confirmationText);
         if (!$request->getUserVar('confirmed')) {
             // Display assign pub ids modal
             $assignPublicIdentifiersForm->initData($args, $request);
             return new JSONMessage(true, $assignPublicIdentifiersForm->fetch($request));
         }
         // Asign pub ids
         $assignPublicIdentifiersForm->readInputData();
         $assignPublicIdentifiersForm->execute($request);
         // Set the status of any attendant queued articles to STATUS_PUBLISHED.
         $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
         $articleDao = DAORegistry::getDAO('ArticleDAO');
         $publishedArticles = $publishedArticleDao->getPublishedArticles($issueId);
         foreach ($publishedArticles as $publishedArticle) {
             $article = $articleDao->getById($publishedArticle->getId());
             if ($article && $article->getStatus() == STATUS_QUEUED) {
                 $article->setStatus(STATUS_PUBLISHED);
                 $article->stampStatusModified();
                 $articleDao->updateObject($article);
                 if (!$articleSearchIndex) {
                     import('classes.search.ArticleSearchIndex');
                     $articleSearchIndex = new ArticleSearchIndex();
                 }
                 $articleSearchIndex->articleMetadataChanged($publishedArticle);
             }
             // delete article tombstone
             $tombstoneDao = DAORegistry::getDAO('DataObjectTombstoneDAO');
             $tombstoneDao->deleteByDataObjectId($article->getId());
         }
     }
     $issue->setCurrent(1);
     $issue->setPublished(1);
     $issue->setDatePublished(Core::getCurrentDate());
     // If subscriptions with delayed open access are enabled then
     // update open access date according to open access delay policy
     if ($journal->getSetting('publishingMode') == PUBLISHING_MODE_SUBSCRIPTION && $journal->getSetting('enableDelayedOpenAccess')) {
         $delayDuration = $journal->getSetting('delayedOpenAccessDuration');
         $delayYears = (int) floor($delayDuration / 12);
         $delayMonths = (int) fmod($delayDuration, 12);
         $curYear = date('Y');
         $curMonth = date('n');
         $curDay = date('j');
         $delayOpenAccessYear = $curYear + $delayYears + (int) floor(($curMonth + $delayMonths) / 12);
         $delayOpenAccessMonth = (int) fmod($curMonth + $delayMonths, 12);
         $issue->setAccessStatus(ISSUE_ACCESS_SUBSCRIPTION);
         $issue->setOpenAccessDate(date('Y-m-d H:i:s', mktime(0, 0, 0, $delayOpenAccessMonth, $curDay, $delayOpenAccessYear)));
     }
     $issueDao = DAORegistry::getDAO('IssueDAO');
     $issueDao->updateCurrent($journalId, $issue);
     if ($articleSearchIndex) {
         $articleSearchIndex->articleChangesFinished();
     }
     // Send a notification to associated users
     import('classes.notification.NotificationManager');
     $notificationManager = new NotificationManager();
     $notificationUsers = array();
     $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
     $allUsers = $userGroupDao->getUsersByContextId($journalId);
     while ($user = $allUsers->next()) {
         $notificationUsers[] = array('id' => $user->getId());
     }
     foreach ($notificationUsers as $userRole) {
         $notificationManager->createNotification($request, $userRole['id'], NOTIFICATION_TYPE_PUBLISHED_ISSUE, $journalId);
     }
     $notificationManager->sendToMailingList($request, $notificationManager->createNotification($request, UNSUBSCRIBED_USER_NOTIFICATION, NOTIFICATION_TYPE_PUBLISHED_ISSUE, $journalId));
     return DAO::getDataChangedEvent();
 }
コード例 #2
0
ファイル: IssueEntryTabHandler.inc.php プロジェクト: pkp/ojs
 /**
  * Save publication metadata form when scheduling for publication.
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON object
  */
 function savePublicationMetadataForm($args, $request)
 {
     $submission = $this->getSubmission();
     $stageId = $this->getStageId();
     $user = $request->getUser();
     import('controllers.tab.issueEntry.form.IssueEntryPublicationMetadataForm');
     $form = new IssueEntryPublicationMetadataForm($submission->getId(), $user->getId(), $stageId);
     $form->readInputData();
     if ($form->validate($request)) {
         $form->execute($request);
         // Log the event
         import('lib.pkp.classes.log.SubmissionLog');
         import('classes.log.SubmissionEventLogEntry');
         // Log consts
         SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_ISSUE_METADATA_UPDATE, 'submission.event.issueMetadataUpdated');
         // Create trivial notification in place on the form
         $notificationManager = new NotificationManager();
         $notificationKey = 'notification.savedIssueMetadata';
         $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __($notificationKey)));
         // Display assign public identifiers form
         $assignPubIds = false;
         $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true);
         foreach ($pubIdPlugins as $pubIdPlugin) {
             if ($pubIdPlugin->isObjectTypeEnabled('Submission', $submission->getContextId())) {
                 $assignPubIds = true;
                 break;
             }
         }
         if ($assignPubIds) {
             import('controllers.grid.pubIds.form.AssignPublicIdentifiersForm');
             $formTemplate = $this->getAssignPublicIdentifiersFormTemplate();
             $formParams = array('stageId' => $stageId);
             $assignPublicIdentifiersForm = new AssignPublicIdentifiersForm($formTemplate, $submission, true, '', $formParams);
             $assignPublicIdentifiersForm->initData($args, $request);
             return new JSONMessage(true, $assignPublicIdentifiersForm->fetch($request));
         } else {
             return new JSONMessage();
         }
     } else {
         return new JSONMessage(true, $form->fetch($request));
     }
 }