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

Implemented getLink for ChatPageMenuItemProvider

This commit is contained in:
Tim Düsterhus 2011-12-15 10:54:18 +01:00
parent c8ee2ca94e
commit 18d27897e4

View File

@ -1,5 +1,6 @@
<?php <?php
namespace wcf\system\menu\page; namespace wcf\system\menu\page;
use \wcf\data\chat\room\ChatRoom;
/** /**
* PageMenuItemProvider for chat. * PageMenuItemProvider for chat.
@ -11,21 +12,34 @@
* @subpackage system.menu.page * @subpackage system.menu.page
*/ */
class ChatPageMenuItemProvider extends DefaultPageMenuItemProvider { class ChatPageMenuItemProvider extends DefaultPageMenuItemProvider {
protected $room = null;
/** /**
* Hides the button when there is no valid room * Hides the button when there is no valid room
* *
* @see wcf\system\menu\page\PageMenuItemProvider::isVisible() * @see \wcf\system\menu\page\PageMenuItemProvider::isVisible()
*/ */
public function isVisible() { public function isVisible() {
// guests are not supported // guests are not supported
if (!\wcf\system\WCF::getUser()->userID) return false; if (!\wcf\system\WCF::getUser()->userID) return false;
try { try {
\wcf\data\chat\room\ChatRoom::getCache()->seek(0); ChatRoom::getCache()->seek(0);
return true; return true;
} }
catch (\OutOfBoundsException $e) { catch (\OutOfBoundsException $e) {
return false; return false;
} }
} }
/**
* Modifies the link to show the Link we would be redirect to.
*
* @see \wcf\system\menu\page\PageMenuItemProvider::getLink()
*/
public function getLink() {
\wcf\util\HeaderUtil::redirect(\wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array(
'object' => ChatRoom::getCache()->search(ChatRoom::getCache()->key())
)));
}
} }