mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Add optional reasons to suspensions
Also use $pageLinks in chatSuspension.tpl and add the missing name to testrooms name
This commit is contained in:
parent
eb27166c6c
commit
3028edba7d
@ -84,6 +84,7 @@
|
||||
<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}{/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}{/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}{/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}{/link}">{lang}chat.acp.suspension.reason{/lang}</a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -97,6 +98,7 @@
|
||||
<td id="columnTime">{$suspension->time|plainTime}</td>
|
||||
<td id="columnExpires">{$suspension->expires|plainTime} ({$suspension->expires|dateDiff})</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>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
@ -104,7 +106,7 @@
|
||||
</div>
|
||||
|
||||
<div class="contentNavigation">
|
||||
{pages print=true assign=pagesLinks application="chat" controller="ChatSuspensionList" link="pageNo=%d&username=$username&issuerUsername=$issuerUsername&roomID=$roomID&suspensionType=$suspensionType"}
|
||||
{@$pagesLinks}
|
||||
</div>
|
||||
{else}
|
||||
<p class="info">{lang}wcf.global.noItems{/lang}</p>
|
||||
|
@ -31,7 +31,7 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage {
|
||||
/**
|
||||
* @see \wcf\page\SortablePage::$validSortFields
|
||||
*/
|
||||
public $validSortFields = array('suspensionID', 'userID', 'username', 'roomID', 'type', 'expires', 'issuer', 'time');
|
||||
public $validSortFields = array('suspensionID', 'userID', 'username', 'roomID', 'type', 'expires', 'issuer', 'time', 'reason');
|
||||
|
||||
/**
|
||||
* @see \wcf\page\MultipleLinkPage::$objectListClassName
|
||||
|
@ -1,9 +1,6 @@
|
||||
<?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.
|
||||
@ -15,26 +12,5 @@
|
||||
* @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,
|
||||
'time' => TIME_NOW,
|
||||
'issuer' => WCF::getUser()->userID
|
||||
)
|
||||
));
|
||||
$this->suspensionAction->executeAction();
|
||||
}
|
||||
const SUSPENSION_TYPE = suspension\Suspension::TYPE_BAN;
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
<?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,29 +11,6 @@
|
||||
* @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,
|
||||
'time' => TIME_NOW,
|
||||
'issuer' => WCF::getUser()->userID
|
||||
)
|
||||
));
|
||||
$this->suspensionAction->executeAction();
|
||||
}
|
||||
class GbanCommand extends GmuteCommand {
|
||||
const SUSPENSION_TYPE = suspension\Suspension::TYPE_BAN;
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ 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) {
|
||||
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'));
|
||||
}
|
||||
|
||||
@ -31,10 +31,11 @@ public function executeAction() {
|
||||
'data' => array(
|
||||
'userID' => $this->user->userID,
|
||||
'roomID' => null,
|
||||
'type' => suspension\Suspension::TYPE_MUTE,
|
||||
'type' => self::SUSPENSION_TYPE,
|
||||
'expires' => $this->expires,
|
||||
'time' => TIME_NOW,
|
||||
'issuer' => WCF::getUser()->userID
|
||||
'issuer' => WCF::getUser()->userID,
|
||||
'reason' => $this->reason
|
||||
)
|
||||
));
|
||||
$this->suspensionAction->executeAction();
|
||||
|
@ -15,17 +15,25 @@
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class MuteCommand extends \chat\system\command\AbstractRestrictedCommand {
|
||||
const SUSPENSION_TYPE = suspension\Suspension::TYPE_MUTE;
|
||||
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 {
|
||||
list($username, $modifier) = explode(',', $commandHandler->getParameters(), 2);
|
||||
$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);
|
||||
@ -48,8 +56,8 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
|
||||
}
|
||||
|
||||
public function executeAction() {
|
||||
if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $this->room, suspension\Suspension::TYPE_MUTE)) {
|
||||
if ($suspension->expires > $this->expires) {
|
||||
if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $this->room, static::SUSPENSION_TYPE)) {
|
||||
if ($suspension->expires >= $this->expires) {
|
||||
throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists'));
|
||||
}
|
||||
|
||||
@ -64,7 +72,8 @@ public function executeAction() {
|
||||
'type' => suspension\Suspension::TYPE_MUTE,
|
||||
'expires' => $this->expires,
|
||||
'time' => TIME_NOW,
|
||||
'issuer' => WCF::getUser()->userID
|
||||
'issuer' => WCF::getUser()->userID,
|
||||
'reason' => $this->reason
|
||||
)
|
||||
));
|
||||
$this->suspensionAction->executeAction();
|
||||
@ -95,7 +104,8 @@ 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)))
|
||||
'type' => str_replace(array('chat\system\command\commands\\', 'command'), '', strtolower(get_class($this))),
|
||||
'message' => $this->suspensionMessage
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ CREATE TABLE chat1_suspension (
|
||||
expires INT(10) NOT NULL,
|
||||
time INT(10) NOT NULL,
|
||||
issuer INT(10) DEFAULT NULL,
|
||||
reason VARCHAR(255) NOT NULL DEFAULT '',
|
||||
|
||||
UNIQUE KEY suspension (userID, roomID, type),
|
||||
KEY (roomID),
|
||||
@ -78,5 +79,5 @@ ALTER TABLE wcf1_user ADD FOREIGN KEY (chatRoomID) REFERENCES chat1_room (roomID
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user