Apply PSR-12 code style (#3886)
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / box / ArticleCommentListBoxController.class.php
CommitLineData
0943780a 1<?php
a9229942 2
0943780a 3namespace wcf\system\box;
a9229942 4
48862f8e 5use wcf\data\article\Article;
a9229942 6use wcf\data\article\category\ArticleCategory;
0943780a
MS
7use wcf\data\comment\ViewableCommentList;
8use wcf\system\language\LanguageFactory;
9use wcf\system\WCF;
10
11/**
12 * Box controller implementation for a list of article comments.
a9229942
TD
13 *
14 * @author Matthias Schmidt
15 * @copyright 2001-2019 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package WoltLabSuite\Core\System\Box
0943780a 18 */
a9229942
TD
19class ArticleCommentListBoxController extends AbstractCommentListBoxController
20{
21 /**
22 * @inheritDoc
23 */
24 protected $objectTypeName = 'com.woltlab.wcf.articleComment';
25
26 /**
27 * @inheritDoc
28 */
29 protected function applyObjectTypeFilters(ViewableCommentList $commentList)
30 {
31 $accessibleCategoryIDs = ArticleCategory::getAccessibleCategoryIDs();
32 if (!empty($accessibleCategoryIDs)) {
33 $commentList->sqlJoins .= ' INNER JOIN wcf' . WCF_N . '_article_content article_content ON (article_content.articleContentID = comment.objectID)';
34 $commentList->sqlJoins .= ' INNER JOIN wcf' . WCF_N . '_article article ON (article.articleID = article_content.articleID)';
35 $commentList->sqlSelects = 'article_content.title';
36
37 $commentList->getConditionBuilder()->add('article.categoryID IN (?)', [$accessibleCategoryIDs]);
38 $commentList->getConditionBuilder()->add('article.publicationStatus = ?', [Article::PUBLISHED]);
39
40 // apply language filter
41 if (LanguageFactory::getInstance()->multilingualismEnabled() && !empty(WCF::getUser()->getLanguageIDs())) {
42 $commentList->getConditionBuilder()->add(
43 '(article_content.languageID IN (?) OR article_content.languageID IS NULL)',
44 [WCF::getUser()->getLanguageIDs()]
45 );
46 }
47 } else {
48 $commentList->getConditionBuilder()->add('0 = 1');
49 }
50 }
0943780a 51}