/** * 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(); }
/** * Assign submission public identifiers when scheduling for publication. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function assignPubIds($args, $request) { $submission = $this->getSubmission(); $stageId = $this->getStageId(); import('controllers.grid.pubIds.form.AssignPublicIdentifiersForm'); $formTemplate = $this->getAssignPublicIdentifiersFormTemplate(); $formParams = array('stageId' => $stageId); $assignPublicIdentifiersForm = new AssignPublicIdentifiersForm($formTemplate, $submission, true, '', $formParams); // Asign pub ids $assignPublicIdentifiersForm->readInputData(); $assignPublicIdentifiersForm->execute($request, true); return new JSONMessage(); }