2018-08-16 22:30:59 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2021-02-04 22:04:35 +00:00
|
|
|
* Copyright (C) 2010-2021 Tim Düsterhus
|
|
|
|
* Copyright (C) 2010-2021 Woltlab GmbH
|
2018-08-16 22:30:59 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace chat\system\cache\builder;
|
|
|
|
|
|
|
|
use \wcf\system\acl\ACLHandler;
|
|
|
|
use \wcf\system\WCF;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Caches the chat permissions for a combination of user groups.
|
|
|
|
*/
|
|
|
|
class PermissionCacheBuilder extends \wcf\system\cache\builder\AbstractCacheBuilder {
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function rebuild(array $parameters) {
|
|
|
|
$data = [ ];
|
|
|
|
|
|
|
|
if (!empty($parameters)) {
|
|
|
|
$conditionBuilder = new \wcf\system\database\util\PreparedStatementConditionBuilder();
|
|
|
|
$conditionBuilder->add('acl_option.objectTypeID = ?', [ ACLHandler::getInstance()->getObjectTypeID('be.bastelstu.chat.room') ]);
|
|
|
|
$conditionBuilder->add('option_to_group.groupID IN (?)', [ $parameters ]);
|
|
|
|
$sql = "SELECT option_to_group.objectID AS roomID,
|
|
|
|
option_to_group.optionValue,
|
|
|
|
acl_option.optionName AS permission
|
2022-03-04 16:52:33 +00:00
|
|
|
FROM wcf1_acl_option acl_option
|
|
|
|
INNER JOIN wcf1_acl_option_to_group option_to_group
|
2018-08-16 22:30:59 +00:00
|
|
|
ON option_to_group.optionID = acl_option.optionID
|
|
|
|
".$conditionBuilder;
|
2022-03-04 16:52:33 +00:00
|
|
|
$statement = WCF::getDB()->prepare($sql);
|
2018-08-16 22:30:59 +00:00
|
|
|
$statement->execute($conditionBuilder->getParameters());
|
|
|
|
while (($row = $statement->fetchArray())) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|