Merged com.woltlab.wcf.acl into WCF
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / cache / builder / CategoryACLOptionCacheBuilder.class.php
CommitLineData
092bdf82
AE
1<?php
2namespace wcf\system\cache\builder;
3use wcf\system\category\CategoryHandler;
4use wcf\system\acl\ACLHandler;
5
6/**
7 * Caches the acl options of categories.
8 *
9 * @author Matthias Schmidt
10 * @copyright 2001-2012 WoltLab GmbH
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 */
16class CategoryACLOptionCacheBuilder implements ICacheBuilder {
17 /**
18 * @see wcf\system\cache\ICacheBuilder::getData()
19 */
20 public function getData(array $cacheResource) {
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 }
41
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}