1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2025-01-23 02:10:41 +00:00
Tims-Chat/file/lib/page/ChatRefreshRoomListPage.class.php

91 lines
2.1 KiB
PHP
Raw Normal View History

2011-12-18 16:08:51 +01: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 17:50:33 +01:00
* @copyright 2010-2012 Tim Düsterhus
2011-12-18 16:08:51 +01:00
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package be.bastelstu.wcf.chat
2011-12-18 16:08:51 +01:00
* @subpackage page
*/
class ChatRefreshRoomListPage extends AbstractPage {
2012-08-08 16:51:24 +02:00
/**
* @see wcf\page\AbstractPage::$loginRequired
*/
public $loginRequired = true;
/**
* @see \wcf\page\AbstractPage::$neededModules
*/
2011-12-18 16:08:51 +01:00
public $neededModules = array('CHAT_ACTIVE');
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
public $neededPermissions = array();
2012-06-10 18:48:08 +02:00
public $room = null;
2011-12-18 16:08:51 +01:00
public $rooms = array();
/**
* @see \wcf\page\AbstractPage::$useTemplate
*/
2011-12-18 16:08:51 +01:00
public $useTemplate = false;
2012-08-12 20:30:08 +02:00
/**
* shortcut for the active request
* @see wcf\system\request\Request::getRequestObject()
*/
public $request = null;
/**
* Disallows direct access.
*
* @see wcf\page\IPage::__run()
*/
public function __run() {
2012-08-28 21:58:47 +02:00
if (($this->request = \wcf\system\request\RequestHandler::getInstance()->getActiveRequest()->getRequestObject()) === $this) throw new IllegalLinkException();
2012-08-12 20:30:08 +02:00
parent::__run();
}
2011-12-18 16:08:51 +01:00
/**
* @see \wcf\page\IPage::readData()
2011-12-18 16:08:51 +01:00
*/
public function readData() {
parent::readData();
2011-12-18 16:08:51 +01:00
$this->rooms = chat\room\ChatRoom::getCache();
$roomID = \wcf\util\ChatUtil::readUserData('roomID');
2012-09-07 22:37:25 +02:00
if (!isset($this->rooms[$roomID])) throw new \wcf\system\exception\IllegalLinkException();
$this->room = $this->rooms[$roomID];
2011-12-18 16:08:51 +01: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 12:45:05 +01:00
if (!$room->canEnter()) continue;
2011-12-18 16:08:51 +01: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;
}
}