/** * @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>.'); } }
$newArticle->dumpToHtml(); // Schedule future event echo "Scheduling future event...<br>"; $datetime = strftime("2100-%m-%d %H:%M:00"); $articlePublishObj2 = new ArticlePublish($newArticle->getArticleId(), 1, $datetime); $articlePublishObj2->create(); $articlePublishObj2->setPublishAction('P'); // Verify echo "Number of pending actions (should be zero): ".count(ArticlePublish::GetPendingActions())."<br>"; // Schedule past event echo "Scheduling past event...<br>"; $datetime = strftime("1900-%m-%d %H:%M:00"); $articlePublishObj3 = new ArticlePublish($newArticle->getArticleId(), 1, $datetime); $articlePublishObj3->create(); $articlePublishObj3->setPublishAction('P'); // Verify echo "Number of pending actions (should be one): ".count(ArticlePublish::GetPendingActions())."<br>"; // delete the article echo "Deleting the article.<br>"; $newArticle->delete(); echo "Deleting the events.<br>"; $articlePublishObj->delete(); $articlePublishObj2->delete(); $articlePublishObj3->delete();
/** * Delete article from database. This will * only delete one specific translation of the article. * * @return boolean */ public function delete() { // It is an optimization to put these here because in most cases // you dont need these files. require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleImage.php'); require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleTopic.php'); require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleIndex.php'); require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleAttachment.php'); require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleComment.php'); require_once($GLOBALS['g_campsiteDir'].'/classes/ArticlePublish.php'); // Delete scheduled publishing ArticlePublish::OnArticleDelete($this->m_data['Number'], $this->m_data['IdLanguage']); // Delete Article Comments ArticleComment::OnArticleDelete($this->m_data['Number'], $this->m_data['IdLanguage']); // is this the last translation? if (count($this->getLanguages()) <= 1) { // Delete image pointers ArticleImage::OnArticleDelete($this->m_data['Number']); // Delete topics pointers ArticleTopic::OnArticleDelete($this->m_data['Number']); // Delete file pointers ArticleAttachment::OnArticleDelete($this->m_data['Number']); // Delete indexes ArticleIndex::OnArticleDelete($this->getPublicationId(), $this->getIssueNumber(), $this->getSectionNumber(), $this->getLanguageId(), $this->getArticleNumber()); } // geo-map processing // is this the last translation? if (count($this->getLanguages()) <= 1) { // unlink the article-map pointers Geo_Map::OnArticleDelete($this->m_data['Number']); } else { // removing non-last translation of the map poi contents Geo_Map::OnLanguageDelete($this->m_data['Number'], $this->m_data['IdLanguage']); } // Delete row from article type table. $articleData = new ArticleData($this->m_data['Type'], $this->m_data['Number'], $this->m_data['IdLanguage']); $articleData->delete(); $tmpObj = clone $this; // for log $tmpData = $this->m_data; $tmpData['languageName'] = $this->getLanguageName(); // Delete row from Articles table. $deleted = parent::delete(); if ($deleted) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } Log::ArticleMessage($tmpObj, getGS('Article deleted.'), null, 32); } $this->m_cacheUpdate = true; return $deleted; } // fn delete
/** * Execute all pending actions. * @return void */ public static function DoPendingActions() { $actions = ArticlePublish::GetPendingActions(); foreach ($actions as $articlePublishObj) { $articlePublishObj->doAction(); } if (count($actions) > 0) { CampCache::singleton()->clear('user'); } return count($actions); } // fn DoPendingActions
try { parent.$.fancybox.reload = true; parent.$.fancybox.message = '<?php putGS('You can not schedule opposing events at the same time'); ?> '; parent.$.fancybox.close(); } catch (e) { } </script> <?php exit; } } } $articlePublishObj = new ArticlePublish(); $articlePublishObj->create(); $articlePublishObj->setArticleNumber($tmpArticle->getArticleNumber()); $articlePublishObj->setLanguageId($tmpArticle->getLanguageId()); $articlePublishObj->setActionTime($publishTime); if ($f_publish_action == "P" || $f_publish_action == "U") { $articlePublishObj->setPublishAction($f_publish_action); } if ($f_front_page_action == "S" || $f_front_page_action == "R") { $articlePublishObj->setFrontPageAction($f_front_page_action); } if ($f_section_page_action == "S" || $f_section_page_action == "R") { $articlePublishObj->setSectionPageAction($f_section_page_action); } Log::ArticleMessage($tmpArticle, getGS('Scheduled action added'), $g_user->getUserId(), 37); }
if (!is_null($f_action_workflow)) { $f_action_workflow = strtoupper($f_action_workflow); if (in_array($f_action_workflow, array('Y', 'M', 'S', 'N'))) { $access = false; // A publisher can change the status in any way he sees fit. // Someone who can change an article can submit/unsubmit articles. // A user who owns the article may submit it. if ($g_user->hasPermission('Publish') || $g_user->hasPermission('ChangeArticle') && $f_action_workflow != 'Y' || $articleObj->userCanModify($g_user) && $f_action_workflow == 'S') { $access = true; } // If the article is set to New, remove all the autopublish events if ($f_action_workflow == 'N') { $articleEvents = ArticlePublish::GetArticleEvents($f_article_number, $f_language_selected, TRUE); foreach ($articleEvents as $event) { $eventId = $event->getArticlePublishId(); $articlePublishObj = new ArticlePublish($eventId); if ($articlePublishObj->exists()) { $articlePublishObj->delete(); } } } if (!$access) { camp_html_add_msg($translator->trans("You do not have the right to change this article status. Once submitted an article can only be changed by authorized users.", array(), 'articles')); camp_html_goto_page(camp_html_article_url($articleObj, $f_language_id, "edit.php")); } // If the article is not yet categorized, force it to be before publication. if (($f_action_workflow == "Y" || $f_action_workflow == 'M') && ($articleObj->getPublicationId() == 0 || $articleObj->getIssueNumber() == 0 || $articleObj->getSectionNumber() == 0)) { $args = $_REQUEST; $argsStr = camp_implode_keys_and_values($_REQUEST, "=", "&"); $argsStr .= "&f_article_code[]=" . $f_article_number . "_" . $f_language_selected; $argsStr .= "&f_mode=single&f_action=publish";
/** * Delete article from database. This will * only delete one specific translation of the article. * * @return boolean */ public function delete() { // It is an optimization to put these here because in most cases // you dont need these files. require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleImage.php'; require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleTopic.php'; require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleIndex.php'; require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleAttachment.php'; require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticlePublish.php'; // Delete scheduled publishing ArticlePublish::OnArticleDelete($this->m_data['Number'], $this->m_data['IdLanguage']); $translator = \Zend_Registry::get('container')->getService('translator'); // Delete Article Comments // @todo change this with DOCTRINE2 CASCADE DELETE $em = Zend_Registry::get('container')->getService('em'); $repository = $em->getRepository('Newscoop\\Entity\\Comment'); $repository->deleteArticle($this->m_data['Number'], $this->m_data['IdLanguage']); $repository = $em->getRepository('Newscoop\\Entity\\ArticleDatetime'); $repository->deleteByArticle($this->m_data['Number']); $em->flush(); // is this the last translation? if (count($this->getLanguages()) <= 1) { // Delete image pointers ArticleImage::OnArticleDelete($this->m_data['Number']); // Delete topics pointers ArticleTopic::OnArticleDelete($this->m_data['Number']); // Delete file pointers ArticleAttachment::OnArticleDelete($this->m_data['Number']); // Delete related articles ContextBox::OnArticleDelete($this->m_data['Number']); ContextBoxArticle::OnArticleDelete($this->m_data['Number']); // Delete the article from playlists $em = Zend_Registry::get('container')->getService('em'); $repository = $em->getRepository('Newscoop\\Entity\\PlaylistArticle'); $repository->deleteArticle($this->m_data['Number']); $em->flush(); // Delete indexes ArticleIndex::OnArticleDelete($this->getPublicationId(), $this->getIssueNumber(), $this->getSectionNumber(), $this->getLanguageId(), $this->getArticleNumber()); } // geo-map processing // is this the last translation? if (count($this->getLanguages()) <= 1) { // unlink the article-map pointers Geo_Map::OnArticleDelete($this->m_data['Number']); } else { // removing non-last translation of the map poi contents Geo_Map::OnLanguageDelete($this->m_data['Number'], $this->m_data['IdLanguage']); } // Delete row from article type table. $articleData = new ArticleData($this->m_data['Type'], $this->m_data['Number'], $this->m_data['IdLanguage']); $articleData->delete(); $tmpObj = clone $this; // for log $tmpData = $this->m_data; $tmpData['languageName'] = $this->getLanguageName(); // Delete row from Articles table. $deleted = parent::delete(); if ($deleted) { $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache'); $cacheService->clearNamespace('article'); Log::ArticleMessage($tmpObj, $translator->trans('Article deleted.', array(), 'api'), null, 32); } $this->m_cacheUpdate = true; return $deleted; }
if ($blogService->isBlogger($g_user)) { $userIsBlogger = true; $userSection = $blogService->getSection($g_user); if (empty($userSection) || $userSection->getSectionId() != $articleObj->getSection()->getSectionId()) { camp_html_display_error(getGS("You're not allowed to edit article.")); exit; } } $articleData = $articleObj->getArticleData(); // Get article type fields. $dbColumns = $articleData->getUserDefinedColumns(FALSE, TRUE); $articleType = new ArticleType($articleObj->getType()); $articleImages = ArticleImage::GetImagesByArticleNumber($f_article_number); $lockUserObj = new User($articleObj->getLockedByUser()); $articleCreator = new User($articleObj->getCreatorId()); $articleEvents = ArticlePublish::GetArticleEvents($f_article_number, $f_language_selected, TRUE); $articleTopics = ArticleTopic::GetArticleTopics($f_article_number); $articleFiles = ArticleAttachment::GetAttachmentsByArticleNumber($f_article_number, $f_language_selected); $articleLanguages = $articleObj->getLanguages(); // Create displayable "last modified" time. $lastModified = strtotime($articleObj->getLastModified()); $today = getdate(); $savedOn = getdate($lastModified); $savedToday = true; if ($today['year'] != $savedOn['year'] || $today['mon'] != $savedOn['mon'] || $today['mday'] != $savedOn['mday']) { $savedToday = FALSE; } $sectionObj = null; $showComments = FALSE; $showCommentControls = FALSE; if ($f_publication_id > 0) {