Fixed visibility of deleted articles
authorMarcel Werk <burntime@woltlab.com>
Wed, 13 Dec 2017 09:35:56 +0000 (10:35 +0100)
committerMarcel Werk <burntime@woltlab.com>
Wed, 13 Dec 2017 09:36:19 +0000 (10:36 +0100)
wcfsetup/install/files/lib/data/article/CategoryArticleList.class.php
wcfsetup/install/files/lib/data/article/category/ArticleCategoryCache.class.php

index ea1af91532c20f56da7039ba1605774fb9115319..6715e2fcc48ef19e9010fc65b3d10577c42360d9 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\data\article;
 use wcf\data\article\category\ArticleCategory;
+use wcf\system\WCF;
 
 /**
  * Represents a list of articles in a specific category.
@@ -38,5 +39,9 @@ class CategoryArticleList extends AccessibleArticleList {
                
                $this->getConditionBuilder()->add('article.categoryID IN (?)', [$categoryIDs]);
                $this->getConditionBuilder()->add('article.publicationStatus = ?', [Article::PUBLISHED]);
+               
+               if (!WCF::getSession()->getPermission('admin.content.article.canManageArticle')) {
+                       $this->getConditionBuilder()->add('article.isDeleted = ?', [0]);
+               }
        }
 }
index dd304fb8be48b11e53f56bf8882dbc2f3f1f145f..afa1606f4f566834ed409775b39e7e751e65c8d5 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\data\article\category;
 use wcf\data\article\Article;
 use wcf\data\category\Category;
 use wcf\system\category\CategoryHandler;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\SingletonFactory;
 use wcf\system\WCF;
 
@@ -28,12 +29,18 @@ class ArticleCategoryCache extends SingletonFactory {
        protected function initArticles() {
                $this->articles = [];
                
+               $conditionBuilder = new PreparedStatementConditionBuilder();
+               $conditionBuilder->add('publicationStatus = ?', [Article::PUBLISHED]);
+               if (!WCF::getSession()->getPermission('admin.content.article.canManageArticle')) {
+                       $conditionBuilder->add('isDeleted = ?', [0]);
+               }
+               
                $sql = "SELECT          COUNT(*) AS count, categoryID
                        FROM            wcf" . WCF_N . "_article
-                       WHERE           publicationStatus = ?
+                       ".$conditionBuilder."           
                        GROUP BY        categoryID";
                $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute([Article::PUBLISHED]);
+               $statement->execute($conditionBuilder->getParameters());
                $articles = $statement->fetchMap('categoryID', 'count');
                
                $categoryToParent = [];