diff --git a/file/lib/data/chat/room/ChatRoom.class.php b/file/lib/data/chat/room/ChatRoom.class.php new file mode 100644 index 0000000..dc1bc5b --- /dev/null +++ b/file/lib/data/chat/room/ChatRoom.class.php @@ -0,0 +1,52 @@ + + * @package timwolla.wcf.chat + * @subpackage data.chat.room + */ +class ChatRoom extends \wcf\data\DatabaseObject { + /** + * @see wcf\data\DatabaseObject::$databaseTableName + */ + protected static $databaseTableName = 'chat_room'; + + /** + * @see wcf\data\DatabaseObject::$databaseTableIndexName + */ + protected static $databaseTableIndexName = 'roomID'; + + /** + * Caches rooms. + * + * @var array + */ + protected static $cache = null; + + /** + * Loads the room cache. + */ + protected static function getCache() { + if (self::$cache !== null) return; + CacheHandler::getInstance()->addResource( + 'chatrooms', + WCF_DIR.'cache/cache.chatrooms.php', + 'wcf\system\cache\builder\ChatRoomCacheBuilder' + ); + self::$cache = CacheHandler::getInstance()->get('chatrooms'); + } + + /** + * Returns the name of this chat-room. + * + * @return string + */ + public function __tostring() { + return $this->title; + } +} diff --git a/file/lib/data/chat/room/ChatRoomList.class.php b/file/lib/data/chat/room/ChatRoomList.class.php new file mode 100644 index 0000000..0c34470 --- /dev/null +++ b/file/lib/data/chat/room/ChatRoomList.class.php @@ -0,0 +1,18 @@ + + * @package timwolla.wcf.chat + * @subpackage data.chat.room + */ +class ChatRoomList extends \wcf\data\DatabaseObjectList { + /** + * @see wcf\data\DatabaseObjectList::$className + */ + public $className = 'wcf\data\chat\room\ChatRoom'; +} diff --git a/file/lib/system/cache/builder/ChatRoomCacheBuilder.class.php b/file/lib/system/cache/builder/ChatRoomCacheBuilder.class.php new file mode 100644 index 0000000..c645d67 --- /dev/null +++ b/file/lib/system/cache/builder/ChatRoomCacheBuilder.class.php @@ -0,0 +1,27 @@ + + * @package timwolla.wcf.chat + * @subpackage system.cache.builder + */ +class ChatRoomCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData(array $cacheResource) { + // get all chat rooms + $roomList = new \wcf\data\chat\room\ChatRoomList(); + $roomList->sqlOrderBy = "chat_room.position"; + $roomList->sqlLimit = 0; + $roomList->readObjects(); + $rooms = $roomList->getObjects(); + + return $rooms; + } +}