Added option to skip option categories
authorAlexander Ebert <ebert@woltlab.com>
Tue, 21 Feb 2012 14:51:34 +0000 (15:51 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 21 Feb 2012 14:51:34 +0000 (15:51 +0100)
wcfsetup/install/files/lib/system/option/OptionHandler.class.php
wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php

index 89c8dcb2eec2453fdbd09760335a20df51c6f0c3..71827b6cf4eca2dac93b6e64e442ebca269c1dd0 100644 (file)
@@ -386,8 +386,14 @@ class OptionHandler implements IOptionHandler {
         * Creates a list of all active options.
         * 
         * @param       string          $parentCategoryName
+        * @param       array<string>   $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);
                                }
                        }
                }
index bdff954d888fe86456aeb41a3e6afb9a077aeda7..e187271832d9cda1046a2dea4333de816aa1ef72 100644 (file)
@@ -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<string>           $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;
                }