From 81462252dcc72dfec08ab35c97fa3ec0ed66f037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 5 Mar 2012 16:49:45 +0100 Subject: [PATCH] PackageDependencyHandler is now a Singleton Fixes Tims Chat in accordance to WoltLab/WCF@6eb121400f68e60cefb5a01f8e2d181c14bd4c7c --- file/lib/acp/form/ChatRoomAddForm.class.php | 4 ++-- file/lib/acp/form/ChatRoomEditForm.class.php | 18 +++++++++--------- file/lib/data/chat/room/ChatRoom.class.php | 4 ++-- .../data/chat/room/ChatRoomEditor.class.php | 2 +- .../ChatPermissionCacheBuilder.class.php | 2 +- .../permission/ChatPermissionHandler.class.php | 8 ++++---- file/lib/util/ChatUtil.class.php | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/file/lib/acp/form/ChatRoomAddForm.class.php b/file/lib/acp/form/ChatRoomAddForm.class.php index e5a95e1..3959c7b 100644 --- a/file/lib/acp/form/ChatRoomAddForm.class.php +++ b/file/lib/acp/form/ChatRoomAddForm.class.php @@ -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( diff --git a/file/lib/acp/form/ChatRoomEditForm.class.php b/file/lib/acp/form/ChatRoomEditForm.class.php index a0298be..45afe02 100644 --- a/file/lib/acp/form/ChatRoomEditForm.class.php +++ b/file/lib/acp/form/ChatRoomEditForm.class.php @@ -1,8 +1,8 @@ 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; diff --git a/file/lib/data/chat/room/ChatRoom.class.php b/file/lib/data/chat/room/ChatRoom.class.php index bc29a31..686b1ec 100644 --- a/file/lib/data/chat/room/ChatRoom.class.php +++ b/file/lib/data/chat/room/ChatRoom.class.php @@ -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 diff --git a/file/lib/data/chat/room/ChatRoomEditor.class.php b/file/lib/data/chat/room/ChatRoomEditor.class.php index 43216c4..24cc939 100644 --- a/file/lib/data/chat/room/ChatRoomEditor.class.php +++ b/file/lib/data/chat/room/ChatRoomEditor.class.php @@ -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) { diff --git a/file/lib/system/cache/builder/ChatPermissionCacheBuilder.class.php b/file/lib/system/cache/builder/ChatPermissionCacheBuilder.class.php index 947b05b..783138d 100644 --- a/file/lib/system/cache/builder/ChatPermissionCacheBuilder.class.php +++ b/file/lib/system/cache/builder/ChatPermissionCacheBuilder.class.php @@ -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)); diff --git a/file/lib/system/chat/permission/ChatPermissionHandler.class.php b/file/lib/system/chat/permission/ChatPermissionHandler.class.php index fc3e79e..d304954 100644 --- a/file/lib/system/chat/permission/ChatPermissionHandler.class.php +++ b/file/lib/system/chat/permission/ChatPermissionHandler.class.php @@ -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); diff --git a/file/lib/util/ChatUtil.class.php b/file/lib/util/ChatUtil.class.php index 1be6657..2130185 100644 --- a/file/lib/util/ChatUtil.class.php +++ b/file/lib/util/ChatUtil.class.php @@ -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);