<?php
namespace wcf\acp\form;
+use wcf\data\article\Article;
use wcf\data\article\category\ArticleCategory;
use wcf\data\article\ArticleAction;
use wcf\data\category\CategoryNodeTree;
* publication status
* @var integer
*/
- public $publicationStatus = 1;
+ public $publicationStatus = Article::PUBLISHED;
/**
* publication date (ISO 8601)
}
if (!empty($_POST['enableComments'])) $this->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);
}
}
// 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');
}
'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,
// 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();
$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,
}
else {
$this->getConditionBuilder()->add('article.categoryID IN (?)', [$accessibleCategoryIDs]);
- $this->getConditionBuilder()->add('article.publicationStatus = ?', [1]);
+ $this->getConditionBuilder()->add('article.publicationStatus = ?', [Article::PUBLISHED]);
}
}
}
*/
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[]
}
$this->getConditionBuilder()->add('article.categoryID IN (?)', [$categoryIDs]);
- $this->getConditionBuilder()->add('article.publicationStatus = ?', [1]);
+ $this->getConditionBuilder()->add('article.publicationStatus = ?', [Article::PUBLISHED]);
}
}
<?php
namespace wcf\system\cronjob;
+use wcf\data\article\Article;
use wcf\data\article\ArticleEditor;
use wcf\data\article\ArticleList;
use wcf\data\cronjob\Cronjob;
parent::execute($cronjob);
$articleList = new ArticleList();
- $articleList->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;
/** @var ArticleEditor $editor */
$editor->update([
'time' => $editor->publicationDate,
- 'publicationStatus' => 1,
+ 'publicationStatus' => Article::PUBLISHED,
'publicationDate' => 0
]);
}
<?php
namespace wcf\system\search;
+use wcf\data\article\Article;
use wcf\data\article\category\ArticleCategory;
use wcf\data\article\content\SearchResultArticleContent;
use wcf\data\article\content\SearchResultArticleContentList;
}
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->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;
}