2011-11-27 11:46:10 +00:00
|
|
|
<?php
|
|
|
|
namespace wcf\system\menu\page;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 {
|
|
|
|
/**
|
|
|
|
* Hides the button when there is no valid room
|
|
|
|
*
|
|
|
|
* @see wcf\system\menu\page\PageMenuItemProvider::isVisible()
|
|
|
|
*/
|
|
|
|
public function isVisible() {
|
2011-11-27 19:01:28 +00:00
|
|
|
// guests are not supported
|
2011-11-29 15:57:44 +00:00
|
|
|
if (!\wcf\system\WCF::getUser()->userID) return false;
|
2011-11-27 19:01:28 +00:00
|
|
|
|
2011-11-27 11:46:10 +00:00
|
|
|
try {
|
|
|
|
\wcf\data\chat\room\ChatRoom::getCache()->seek(0);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
catch (\OutOfBoundsException $e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|