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:
parent
c8ee2ca94e
commit
18d27897e4
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace wcf\system\menu\page;
|
||||
use \wcf\data\chat\room\ChatRoom;
|
||||
|
||||
/**
|
||||
* PageMenuItemProvider for chat.
|
||||
@ -11,21 +12,34 @@
|
||||
* @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()
|
||||
* @see \wcf\system\menu\page\PageMenuItemProvider::isVisible()
|
||||
*/
|
||||
public function isVisible() {
|
||||
// guests are not supported
|
||||
if (!\wcf\system\WCF::getUser()->userID) return false;
|
||||
|
||||
try {
|
||||
\wcf\data\chat\room\ChatRoom::getCache()->seek(0);
|
||||
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() {
|
||||
\wcf\util\HeaderUtil::redirect(\wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array(
|
||||
'object' => ChatRoom::getCache()->search(ChatRoom::getCache()->key())
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user