diff --git a/acptemplate/chatSuspensionList.tpl b/acptemplate/chatSuspensionList.tpl index a8b6b91..7bba8b0 100644 --- a/acptemplate/chatSuspensionList.tpl +++ b/acptemplate/chatSuspensionList.tpl @@ -84,6 +84,7 @@
{lang}wcf.global.noItems{/lang}
diff --git a/file/lib/acp/page/ChatSuspensionListPage.class.php b/file/lib/acp/page/ChatSuspensionListPage.class.php index 062f8be..23b75c8 100644 --- a/file/lib/acp/page/ChatSuspensionListPage.class.php +++ b/file/lib/acp/page/ChatSuspensionListPage.class.php @@ -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 diff --git a/file/lib/system/command/commands/BanCommand.class.php b/file/lib/system/command/commands/BanCommand.class.php index f090dfa..967e4b0 100644 --- a/file/lib/system/command/commands/BanCommand.class.php +++ b/file/lib/system/command/commands/BanCommand.class.php @@ -1,9 +1,6 @@ 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; } diff --git a/file/lib/system/command/commands/GbanCommand.class.php b/file/lib/system/command/commands/GbanCommand.class.php index 9cd3593..55c3f7e 100644 --- a/file/lib/system/command/commands/GbanCommand.class.php +++ b/file/lib/system/command/commands/GbanCommand.class.php @@ -1,9 +1,6 @@ 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; } diff --git a/file/lib/system/command/commands/GmuteCommand.class.php b/file/lib/system/command/commands/GmuteCommand.class.php index e54a768..812012c 100644 --- a/file/lib/system/command/commands/GmuteCommand.class.php +++ b/file/lib/system/command/commands/GmuteCommand.class.php @@ -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(); diff --git a/file/lib/system/command/commands/MuteCommand.class.php b/file/lib/system/command/commands/MuteCommand.class.php index 2055fe4..59f2072 100644 --- a/file/lib/system/command/commands/MuteCommand.class.php +++ b/file/lib/system/command/commands/MuteCommand.class.php @@ -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 )); } } diff --git a/install.sql b/install.sql index 21148c7..b356ac2 100644 --- a/install.sql +++ b/install.sql @@ -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);