From: Marcel Werk Date: Thu, 9 Jun 2016 10:32:28 +0000 (+0200) Subject: Added publication cronjob for delayed articles X-Git-Tag: 3.0.0_Beta_1~1475 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a24a65880ae89e4dd5c3ea59ebedca4e4732f112;p=GitHub%2FWoltLab%2FWCF.git Added publication cronjob for delayed articles --- diff --git a/com.woltlab.wcf/cronjob.xml b/com.woltlab.wcf/cronjob.xml index b8bab7a83e..ee7d596c12 100644 --- a/com.woltlab.wcf/cronjob.xml +++ b/com.woltlab.wcf/cronjob.xml @@ -189,6 +189,19 @@ 1 1 + + + wcf\system\cronjob\ArticlePublicationCronjob + + + */5 + * + * + * + * + 1 + 1 + diff --git a/wcfsetup/install/files/lib/system/cronjob/ArticlePublicationCronjob.class.php b/wcfsetup/install/files/lib/system/cronjob/ArticlePublicationCronjob.class.php new file mode 100644 index 0000000000..1296b2c4d8 --- /dev/null +++ b/wcfsetup/install/files/lib/system/cronjob/ArticlePublicationCronjob.class.php @@ -0,0 +1,41 @@ + + * @package com.woltlab.wcf + * @subpackage system.cronjob + * @category Community Framework + * @since 2.2 + */ +class ArticlePublicationCronjob extends AbstractCronjob { + /** + * @inheritDoc + */ + public function execute(Cronjob $cronjob) { + parent::execute($cronjob); + + $articleList = new ArticleList(); + $articleList->getConditionBuilder()->add('article.publicationStatus = ?', [2]); + $articleList->getConditionBuilder()->add('article.publicationDate > ?', [0]); + $articleList->getConditionBuilder()->add('article.publicationDate <= ?', [TIME_NOW]); + $articleList->decoratorClassName = ArticleEditor::class; + $articleList->readObjects(); + + foreach ($articleList as $editor) { + /** @var ArticleEditor $editor */ + $editor->update([ + 'time' => $editor->publicationDate, + 'publicationStatus' => 1, + 'publicationDate' => 0 + ]); + } + } +}