From 1c1f695ecdd8fa365d0b8ce7c54eef7d378c6978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 13 Feb 2014 16:39:16 +0100 Subject: [PATCH] Add option to force a room selection --- file/lib/page/ChatPage.class.php | 23 +- .../page/ChatPageMenuItemProvider.class.php | 2 + option.xml | 5 + template/chat.tpl | 318 ++++++++++-------- 4 files changed, 197 insertions(+), 151 deletions(-) diff --git a/file/lib/page/ChatPage.class.php b/file/lib/page/ChatPage.class.php index e2ce651..307c681 100644 --- a/file/lib/page/ChatPage.class.php +++ b/file/lib/page/ChatPage.class.php @@ -173,16 +173,21 @@ public function readRoom() { if ($this->roomID === 0) { // no room given - $room = reset($this->rooms); - if ($room === null) { - // no valid room found - throw new exception\IllegalLinkException(); + if (CHAT_FORCE_ROOM_SELECT) { + return; + } + else { + $room = reset($this->rooms); + if ($room === null) { + // no valid room found + throw new exception\IllegalLinkException(); + } + // redirect to first chat-room + \wcf\util\HeaderUtil::redirect(\wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array( + 'object' => $room + ))); + exit; } - // redirect to first chat-room - \wcf\util\HeaderUtil::redirect(\wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array( - 'object' => $room - ))); - exit; } if (!isset($this->rooms[$this->roomID])) throw new exception\IllegalLinkException(); diff --git a/file/lib/system/menu/page/ChatPageMenuItemProvider.class.php b/file/lib/system/menu/page/ChatPageMenuItemProvider.class.php index 78c6f3e..bd3bcd3 100644 --- a/file/lib/system/menu/page/ChatPageMenuItemProvider.class.php +++ b/file/lib/system/menu/page/ChatPageMenuItemProvider.class.php @@ -44,6 +44,8 @@ public function isVisible() { * @see \wcf\system\menu\page\PageMenuItemProvider::getLink() */ public function getLink() { + if (CHAT_FORCE_ROOM_SELECT) return parent::getLink(); + return \wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array( 'application' => 'chat', 'object' => $this->room, diff --git a/option.xml b/option.xml index 8dbebeb..347536f 100644 --- a/option.xml +++ b/option.xml @@ -18,6 +18,11 @@ boolean 1 +