/** * @see Console\Command\Command */ protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) { $issueActions = \IssuePublish::DoPendingActions(); $articleActions = \ArticlePublish::DoPendingActions(); if ($issueActions > 0 || $articleActions > 0) { fopen(realpath(APPLICATION_PATH . '/../') . '/reset_cache', 'w'); } if ($input->getOption('verbose')) { $output->writeln('Published issues: <info>' . $issueActions . '</info>.'); $output->writeln('Published articles: <info>' . $articleActions . '</info>.'); } }
/** * Delete the Issue, and optionally all sections and articles contained within it. * @param boolean $p_deleteSections * @param boolean $p_deleteArticles * @return int * Return the number of articles deleted. */ public function delete($p_deleteSections = true, $p_deleteArticles = true) { global $g_ado_db; // Delete all scheduled publishing events IssuePublish::OnIssueDelete($this->m_data['IdPublication'], $this->m_data['Number'], $this->m_data['IdLanguage']); $articlesDeleted = 0; if ($p_deleteSections) { $sections = Section::GetSections($this->m_data['IdPublication'], $this->m_data['Number'], $this->m_data['IdLanguage']); foreach ($sections as $section) { $articlesDeleted += $section->delete($p_deleteArticles); } } $tmpData = $this->m_data; $success = parent::delete(); if ($success) { $outputSettingIssues = $this->getOutputSettingIssueService()->findByIssue($tmpData['id']); foreach ($outputSettingIssues as $outputSet) { $this->getOutputSettingIssueService()->delete($outputSet); } } return $articlesDeleted; }
echo "<h2>ISSUE AUTOPUBLISH TESTS</h2>"; echo "Creating an issue...<br>"; $issueId = rand(); $issue = new Issue(1, 1, $issueId); $issue->create($issueId); $issue->fetch(); $issue->dumpToHtml(); $article1 = new Article(1, 1, $issueId, 1); $article1->create('fastnews', 'issue schueduled publish test '.rand()); $article2 = new Article(1, 1, $issueId, 1); $article2->create('fastnews', 'issue schueduled publish test '.rand()); // Create issue publish event echo "Creating issue publish event...<br>"; $datetime = strftime("%Y-%m-%d %H:%M:00"); $issuePublishEvent = new IssuePublish(1, $issueId, 1, $datetime); $issuePublishEvent->create(); $issuePublishEvent->setPublishAction('P'); $issuePublishEvent->setPublishArticlesAction('Y'); $issuePublishEvent->fetch(); $issuePublishEvent->dumpToHtml(); echo "Executing pending events:<br>"; $events = IssuePublish::GetPendingActions(); foreach ($events as $event) { $event->doAction(); $event->dumpToHtml(); } // Check if issues are published echo "Is the issue published?<br>";
/** * Execute all pending actions. * @return void */ public static function DoPendingActions() { $actions = IssuePublish::GetPendingActions(); foreach ($actions as $issuePublishObj) { $issuePublishObj->doAction(); } if (count($actions) > 0) { CampCache::singleton()->clear('user'); } return count($actions); }
$correct = 0; $past_publish = 1; } } } } if ($publish_articles != "Y" && $publish_articles != "N") { $publish_articles = "N"; } $created = 0; if ($correct) { $issuePublishExists = true; $publish_time = $publish_date . " " . $publish_hour . ":" . $publish_min . ":00"; $issuePublishObj = new IssuePublish($event_id); if (!$issuePublishObj->exists()) { $issuePublishObj->create(); $issuePublishObj->setPublicationId($Pub); $issuePublishObj->setIssueNumber($Issue); $issuePublishObj->setLanguageId($Language); $issuePublishExists = false; } $issuePublishObj->setPublishAction($action); $issuePublishObj->setPublishArticlesAction($publish_articles); $issuePublishObj->setActionTime($publish_time); $created = 1; } if ($created) { $action = ($issuePublishExists) ? 'updated' : 'added';
/** * Delete the Issue, and optionally all sections and articles contained within it. * @param boolean $p_deleteSections * @param boolean $p_deleteArticles * @return int * Return the number of articles deleted. */ public function delete($p_deleteSections = true, $p_deleteArticles = true) { global $g_ado_db; // Delete all scheduled publishing events IssuePublish::OnIssueDelete($this->m_data['IdPublication'], $this->m_data['Number'], $this->m_data['IdLanguage']); $articlesDeleted = 0; if ($p_deleteSections) { $sections = Section::GetSections($this->m_data['IdPublication'], $this->m_data['Number'], $this->m_data['IdLanguage']); foreach ($sections as $section) { $articlesDeleted += $section->delete($p_deleteArticles); } } $tmpData = $this->m_data; $success = parent::delete(); if ($success) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Issue "$1" ($2) from publication $3 deleted', $tmpData['Name'], $tmpData['Number'], $tmpData['IdPublication']); Log::Message($logtext, null, 12); } return $articlesDeleted; } // fn delete
<?php if ($g_user->hasPermission('DeleteIssue')) { ?> <TD ALIGN="LEFT" VALIGN="TOP"><B><?php echo $translator->trans("Delete"); ?> </B></TD> <?php } ?> </TR> <?php $currentIssue = -1; foreach ($allIssues as $issue) { $pendingEvents = IssuePublish::GetIssueEvents($issue->getPublicationId(), $issue->getIssueNumber(), $issue->getLanguageId(), false); ?> <TR <?php if ($color) { $color = 0; ?> class="list_row_even"<?php } else { $color = 1; ?> class="list_row_odd"<?php } ?> > <TD ALIGN="RIGHT">
if (!Input::IsValid()) { camp_html_display_error(getGS('Invalid Input: $1', Input::GetErrorString())); exit; } $publicationObj = new Publication($Pub); $issueObj = new Issue($Pub, $Language, $Issue); $action = ''; $publish_articles = ''; $publish_date = date("Y-m-d"); $publish_hour = (date("H") + 1); $publish_min = "00"; if (!is_null($event_id)) { $issuePublishObj = new IssuePublish($event_id); if ($issuePublishObj->exists()) { $action = $issuePublishObj->getPublishAction(); $publish_articles = $issuePublishObj->getPublishArticlesAction(); } $datetime = explode(" ", trim($issuePublishObj->getActionTime())); $publish_date = $datetime[0]; $publish_time = explode(":", trim($datetime[1])); $publish_hour = $publish_time[0]; $publish_min = $publish_time[1]; } camp_html_content_top(getGS('Issue Publishing Schedule'), array('Pub' => $publicationObj, 'Issue' => $issueObj), true, true); ?>
} $publicationObj = new Publication($Pub); if (!$publicationObj->exists()) { camp_html_display_error(getGS('Publication does not exist.')); exit; } $issueObj = new Issue($Pub, $Language, $Issue); if (!$issueObj->exists()) { camp_html_display_error(getGS('Issue does not exist.')); exit; } $allLanguages = Language::GetLanguages(null, null, null, array(), array(), true); // Get translations of this issue $issueTranslations = Issue::GetIssues($Pub, null, $Issue, null, null, false, null, true); $excludeLanguageIds = DbObjectArray::GetColumn($issueTranslations, 'IdLanguage'); $allEvents = IssuePublish::GetIssueEvents($Pub, $Issue, $Language); $publish_date = date("Y-m-d"); $publish_hour = date("H") + 1; $publish_min = "00"; camp_html_content_top(getGS('Change issue details'), array('Pub' => $publicationObj, 'Issue' => $issueObj), true, true); $url_args1 = "Pub={$Pub}"; $url_args2 = $url_args1 . "&Issue={$Issue}&Language={$Language}"; $url_args3 = "f_publication_id={$Pub}&f_issue_number={$Issue}&f_language_id={$Language}"; if (Issue::GetNumIssues($Pub) <= 0) { $url_add = "add_new.php"; } else { $url_add = "qadd.php"; } //@New theme management $resourceId = new ResourceId('Publication/Edit'); $themeManagementService = $resourceId->getService(IThemeManagementService::NAME_1);
require_once $GLOBALS['g_campsiteDir'] . "/{$ADMIN_DIR}/issues/issue_common.php"; require_once $GLOBALS['g_campsiteDir'] . '/classes/IssuePublish.php'; if (!SecurityToken::isValid()) { camp_html_display_error(getGS('Invalid security token!')); exit; } // Check permissions if (!$g_user->hasPermission('Publish')) { camp_html_display_error(getGS("You do not have the right to schedule issues or articles for automatic publishing.")); } $Pub = Input::Get('Pub', 'int', 0); $Issue = Input::Get('Issue', 'int', 0); $Language = Input::Get('Language', 'int', 0); $event_id = trim(Input::Get('event_id', 'string', '')); $action = new IssuePublish($event_id); $deleted = $action->delete(); if ($deleted) { $issueObj = new Issue($Pub, $Language, $Issue); camp_html_goto_page("/{$ADMIN}/issues/edit.php?Pub={$Pub}&Issue={$Issue}&Language={$Language}"); } $publicationObj = new Publication($Pub); $issueObj = new Issue($Pub, $Language, $Issue); $crumbs = array("Pub" => $publicationObj, "Issue" => $issueObj); camp_html_content_top(getGS("Delete scheduled publish action"), $crumbs); ?> <P> <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="8" class="message_box"> <TR> <TD COLSPAN="2">