mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Redirect to correct room if there is no id given
Additionally pass rooms to template
This commit is contained in:
parent
aba9a07a3c
commit
74464ff83b
@ -11,7 +11,7 @@
|
||||
* @package timwolla.wcf.chat
|
||||
* @subpackage data.chat.room
|
||||
*/
|
||||
class ChatRoom extends \wcf\data\DatabaseObject {
|
||||
class ChatRoom extends \wcf\data\DatabaseObject implements \wcf\system\request\IRouteController {
|
||||
/**
|
||||
* @see wcf\data\DatabaseObject::$databaseTableName
|
||||
*/
|
||||
@ -46,11 +46,27 @@ public static function getCache() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this chat-room.
|
||||
*
|
||||
* @return string
|
||||
* @see \wcf\data\chat\room\ChatRoom::getTitle();
|
||||
*/
|
||||
public function __tostring() {
|
||||
return $this->getTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this chat-room.
|
||||
*
|
||||
* @see \wcf\system\request\IRouteController
|
||||
*/
|
||||
public function getTitle() {
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of this chat-room.
|
||||
*
|
||||
* @see \wcf\system\request\RRouteHandler
|
||||
*/
|
||||
public function getID() {
|
||||
return $this->roomID;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,9 @@ public function assignVariables() {
|
||||
parent::assignVariables();
|
||||
|
||||
WCF::getTPL()->assign(array(
|
||||
'roomID' => $this->roomID
|
||||
'room' => $this->room,
|
||||
'roomID' => $this->roomID,
|
||||
'rooms' => $this->rooms
|
||||
));
|
||||
}
|
||||
|
||||
@ -36,6 +38,13 @@ public function assignVariables() {
|
||||
public function readData() {
|
||||
parent::readData();
|
||||
$this->rooms = chat\room\ChatRoom::getCache();
|
||||
if ($this->roomID === 0) {
|
||||
$this->rooms->seek(0);
|
||||
\wcf\util\HeaderUtil::redirect(\wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array(
|
||||
'object' => $this->rooms->search($this->rooms->key())
|
||||
)));
|
||||
exit;
|
||||
}
|
||||
$this->room = $this->rooms->search($this->roomID);
|
||||
|
||||
if (!$this->room) throw new \wcf\system\exception\IllegalLinkException();
|
||||
|
Loading…
Reference in New Issue
Block a user