1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-11-01 14:20:07 +00:00
Tims-Chat/file/lib/system/menu/page/ChatPageMenuItemProvider.class.php
Tim Düsterhus c24402ec86 Fix getLink
Call isVisible again directly before getLink to ensure the pointer is at the first place.
... and we also have to return the new link! ;)
2011-12-15 10:56:22 +01:00

47 lines
1.2 KiB
PHP

<?php
namespace wcf\system\menu\page;
use \wcf\data\chat\room\ChatRoom;
/**
* PageMenuItemProvider for chat.
*
* @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat
* @subpackage system.menu.page
*/
class ChatPageMenuItemProvider extends DefaultPageMenuItemProvider {
protected $room = null;
/**
* Hides the button when there is no valid room
*
* @see \wcf\system\menu\page\PageMenuItemProvider::isVisible()
*/
public function isVisible() {
// guests are not supported
if (!\wcf\system\WCF::getUser()->userID) return false;
try {
ChatRoom::getCache()->seek(0);
return true;
}
catch (\OutOfBoundsException $e) {
return false;
}
}
/**
* Modifies the link to show the Link we would be redirect to.
*
* @see \wcf\system\menu\page\PageMenuItemProvider::getLink()
*/
public function getLink() {
if (!$this->isVisible()) return parent::getLink();
return \wcf\util\HeaderUtil::redirect(\wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array(
'object' => ChatRoom::getCache()->search(ChatRoom::getCache()->key())
)));
}
}