1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-26 22:20:08 +00:00
Tims-Chat/file/lib/system/menu/page/ChatPageMenuItemProvider.class.php

48 lines
1.2 KiB
PHP
Raw Normal View History

2011-11-27 11:46:10 +00:00
<?php
2013-01-19 19:36:40 +00:00
namespace chat\system\menu\page;
2011-11-27 11:46:10 +00:00
/**
* PageMenuItemProvider for chat.
*
* @author Tim Düsterhus
2013-01-19 19:36:40 +00:00
* @copyright 2010-2013 Tim Düsterhus
2011-11-27 11:46:10 +00:00
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
2013-01-19 19:36:40 +00:00
* @package be.bastelstu.chat
2011-11-27 11:46:10 +00:00
* @subpackage system.menu.page
*/
2013-01-19 19:36:40 +00:00
class ChatPageMenuItemProvider extends \wcf\system\menu\page\DefaultPageMenuItemProvider {
protected $room = null;
2011-11-27 11:46:10 +00:00
/**
* Hides the button when there is no valid room
*
* @see \wcf\system\menu\page\PageMenuItemProvider::isVisible()
2011-11-27 11:46:10 +00:00
*/
public function isVisible() {
// guests are not supported
if (!\wcf\system\WCF::getUser()->userID) return false;
2013-01-19 19:36:40 +00:00
$cache = \chat\data\room\Room::getCache();
2012-09-07 20:32:42 +00:00
foreach ($cache as $this->room) {
if ($this->room->canEnter()) {
return true;
2011-12-26 11:43:19 +00:00
}
2011-11-27 11:46:10 +00:00
}
2012-09-07 20:32:42 +00:00
return false;
2011-11-27 11:46:10 +00:00
}
/**
* 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(
2013-01-19 19:36:40 +00:00
'application' => 'chat',
'object' => $this->room
));
}
2011-11-27 11:46:10 +00:00
}