Commit | Line | Data |
---|---|---|
092bdf82 AE |
1 | <?php |
2 | namespace wcf\system\cache\builder; | |
092bdf82 | 3 | use wcf\system\acl\ACLHandler; |
bcb9c1bf | 4 | use wcf\system\category\CategoryHandler; |
092bdf82 AE |
5 | |
6 | /** | |
7 | * Caches the acl options of categories. | |
8 | * | |
9 | * @author Matthias Schmidt | |
07356d6b | 10 | * @copyright 2001-2013 WoltLab GmbH |
092bdf82 AE |
11 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> |
12 | * @package com.woltlab.wcf | |
13 | * @subpackage system.cache.builder | |
14 | * @category Community Framework | |
15 | */ | |
07356d6b | 16 | class CategoryACLOptionCacheBuilder extends AbstractCacheBuilder { |
092bdf82 | 17 | /** |
07356d6b | 18 | * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() |
092bdf82 | 19 | */ |
07356d6b | 20 | public function rebuild(array $parameters) { |
092bdf82 AE |
21 | $data = array(); |
22 | foreach (CategoryHandler::getInstance()->getCategories() as $objectTypeName => $categories) { | |
23 | $objectType = CategoryHandler::getInstance()->getObjectTypeByName($objectTypeName); | |
24 | $aclObjectType = $objectType->getProcessor()->getObjectTypeName('com.woltlab.wcf.acl'); | |
25 | if (!$aclObjectType) { | |
26 | continue; | |
27 | } | |
28 | ||
29 | $aclOptions = ACLHandler::getInstance()->getPermissions(ACLHandler::getInstance()->getObjectTypeID($aclObjectType), array_keys($categories)); | |
30 | $options = $aclOptions['options']->getObjects(); | |
31 | ||
32 | $data = array(); | |
33 | foreach (array('group', 'user') as $type) { | |
34 | foreach ($aclOptions[$type] as $categoryID => $optionData) { | |
35 | if (!isset($aclValues[$categoryID])) { | |
36 | $data[$categoryID] = array( | |
37 | 'group' => array(), | |
38 | 'user' => array() | |
39 | ); | |
40 | } | |
4dfe7d94 | 41 | |
092bdf82 AE |
42 | foreach ($optionData as $typeID => $optionValues) { |
43 | $data[$categoryID][$type][$typeID] = array(); | |
44 | ||
45 | foreach ($optionValues as $optionID => $optionValue) { | |
46 | $data[$categoryID][$type][$typeID][$options[$optionID]->optionName] = $optionValue; | |
47 | } | |
48 | } | |
49 | } | |
50 | } | |
51 | } | |
52 | ||
53 | return $data; | |
54 | } | |
55 | } |