mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Add permissions for suspension viewing
This commit is contained in:
parent
6d539e7f0a
commit
0025fc63ee
@ -26,7 +26,7 @@
|
||||
<acpmenuitem name="chat.acp.menu.link.suspension.list">
|
||||
<controller><![CDATA[chat\acp\page\ChatSuspensionListPage]]></controller>
|
||||
<parent>chat.acp.menu.link.chat</parent>
|
||||
<!--TODO: <permissions></permissions> -->
|
||||
<permissions>mod.chat.canViewAllSuspensions</permissions>
|
||||
<showorder>1</showorder>
|
||||
</acpmenuitem>
|
||||
</import>
|
||||
|
@ -118,7 +118,7 @@
|
||||
<td id="columnTime">{$suspension->time|plainTime}</td>
|
||||
<td id="columnExpires">
|
||||
<p>{$suspension->expires|plainTime}{if $suspension->expires > TIME_NOW} ({$suspension->expires|dateDiff}){/if}</p>
|
||||
{if $suspension->revoker}<p><small>{lang}chat.acp.suspension.revokedBy{/lang}</small></p>{/if}
|
||||
{if $suspension->revoker && $suspension->expires <= TIME_NOW}<p><small>{lang}chat.acp.suspension.revokedBy{/lang}</small></p>{/if}
|
||||
</td>
|
||||
<td id="columnIssuer"><a href="{link application='chat' controller='ChatSuspensionList'}issuerUserID={$suspension->issuer}{/link}">{$suspension->issuerUsername}</a></td>
|
||||
<td id="columnMessage"{if $suspension->reason != $suspension->reason|truncate:30} class="jsTooltip" title="{$suspension->reason}"{/if}>{$suspension->reason|truncate:30}</a></td>
|
||||
|
@ -20,8 +20,7 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage {
|
||||
/**
|
||||
* @see \wcf\page\AbstractPage::$neededPermissions
|
||||
*/
|
||||
// TODO: Permissions
|
||||
public $neededPermissions = array();
|
||||
public $neededPermissions = array('mod.chat.canViewAllSuspensions');
|
||||
|
||||
/**
|
||||
* @see \wcf\page\SortablePage::$defaultSortField
|
||||
@ -148,7 +147,7 @@ protected function initObjectList() {
|
||||
LEFT JOIN wcf".WCF_N."_user user_table2
|
||||
ON suspension.issuer = user_table2.userID
|
||||
LEFT JOIN wcf".WCF_N."_user user_table3
|
||||
ON suspension.issuer = user_table3.userID";
|
||||
ON suspension.issuer = user_table3.userID";
|
||||
$conditionJoins = " LEFT JOIN chat".WCF_N."_room room_table
|
||||
ON suspension.roomID = room_table.roomID";
|
||||
$this->objectList->sqlConditionJoins .= $conditionJoins;
|
||||
|
@ -22,8 +22,8 @@ class Suspension extends \chat\data\CHATDatabaseObject {
|
||||
*/
|
||||
protected static $databaseTableIndexName = 'suspensionID';
|
||||
|
||||
const TYPE_MUTE = 1;
|
||||
const TYPE_BAN = 2;
|
||||
const TYPE_MUTE = 'mute';
|
||||
const TYPE_BAN = 'ban';
|
||||
|
||||
/**
|
||||
* Returns whether the suspension still is valid.
|
||||
@ -34,6 +34,34 @@ public function isValid() {
|
||||
return $this->expires > TIME_NOW;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given user may view this suspension.
|
||||
*
|
||||
* @param \wcf\data\user\User $user
|
||||
* @return boolean
|
||||
*/
|
||||
public function isVisible($user = null) {
|
||||
if ($user === null) $user = WCF::getUser();
|
||||
|
||||
$ph = new \chat\system\permission\PermissionHandler($user);
|
||||
if ($ph->getPermission($this->getRoom(), 'mod.canViewAllSuspensions')) return true;
|
||||
if ($ph->getPermission($this->getRoom(), 'mod.canG'.$this->type)) return true;
|
||||
if (!$this->room) return false;
|
||||
if ($ph->getPermission($this->getRoom(), 'mod.can'.ucfirst($this->type))) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the room of this suspension.
|
||||
*
|
||||
* @return \chat\data\room\Room
|
||||
*/
|
||||
public function getRoom() {
|
||||
if (!$this->roomID) return new \chat\data\room\Room(null, array('roomID' => null));
|
||||
|
||||
return \chat\data\room\RoomCache::getInstance()->getRoom($this->roomID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the suspensions for the specified user (current user if no user was specified).
|
||||
*
|
||||
|
@ -91,7 +91,7 @@ public function checkPermission() {
|
||||
|
||||
$this->room = $this->commandHandler->getRoom();
|
||||
$ph = new \chat\system\permission\PermissionHandler();
|
||||
if (!$ph->getPermission($this->room, 'mod.can'.ucfirst(static::IDENTIFIER))) throw new \wcf\system\exception\PermissionDeniedException();
|
||||
if (!$ph->getPermission($this->room, 'mod.can'.ucfirst((static::IS_GLOBAL ? 'g' : '').static::SUSPENSION_TYPE))) throw new \wcf\system\exception\PermissionDeniedException();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,7 +108,7 @@ public function getMessage() {
|
||||
return serialize(array(
|
||||
'link' => $this->link,
|
||||
'expires' => $this->expires,
|
||||
'type' => static::IDENTIFIER,
|
||||
'type' => (static::IS_GLOBAL ? 'g' : '').static::SUSPENSION_TYPE,
|
||||
'reason' => $this->reason
|
||||
));
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public function checkPermission() {
|
||||
|
||||
$this->room = $this->commandHandler->getRoom();
|
||||
$ph = new \chat\system\permission\PermissionHandler();
|
||||
if (!$ph->getPermission($this->room, 'mod.can'.ucfirst(static::IDENTIFIER))) throw new \wcf\system\exception\PermissionDeniedException();
|
||||
if (!$ph->getPermission($this->room, 'mod.can'.ucfirst((static::IS_GLOBAL ? 'g' : '').static::SUSPENSION_TYPE))) throw new \wcf\system\exception\PermissionDeniedException();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,7 +76,7 @@ public function getType() {
|
||||
public function getMessage() {
|
||||
return serialize(array(
|
||||
'link' => $this->link,
|
||||
'type' => 'un'.static::IDENTIFIER
|
||||
'type' => 'un'.(static::IS_GLOBAL ? 'g' : '').static::SUSPENSION_TYPE,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class BanCommand extends \chat\system\command\AbstractSuspensionCommand {
|
||||
const IDENTIFIER = 'ban';
|
||||
const IS_GLOBAL = false;
|
||||
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN;
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class GbanCommand extends \chat\system\command\AbstractSuspensionCommand {
|
||||
const IDENTIFIER = 'gban';
|
||||
const IS_GLOBAL = true;
|
||||
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN;
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class GmuteCommand extends \chat\system\command\AbstractSuspensionCommand {
|
||||
const IDENTIFIER = 'gmute';
|
||||
const IS_GLOBAL = true;
|
||||
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE;
|
||||
}
|
||||
|
@ -45,11 +45,11 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
|
||||
}
|
||||
|
||||
// Suspensions
|
||||
// TODO: Permissions
|
||||
$suspensions = \chat\data\suspension\Suspension::getSuspensionsForUser($this->user);
|
||||
foreach ($suspensions as $roomSuspensions) {
|
||||
foreach ($roomSuspensions as $typeSuspension) {
|
||||
if (!$typeSuspension->isValid()) continue;
|
||||
if (!$typeSuspension->isVisible()) continue;
|
||||
|
||||
$dateTime = DateUtil::getDateTimeByTimestamp($typeSuspension->expires);
|
||||
$name = WCF::getLanguage()->getDynamicVariable('chat.general.information.suspension', array(
|
||||
|
@ -11,7 +11,6 @@
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class MuteCommand extends \chat\system\command\AbstractSuspensionCommand {
|
||||
const IDENTIFIER = 'mute';
|
||||
const IS_GLOBAL = false;
|
||||
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE;
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class UnbanCommand extends \chat\system\command\AbstractUnsuspensionCommand {
|
||||
const IDENTIFIER = 'ban';
|
||||
const IS_GLOBAL = false;
|
||||
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN;
|
||||
}
|
||||
|
@ -10,8 +10,7 @@
|
||||
* @package be.bastelstu.chat
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class GunbanCommand extends \chat\system\command\AbstractUnsuspensionCommand {
|
||||
const IDENTIFIER = 'gban';
|
||||
class UngbanCommand extends \chat\system\command\AbstractUnsuspensionCommand {
|
||||
const IS_GLOBAL = true;
|
||||
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN;
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class UngmuteCommand extends \chat\system\command\AbstractUnsuspensionCommand {
|
||||
const IDENTIFIER = 'gmute';
|
||||
const IS_GLOBAL = true;
|
||||
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE;
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class UnmuteCommand extends \chat\system\command\AbstractUnsuspensionCommand {
|
||||
const IDENTIFIER = 'mute';
|
||||
const IS_GLOBAL = false;
|
||||
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ CREATE TABLE chat1_suspension (
|
||||
suspensionID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
userID INT(10) NOT NULL,
|
||||
roomID INT(10) DEFAULT NULL,
|
||||
type TINYINT(3) NOT NULL,
|
||||
type VARCHAR(15) NOT NULL,
|
||||
expires INT(10) NOT NULL,
|
||||
time INT(10) NOT NULL,
|
||||
issuer INT(10) DEFAULT NULL,
|
||||
|
@ -144,8 +144,8 @@
|
||||
</category>
|
||||
|
||||
<category name="chat.suspension">
|
||||
<item name="chat.suspension.1"><![CDATA[Knebel]]></item>
|
||||
<item name="chat.suspension.2"><![CDATA[Bann]]></item>
|
||||
<item name="chat.suspension.mute"><![CDATA[Knebel]]></item>
|
||||
<item name="chat.suspension.ban"><![CDATA[Bann]]></item>
|
||||
</category>
|
||||
|
||||
<!-- I18N Values -->
|
||||
|
@ -5,7 +5,7 @@
|
||||
<packagedescription><![CDATA[Chat for WoltLab Community Framework™.]]></packagedescription>
|
||||
<packagedescription language="de"><![CDATA[Chat für WoltLab Community Framework™.]]></packagedescription>
|
||||
<isapplication>1</isapplication>
|
||||
<version>3.0.0 Alpha 66</version><!-- Codename: Codenames are overrated -->
|
||||
<version>3.0.0 Alpha 80</version><!-- Codename: Codenames are overrated -->
|
||||
<date>2011-11-26</date>
|
||||
<license><![CDATA[Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>]]></license>
|
||||
</packageinformation>
|
||||
|
@ -56,6 +56,12 @@
|
||||
<defaultvalue>0</defaultvalue>
|
||||
<admindefaultvalue>1</admindefaultvalue>
|
||||
</option>
|
||||
<option name="mod.chat.canViewAllSuspensions">
|
||||
<categoryname>mod.chat</categoryname>
|
||||
<optiontype>boolean</optiontype>
|
||||
<defaultvalue>0</defaultvalue>
|
||||
<admindefaultvalue>1</admindefaultvalue>
|
||||
</option>
|
||||
<option name="mod.chat.canMute">
|
||||
<categoryname>mod.chat</categoryname>
|
||||
<optiontype>boolean</optiontype>
|
||||
|
Loading…
Reference in New Issue
Block a user