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> <objecttype>be.bastelstu.chat.room</objecttype>
<categoryname>mod</categoryname> <categoryname>mod</categoryname>
</option> </option>
<option name="mod.canReadLog">
<objecttype>be.bastelstu.chat.room</objecttype>
<categoryname>mod</categoryname>
</option>
</options> </options>
</import> </import>
</data> </data>

View File

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

View File

@ -35,7 +35,7 @@ class LogPage extends \wcf\page\AbstractPage {
/** /**
* @see \wcf\page\AbstractPage::$neededPermissions * @see \wcf\page\AbstractPage::$neededPermissions
*/ */
public $neededPermissions = array(); public $neededPermissions = array('mod.chat.canReadLog');
/** /**
* given roomID * given roomID
@ -49,29 +49,6 @@ class LogPage extends \wcf\page\AbstractPage {
*/ */
public $room = null; 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() * @see \wcf\page\IPage::assignVariables()
*/ */
@ -81,8 +58,7 @@ public function assignVariables() {
WCF::getTPL()->assign(array( WCF::getTPL()->assign(array(
'messages' => $this->messages, 'messages' => $this->messages,
'room' => $this->room, 'room' => $this->room,
'roomID' => $this->roomID, 'roomID' => $this->roomID
'rooms' => $this->rooms
)); ));
} }
@ -92,7 +68,7 @@ public function assignVariables() {
public function readParameters() { public function readParameters() {
parent::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]; $this->room = $cache[$this->roomID];
if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException(); 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 // TODO: actually read the correct messages
$this->messages = data\message\MessageList::getNewestMessages($this->room, 150); $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 = new \wcf\system\request\Route('chatAction');
$route->setSchema('/{controller}/{action}/{id}'); $route->setSchema('/{controller}/{action}/{id}');
$route->setParameterOption('controller', null, 'Chat'); $route->setParameterOption('controller', null, 'Chat');
$route->setParameterOption('action', null, '(Log|Send)'); $route->setParameterOption('action', null, '(Send)');
$route->setParameterOption('id', null, '\d+', true); $route->setParameterOption('id', null, '\d+', true);
$eventObj->addRoute($route); $eventObj->addRoute($route);
} }

View File

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