1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

Throw IllegalLinkException when no room is there

Additionally added dummy join message.
This commit is contained in:
Tim Düsterhus 2011-11-27 12:38:02 +01:00
parent 35a22767fc
commit c92e1079c3

View File

@ -39,15 +39,33 @@ public function readData() {
parent::readData(); parent::readData();
$this->rooms = chat\room\ChatRoom::getCache(); $this->rooms = chat\room\ChatRoom::getCache();
if ($this->roomID === 0) { if ($this->roomID === 0) {
try {
$this->rooms->seek(0); $this->rooms->seek(0);
\wcf\util\HeaderUtil::redirect(\wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array( \wcf\util\HeaderUtil::redirect(\wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array(
'object' => $this->rooms->search($this->rooms->key()) 'object' => $this->rooms->search($this->rooms->key())
))); )));
exit; exit;
} }
catch (\OutOfBoundsException $e) {
throw new \wcf\system\exception\IllegalLinkException();
}
}
$this->room = $this->rooms->search($this->roomID); $this->room = $this->rooms->search($this->roomID);
if (!$this->room) throw new \wcf\system\exception\IllegalLinkException(); if (!$this->room) throw new \wcf\system\exception\IllegalLinkException();
chat\message\ChatMessageEditor::create(array(
'roomID' => $this->room->roomID,
'sender' => WCF::getUser()->userID,
'username' => WCF::getUser()->username,
'time' => TIME_NOW,
'type' => chat\message\ChatMessage::TYPE_JOIN,
'message' => 'join',
'enableSmilies' => 0,
'enableHTML' => 0,
'color1' => 0xFF0000,
'color2' => 0x00FF00
));
} }
/** /**