2012-11-23 19:42:05 +00:00
|
|
|
<?php
|
2013-01-19 19:36:40 +00:00
|
|
|
namespace chat\page;
|
|
|
|
use \chat\data;
|
2012-11-23 19:42:05 +00:00
|
|
|
use \wcf\system\exception\IllegalLinkException;
|
|
|
|
use \wcf\system\exception\PermissionDeniedException;
|
|
|
|
use \wcf\system\WCF;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the chat-log.
|
|
|
|
*
|
|
|
|
* @author Tim Düsterhus
|
2013-01-19 19:36:40 +00:00
|
|
|
* @copyright 2010-2013 Tim Düsterhus
|
2012-11-23 19:42:05 +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
|
2012-11-23 19:42:05 +00:00
|
|
|
* @subpackage page
|
|
|
|
*/
|
2013-01-19 19:36:40 +00:00
|
|
|
class LogPage extends \wcf\page\AbstractPage {
|
2012-11-23 19:42:05 +00:00
|
|
|
/**
|
|
|
|
* @see wcf\page\AbstractPage::$loginRequired
|
|
|
|
*/
|
|
|
|
public $loginRequired = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TODO: comment this
|
|
|
|
*
|
|
|
|
* @var array<\wcf\data\chat\message\ChatMessage>
|
|
|
|
*/
|
|
|
|
public $messages = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see \wcf\page\AbstractPage::$neededModules
|
|
|
|
*/
|
2013-05-23 20:14:07 +00:00
|
|
|
public $neededModules = array('MODULE_CHAT');
|
2012-11-23 19:42:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @see \wcf\page\AbstractPage::$neededPermissions
|
|
|
|
*/
|
2013-02-02 22:22:01 +00:00
|
|
|
public $neededPermissions = array('mod.chat.canReadLog');
|
2012-11-23 19:42:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* given roomID
|
|
|
|
* @var integer
|
|
|
|
*/
|
|
|
|
public $roomID = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* given room
|
2013-01-19 19:36:40 +00:00
|
|
|
* @var \chat\data\room\Chat
|
2012-11-23 19:42:05 +00:00
|
|
|
*/
|
|
|
|
public $room = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see \wcf\page\IPage::assignVariables()
|
|
|
|
*/
|
|
|
|
public function assignVariables() {
|
|
|
|
parent::assignVariables();
|
|
|
|
|
|
|
|
WCF::getTPL()->assign(array(
|
|
|
|
'messages' => $this->messages,
|
|
|
|
'room' => $this->room,
|
2013-02-02 22:22:01 +00:00
|
|
|
'roomID' => $this->roomID
|
2012-11-23 19:42:05 +00:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see \wcf\page\IPage::readParameters()
|
|
|
|
*/
|
|
|
|
public function readParameters() {
|
|
|
|
parent::readParameters();
|
|
|
|
|
2013-02-02 22:22:01 +00:00
|
|
|
if (isset($_REQUEST['id'])) $this->roomID = intval($_REQUEST['id']);
|
2012-11-23 19:42:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see \wcf\page\IPage::readData()
|
|
|
|
*/
|
|
|
|
public function readData() {
|
|
|
|
parent::readData();
|
|
|
|
|
2013-01-19 19:36:40 +00:00
|
|
|
$cache = data\room\Room::getCache();
|
2012-11-23 19:42:05 +00:00
|
|
|
if (!isset($cache[$this->roomID])) throw new IllegalLinkException();
|
|
|
|
|
|
|
|
$this->room = $cache[$this->roomID];
|
|
|
|
if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException();
|
|
|
|
|
|
|
|
// TODO: actually read the correct messages
|
2013-01-19 19:36:40 +00:00
|
|
|
$this->messages = data\message\MessageList::getNewestMessages($this->room, 150);
|
2012-11-23 19:42:05 +00:00
|
|
|
}
|
|
|
|
}
|