1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

Check permissions for log in template

This commit is contained in:
Tim Düsterhus 2013-02-02 23:22:01 +01:00
parent a82b392001
commit 99da19966d
5 changed files with 11 additions and 43 deletions

View File

@ -37,10 +37,6 @@
<objecttype>be.bastelstu.chat.room</objecttype>
<categoryname>mod</categoryname>
</option>
<option name="mod.canReadLog">
<objecttype>be.bastelstu.chat.room</objecttype>
<categoryname>mod</categoryname>
</option>
</options>
</import>
</data>

View File

@ -161,10 +161,6 @@ public function readParameters() {
$this->request = $this;
switch ($this->action) {
case 'Log':
$this->request = new LogPage();
$this->request->__run();
exit;
case 'Send':
$this->request = new \chat\form\ChatForm();
$this->request->__run();

View File

@ -35,7 +35,7 @@ class LogPage extends \wcf\page\AbstractPage {
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
public $neededPermissions = array();
public $neededPermissions = array('mod.chat.canReadLog');
/**
* given roomID
@ -49,29 +49,6 @@ class LogPage extends \wcf\page\AbstractPage {
*/
public $room = null;
/**
* all rooms in the current installation
* @var array<\chat\data\room\Room>
*/
public $rooms = array();
/**
* 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() {
if (($this->request = \wcf\system\request\RequestHandler::getInstance()->getActiveRequest()->getRequestObject()) === $this) throw new IllegalLinkException();
parent::__run();
}
/**
* @see \wcf\page\IPage::assignVariables()
*/
@ -81,8 +58,7 @@ public function assignVariables() {
WCF::getTPL()->assign(array(
'messages' => $this->messages,
'room' => $this->room,
'roomID' => $this->roomID,
'rooms' => $this->rooms
'roomID' => $this->roomID
));
}
@ -92,7 +68,7 @@ public function assignVariables() {
public function readParameters() {
parent::readParameters();
if (isset($_REQUEST['id'])) $this->roomID = (int) $_REQUEST['id'];
if (isset($_REQUEST['id'])) $this->roomID = intval($_REQUEST['id']);
}
/**
@ -106,8 +82,6 @@ public function readData() {
$this->room = $cache[$this->roomID];
if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException();
$ph = new \chat\system\permission\PermissionHandler();
if (!$ph->getPermission($this->room, 'mod.canReadLog')) throw new \wcf\system\exception\PermissionDeniedException();
// TODO: actually read the correct messages
$this->messages = data\message\MessageList::getNewestMessages($this->room, 150);

View File

@ -18,7 +18,7 @@ public function execute($eventObj, $className, $eventName) {
$route = new \wcf\system\request\Route('chatAction');
$route->setSchema('/{controller}/{action}/{id}');
$route->setParameterOption('controller', null, 'Chat');
$route->setParameterOption('action', null, '(Log|Send)');
$route->setParameterOption('action', null, '(Send)');
$route->setParameterOption('id', null, '\d+', true);
$eventObj->addRoute($route);
}

View File

@ -1,5 +1,7 @@
<li>
{if $__wcf->session->getPermission('mod.chat.canReadLog')}
<li>
<a id="chatLogLink" title="{lang}chat.general.protocol{/lang}" class="jsTooltip">
<span class="icon icon16 icon-eye-open"></span> <span>{lang}chat.general.protocol{/lang}</span>
</a>
</li>
</li>
{/if}