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;
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
$chatRoomEditor->update(array(
@ -108,7 +108,7 @@ public function save() {
}
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
$chatRoomEditor->update(array(

View File

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

View File

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

View File

@ -29,7 +29,7 @@ public static function resetCache() {
*/
public static function deleteAll(array $objectIDs = array()) {
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();
foreach ($objectIDs as $objectID) {

View File

@ -22,7 +22,7 @@ public function getData(array $cacheResource) {
if (count($groupIDs)) {
$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('option_to_group.optionID = acl_option.optionID');
$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()
*/
protected function init() {
$packageID = PackageDependencyHandler::getPackageID('timwolla.wcf.chat');
$packageID = PackageDependencyHandler::getInstance()->getPackageID('timwolla.wcf.chat');
$ush = \wcf\system\user\storage\UserStorageHandler::getInstance();
// get groups permissions
$groups = 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);
// get user permissions
@ -49,7 +49,7 @@ protected function init() {
$userPermissions = array();
$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('option_to_user.optionID = acl_option.optionID');
$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.
*/
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->resetAll('chatUserPermissions', $packageID);

View File

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