1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

PackageDependencyHandler is now a Singleton

Fixes Tims Chat in accordance to WoltLab/WCF@6eb121400f
This commit is contained in:
Tim Düsterhus 2012-03-05 16:49:45 +01:00
parent 583cbf2903
commit 81462252dc
7 changed files with 21 additions and 21 deletions

View File

@ -99,7 +99,7 @@ public function save() {
$roomID = $returnValues['returnValues']->roomID; $roomID = $returnValues['returnValues']->roomID;
if (!I18nHandler::getInstance()->isPlainValue('title')) { if (!I18nHandler::getInstance()->isPlainValue('title')) {
I18nHandler::getInstance()->save('title', 'wcf.chat.room.title'.$roomID, 'wcf.chat.room', PackageDependencyHandler::getPackageID('timwolla.wcf.chat')); I18nHandler::getInstance()->save('title', 'wcf.chat.room.title'.$roomID, 'wcf.chat.room', PackageDependencyHandler::getInstance()->getPackageID('timwolla.wcf.chat'));
// update title // update title
$chatRoomEditor->update(array( $chatRoomEditor->update(array(
@ -108,7 +108,7 @@ public function save() {
} }
if (!I18nHandler::getInstance()->isPlainValue('topic')) { if (!I18nHandler::getInstance()->isPlainValue('topic')) {
I18nHandler::getInstance()->save('topic', 'wcf.chat.room.topic'.$roomID, 'wcf.chat.room', PackageDependencyHandler::getPackageID('timwolla.wcf.chat')); I18nHandler::getInstance()->save('topic', 'wcf.chat.room.topic'.$roomID, 'wcf.chat.room', PackageDependencyHandler::getInstance()->getPackageID('timwolla.wcf.chat'));
// update topic // update topic
$chatRoomEditor->update(array( $chatRoomEditor->update(array(

View File

@ -1,8 +1,8 @@
<?php <?php
namespace wcf\acp\form; namespace wcf\acp\form;
use wcf\system\language\I18nHandler; use \wcf\system\language\I18nHandler;
use wcf\system\package\PackageDependencyHandler; use \wcf\system\package\PackageDependencyHandler;
use wcf\system\WCF; use \wcf\system\WCF;
/** /**
* Shows the chatroom edit form. * Shows the chatroom edit form.
@ -64,20 +64,20 @@ public function save() {
$this->title = 'wcf.chat.room.title'.$this->roomObj->roomID; $this->title = 'wcf.chat.room.title'.$this->roomObj->roomID;
if (I18nHandler::getInstance()->isPlainValue('title')) { if (I18nHandler::getInstance()->isPlainValue('title')) {
I18nHandler::getInstance()->remove($this->title, PackageDependencyHandler::getPackageID('timwolla.wcf.chat')); I18nHandler::getInstance()->remove($this->title, PackageDependencyHandler::getInstance()->getPackageID('timwolla.wcf.chat'));
$this->title = I18nHandler::getInstance()->getValue('title'); $this->title = I18nHandler::getInstance()->getValue('title');
} }
else { else {
I18nHandler::getInstance()->save('title', $this->title, 'wcf.chat.room', PackageDependencyHandler::getPackageID('timwolla.wcf.chat')); I18nHandler::getInstance()->save('title', $this->title, 'wcf.chat.room', PackageDependencyHandler::getInstance()->getPackageID('timwolla.wcf.chat'));
} }
$this->topic = 'wcf.chat.room.topic'.$this->roomObj->roomID; $this->topic = 'wcf.chat.room.topic'.$this->roomObj->roomID;
if (I18nHandler::getInstance()->isPlainValue('topic')) { if (I18nHandler::getInstance()->isPlainValue('topic')) {
I18nHandler::getInstance()->remove($this->topic, PackageDependencyHandler::getPackageID('timwolla.wcf.chat')); I18nHandler::getInstance()->remove($this->topic, PackageDependencyHandler::getInstance()->getPackageID('timwolla.wcf.chat'));
$this->topic = I18nHandler::getInstance()->getValue('topic'); $this->topic = I18nHandler::getInstance()->getValue('topic');
} }
else { else {
I18nHandler::getInstance()->save('topic', $this->topic, 'wcf.chat.room', PackageDependencyHandler::getPackageID('timwolla.wcf.chat')); I18nHandler::getInstance()->save('topic', $this->topic, 'wcf.chat.room', PackageDependencyHandler::getInstance()->getPackageID('timwolla.wcf.chat'));
} }
\wcf\system\acl\ACLHandler::getInstance()->save($this->roomID, $this->objectTypeID); \wcf\system\acl\ACLHandler::getInstance()->save($this->roomID, $this->objectTypeID);
@ -105,8 +105,8 @@ public function readData() {
parent::readData(); parent::readData();
if (!count($_POST)) { if (!count($_POST)) {
I18nHandler::getInstance()->setOptions('title', PackageDependencyHandler::getPackageID('timwolla.wcf.chat'), $this->roomObj->title, 'wcf.chat.room.title\d+'); I18nHandler::getInstance()->setOptions('title', PackageDependencyHandler::getInstance()->getPackageID('timwolla.wcf.chat'), $this->roomObj->title, 'wcf.chat.room.title\d+');
I18nHandler::getInstance()->setOptions('topic', PackageDependencyHandler::getPackageID('timwolla.wcf.chat'), $this->roomObj->topic, 'wcf.chat.room.topic\d+'); I18nHandler::getInstance()->setOptions('topic', PackageDependencyHandler::getInstance()->getPackageID('timwolla.wcf.chat'), $this->roomObj->topic, 'wcf.chat.room.topic\d+');
$this->title = $this->roomObj->title; $this->title = $this->roomObj->title;
$this->topic = $this->roomObj->topic; $this->topic = $this->roomObj->topic;

View File

@ -43,7 +43,7 @@ public function __toString() {
* @return integer * @return integer
*/ */
public function countUsers() { public function countUsers() {
$packageID = \wcf\system\package\PackageDependencyHandler::getPackageID('timwolla.wcf.chat'); $packageID = \wcf\system\package\PackageDependencyHandler::getInstance()->getPackageID('timwolla.wcf.chat');
$sql = "SELECT $sql = "SELECT
count(*) as count count(*) as count
@ -100,7 +100,7 @@ public function getTitle() {
* @return array<\wcf\data\user\User> * @return array<\wcf\data\user\User>
*/ */
public function getUsers() { public function getUsers() {
$packageID = \wcf\system\package\PackageDependencyHandler::getPackageID('timwolla.wcf.chat'); $packageID = \wcf\system\package\PackageDependencyHandler::getInstance()->getPackageID('timwolla.wcf.chat');
$sql = "SELECT $sql = "SELECT
userID userID

View File

@ -29,7 +29,7 @@ public static function resetCache() {
*/ */
public static function deleteAll(array $objectIDs = array()) { public static function deleteAll(array $objectIDs = array()) {
parent::deleteAll($objectIDs); parent::deleteAll($objectIDs);
$packageID = \wcf\system\package\PackageDependencyHandler::getPackageID('timwolla.wcf.chat'); $packageID = \wcf\system\package\PackageDependencyHandler::getInstance()->getPackageID('timwolla.wcf.chat');
WCF::getDB()->beginTransaction(); WCF::getDB()->beginTransaction();
foreach ($objectIDs as $objectID) { foreach ($objectIDs as $objectID) {

View File

@ -22,7 +22,7 @@ public function getData(array $cacheResource) {
if (count($groupIDs)) { if (count($groupIDs)) {
$conditionBuilder = new \wcf\system\database\util\PreparedStatementConditionBuilder(); $conditionBuilder = new \wcf\system\database\util\PreparedStatementConditionBuilder();
$conditionBuilder->add('acl_option.packageID IN (?)', array(\wcf\system\package\PackageDependencyHandler::getDependencies())); $conditionBuilder->add('acl_option.packageID IN (?)', array(\wcf\system\package\PackageDependencyHandler::getInstance()->getDependencies()));
$conditionBuilder->add('acl_option.objectTypeID = ?', array(\wcf\system\acl\ACLHandler::getInstance()->getObjectTypeID('timwolla.wcf.chat.room'))); $conditionBuilder->add('acl_option.objectTypeID = ?', array(\wcf\system\acl\ACLHandler::getInstance()->getObjectTypeID('timwolla.wcf.chat.room')));
$conditionBuilder->add('option_to_group.optionID = acl_option.optionID'); $conditionBuilder->add('option_to_group.optionID = acl_option.optionID');
$conditionBuilder->add('option_to_group.groupID IN (?)', array($groupIDs)); $conditionBuilder->add('option_to_group.groupID IN (?)', array($groupIDs));

View File

@ -27,13 +27,13 @@ class ChatPermissionHandler extends \wcf\system\SingletonFactory {
* @see \wcf\system\SingletonFactory::init() * @see \wcf\system\SingletonFactory::init()
*/ */
protected function init() { protected function init() {
$packageID = PackageDependencyHandler::getPackageID('timwolla.wcf.chat'); $packageID = PackageDependencyHandler::getInstance()->getPackageID('timwolla.wcf.chat');
$ush = \wcf\system\user\storage\UserStorageHandler::getInstance(); $ush = \wcf\system\user\storage\UserStorageHandler::getInstance();
// get groups permissions // get groups permissions
$groups = implode(',', WCF::getUser()->getGroupIDs()); $groups = implode(',', WCF::getUser()->getGroupIDs());
$groupsFileName = \wcf\util\StringUtil::getHash(implode('-', WCF::getUser()->getGroupIDs())); $groupsFileName = \wcf\util\StringUtil::getHash(implode('-', WCF::getUser()->getGroupIDs()));
CacheHandler::getInstance()->addResource('chatPermission-'.$groups, WCF_DIR.'cache/cache.chatPermission-'.$groupsFileName.'.php', 'wcf\system\cache\builder\ChatPermissionCacheBuilder'); CacheHandler::getInstance()->addResource('chatPermission-'.$groups, WCF_DIR.'cache/cache.chatPermission-'.$groupsFileName.'.php', '\wcf\system\cache\builder\ChatPermissionCacheBuilder');
$this->chatPermissions = CacheHandler::getInstance()->get('chatPermission-'.$groups); $this->chatPermissions = CacheHandler::getInstance()->get('chatPermission-'.$groups);
// get user permissions // get user permissions
@ -49,7 +49,7 @@ protected function init() {
$userPermissions = array(); $userPermissions = array();
$conditionBuilder = new \wcf\system\database\util\PreparedStatementConditionBuilder(); $conditionBuilder = new \wcf\system\database\util\PreparedStatementConditionBuilder();
$conditionBuilder->add('acl_option.packageID IN (?)', array(PackageDependencyHandler::getDependencies())); $conditionBuilder->add('acl_option.packageID IN (?)', array(PackageDependencyHandler::getInstance()->getDependencies()));
$conditionBuilder->add('acl_option.objectTypeID = ?', array(ACLHandler::getInstance()->getObjectTypeID('timwolla.wcf.chat.room'))); $conditionBuilder->add('acl_option.objectTypeID = ?', array(ACLHandler::getInstance()->getObjectTypeID('timwolla.wcf.chat.room')));
$conditionBuilder->add('option_to_user.optionID = acl_option.optionID'); $conditionBuilder->add('option_to_user.optionID = acl_option.optionID');
$conditionBuilder->add('option_to_user.userID = ?', array(WCF::getUser()->userID)); $conditionBuilder->add('option_to_user.userID = ?', array(WCF::getUser()->userID));
@ -97,7 +97,7 @@ public function getPermission(\wcf\data\chat\room\ChatRoom $room, $permission) {
* Clears the cache. * Clears the cache.
*/ */
public static function clearCache() { public static function clearCache() {
$packageID = PackageDependencyHandler::getPackageID('timwolla.wcf.chat'); $packageID = PackageDependencyHandler::getInstance()->getPackageID('timwolla.wcf.chat');
$ush = \wcf\system\user\storage\UserStorageHandler::getInstance(); $ush = \wcf\system\user\storage\UserStorageHandler::getInstance();
$ush->resetAll('chatUserPermissions', $packageID); $ush->resetAll('chatUserPermissions', $packageID);

View File

@ -58,7 +58,7 @@ public static function gradient($string, $start, $end) {
*/ */
public static function readUserData($field) { public static function readUserData($field) {
$ush = UserStorageHandler::getInstance(); $ush = UserStorageHandler::getInstance();
$packageID = PackageDependencyHandler::getPackageID('timwolla.wcf.chat'); $packageID = PackageDependencyHandler::getInstance()->getPackageID('timwolla.wcf.chat');
// load storage // load storage
$ush->loadStorage(array(WCF::getUser()->userID), $packageID); $ush->loadStorage(array(WCF::getUser()->userID), $packageID);
@ -96,7 +96,7 @@ public static function /* int */ getRandomNumber() {
*/ */
public static function writeUserData(array $data) { public static function writeUserData(array $data) {
$ush = UserStorageHandler::getInstance(); $ush = UserStorageHandler::getInstance();
$packageID = PackageDependencyHandler::getPackageID('timwolla.wcf.chat'); $packageID = PackageDependencyHandler::getInstance()->getPackageID('timwolla.wcf.chat');
foreach($data as $key => $value) { foreach($data as $key => $value) {
$ush->update(WCF::getUser()->userID, $key, (isset(static::$serialize[$key])) ? serialize($value) : $value, $packageID); $ush->update(WCF::getUser()->userID, $key, (isset(static::$serialize[$key])) ? serialize($value) : $value, $packageID);