mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Made suspension commands more abstract
This commit is contained in:
parent
f9fa3a7841
commit
6d539e7f0a
115
file/lib/system/command/AbstractSuspensionCommand.class.php
Normal file
115
file/lib/system/command/AbstractSuspensionCommand.class.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?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();
|
||||
$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
|
||||
));
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
<?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();
|
||||
$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
|
||||
));
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
namespace chat\system\command\commands;
|
||||
use \chat\data\suspension;
|
||||
|
||||
/**
|
||||
* Bans a user.
|
||||
@ -11,6 +10,8 @@
|
||||
* @package be.bastelstu.chat
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class BanCommand extends MuteCommand {
|
||||
const SUSPENSION_TYPE = suspension\Suspension::TYPE_BAN;
|
||||
class BanCommand extends \chat\system\command\AbstractSuspensionCommand {
|
||||
const IDENTIFIER = 'ban';
|
||||
const IS_GLOBAL = false;
|
||||
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
namespace chat\system\command\commands;
|
||||
use \chat\data\suspension;
|
||||
|
||||
/**
|
||||
* Globally bans a user.
|
||||
@ -11,6 +10,8 @@
|
||||
* @package be.bastelstu.chat
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class GbanCommand extends GmuteCommand {
|
||||
const SUSPENSION_TYPE = suspension\Suspension::TYPE_BAN;
|
||||
class GbanCommand extends \chat\system\command\AbstractSuspensionCommand {
|
||||
const IDENTIFIER = 'gban';
|
||||
const IS_GLOBAL = true;
|
||||
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN;
|
||||
}
|
||||
|
@ -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,32 +10,8 @@
|
||||
* @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, 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;
|
||||
}
|
||||
|
@ -1,34 +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), 'revoke', array(
|
||||
'revoker' => WCF::getUser()->userID
|
||||
));
|
||||
$action->executeAction();
|
||||
}
|
||||
else {
|
||||
throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.notExists'));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,34 +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), 'revoke', array(
|
||||
'revoker' => WCF::getUser()->userID
|
||||
));
|
||||
$action->executeAction();
|
||||
}
|
||||
else {
|
||||
throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.notExists'));
|
||||
}
|
||||
}
|
||||
}
|
@ -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,100 +10,8 @@
|
||||
* @package be.bastelstu.chat
|
||||
* @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 {
|
||||
$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 ($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;
|
||||
}
|
||||
|
@ -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,19 +10,8 @@
|
||||
* @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), '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;
|
||||
}
|
||||
|
17
file/lib/system/command/commands/UngbanCommand.class.php
Normal file
17
file/lib/system/command/commands/UngbanCommand.class.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?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 GunbanCommand extends \chat\system\command\AbstractUnsuspensionCommand {
|
||||
const IDENTIFIER = 'gban';
|
||||
const IS_GLOBAL = true;
|
||||
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN;
|
||||
}
|
17
file/lib/system/command/commands/UngmuteCommand.class.php
Normal file
17
file/lib/system/command/commands/UngmuteCommand.class.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?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 IDENTIFIER = 'gmute';
|
||||
const IS_GLOBAL = true;
|
||||
const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE;
|
||||
}
|
@ -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,69 +10,8 @@
|
||||
* @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), '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;
|
||||
}
|
||||
|
@ -137,8 +137,8 @@
|
||||
<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>
|
||||
|
@ -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 -->
|
||||
|
||||
|
@ -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 59</version><!-- Codename: Codenames are overrated -->
|
||||
<version>3.0.0 Alpha 66</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>
|
||||
|
Loading…
Reference in New Issue
Block a user