From b3fcbaa4797988be2e6d0954a2e22c945b616c25 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 21 Feb 2012 15:51:34 +0100 Subject: [PATCH] Added option to skip option categories --- .../files/lib/system/option/OptionHandler.class.php | 10 ++++++++-- .../lib/system/option/user/UserOptionHandler.class.php | 7 ++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/lib/system/option/OptionHandler.class.php b/wcfsetup/install/files/lib/system/option/OptionHandler.class.php index 89c8dcb2ee..71827b6cf4 100644 --- a/wcfsetup/install/files/lib/system/option/OptionHandler.class.php +++ b/wcfsetup/install/files/lib/system/option/OptionHandler.class.php @@ -386,8 +386,14 @@ class OptionHandler implements IOptionHandler { * Creates a list of all active options. * * @param string $parentCategoryName + * @param array $ignoreCategories */ - protected function loadActiveOptions($parentCategoryName) { + protected function loadActiveOptions($parentCategoryName, array $ignoreCategories = array()) { + // skip ignored categories + if (in_array($parentCategoryName, $ignoreCategories)) { + return; + } + if (!isset($this->cachedCategories[$parentCategoryName]) || $this->checkCategory($this->cachedCategories[$parentCategoryName])) { if (isset($this->cachedOptionToCategories[$parentCategoryName])) { foreach ($this->cachedOptionToCategories[$parentCategoryName] as $optionName) { @@ -399,7 +405,7 @@ class OptionHandler implements IOptionHandler { if (isset($this->cachedCategoryStructure[$parentCategoryName])) { foreach ($this->cachedCategoryStructure[$parentCategoryName] as $categoryName) { - $this->loadActiveOptions($categoryName); + $this->loadActiveOptions($categoryName, $ignoreCategories); } } } diff --git a/wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php b/wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php index bdff954d88..e187271832 100644 --- a/wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php +++ b/wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php @@ -47,14 +47,15 @@ class UserOptionHandler extends OptionHandler { /** * Sets option values for a certain user. * - * @param wcf\data\user\User + * @param wcf\data\user\User $user + * @param array $ignoreCategories */ - public function setUser(User $user) { + public function setUser(User $user, array $ignoreCategories) { $this->optionValues = array(); $this->user = $user; if (!$this->didInit) { - $this->loadActiveOptions($this->categoryName); + $this->loadActiveOptions($this->categoryName, $ignoreCategories); $this->didInit = true; } -- 2.20.1