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

Fixing Chat*(Page|Form|Action)

This commit is contained in:
Tim Düsterhus 2012-09-07 22:37:25 +02:00
parent ec0154e3a4
commit f777bc1d2e
5 changed files with 21 additions and 19 deletions

View File

@ -67,8 +67,9 @@ public function execute() {
$this->userData['roomID'] = \wcf\util\ChatUtil::readUserData('roomID'); $this->userData['roomID'] = \wcf\util\ChatUtil::readUserData('roomID');
$this->room = chat\room\ChatRoom::getCache()->search($this->userData['roomID']); $cache = chat\room\ChatRoom::getCache();
if (!$this->room) throw new \wcf\system\exception\IllegalLinkException(); if (!isset($cache[$this->userData['roomID']])) throw new \wcf\system\exception\IllegalLinkException();
$this->room = $cache[$this->userData['roomID']];
if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException(); if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException();
if (CHAT_DISPLAY_JOIN_LEAVE) { if (CHAT_DISPLAY_JOIN_LEAVE) {

View File

@ -95,8 +95,10 @@ public function readData() {
$this->userData['roomID'] = \wcf\util\ChatUtil::readUserData('roomID'); $this->userData['roomID'] = \wcf\util\ChatUtil::readUserData('roomID');
$this->userData['away'] = \wcf\util\ChatUtil::readUserData('away'); $this->userData['away'] = \wcf\util\ChatUtil::readUserData('away');
$this->room = chat\room\ChatRoom::getCache()->search($this->userData['roomID']); $cache = chat\room\ChatRoom::getCache();
if (!$this->room) throw new \wcf\system\exception\IllegalLinkException(); if (!isset($cache[$this->userData['roomID']])) throw new \wcf\system\exception\IllegalLinkException();
$this->room = $cache[$this->userData['roomID']];
if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException(); if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException();
if (!$this->room->canWrite()) throw new \wcf\system\exception\PermissionDeniedException(); if (!$this->room->canWrite()) throw new \wcf\system\exception\PermissionDeniedException();
parent::readData(); parent::readData();

View File

@ -133,9 +133,10 @@ public function readMessages() {
*/ */
public function readRoom() { public function readRoom() {
$roomID = \wcf\util\ChatUtil::readUserData('roomID'); $roomID = \wcf\util\ChatUtil::readUserData('roomID');
$cache = chat\room\ChatRoom::getCache();
if (!isset($cache[$roomID])) throw new \wcf\system\exception\IllegalLinkException();
$this->room = chat\room\ChatRoom::getCache()->search($roomID); $this->room = $cache[$roomID];
if (!$this->room) throw new \wcf\system\exception\IllegalLinkException();
if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException(); if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException();
} }

View File

@ -213,22 +213,20 @@ public function readRoom() {
if ($this->roomID === 0) { if ($this->roomID === 0) {
// no room given // no room given
try { $room = reset($this->rooms);
// redirect to first chat-room if ($room === null) {
$this->rooms->seek(0);
\wcf\util\HeaderUtil::redirect(\wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array(
'object' => $this->rooms->current()
)));
exit;
}
catch (\OutOfBoundsException $e) {
// no valid room found // no valid room found
throw new \wcf\system\exception\IllegalLinkException(); throw new \wcf\system\exception\IllegalLinkException();
} }
// redirect to first chat-room
\wcf\util\HeaderUtil::redirect(\wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array(
'object' => $room
)));
exit;
} }
$this->room = $this->rooms->search($this->roomID); if (!isset($this->rooms[$this->roomID])) throw new \wcf\system\exception\IllegalLinkException();
if (!$this->room) throw new \wcf\system\exception\IllegalLinkException(); $this->room = $this->rooms[$this->roomID];
if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException(); if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException();
} }

View File

@ -62,8 +62,8 @@ public function readData() {
$this->rooms = chat\room\ChatRoom::getCache(); $this->rooms = chat\room\ChatRoom::getCache();
$roomID = \wcf\util\ChatUtil::readUserData('roomID'); $roomID = \wcf\util\ChatUtil::readUserData('roomID');
$this->room = $this->rooms->search($roomID); if (!isset($this->rooms[$roomID])) throw new \wcf\system\exception\IllegalLinkException();
if (!$this->room) throw new \wcf\system\exception\IllegalLinkException(); $this->room = $this->rooms[$roomID];
} }
/** /**