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

Merge branch 'suspensionList'

Closes #34
This commit is contained in:
Tim Düsterhus 2013-06-22 18:44:28 +02:00
commit 096a18c096
27 changed files with 801 additions and 388 deletions

View File

@ -22,5 +22,12 @@
<permissions>admin.chat.canAddRoom</permissions>
<showorder>2</showorder>
</acpmenuitem>
<acpmenuitem name="chat.acp.menu.link.suspension.list">
<controller><![CDATA[chat\acp\page\ChatSuspensionListPage]]></controller>
<parent>chat.acp.menu.link.chat</parent>
<permissions>admin.chat.canManageSuspensions</permissions>
<showorder>1</showorder>
</acpmenuitem>
</import>
</data>

View File

@ -0,0 +1,167 @@
{include file='header' pageTitle='chat.acp.suspension.list'}
<script type="text/javascript">
//<![CDATA[
$(function() {
new WCF.Search.User('#username', null, false, [ ], false);
new WCF.Search.User('#issuerUsername', null, false, [ ], false);
var proxy = new WCF.Action.Proxy({
success: function (data, textStatus, jqXHR) {
$('.jsSuspensionRow').each(function(index, row) {
var row = $(row);
if (WCF.inArray(row.data('objectID'), data.objectIDs)) {
row.find('.jsRevokeButton').addClass('disabled').removeClass('pointer').off('click');
(new WCF.System.Notification('{"chat.acp.suspension.revoke.success"|language|encodeJS}')).show();
}
});
}
});
$('.jsRevokeButton:not(.disabled)').click(function () {
var objectID = $(this).parents('.jsSuspensionRow').data('objectID');
WCF.System.Confirmation.show($(this).data('confirmMessage'), $.proxy(function (action) {
if (action === 'confirm') {
proxy.setOption('data', {
actionName: 'revoke',
className: '\\chat\\data\\suspension\\SuspensionAction',
objectIDs: [ objectID ]
});
proxy.sendRequest();
}
}, this));
});
});
//]]>
</script>
<header class="boxHeadline">
<h1>{lang}chat.acp.suspension.list{/lang}</h1>
</header>
<form method="post" action="{link controller='ChatSuspensionList' application='chat'}{/link}">
<div class="container containerPadding marginTop">
<fieldset>
<legend>{lang}wcf.global.filter{/lang}</legend>
<dl>
<dd>
<label><input type="checkbox" id="displayRevoked" name="displayRevoked" value="1"{if $displayRevoked} checked="checked"{/if} /> {lang}chat.acp.suspension.displayRevoked{/lang}</label>
</dd>
</dl>
<dl>
<dt><label for="username">{lang}wcf.user.username{/lang}</label></dt>
<dd>
<input type="text" id="username" name="username" class="medium" value="{$username}" />
</dd>
</dl>
<dl>
<dt><label for="issuerUsername">{lang}chat.acp.suspension.issuer{/lang}</label></dt>
<dd>
<input type="text" id="issuerUsername" name="issuerUsername" class="medium" value="{$issuerUsername}" />
</dd>
</dl>
<dl>
<dt><label for="roomID">{lang}chat.general.room{/lang}</label></dt>
<dd>
<select id="roomID" name="roomID">
<option value="-1"{if $roomID == -1} selected="selected"{/if}></option>
<option value="0"{if $roomID == 0} selected="selected"{/if}>{lang}chat.room.global{/lang}</option>
<option value="" disabled="disabled">-------------</option>
{foreach from=$availableRooms key=id item=room}
<option value="{$id}" {if $roomID == $id}selected="selected"{/if}>{$room}</option>
{/foreach}
</select>
</dd>
</dl>
<dl>
<dt><label for="suspensionType">{lang}chat.acp.suspension.type{/lang}</label></dt>
<dd>
<select id="suspensionType" name="suspensionType">
<option value=""{if $suspensionType == null} selected="selected"{/if}></option>
<option value="{'\chat\data\suspension\Suspension::TYPE_MUTE'|constant}"{if $suspensionType == '\chat\data\suspension\Suspension::TYPE_MUTE'|constant} selected="selected"{/if}>{lang}chat.suspension.{'\chat\data\suspension\Suspension::TYPE_MUTE'|constant}{/lang}</option>
<option value="{'\chat\data\suspension\Suspension::TYPE_BAN'|constant}"{if $suspensionType == '\chat\data\suspension\Suspension::TYPE_BAN'|constant} selected="selected"{/if}>{lang}chat.suspension.{'\chat\data\suspension\Suspension::TYPE_BAN'|constant}{/lang}</option>
</select>
</dd>
</dl>
</fieldset>
</div>
<div class="formSubmit">
<input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s" />
</div>
</form>
{if $objects|count}
{capture assign=additionalParameters}{*
*}{if $userID}&userID={$userID}{/if}{*
*}{if $issuerUserID}&issuerUserID={$issuerUserID}{/if}{*
*}{if $roomID}&roomID={$roomID}{/if}{*
*}{if $suspensionType}&suspensionType={$suspensionType}{/if}{*
*}{if $displayRevoked}&displayRevoked={$displayRevoked}{/if}{*
*}{/capture}
<div class="contentNavigation">
{pages print=true assign=pagesLinks application="chat" controller="ChatSuspensionList" link="pageNo=%d$additionalParameters"}
</div>
<div class="tabularBox tabularBoxTitle marginTop">
<header>
<h2>{lang}chat.acp.suspension.list{/lang} <span class="badge badgeInverse">{#$items}</span></h2>
</header>
<table class="table">
<thead>
<tr>
<th class="columnID{if $sortField == 'suspensionID'} active {@$sortOrder}{/if}" colspan="2"><a href="{link application='chat' controller='ChatSuspensionList'}pageNo={@$pageNo}&sortField=suspensionID&sortOrder={if $sortField == 'suspensionID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$additionalParameters}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
<th class="columnUsername{if $sortField == 'username'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='ChatSuspensionList'}pageNo={@$pageNo}&sortField=username&sortOrder={if $sortField == 'username' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$additionalParameters}{/link}">{lang}wcf.user.username{/lang}</a></th>
<th class="columnRoomID{if $sortField == 'roomID'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='ChatSuspensionList'}pageNo={@$pageNo}&sortField=roomID&sortOrder={if $sortField == 'roomID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$additionalParameters}{/link}">{lang}chat.general.room{/lang}</a></th>
<th class="columnSuspensionType{if $sortField == 'type'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='ChatSuspensionList'}pageNo={@$pageNo}&sortField=type&sortOrder={if $sortField == 'type' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$additionalParameters}{/link}">{lang}chat.acp.suspension.type{/lang}</a></th>
<th class="columnTime{if $sortField == 'time'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='ChatSuspensionList'}pageNo={@$pageNo}&sortField=time&sortOrder={if $sortField == 'time' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$additionalParameters}{/link}">{lang}chat.general.time{/lang}</a></th>
<th class="columnExpires{if $sortField == 'expires'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='ChatSuspensionList'}pageNo={@$pageNo}&sortField=expires&sortOrder={if $sortField == 'expires' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$additionalParameters}{/link}">{lang}chat.general.expires{/lang}</a></th>
<th class="columnIssuer{if $sortField == 'issuer'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='ChatSuspensionList'}pageNo={@$pageNo}&sortField=issuer&sortOrder={if $sortField == 'issuer' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$additionalParameters}{/link}">{lang}chat.acp.suspension.issuer{/lang}</a></th>
<th class="columnMessage{if $sortField == 'reason'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='ChatSuspensionList'}pageNo={@$pageNo}&sortField=reason&sortOrder={if $sortField == 'reason' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$additionalParameters}{/link}">{lang}chat.acp.suspension.reason{/lang}</a></th>
{event name='columnHeads'}
</tr>
</thead>
<tbody>
{foreach from=$objects item=$suspension}
<tr class="jsSuspensionRow" data-object-id="{$suspension->suspensionID}">
<td class="columnIcon">
<span class="icon icon16 icon-undo{if $suspension->expires <= TIME_NOW} disabled{else} pointer{/if} jsRevokeButton" title="{lang}chat.acp.suspension.revoked{/lang}" data-confirm-message="{lang}chat.acp.suspension.revoke.sure{/lang}"></span>
{event name='rowButtons'}
</td>
<td id="columnID">{#$suspension->suspensionID}</td>
<td id="columnUsername"><a href="{link application='chat' controller='ChatSuspensionList'}userID={$suspension->userID}{/link}">{$suspension->username}</a></td>
<td id="columnRoomID"><a href="{link application='chat' controller='ChatSuspensionList'}roomID={if $suspension->roomID}{$suspension->roomID}{else}0{/if}{/link}">{if $suspension->roomID}{$suspension->roomTitle|language}{else}{lang}chat.room.global{/lang}{/if}</a></td>
<td id="columnSuspensionType"><a href="{link application='chat' controller='ChatSuspensionList'}suspensionType={$suspension->type}{/link}">{lang}chat.suspension.{@$suspension->type}{/lang}</a></td>
<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 && $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>
{event name='columns'}
</tr>
{/foreach}
</tbody>
</table>
</div>
<div class="contentNavigation">
{@$pagesLinks}
</div>
{else}
<p class="info">{lang}wcf.global.noItems{/lang}</p>
{/if}
{include file='footer'}

View File

@ -0,0 +1,172 @@
<?php
namespace chat\acp\page;
use \wcf\system\WCF;
/**
* Lists chat suspensions.
*
* @author Maximilian Mader
* @copyright 2010-2013 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package be.bastelstu.chat
* @subpackage acp.page
*/
class ChatSuspensionListPage extends \wcf\page\SortablePage {
/**
* @see \wcf\page\AbstractPage::$activeMenuItem
*/
public $activeMenuItem = 'chat.acp.menu.link.suspension.list';
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
public $neededPermissions = array('admin.chat.canManageSuspensions');
/**
* @see \wcf\page\SortablePage::$defaultSortField
*/
public $defaultSortField = 'expires';
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
public $validSortFields = array('suspensionID', 'userID', 'username', 'roomID', 'type', 'expires', 'issuer', 'time', 'reason');
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
*/
public $objectListClassName = 'chat\data\suspension\SuspensionList';
/**
* type filter
*
* @var integer
*/
public $filterSuspensionType = null;
/**
* user filter
*
* @var integer
*/
public $filterUserID = null;
/*
* username
*
* @var String
*/
public $filterUsername = null;
/**
* issuer filter
*
* @var integer
*/
public $filterIssuerUserID = null;
/*
* issuer username
*
* @var String
*/
public $filterIssuerUsername = null;
/**
* room filter
*
* @var integer
*/
public $filterRoomID = null;
/**
* display revoked suspensions
*
* @var integer
*/
public $displayRevoked = 0;
/**
* @see \wcf\page\IPage::readParameters()
*/
public function readParameters() {
parent::readParameters();
// get usernames
if (isset($_REQUEST['username']) && !empty($_REQUEST['username'])) $this->filterUsername = \wcf\util\StringUtil::trim($_REQUEST['username']);
if (isset($_REQUEST['issuerUsername']) && !empty($_REQUEST['issuerUsername'])) $this->filterIssuerUsername = \wcf\util\StringUtil::trim($_REQUEST['issuerUsername']);
// get user IDs by username
if ($this->filterUsername != null) $this->filterUserID = \wcf\data\user\UserProfile::getUserProfileByUsername($this->filterUsername)->userID;
if ($this->filterIssuerUsername != null) $this->filterIssuerUserID = \wcf\data\user\UserProfile::getUserProfileByUsername($this->filterIssuerUsername)->userID;
// get user IDs by request if no username was sent
if ($this->filterUserID === null && isset($_REQUEST['userID']) && !empty($_REQUEST['userID'])) $this->filterUserID = intval($_REQUEST['userID']);
if ($this->filterIssuerUserID === null && isset($_REQUEST['issuerUserID']) && !empty($_REQUEST['issuerUserID'])) $this->filterIssuerUserID = intval($_REQUEST['issuerUserID']);
// get usernames by ID if no usernames were sent
if ($this->filterUsername === null) $this->filterUsername = \wcf\data\user\UserProfile::getUserProfile($this->filterUserID);
if ($this->filterIssuerUsername === null) $this->filterIssuerUsername = \wcf\data\user\UserProfile::getUserProfile($this->filterIssuerUserID);
// get room IDs by request
if (isset($_REQUEST['roomID']) && $_REQUEST['roomID'] != -1) $this->filterRoomID = intval($_REQUEST['roomID']);
if (isset($_REQUEST['suspensionType']) && !empty($_REQUEST['suspensionType'])) $this->filterSuspensionType = intval($_REQUEST['suspensionType']);
// display revoked
if (isset($_REQUEST['displayRevoked'])) $this->displayRevoked = intval($_REQUEST['displayRevoked']);
}
/**
* @see wcf\page\IPage::assignVariables()
*/
public function assignVariables() {
parent::assignVariables();
WCF::getTPL()->assign(array(
'availableRooms' => \chat\data\room\RoomCache::getInstance()->getRooms(),
'roomID' => ($this->filterRoomID !== null) ? $this->filterRoomID : -1,
'username' => $this->filterUsername,
'issuerUsername' => $this->filterIssuerUsername,
'suspensionType' => $this->filterSuspensionType,
'userID' => $this->filterUserID,
'issuerUserID' => $this->filterIssuerUserID,
'displayRevoked' => $this->displayRevoked
));
}
/**
* @see \wcf\page\MultipleLinkPage::readObjects()
*/
protected function initObjectList() {
parent::initObjectList();
$this->objectList->sqlSelects .= "user_table.username, user_table2.username AS issuerUsername, user_table3.username AS revokerUsername, room_table.title AS roomTitle";
$this->objectList->sqlJoins .= "
LEFT JOIN wcf".WCF_N."_user user_table
ON suspension.userID = user_table.userID
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";
$conditionJoins = " LEFT JOIN chat".WCF_N."_room room_table
ON suspension.roomID = room_table.roomID";
$this->objectList->sqlConditionJoins .= $conditionJoins;
$this->objectList->sqlJoins .= $conditionJoins;
if (!$this->displayRevoked) {
$this->objectList->getConditionBuilder()->add('expires > ?', array(TIME_NOW));
}
$this->objectList->getConditionBuilder()->add('(room_table.permanent = ? OR suspension.roomID IS NULL)', array(1));
if ($this->filterSuspensionType !== null) $this->objectList->getConditionBuilder()->add('suspension.type = ?', array($this->filterSuspensionType));
if ($this->filterUserID !== null) $this->objectList->getConditionBuilder()->add('suspension.userID = ?', array($this->filterUserID));
if ($this->filterIssuerUserID !== null) $this->objectList->getConditionBuilder()->add('suspension.issuer = ?', array($this->filterIssuerUserID));
if ($this->filterRoomID !== null) {
if ($this->filterRoomID === 0) {
$this->objectList->getConditionBuilder()->add('suspension.roomID IS NULL', array());
}
else {
$this->objectList->getConditionBuilder()->add('suspension.roomID = ?', array($this->filterRoomID));
}
}
}
}

View File

@ -39,26 +39,33 @@ public function __toString() {
public function canEnter(\wcf\data\user\User $user = null) {
if ($user === null) $user = WCF::getUser();
if (!$user->userID) return false;
$user = new \wcf\data\user\UserProfile($user);
$ph = new \chat\system\permission\PermissionHandler($user);
$suspensions = Suspension::getSuspensionsForUser($user);
if ($user->getPermission('admin.chat.canManageSuspensions')) return true;
if ($user->getPermission('mod.chat.canGban')) return true;
$canEnter = $ph->getPermission($this, 'user.canEnter');
$ph = new \chat\system\permission\PermissionHandler($user->getDecoratedObject());
if ($ph->getPermission($this, 'mod.canAlwaysEnter')) return true;
if ($ph->getPermission($this, 'mod.canBan')) return true;
if (!$ph->getPermission($this, 'user.canEnter')) return false;
$suspensions = Suspension::getSuspensionsForUser($user->getDecoratedObject());
// room suspension
if ($canEnter && isset($suspensions[$this->roomID][Suspension::TYPE_BAN])) {
if (isset($suspensions[$this->roomID][Suspension::TYPE_BAN])) {
if ($suspensions[$this->roomID][Suspension::TYPE_BAN]->isValid()) {
$canEnter = false;
return false;
}
}
// global suspension
if ($canEnter && isset($suspensions[null][Suspension::TYPE_BAN])) {
if (isset($suspensions[null][Suspension::TYPE_BAN])) {
if ($suspensions[null][Suspension::TYPE_BAN]->isValid()) {
$canEnter = false;
return false;
}
}
return $canEnter || $ph->getPermission($this, 'mod.canAlwaysEnter');
return true;
}
/**
@ -70,26 +77,33 @@ public function canEnter(\wcf\data\user\User $user = null) {
public function canWrite(\wcf\data\user\User $user = null) {
if ($user === null) $user = WCF::getUser();
if (!$user->userID) return false;
$user = new \wcf\data\user\UserProfile($user);
$ph = new \chat\system\permission\PermissionHandler($user);
$suspensions = Suspension::getSuspensionsForUser($user);
if ($user->getPermission('admin.chat.canManageSuspensions')) return true;
if ($user->getPermission('mod.chat.canGmute')) return true;
$canWrite = $ph->getPermission($this, 'user.canWrite');
$ph = new \chat\system\permission\PermissionHandler($user->getDecoratedObject());
if ($ph->getPermission($this, 'mod.canAlwaysWrite')) return true;
if ($ph->getPermission($this, 'mod.canMute')) return true;
if (!$ph->getPermission($this, 'user.canWrite')) return false;
$suspensions = Suspension::getSuspensionsForUser($user->getDecoratedObject());
// room suspension
if ($canWrite && isset($suspensions[$this->roomID][Suspension::TYPE_MUTE])) {
if (isset($suspensions[$this->roomID][Suspension::TYPE_MUTE])) {
if ($suspensions[$this->roomID][Suspension::TYPE_MUTE]->isValid()) {
$canWrite = false;
return false;
}
}
// global suspension
if ($canWrite && isset($suspensions[null][Suspension::TYPE_MUTE])) {
if (isset($suspensions[null][Suspension::TYPE_MUTE])) {
if ($suspensions[null][Suspension::TYPE_MUTE]->isValid()) {
$canWrite = false;
return false;
}
}
return $canWrite || $ph->getPermission($this, 'mod.canAlwaysWrite');
return true;
}
/**

View File

@ -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,36 @@ 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();
$user = new \wcf\data\user\UserProfile($user);
$ph = new \chat\system\permission\PermissionHandler($user->getDecoratedObject());
if ($user->getPermission('admin.chat.canManageSuspensions')) return true;
if ($user->getPermission('mod.chat.canG'.$this->type)) return true;
if (!$this->roomID) 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).
*
@ -53,15 +83,17 @@ public static function getSuspensionsForUser(\wcf\data\user\User $user = null) {
if ($suspensions === false) throw new \wcf\system\exception\SystemException();
}
catch (\wcf\system\exception\SystemException $e) {
$condition = new \wcf\system\database\util\PreparedStatementConditionBuilder();
$condition->add('userID = ?', array($user->userID));
$condition->add('expires > ?', array(TIME_NOW));
$sql = "SELECT
*
FROM
chat".WCF_N."_suspension
WHERE
userID = ?
AND expires > ?";
".$condition;
$stmt = WCF::getDB()->prepareStatement($sql);
$stmt->execute(array($user->userID, TIME_NOW));
$stmt->execute($condition->getParameters());
$suspensions = array();
while ($suspension = $stmt->fetchObject('\chat\data\suspension\Suspension')) {
@ -76,7 +108,7 @@ public static function getSuspensionsForUser(\wcf\data\user\User $user = null) {
/**
* Returns the appropriate suspension for user, room and type.
* Returns false if no suspension was found.
* Returns false if no active suspension was found.
*
* @param \wcf\data\user\User $user
* @param \chat\data\room\Room $room
@ -84,23 +116,21 @@ public static function getSuspensionsForUser(\wcf\data\user\User $user = null) {
* @return \chat\data\suspension\Suspension
*/
public static function getSuspensionByUserRoomAndType(\wcf\data\user\User $user, \chat\data\room\Room $room, $type) {
$condition = new \wcf\system\database\util\PreparedStatementConditionBuilder();
$condition->add('userID = ?', array($user->userID));
$condition->add('type = ?', array($type));
$condition->add('expires > ?', array(TIME_NOW));
if ($room->roomID) $condition->add('roomID = ?', array($room->roomID));
else $condition->add('roomID IS NULL');
$sql = "SELECT
*
FROM
chat".WCF_N."_suspension
WHERE
userID = ?
AND type = ?";
$parameter = array($user->userID, $type);
if ($room->roomID) {
$sql .= " AND roomID = ?";
$parameter[] = $room->roomID;
}
else $sql .= " AND roomID IS NULL";
".$condition;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($parameter);
$statement->execute($condition->getParameters());
$row = $statement->fetchArray();
if (!$row) return false;

View File

@ -1,5 +1,6 @@
<?php
namespace chat\data\suspension;
use \wcf\system\WCF;
/**
* Executes chat-suspension-related actions.
@ -17,23 +18,28 @@ class SuspensionAction extends \wcf\data\AbstractDatabaseObjectAction {
protected $className = '\chat\data\suspension\SuspensionEditor';
/**
* Deletes expired suspensions.
*
* @return integer Number of deleted suspensions
* Validates permissions and parameters
*/
public function prune() {
$sql = "SELECT
".call_user_func(array($this->className, 'getDatabaseTableIndexName'))."
FROM
".call_user_func(array($this->className, 'getDatabaseTableName'))."
WHERE
expires < ?";
$stmt = \wcf\system\WCF::getDB()->prepareStatement($sql);
$stmt->execute(array(TIME_NOW));
$objectIDs = array();
public function validateRevoke() {
WCF::getSession()->checkPermissions((array) 'admin.chat.canManageSuspensions');
while ($objectID = $stmt->fetchColumn()) $objectIDs[] = $objectID;
$this->parameters['revoker'] = WCF::getUser()->userID;
}
return call_user_func(array($this->className, 'deleteAll'), $objectIDs);
/**
* Revokes suspensions.
*/
public function revoke() {
if (!isset($this->parameters['revoker'])) {
$this->parameters['revoker'] = null;
}
$objectAction = new self($this->objectIDs, 'update', array(
'data' => array(
'expires' => TIME_NOW,
'revoker' => $this->parameters['revoker']
)
));
$objectAction->executeAction();
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace chat\data\suspension;
/**
* Represents a list of chat suspensions.
*
* @author Maximilian Mader
* @copyright 2010-2013 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package be.bastelstu.chat
* @subpackage data.suspension
*/
class SuspensionList extends \wcf\data\DatabaseObjectList {
/**
* @see wcf\data\DatabaseObjectList::$className
*/
public $className = 'chat\data\suspension\Suspension';
}

View File

@ -0,0 +1,126 @@
<?php
namespace chat\system\command;
use \chat\data\suspension;
use \chat\util\ChatUtil;
use \wcf\data\user\User;
use \wcf\system\WCF;
/**
* Default implementation for suspension commands
*
* @author Tim Düsterhus
* @copyright 2010-2013 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package be.bastelstu.chat
* @subpackage system.chat.command
*/
abstract class AbstractSuspensionCommand extends AbstractRestrictedCommand {
public $user = null;
public $expires = 0;
public $suspensionAction = null;
public $link = '';
public $room = null;
public $reason = '';
public function __construct(\chat\system\command\CommandHandler $commandHandler) {
parent::__construct($commandHandler);
try {
$parameters = explode(',', $commandHandler->getParameters(), 3);
list($username, $modifier) = $parameters;
if (isset($parameters[2])) {
$this->reason = \wcf\util\StringUtil::trim($parameters[2]);
}
$modifier = ChatUtil::timeModifier(\wcf\util\StringUtil::trim($modifier));
$expires = strtotime($modifier, TIME_NOW);
$this->expires = min(max(-0x80000000, $expires), 0x7FFFFFFF);
}
catch (\wcf\system\exception\SystemException $e) {
throw new \InvalidArgumentException();
}
$this->user = User::getUserByUsername($username);
if (!$this->user->userID) throw new \chat\system\command\UserNotFoundException($username);
$profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array(
'object' => $this->user
));
$this->link = "[url='".$profile."']".$this->user->username.'[/url]';
$this->executeAction();
$this->didInit();
}
public function executeAction() {
if (static::IS_GLOBAL) $room = new \chat\data\room\Room(null, array('roomID' => null));
else $room = $this->room;
if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $room, static::SUSPENSION_TYPE)) {
if ($suspension->expires >= $this->expires) {
throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists'));
}
$action = new suspension\SuspensionAction(array($suspension), 'revoke', array(
'revoker' => WCF::getUser()->userID
));
$action->executeAction();
}
$this->suspensionAction = new suspension\SuspensionAction(array(), 'create', array(
'data' => array(
'userID' => $this->user->userID,
'roomID' => $room->roomID ?: null,
'type' => static::SUSPENSION_TYPE,
'expires' => $this->expires,
'time' => TIME_NOW,
'issuer' => WCF::getUser()->userID,
'reason' => $this->reason
)
));
$this->suspensionAction->executeAction();
}
/**
* @see \chat\system\command\IRestrictedChatCommand::checkPermission()
*/
public function checkPermission() {
parent::checkPermission();
$this->room = $this->commandHandler->getRoom();
if (WCF::getSession()->getPermission('admin.chat.canManageSuspensions')) return;
$ph = new \chat\system\permission\PermissionHandler();
if (static::IS_GLOBAL) {
WCF::getSession()->checkPermissions((array) 'mod.chat.canG'.static::SUSPENSION_TYPE);
}
else {
if (!WCF::getSession()->getPermission('mod.chat.canG'.static::SUSPENSION_TYPE)) {
if (!$ph->getPermission($this->room, 'mod.can'.ucfirst(static::SUSPENSION_TYPE))) {
throw new \wcf\system\exception\PermissionDeniedException();
}
}
}
}
/**
* @see \chat\system\command\ICommand::getType()
*/
public function getType() {
return \chat\data\message\Message::TYPE_MODERATE;
}
/**
* @see \chat\system\command\ICommand::getMessage()
*/
public function getMessage() {
return serialize(array(
'link' => $this->link,
'expires' => $this->expires,
'type' => (static::IS_GLOBAL ? 'g' : '').static::SUSPENSION_TYPE,
'reason' => $this->reason
));
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace chat\system\command;
use \chat\data\suspension;
use \chat\util\ChatUtil;
use \wcf\data\user\User;
use \wcf\system\WCF;
/**
* Default implementation for suspension commands
*
* @author Tim Düsterhus
* @copyright 2010-2013 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package be.bastelstu.chat
* @subpackage system.chat.command
*/
abstract class AbstractUnsuspensionCommand extends AbstractRestrictedCommand {
public $user = null;
public $suspensionAction = null;
public $link = '';
public $room = null;
public function __construct(\chat\system\command\CommandHandler $commandHandler) {
parent::__construct($commandHandler);
$username = rtrim($commandHandler->getParameters(), ',');
$this->user = User::getUserByUsername($username);
if (!$this->user->userID) throw new \chat\system\command\UserNotFoundException($username);
$profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array(
'object' => $this->user
));
$this->link = "[url='".$profile."']".$this->user->username.'[/url]';
$this->executeAction();
$this->didInit();
}
public function executeAction() {
if (static::IS_GLOBAL) $room = new \chat\data\room\Room(null, array('roomID' => null));
else $room = $this->room;
if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $room, static::SUSPENSION_TYPE)) {
$action = new suspension\SuspensionAction(array($suspension), 'revoke', array(
'revoker' => WCF::getUser()->userID
));
$action->executeAction();
}
else {
throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.notExists'));
}
}
/**
* @see \chat\system\command\IRestrictedChatCommand::checkPermission()
*/
public function checkPermission() {
parent::checkPermission();
$this->room = $this->commandHandler->getRoom();
if (WCF::getSession()->getPermission('admin.chat.canManageSuspensions')) return;
$ph = new \chat\system\permission\PermissionHandler();
if (static::IS_GLOBAL) {
WCF::getSession()->checkPermission((array) 'mod.chat.canG'.static::SUSPENSION_TYPE);
}
else {
if (!WCF::getSession()->getPermission('mod.chat.canG'.static::SUSPENSION_TYPE)) {
if (!$ph->getPermission($this->room, 'mod.can'.ucfirst(static::SUSPENSION_TYPE))) {
throw new \wcf\system\exception\PermissionDeniedException();
}
}
}
}
/**
* @see \chat\system\command\ICommand::getType()
*/
public function getType() {
return \chat\data\message\Message::TYPE_MODERATE;
}
/**
* @see \chat\system\command\ICommand::getMessage()
*/
public function getMessage() {
return serialize(array(
'link' => $this->link,
'type' => 'un'.(static::IS_GLOBAL ? 'g' : '').static::SUSPENSION_TYPE,
));
}
}

View File

@ -36,11 +36,4 @@ public function getType() {
public function getMessage() {
return \wcf\system\bbcode\PreParser::getInstance()->parse($this->commandHandler->getParameters(), explode(',', WCF::getSession()->getPermission('user.chat.allowedBBCodes')));
}
/**
* @see \chat\system\command\ICommand::getReceiver()
*/
public function getReceiver() {
return WCF::getUser()->userID;
}
}

View File

@ -1,9 +1,5 @@
<?php
namespace chat\system\command\commands;
use \chat\data\suspension;
use \chat\util\ChatUtil;
use \wcf\data\user\User;
use \wcf\system\WCF;
/**
* Bans a user.
@ -14,25 +10,7 @@
* @package be.bastelstu.chat
* @subpackage system.chat.command.commands
*/
class BanCommand extends MuteCommand {
public function executeAction() {
if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $this->room, suspension\Suspension::TYPE_BAN)) {
if ($suspension->expires > $this->expires) {
throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists'));
}
$action = new suspension\SuspensionAction(array($suspension), 'delete');
$action->executeAction();
}
$this->suspensionAction = new suspension\SuspensionAction(array(), 'create', array(
'data' => array(
'userID' => $this->user->userID,
'roomID' => WCF::getUser()->chatRoomID,
'type' => suspension\Suspension::TYPE_BAN,
'expires' => $this->expires
)
));
$this->suspensionAction->executeAction();
}
class BanCommand extends \chat\system\command\AbstractSuspensionCommand {
const IS_GLOBAL = false;
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN;
}

View File

@ -1,9 +1,5 @@
<?php
namespace chat\system\command\commands;
use \chat\data\suspension;
use \chat\util\ChatUtil;
use \wcf\data\user\User;
use \wcf\system\WCF;
/**
* Globally bans a user.
@ -14,27 +10,7 @@
* @package be.bastelstu.chat
* @subpackage system.chat.command.commands
*/
class GbanCommand extends MuteCommand {
public function executeAction() {
$room = new \chat\data\room\Room(null, array('roomID' => null));
if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $room, suspension\Suspension::TYPE_BAN)) {
if ($suspension->expires > $this->expires) {
throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists'));
}
$action = new suspension\SuspensionAction(array($suspension), 'delete');
$action->executeAction();
}
$this->suspensionAction = new suspension\SuspensionAction(array(), 'create', array(
'data' => array(
'userID' => $this->user->userID,
'roomID' => null,
'type' => suspension\Suspension::TYPE_BAN,
'expires' => $this->expires
)
));
$this->suspensionAction->executeAction();
}
class GbanCommand extends \chat\system\command\AbstractSuspensionCommand {
const IS_GLOBAL = true;
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN;
}

View File

@ -1,12 +1,8 @@
<?php
namespace chat\system\command\commands;
use \chat\data\suspension;
use \chat\util\ChatUtil;
use \wcf\data\user\User;
use \wcf\system\WCF;
/**
* Globally bans a user.
* Globally mutes a user.
*
* @author Tim Düsterhus
* @copyright 2010-2013 Tim Düsterhus
@ -14,27 +10,7 @@
* @package be.bastelstu.chat
* @subpackage system.chat.command.commands
*/
class GmuteCommand extends MuteCommand {
public function executeAction() {
$room = new \chat\data\room\Room(null, array('roomID' => null));
if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $room, suspension\Suspension::TYPE_MUTE)) {
if ($suspension->expires > $this->expires) {
throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists'));
}
$action = new suspension\SuspensionAction(array($suspension), 'delete');
$action->executeAction();
}
$this->suspensionAction = new suspension\SuspensionAction(array(), 'create', array(
'data' => array(
'userID' => $this->user->userID,
'roomID' => null,
'type' => suspension\Suspension::TYPE_MUTE,
'expires' => $this->expires
)
));
$this->suspensionAction->executeAction();
}
class GmuteCommand extends \chat\system\command\AbstractSuspensionCommand {
const IS_GLOBAL = true;
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE;
}

View File

@ -1,32 +0,0 @@
<?php
namespace chat\system\command\commands;
use \chat\data\suspension;
use \chat\util\ChatUtil;
use \wcf\data\user\User;
use \wcf\system\WCF;
/**
* Unbans a user globally.
*
* @author Tim Düsterhus
* @copyright 2010-2013 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package be.bastelstu.chat
* @subpackage system.chat.command.commands
*/
class GunbanCommand extends UnmuteCommand {
/**
* @see \chat\system\command\commands\UnmuteCommand::executeAction()
*/
public function executeAction() {
$room = new \chat\data\room\Room(null, array('roomID' => null));
if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $room, suspension\Suspension::TYPE_BAN)) {
$action = new suspension\SuspensionAction(array($suspension), 'delete');
$action->executeAction();
}
else {
throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.notExists'));
}
}
}

View File

@ -1,32 +0,0 @@
<?php
namespace chat\system\command\commands;
use \chat\data\suspension;
use \chat\util\ChatUtil;
use \wcf\data\user\User;
use \wcf\system\WCF;
/**
* Unmutes a user globally.
*
* @author Tim Düsterhus
* @copyright 2010-2013 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package be.bastelstu.chat
* @subpackage system.chat.command.commands
*/
class GunmuteCommand extends UnmuteCommand {
/**
* @see \chat\system\command\commands\UnmuteCommand::executeAction()
*/
public function executeAction() {
$room = new \chat\data\room\Room(null, array('roomID' => null));
if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $room, suspension\Suspension::TYPE_MUTE)) {
$action = new suspension\SuspensionAction(array($suspension), 'delete');
$action->executeAction();
}
else {
throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.notExists'));
}
}
}

View File

@ -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(

View File

@ -1,9 +1,5 @@
<?php
namespace chat\system\command\commands;
use \chat\data\suspension;
use \chat\util\ChatUtil;
use \wcf\data\user\User;
use \wcf\system\WCF;
/**
* Mutes a user.
@ -14,86 +10,7 @@
* @package be.bastelstu.chat
* @subpackage system.chat.command.commands
*/
class MuteCommand extends \chat\system\command\AbstractRestrictedCommand {
public $user = null;
public $expires = 0;
public $suspensionAction = null;
public $link = '';
public $room = null;
public function __construct(\chat\system\command\CommandHandler $commandHandler) {
parent::__construct($commandHandler);
try {
list($username, $modifier) = explode(',', $commandHandler->getParameters(), 2);
$modifier = ChatUtil::timeModifier(\wcf\util\StringUtil::trim($modifier));
$expires = strtotime($modifier, TIME_NOW);
$this->expires = min(max(-0x80000000, $expires), 0x7FFFFFFF);
}
catch (\wcf\system\exception\SystemException $e) {
throw new \InvalidArgumentException();
}
$this->user = User::getUserByUsername($username);
if (!$this->user->userID) throw new \chat\system\command\UserNotFoundException($username);
$profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array(
'object' => $this->user
));
$this->link = "[url='".$profile."']".$this->user->username.'[/url]';
$this->executeAction();
$this->didInit();
}
public function executeAction() {
if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $this->room, suspension\Suspension::TYPE_MUTE)) {
if ($suspension->expires > $this->expires) {
throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists'));
}
$action = new suspension\SuspensionAction(array($suspension), 'delete');
$action->executeAction();
}
$this->suspensionAction = new suspension\SuspensionAction(array(), 'create', array(
'data' => array(
'userID' => $this->user->userID,
'roomID' => WCF::getUser()->chatRoomID,
'type' => suspension\Suspension::TYPE_MUTE,
'expires' => $this->expires
)
));
$this->suspensionAction->executeAction();
}
/**
* @see \chat\system\command\IRestrictedChatCommand::checkPermission()
*/
public function checkPermission() {
parent::checkPermission();
$this->room = $this->commandHandler->getRoom();
$ph = new \chat\system\permission\PermissionHandler();
if (!$ph->getPermission($this->room, 'mod.can'.str_replace(array('chat\system\command\commands\\', 'Command'), '', get_class($this)))) throw new \wcf\system\exception\PermissionDeniedException();
}
/**
* @see \chat\system\command\ICommand::getType()
*/
public function getType() {
return \chat\data\message\Message::TYPE_MODERATE;
}
/**
* @see \chat\system\command\ICommand::getMessage()
*/
public function getMessage() {
return serialize(array(
'link' => $this->link,
'expires' => $this->expires,
'type' => str_replace(array('chat\system\command\commands\\', 'command'), '', strtolower(get_class($this)))
));
}
class MuteCommand extends \chat\system\command\AbstractSuspensionCommand {
const IS_GLOBAL = false;
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE;
}

View File

@ -1,9 +1,5 @@
<?php
namespace chat\system\command\commands;
use \chat\data\suspension;
use \chat\util\ChatUtil;
use \wcf\data\user\User;
use \wcf\system\WCF;
/**
* Bans a user.
@ -14,17 +10,7 @@
* @package be.bastelstu.chat
* @subpackage system.chat.command.commands
*/
class UnbanCommand extends UnmuteCommand {
/**
* @see \chat\system\command\commands\UnmuteCommand::executeAction()
*/
public function executeAction() {
if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $this->room, suspension\Suspension::TYPE_BAN)) {
$action = new suspension\SuspensionAction(array($suspension), 'delete');
$action->executeAction();
}
else {
throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.notExists'));
}
}
class UnbanCommand extends \chat\system\command\AbstractUnsuspensionCommand {
const IS_GLOBAL = false;
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN;
}

View File

@ -0,0 +1,16 @@
<?php
namespace chat\system\command\commands;
/**
* Unbans a user globally.
*
* @author Tim Düsterhus
* @copyright 2010-2013 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package be.bastelstu.chat
* @subpackage system.chat.command.commands
*/
class UngbanCommand extends \chat\system\command\AbstractUnsuspensionCommand {
const IS_GLOBAL = true;
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN;
}

View File

@ -0,0 +1,16 @@
<?php
namespace chat\system\command\commands;
/**
* Unmutes a user globally.
*
* @author Tim Düsterhus
* @copyright 2010-2013 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package be.bastelstu.chat
* @subpackage system.chat.command.commands
*/
class UngmuteCommand extends \chat\system\command\AbstractUnsuspensionCommand {
const IS_GLOBAL = true;
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE;
}

View File

@ -1,8 +1,5 @@
<?php
namespace chat\system\command\commands;
use \chat\data\suspension;
use \wcf\data\user\User;
use \wcf\system\WCF;
/**
* Unmutes a user.
@ -13,67 +10,7 @@
* @package be.bastelstu.chat
* @subpackage system.chat.command.commands
*/
class UnmuteCommand extends \chat\system\command\AbstractRestrictedCommand {
public $user = null;
public $suspensionAction = null;
public $link = '';
public $room = null;
public function __construct(\chat\system\command\CommandHandler $commandHandler) {
parent::__construct($commandHandler);
$username = rtrim($commandHandler->getParameters(), ',');
$this->user = User::getUserByUsername($username);
if (!$this->user->userID) throw new \chat\system\command\UserNotFoundException($username);
$profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array(
'object' => $this->user
));
$this->link = "[url='".$profile."']".$this->user->username.'[/url]';
$this->executeAction();
$this->didInit();
}
/**
* Removes the suspension.
*/
public function executeAction() {
if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $this->room, suspension\Suspension::TYPE_MUTE)) {
$action = new suspension\SuspensionAction(array($suspension), 'delete');
$action->executeAction();
}
else {
throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.notExists'));
}
}
/**
* @see \chat\system\command\IRestrictedChatCommand::checkPermission()
*/
public function checkPermission() {
parent::checkPermission();
$this->room = $this->commandHandler->getRoom();
$ph = new \chat\system\permission\PermissionHandler();
if (!$ph->getPermission($this->room, 'mod.can'.ucfirst(str_replace(array('chat\system\command\commands\\Un', 'Command'), '', get_class($this))))) throw new \wcf\system\exception\PermissionDeniedException();
}
/**
* @see \chat\system\command\ICommand::getType()
*/
public function getType() {
return \chat\data\message\Message::TYPE_MODERATE;
}
/**
* @see \chat\system\command\ICommand::getMessage()
*/
public function getMessage() {
return serialize(array(
'link' => $this->link,
'type' => str_replace(array('chat\system\command\commands\\', 'command'), '', strtolower(get_class($this)))
));
}
class UnmuteCommand extends \chat\system\command\AbstractUnsuspensionCommand {
const IS_GLOBAL = false;
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE;
}

View File

@ -20,8 +20,6 @@ public function execute(\wcf\data\cronjob\Cronjob $cronjob) {
$messageAction->executeAction();
$roomAction = new data\room\RoomAction(array(), 'prune');
$roomAction->executeAction();
$suspensionAction = new data\suspension\SuspensionAction(array(), 'prune');
$suspensionAction->executeAction();
// kill dead users
$roomAction = new data\room\RoomAction(array(), 'removeDeadUsers');

View File

@ -46,10 +46,14 @@ 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,
reason VARCHAR(255) NOT NULL DEFAULT '',
revoker INT(10) DEFAULT NULL,
UNIQUE KEY suspension (userID, roomID, type),
KEY suspension (userID, roomID, type),
KEY (roomID),
KEY (type),
KEY (expires)
@ -70,10 +74,12 @@ ALTER TABLE chat1_room ADD FOREIGN KEY (owner) REFERENCES wcf1_user (userID) ON
ALTER TABLE chat1_suspension ADD FOREIGN KEY (userID) REFERENCES wcf1_user (userID) ON DELETE CASCADE;
ALTER TABLE chat1_suspension ADD FOREIGN KEY (roomID) REFERENCES chat1_room (roomID) ON DELETE CASCADE;
ALTER TABLE chat1_suspension ADD FOREIGN KEY (issuer) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
ALTER TABLE chat1_suspension ADD FOREIGN KEY (revoker) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
ALTER TABLE wcf1_user ADD FOREIGN KEY (chatRoomID) REFERENCES chat1_room (roomID) ON DELETE SET NULL;
INSERT INTO chat1_room (title, topic, showOrder) VALUES ('chat.room.title1', 'chat.room.topic1', 1);
INSERT INTO chat1_room (title, topic, showOrder) VALUES ('Testroom 2', 'Topic of Testroom 2', 2);
INSERT INTO chat1_room (title, topic, showOrder) VALUES ('Testroom with a very long', 'The topic of this room is rather loing as well!', 3);
INSERT INTO chat1_room (title, topic, showOrder) VALUES ('Testroom with a very long name', 'The topic of this room is rather loing as well!', 3);
INSERT INTO chat1_room (title, topic, showOrder) VALUES ('Room w/o topic', '', 4);

View File

@ -11,10 +11,32 @@
<item name="chat.acp.room.delete.sure"><![CDATA[Wollen Sie den Raum „{$chatRoom}“ wirklich löschen?]]></item>
</category>
<category name="chat.acp.suspension">
<item name="chat.acp.suspension.list"><![CDATA[Sanktionen]]></item>
<item name="chat.acp.suspension.type"><![CDATA[Art der Sanktion]]></item>
<item name="chat.acp.suspension.issuer"><![CDATA[Aussteller]]></item>
<item name="chat.acp.suspension.displayRevoked"><![CDATA[Abgelaufene Sanktionen anzeigen]]></item>
<item name="chat.acp.suspension.reason"><![CDATA[Grund]]></item>
<item name="chat.acp.suspension.revoked"><![CDATA[Zurückziehen]]></item>
<item name="chat.acp.suspension.revokedBy"><![CDATA[Zurückgezogen von {$suspension->revokerUsername}]]></item>
</category>
<category name="chat.acp.menu">
<item name="chat.acp.menu.link"><![CDATA[Chat]]></item>
<item name="chat.acp.menu.link.room.list"><![CDATA[Chaträume auflisten]]></item>
<item name="chat.acp.menu.link.room.add"><![CDATA[Chatraum hinzufügen]]></item>
<item name="chat.acp.menu.link.suspension.list"><![CDATA[Sanktionen auflisten]]></item>
</category>
<category name="wcf.acl.option">
<item name="wcf.acl.option.category.be.bastelstu.chat.room.user"><![CDATA[Benutzerrechte]]></item>
<item name="wcf.acl.option.category.be.bastelstu.chat.room.mod"><![CDATA[Moderative Rechte]]></item>
<item name="wcf.acl.option.be.bastelstu.chat.room.user.canEnter"><![CDATA[Kann Raum betreten]]></item>
<item name="wcf.acl.option.be.bastelstu.chat.room.user.canWrite"><![CDATA[Kann schreiben]]></item>
<item name="wcf.acl.option.be.bastelstu.chat.room.mod.canAlwaysEnter"><![CDATA[Kann Raum immer betreten]]></item>
<item name="wcf.acl.option.be.bastelstu.chat.room.mod.canAlwaysWrite"><![CDATA[Kann immer schreiben]]></item>
<item name="wcf.acl.option.be.bastelstu.chat.room.mod.canMute"><![CDATA[Kann knebeln]]></item>
<item name="wcf.acl.option.be.bastelstu.chat.room.mod.canBan"><![CDATA[Kann bannen]]></item>
</category>
<category name="wcf.acp.group">
@ -24,12 +46,24 @@
<item name="wcf.acp.group.option.user.chat.canTempRoom"><![CDATA[Kann temporäre Räume erstellen]]></item>
<item name="wcf.acp.group.option.category.mod.chat"><![CDATA[Chat]]></item>
<item name="wcf.acp.group.option.mod.chat.canAlwaysEnter"><![CDATA[Kann jeden Raum betreten]]></item>
<item name="wcf.acp.group.option.mod.chat.canAlwaysEnter"><![CDATA[Kann Räume immer betreten]]></item>
<item name="wcf.acp.group.option.mod.chat.canAlwaysEnter.description"><![CDATA[Setzt Banns außer Kraft.]]></item>
<item name="wcf.acp.group.option.mod.chat.canAlwaysWrite"><![CDATA[Kann in jedem Raum schreiben]]></item>
<item name="wcf.acp.group.option.mod.chat.canAlwaysWrite"><![CDATA[Kann immer schreiben]]></item>
<item name="wcf.acp.group.option.mod.chat.canAlwaysWrite.description"><![CDATA[Setzt Knebel außer Kraft.]]></item>
<item name="wcf.acp.group.option.mod.chat.canRestore"><![CDATA[Kann User zurücksetzen]]></item>
<item name="wcf.acp.group.option.mod.chat.canRestore.description"><![CDATA[Setzt Nutzerdaten (Farbe) zurück.]]></item>
<item name="wcf.acp.group.option.mod.chat.canBan"><![CDATA[Kann bannen]]></item>
<item name="wcf.acp.group.option.mod.chat.canBan.description"><![CDATA[Impliziert „Kann Chat immer betreten“]]></item>
<item name="wcf.acp.group.option.mod.chat.canMute"><![CDATA[Kann knebeln]]></item>
<item name="wcf.acp.group.option.mod.chat.canMute.description"><![CDATA[Impliziert „Kann immer schreiben“]]></item>
<item name="wcf.acp.group.option.mod.chat.canGban"><![CDATA[Kann global bannen]]></item>
<item name="wcf.acp.group.option.mod.chat.canGban.description"><![CDATA[Impliziert „Kann bannen“]]></item>
<item name="wcf.acp.group.option.mod.chat.canGmute"><![CDATA[Kann global knebeln]]></item>
<item name="wcf.acp.group.option.mod.chat.canGmute.description"><![CDATA[Impliziert „Kann knebeln“]]></item>
<item name="wcf.acp.group.option.category.admin.chat"><![CDATA[Chat]]></item>
<item name="wcf.acp.group.option.admin.chat.canManageSuspensions"><![CDATA[Kann Sanktionen verwalten]]></item>
<item name="wcf.acp.group.option.admin.chat.canManageSuspensions.description"><![CDATA[Impliziert „Kann bannen“, „Kann knebeln“, „Kann global bannen“, „Kann global knebeln“ und gegenbenenfalls weitere Rechte.]]></item>
</category>
<category name="wcf.acp.option">
@ -59,7 +93,7 @@
</category>
<category name="chat.error">
<item name="chat.error.notFound"><![CDATA[Der Befehl wurde nicht gefunden.]]></item>
<item name="chat.error.notFound"><![CDATA[Der Befehl „{$exception->getCommand()}“ wurde nicht gefunden.]]></item>
<item name="chat.error.userNotFound"><![CDATA[Der Benutzer „{$exception->getUsername()}“ wurde nicht gefunden.]]></item>
<item name="chat.error.permissionDenied"><![CDATA[Sie dürfen diesen Befehl nicht verwenden.]]></item>
<item name="chat.error.duplicateTab"><![CDATA[Der Chat wurde in einem weiteren Tab geöffnet.]]></item>
@ -68,6 +102,9 @@
</category>
<category name="chat.general">
<item name="chat.general.expires"><![CDATA[Ablaufzeitpunkt]]></item>
<item name="chat.general.time"><![CDATA[Datum]]></item>
<item name="chat.general.title"><![CDATA[{lang}chat.header.menu.chat{/lang}]]></item>
<item name="chat.general.protocol"><![CDATA[Protokoll]]></item>
@ -117,21 +154,21 @@
<item name="chat.message.4"><![CDATA[ist jetzt wieder da.]]></item>
<!-- 5 = TYPE_MODERATE -->
<item name="chat.message.5.restore"><![CDATA[hat {@$link} zurückgesetzt.]]></item>
<item name="chat.message.5.mute"><![CDATA[hat {@$link} bis {@$expires|plainTime} geknebelt.]]></item>
<item name="chat.message.5.ban"><![CDATA[hat {@$link} bis {@$expires|plainTime} gebannt.]]></item>
<item name="chat.message.5.gmute"><![CDATA[hat {@$link} bis {@$expires|plainTime} global geknebelt.]]></item>
<item name="chat.message.5.gban"><![CDATA[hat {@$link} bis {@$expires|plainTime} global gebannt.]]></item>
<item name="chat.message.5.mute"><![CDATA[hat {@$link} bis {@$expires|plainTime} geknebelt{if !$reason|empty}: {$reason}{else}.{/if}]]></item>
<item name="chat.message.5.ban"><![CDATA[hat {@$link} bis {@$expires|plainTime} gebannt{if !$reason|empty}: {$reason}{else}.{/if}]]></item>
<item name="chat.message.5.gmute"><![CDATA[hat {@$link} bis {@$expires|plainTime} global geknebelt{if !$reason|empty}: {$reason}{else}.{/if}]]></item>
<item name="chat.message.5.gban"><![CDATA[hat {@$link} bis {@$expires|plainTime} global gebannt{if !$reason|empty}: {$reason}{else}.{/if}]]></item>
<item name="chat.message.5.unmute"><![CDATA[hat {@$link} entknebelt.]]></item>
<item name="chat.message.5.unban"><![CDATA[hat {@$link} entbannt.]]></item>
<item name="chat.message.5.gunmute"><![CDATA[hat {@$link} global entknebelt.]]></item>
<item name="chat.message.5.gunban"><![CDATA[hat {@$link} global entbannt.]]></item>
<item name="chat.message.5.ungmute"><![CDATA[hat {@$link} global entknebelt.]]></item>
<item name="chat.message.5.ungban"><![CDATA[hat {@$link} global entbannt.]]></item>
<item name="chat.message.color.success"><![CDATA[Die Farbe wurde erfolgreich geändert.]]></item>
</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 -->

View File

@ -49,7 +49,9 @@
<optiontype>textarea</optiontype>
<defaultvalue>afk:away
col:color
msg:whisper</defaultvalue>
msg:whisper
gunban:ungban
gunmute:ungmute</defaultvalue>
</option>
<!-- general chat options end -->

View File

@ -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 58</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>

View File

@ -104,6 +104,12 @@
<defaultvalue>0</defaultvalue>
<admindefaultvalue>1</admindefaultvalue>
</option>
<option name="admin.chat.canManageSuspensions">
<categoryname>admin.chat</categoryname>
<optiontype>boolean</optiontype>
<defaultvalue>0</defaultvalue>
<admindefaultvalue>1</admindefaultvalue>
</option>
</options>
</import>
</data>