2011-12-18 15:08:51 +00:00
|
|
|
<?php
|
|
|
|
namespace wcf\page;
|
|
|
|
use \wcf\data\chat;
|
|
|
|
use \wcf\system\cache\CacheHandler;
|
|
|
|
use \wcf\system\WCF;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the chat-interface
|
|
|
|
*
|
|
|
|
* @author Tim Düsterhus
|
2012-01-28 16:50:33 +00:00
|
|
|
* @copyright 2010-2012 Tim Düsterhus
|
2011-12-18 15:08:51 +00:00
|
|
|
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
2012-03-12 16:18:15 +00:00
|
|
|
* @package be.bastelstu.wcf.chat
|
2011-12-18 15:08:51 +00:00
|
|
|
* @subpackage page
|
|
|
|
*/
|
|
|
|
class ChatRefreshRoomListPage extends AbstractPage {
|
2012-08-08 14:51:24 +00:00
|
|
|
/**
|
|
|
|
* @see wcf\page\AbstractPage::$loginRequired
|
|
|
|
*/
|
|
|
|
public $loginRequired = true;
|
|
|
|
|
2012-05-31 14:57:20 +00:00
|
|
|
/**
|
|
|
|
* @see \wcf\page\AbstractPage::$neededModules
|
|
|
|
*/
|
2011-12-18 15:08:51 +00:00
|
|
|
public $neededModules = array('CHAT_ACTIVE');
|
2012-05-31 14:57:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @see \wcf\page\AbstractPage::$neededPermissions
|
|
|
|
*/
|
2012-03-23 16:45:26 +00:00
|
|
|
public $neededPermissions = array('user.chat.canEnter');
|
2012-06-10 16:48:08 +00:00
|
|
|
public $room = null;
|
2011-12-18 15:08:51 +00:00
|
|
|
public $rooms = array();
|
2012-05-31 14:57:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @see \wcf\page\AbstractPage::$useTemplate
|
|
|
|
*/
|
2011-12-18 15:08:51 +00:00
|
|
|
public $useTemplate = false;
|
|
|
|
|
|
|
|
/**
|
2012-05-31 14:57:20 +00:00
|
|
|
* @see \wcf\page\IPage::readData()
|
2011-12-18 15:08:51 +00:00
|
|
|
*/
|
|
|
|
public function readData() {
|
|
|
|
parent::readData();
|
2012-05-31 14:57:20 +00:00
|
|
|
|
2011-12-18 15:08:51 +00:00
|
|
|
$this->rooms = chat\room\ChatRoom::getCache();
|
|
|
|
|
2012-05-31 14:57:20 +00:00
|
|
|
$roomID = \wcf\util\ChatUtil::readUserData('roomID');
|
2012-06-10 16:48:08 +00:00
|
|
|
$this->room = $this->rooms->search($roomID);
|
|
|
|
if (!$this->room) throw new \wcf\system\exception\IllegalLinkException();
|
2011-12-18 15:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see \wcf\page\IPage::show()
|
|
|
|
*/
|
|
|
|
public function show() {
|
|
|
|
parent::show();
|
|
|
|
|
|
|
|
@header('Content-type: application/json');
|
|
|
|
$json = array();
|
|
|
|
foreach ($this->rooms as $room) {
|
2011-12-26 11:45:05 +00:00
|
|
|
if (!$room->canEnter()) continue;
|
2011-12-18 15:08:51 +00:00
|
|
|
$json[] = array(
|
|
|
|
'title' => WCF::getLanguage()->get($room->title),
|
|
|
|
'link' => \wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array(
|
|
|
|
'object' => $room
|
|
|
|
)),
|
|
|
|
'active' => $room->roomID == $this->room->roomID
|
|
|
|
);
|
|
|
|
}
|
|
|
|
echo \wcf\util\JSON::encode($json);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|