* @package be.bastelstu.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; $cache = ChatRoom::getCache(); foreach ($cache as $this->room) { if ($this->room->canEnter()) { return true; } } return false; } /** * Modifies the link to show the Link we would be redirect to. * * @see \wcf\system\menu\page\PageMenuItemProvider::getLink() */ public function getLink() { return \wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array( 'object' => $this->room )); } }