From: Alexander Ebert Date: Sun, 21 Jul 2019 19:53:24 +0000 (+0200) Subject: Hide inaccessible categories for articles X-Git-Tag: 5.2.0_Alpha_3~22 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=156fbe3e2648db4d5b18db7e62d1b37d55d33204;p=GitHub%2FWoltLab%2FWCF.git Hide inaccessible categories for articles Fixes #2959 --- diff --git a/wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php b/wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php index ae2171e252..c9cdd2676a 100644 --- a/wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php @@ -3,6 +3,8 @@ namespace wcf\acp\form; use wcf\data\article\category\ArticleCategory; use wcf\data\article\Article; use wcf\data\article\ArticleAction; +use wcf\data\article\category\ArticleCategoryNode; +use wcf\data\category\CategoryNode; use wcf\data\category\CategoryNodeTree; use wcf\data\label\group\ViewableLabelGroup; use wcf\data\language\Language; @@ -409,7 +411,7 @@ class ArticleAddForm extends AbstractForm { 'content' => !empty($this->content[$language->languageID]) ? $this->content[$language->languageID] : '', 'htmlInputProcessor' => isset($this->htmlInputProcessors[$language->languageID]) ? $this->htmlInputProcessors[$language->languageID] : null, 'imageID' => !empty($this->imageID[$language->languageID]) ? $this->imageID[$language->languageID] : null, - 'teaserImageID' => !empty($this->teaserImageID[$language->languageID]) ? $this->teaserImageID[$language->languageID] : null + 'teaserImageID' => !empty($this->teaserImageID[$language->languageID]) ? $this->teaserImageID[$language->languageID] : null, ]; } } @@ -421,7 +423,7 @@ class ArticleAddForm extends AbstractForm { 'content' => !empty($this->content[0]) ? $this->content[0] : '', 'htmlInputProcessor' => isset($this->htmlInputProcessors[0]) ? $this->htmlInputProcessors[0] : null, 'imageID' => !empty($this->imageID[0]) ? $this->imageID[0] : null, - 'teaserImageID' => !empty($this->teaserImageID[0]) ? $this->teaserImageID[0] : null + 'teaserImageID' => !empty($this->teaserImageID[0]) ? $this->teaserImageID[0] : null, ]; } @@ -434,7 +436,7 @@ class ArticleAddForm extends AbstractForm { 'userID' => $this->author->userID, 'username' => $this->author->username, 'isMultilingual' => $this->isMultilingual, - 'hasLabels' => empty($this->labelIDs) ? 0 : 1 + 'hasLabels' => empty($this->labelIDs) ? 0 : 1, ]; $this->objectAction = new ArticleAction([], 'create', ['data' => array_merge($this->additionalFields, $data), 'content' => $content]); @@ -502,6 +504,12 @@ class ArticleAddForm extends AbstractForm { SmileyCache::getInstance()->assignVariables(); + $accessibleCategoryIDs = ArticleCategory::getAccessibleCategoryIDs(); + $categoryNodeList = (new CategoryNodeTree('com.woltlab.wcf.article.category'))->getIterator(); + $categoryNodes = array_filter(iterator_to_array($categoryNodeList), function(CategoryNode $categoryNode) use (&$accessibleCategoryIDs) { + return in_array($categoryNode->categoryID, $accessibleCategoryIDs); + }); + WCF::getTPL()->assign([ 'action' => 'add', 'isMultilingual' => $this->isMultilingual, @@ -520,10 +528,10 @@ class ArticleAddForm extends AbstractForm { 'teaser' => $this->teaser, 'content' => $this->content, 'availableLanguages' => $this->availableLanguages, - 'categoryNodeList' => (new CategoryNodeTree('com.woltlab.wcf.article.category'))->getIterator(), + 'categoryNodeList' => $categoryNodes, 'labelIDs' => $this->labelIDs, 'labelGroups' => $this->labelGroups, - 'labelGroupsToCategories' => $this->labelGroupsToCategories + 'labelGroupsToCategories' => $this->labelGroupsToCategories, ]); } }