diff --git a/file/lib/system/command/AbstractSuspensionCommand.class.php b/file/lib/system/command/AbstractSuspensionCommand.class.php
new file mode 100644
index 0000000..93f5da2
--- /dev/null
+++ b/file/lib/system/command/AbstractSuspensionCommand.class.php
@@ -0,0 +1,115 @@
+
+ * @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();
+ $ph = new \chat\system\permission\PermissionHandler();
+ if (!$ph->getPermission($this->room, 'mod.can'.ucfirst(static::IDENTIFIER))) 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::IDENTIFIER,
+ 'reason' => $this->reason
+ ));
+ }
+}
diff --git a/file/lib/system/command/AbstractUnsuspensionCommand.class.php b/file/lib/system/command/AbstractUnsuspensionCommand.class.php
new file mode 100644
index 0000000..ba59fcd
--- /dev/null
+++ b/file/lib/system/command/AbstractUnsuspensionCommand.class.php
@@ -0,0 +1,82 @@
+
+ * @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();
+ $ph = new \chat\system\permission\PermissionHandler();
+ if (!$ph->getPermission($this->room, 'mod.can'.ucfirst(static::IDENTIFIER))) 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::IDENTIFIER
+ ));
+ }
+}
diff --git a/file/lib/system/command/commands/BanCommand.class.php b/file/lib/system/command/commands/BanCommand.class.php
index 967e4b0..c2d7ef3 100644
--- a/file/lib/system/command/commands/BanCommand.class.php
+++ b/file/lib/system/command/commands/BanCommand.class.php
@@ -1,6 +1,5 @@
null));
-
- 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' => null,
- 'type' => static::SUSPENSION_TYPE,
- 'expires' => $this->expires,
- 'time' => TIME_NOW,
- 'issuer' => WCF::getUser()->userID,
- 'reason' => $this->reason
- )
- ));
- $this->suspensionAction->executeAction();
- }
+class GmuteCommand extends \chat\system\command\AbstractSuspensionCommand {
+ const IDENTIFIER = 'gmute';
+ const IS_GLOBAL = true;
+ const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE;
}
diff --git a/file/lib/system/command/commands/GunbanCommand.class.php b/file/lib/system/command/commands/GunbanCommand.class.php
deleted file mode 100644
index 04e7eb2..0000000
--- a/file/lib/system/command/commands/GunbanCommand.class.php
+++ /dev/null
@@ -1,34 +0,0 @@
-
- * @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), 'revoke', array(
- 'revoker' => WCF::getUser()->userID
- ));
- $action->executeAction();
- }
- else {
- throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.notExists'));
- }
- }
-}
diff --git a/file/lib/system/command/commands/GunmuteCommand.class.php b/file/lib/system/command/commands/GunmuteCommand.class.php
deleted file mode 100644
index 5016716..0000000
--- a/file/lib/system/command/commands/GunmuteCommand.class.php
+++ /dev/null
@@ -1,34 +0,0 @@
-
- * @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), 'revoke', array(
- 'revoker' => WCF::getUser()->userID
- ));
- $action->executeAction();
- }
- else {
- throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.notExists'));
- }
- }
-}
diff --git a/file/lib/system/command/commands/MuteCommand.class.php b/file/lib/system/command/commands/MuteCommand.class.php
index d4f6c20..25bbd75 100644
--- a/file/lib/system/command/commands/MuteCommand.class.php
+++ b/file/lib/system/command/commands/MuteCommand.class.php
@@ -1,9 +1,5 @@
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 ($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'));
- }
-
- $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' => WCF::getUser()->chatRoomID,
- '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();
- $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))),
- 'reason' => $this->reason
- ));
- }
+class MuteCommand extends \chat\system\command\AbstractSuspensionCommand {
+ const IDENTIFIER = 'mute';
+ const IS_GLOBAL = false;
+ const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE;
}
diff --git a/file/lib/system/command/commands/UnbanCommand.class.php b/file/lib/system/command/commands/UnbanCommand.class.php
index 26529ff..85905b2 100644
--- a/file/lib/system/command/commands/UnbanCommand.class.php
+++ b/file/lib/system/command/commands/UnbanCommand.class.php
@@ -1,9 +1,5 @@
user, $this->room, suspension\Suspension::TYPE_BAN)) {
- $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'));
- }
- }
+class UnbanCommand extends \chat\system\command\AbstractUnsuspensionCommand {
+ const IDENTIFIER = 'ban';
+ const IS_GLOBAL = false;
+ const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN;
}
diff --git a/file/lib/system/command/commands/UngbanCommand.class.php b/file/lib/system/command/commands/UngbanCommand.class.php
new file mode 100644
index 0000000..db4a4a2
--- /dev/null
+++ b/file/lib/system/command/commands/UngbanCommand.class.php
@@ -0,0 +1,17 @@
+
+ * @package be.bastelstu.chat
+ * @subpackage system.chat.command.commands
+ */
+class GunbanCommand extends \chat\system\command\AbstractUnsuspensionCommand {
+ const IDENTIFIER = 'gban';
+ const IS_GLOBAL = true;
+ const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN;
+}
diff --git a/file/lib/system/command/commands/UngmuteCommand.class.php b/file/lib/system/command/commands/UngmuteCommand.class.php
new file mode 100644
index 0000000..c8c073d
--- /dev/null
+++ b/file/lib/system/command/commands/UngmuteCommand.class.php
@@ -0,0 +1,17 @@
+
+ * @package be.bastelstu.chat
+ * @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;
+}
diff --git a/file/lib/system/command/commands/UnmuteCommand.class.php b/file/lib/system/command/commands/UnmuteCommand.class.php
index 0ed2bf1..e7818b2 100644
--- a/file/lib/system/command/commands/UnmuteCommand.class.php
+++ b/file/lib/system/command/commands/UnmuteCommand.class.php
@@ -1,8 +1,5 @@
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), '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();
- $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 IDENTIFIER = 'mute';
+ const IS_GLOBAL = false;
+ const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE;
}
diff --git a/language/de.xml b/language/de.xml
index 34d215c..d642c7a 100644
--- a/language/de.xml
+++ b/language/de.xml
@@ -137,8 +137,8 @@
-
-
+
+
diff --git a/option.xml b/option.xml
index bef3647..9fac9ad 100644
--- a/option.xml
+++ b/option.xml
@@ -49,7 +49,9 @@
textarea
afk:away
col:color
-msg:whisper
+msg:whisper
+gunban:ungban
+gunmute:ungmute
diff --git a/package.xml b/package.xml
index 961162b..1fb22be 100644
--- a/package.xml
+++ b/package.xml
@@ -5,7 +5,7 @@
1
- 3.0.0 Alpha 59
+ 3.0.0 Alpha 66
2011-11-26
]]>