1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-23 21:50:09 +00:00
Tims-Chat/file/lib/system/cache/builder/PermissionCacheBuilder.class.php

42 lines
1.7 KiB
PHP
Raw Normal View History

2012-02-26 17:17:07 +00:00
<?php
2013-01-19 19:36:40 +00:00
namespace chat\system\cache\builder;
2012-02-26 17:17:07 +00:00
use wcf\system\WCF;
/**
* Caches the chat permissions for a combination of user groups.
*
* @author Tim Düsterhus, Marcel Werk
2014-02-27 22:05:09 +00:00
* @copyright 2010-2014 WoltLab GmbH
2012-02-26 17:17:07 +00:00
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
2013-01-19 19:36:40 +00:00
* @package be.bastelstu.chat
2012-02-26 17:17:07 +00:00
* @subpackage system.cache.builder
*/
2013-02-16 20:27:56 +00:00
class PermissionCacheBuilder extends \wcf\system\cache\builder\AbstractCacheBuilder {
2012-02-26 17:17:07 +00:00
/**
2013-02-04 18:27:03 +00:00
* @see wcf\system\cache\AbstractCacheBuilder::rebuild()
2012-02-26 17:17:07 +00:00
*/
2013-02-04 18:27:03 +00:00
public function rebuild(array $parameters) {
2012-02-26 17:17:07 +00:00
$data = array();
2013-02-04 18:27:03 +00:00
if (!empty($parameters)) {
2012-02-26 17:17:07 +00:00
$conditionBuilder = new \wcf\system\database\util\PreparedStatementConditionBuilder();
2013-01-19 19:36:40 +00:00
$conditionBuilder->add('acl_option.objectTypeID = ?', array(\wcf\system\acl\ACLHandler::getInstance()->getObjectTypeID('be.bastelstu.chat.room')));
2012-02-26 17:17:07 +00:00
$conditionBuilder->add('option_to_group.optionID = acl_option.optionID');
2013-02-04 18:27:03 +00:00
$conditionBuilder->add('option_to_group.groupID IN (?)', array($parameters));
2012-02-26 17:17:07 +00:00
$sql = "SELECT option_to_group.groupID, option_to_group.objectID AS roomID, option_to_group.optionValue,
acl_option.optionName AS permission
FROM wcf".WCF_N."_acl_option acl_option,
wcf".WCF_N."_acl_option_to_group option_to_group
".$conditionBuilder;
$stmt = WCF::getDB()->prepareStatement($sql);
$stmt->execute($conditionBuilder->getParameters());
while ($row = $stmt->fetchArray()) {
2012-02-26 17:17:07 +00:00
if (!isset($data[$row['roomID']][$row['permission']])) $data[$row['roomID']][$row['permission']] = $row['optionValue'];
else $data[$row['roomID']][$row['permission']] = $row['optionValue'] || $data[$row['roomID']][$row['permission']];
}
}
return $data;
}
2012-12-20 17:46:38 +00:00
}