mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Added ChatRoom DataBaseObjects
This commit is contained in:
parent
07fcffe5cb
commit
aabebd820e
52
file/lib/data/chat/room/ChatRoom.class.php
Normal file
52
file/lib/data/chat/room/ChatRoom.class.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace wcf\data\chat\room;
|
||||
|
||||
/**
|
||||
* Represents a chat room.
|
||||
*
|
||||
* @author Tim Düsterhus
|
||||
* @copyright 2010-2011 Tim Düsterhus
|
||||
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
||||
* @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<wcf\data\chat\room\ChatRoom>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
18
file/lib/data/chat/room/ChatRoomList.class.php
Normal file
18
file/lib/data/chat/room/ChatRoomList.class.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace wcf\data\chat\room;
|
||||
|
||||
/**
|
||||
* Represents a list of chat rooms.
|
||||
*
|
||||
* @author Tim Düsterhus
|
||||
* @copyright 2010-2011 Tim Düsterhus
|
||||
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
||||
* @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';
|
||||
}
|
27
file/lib/system/cache/builder/ChatRoomCacheBuilder.class.php
vendored
Normal file
27
file/lib/system/cache/builder/ChatRoomCacheBuilder.class.php
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace wcf\system\cache\builder;
|
||||
|
||||
/**
|
||||
* Caches all chat rooms.
|
||||
*
|
||||
* @author Tim Düsterhus
|
||||
* @copyright 2010-2011 Tim Düsterhus
|
||||
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
||||
* @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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user