From: Marcel Werk Date: Mon, 13 Jun 2016 17:20:10 +0000 (+0200) Subject: Introduced constants for publication status of articles X-Git-Tag: 3.0.0_Beta_1~1457 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a124cde50b3071b6259bef07f08599fdaf5a3209;p=GitHub%2FWoltLab%2FWCF.git Introduced constants for publication status of articles --- diff --git a/wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php b/wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php index 4df62712a2..e944d04a48 100644 --- a/wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php @@ -1,5 +1,6 @@ enableComments = 1; if (isset($_POST['publicationStatus'])) $this->publicationStatus = intval($_POST['publicationStatus']); - if ($this->publicationStatus == 2 && isset($_POST['publicationDate'])) { + if ($this->publicationStatus == Article::DELAYED_PUBLICATION && isset($_POST['publicationDate'])) { $this->publicationDate = $_POST['publicationDate']; $this->publicationDateObj = \DateTime::createFromFormat('Y-m-d\TH:i:sP', $this->publicationDate); } @@ -256,10 +257,10 @@ class ArticleAddForm extends AbstractForm { } // publication status - if ($this->publicationStatus < 0 || $this->publicationStatus > 2) { + if ($this->publicationStatus != Article::UNPUBLISHED && $this->publicationStatus != Article::PUBLISHED && $this->publicationStatus != Article::DELAYED_PUBLICATION) { throw new UserInputException('publicationStatus'); } - if ($this->publicationStatus == 2) { + if ($this->publicationStatus == Article::DELAYED_PUBLICATION) { if (empty($this->publicationDate)) { throw new UserInputException('publicationDate'); } @@ -334,7 +335,7 @@ class ArticleAddForm extends AbstractForm { 'time' => $this->timeObj->getTimestamp(), 'categoryID' => $this->categoryID, 'publicationStatus' => $this->publicationStatus, - 'publicationDate' => ($this->publicationStatus == 2 ? $this->publicationDateObj->getTimestamp() : 0), + 'publicationDate' => ($this->publicationStatus == Article::DELAYED_PUBLICATION ? $this->publicationDateObj->getTimestamp() : 0), 'enableComments' => $this->enableComments, 'userID' => $this->author->userID, 'username' => $this->author->username, @@ -353,7 +354,8 @@ class ArticleAddForm extends AbstractForm { // reset variables $this->publicationDate = ''; $this->categoryID = 0; - $this->publicationStatus = $this->enableComments = 1; + $this->publicationStatus = Article::PUBLISHED; + $this->enableComments = ARTICLE_ENABLE_COMMENTS_DEFAULT_VALUE; $this->title = $this->teaser = $this->content = $this->images = $this->imageID = $this->tags = []; $this->setDefaultValues(); diff --git a/wcfsetup/install/files/lib/acp/form/ArticleEditForm.class.php b/wcfsetup/install/files/lib/acp/form/ArticleEditForm.class.php index 437ad04b87..9ebf68e911 100644 --- a/wcfsetup/install/files/lib/acp/form/ArticleEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/ArticleEditForm.class.php @@ -90,7 +90,7 @@ class ArticleEditForm extends ArticleAddForm { $data = [ 'categoryID' => $this->categoryID, 'publicationStatus' => $this->publicationStatus, - 'publicationDate' => ($this->publicationStatus == 2 ? $this->publicationDateObj->getTimestamp() : 0), + 'publicationDate' => ($this->publicationStatus == Article::DELAYED_PUBLICATION ? $this->publicationDateObj->getTimestamp() : 0), 'enableComments' => $this->enableComments, 'userID' => $this->author->userID, 'username' => $this->author->username, diff --git a/wcfsetup/install/files/lib/data/article/AccessibleArticleList.class.php b/wcfsetup/install/files/lib/data/article/AccessibleArticleList.class.php index 147ff1318a..ce215fa7ae 100644 --- a/wcfsetup/install/files/lib/data/article/AccessibleArticleList.class.php +++ b/wcfsetup/install/files/lib/data/article/AccessibleArticleList.class.php @@ -27,7 +27,7 @@ class AccessibleArticleList extends ViewableArticleList { } else { $this->getConditionBuilder()->add('article.categoryID IN (?)', [$accessibleCategoryIDs]); - $this->getConditionBuilder()->add('article.publicationStatus = ?', [1]); + $this->getConditionBuilder()->add('article.publicationStatus = ?', [Article::PUBLISHED]); } } } diff --git a/wcfsetup/install/files/lib/data/article/Article.class.php b/wcfsetup/install/files/lib/data/article/Article.class.php index d3988d1282..e788462100 100644 --- a/wcfsetup/install/files/lib/data/article/Article.class.php +++ b/wcfsetup/install/files/lib/data/article/Article.class.php @@ -42,6 +42,21 @@ class Article extends DatabaseObject implements ILinkableObject { */ protected static $databaseTableIndexName = 'articleID'; + /** + * indicates that article is unpublished + */ + const UNPUBLISHED = 0; + + /** + * indicates that article is published + */ + const PUBLISHED = 1; + + /** + * indicates that the publication of an article is delayed + */ + const DELAYED_PUBLICATION = 2; + /** * article content grouped by language id * @var ArticleContent[] diff --git a/wcfsetup/install/files/lib/data/article/CategoryArticleList.class.php b/wcfsetup/install/files/lib/data/article/CategoryArticleList.class.php index 4df347d21a..cae686705e 100644 --- a/wcfsetup/install/files/lib/data/article/CategoryArticleList.class.php +++ b/wcfsetup/install/files/lib/data/article/CategoryArticleList.class.php @@ -40,6 +40,6 @@ class CategoryArticleList extends AccessibleArticleList { } $this->getConditionBuilder()->add('article.categoryID IN (?)', [$categoryIDs]); - $this->getConditionBuilder()->add('article.publicationStatus = ?', [1]); + $this->getConditionBuilder()->add('article.publicationStatus = ?', [Article::PUBLISHED]); } } diff --git a/wcfsetup/install/files/lib/system/cronjob/ArticlePublicationCronjob.class.php b/wcfsetup/install/files/lib/system/cronjob/ArticlePublicationCronjob.class.php index 1296b2c4d8..d2f997b1f3 100644 --- a/wcfsetup/install/files/lib/system/cronjob/ArticlePublicationCronjob.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/ArticlePublicationCronjob.class.php @@ -1,5 +1,6 @@ getConditionBuilder()->add('article.publicationStatus = ?', [2]); + $articleList->getConditionBuilder()->add('article.publicationStatus = ?', [Article::DELAYED_PUBLICATION]); $articleList->getConditionBuilder()->add('article.publicationDate > ?', [0]); $articleList->getConditionBuilder()->add('article.publicationDate <= ?', [TIME_NOW]); $articleList->decoratorClassName = ArticleEditor::class; @@ -33,7 +34,7 @@ class ArticlePublicationCronjob extends AbstractCronjob { /** @var ArticleEditor $editor */ $editor->update([ 'time' => $editor->publicationDate, - 'publicationStatus' => 1, + 'publicationStatus' => Article::PUBLISHED, 'publicationDate' => 0 ]); } diff --git a/wcfsetup/install/files/lib/system/search/ArticleSearch.class.php b/wcfsetup/install/files/lib/system/search/ArticleSearch.class.php index bed9e8c0c6..93546a5ed1 100644 --- a/wcfsetup/install/files/lib/system/search/ArticleSearch.class.php +++ b/wcfsetup/install/files/lib/system/search/ArticleSearch.class.php @@ -1,5 +1,6 @@ add('wcf'.WCF_N.'_article.categoryID IN (?) AND wcf'.WCF_N.'_article.publicationStatus = ?', [$this->articleCategoryIDs, 1]); + $conditionBuilder->add('wcf'.WCF_N.'_article.categoryID IN (?) AND wcf'.WCF_N.'_article.publicationStatus = ?', [$this->articleCategoryIDs, Article::PUBLISHED]); return $conditionBuilder; }