mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2025-01-09 00:20:08 +00:00
Bugfixes in Command Handling (MuteCommand)
This commit is contained in:
parent
fdb21f3daf
commit
1487fe559d
@ -41,7 +41,7 @@ public function prune() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Validates message sending.
|
||||||
*/
|
*/
|
||||||
public function validateSend() {
|
public function validateSend() {
|
||||||
// read parameters
|
// read parameters
|
||||||
@ -77,10 +77,10 @@ public function validateSend() {
|
|||||||
if (!isset($cache[$this->parameters['userData']['roomID']])) throw new \wcf\system\exception\IllegalLinkException();
|
if (!isset($cache[$this->parameters['userData']['roomID']])) throw new \wcf\system\exception\IllegalLinkException();
|
||||||
$this->parameters['room'] = $cache[$this->parameters['userData']['roomID']];
|
$this->parameters['room'] = $cache[$this->parameters['userData']['roomID']];
|
||||||
|
|
||||||
if (!$this->parameters['room']->canEnter() || !$this->parameters['room']->canWrite()) throw new PermissionDeniedException();
|
if (!$this->parameters['room']->canEnter() || !$this->parameters['room']->canWrite()) throw new \wcf\system\exception\PermissionDeniedException();
|
||||||
|
|
||||||
// handle commands
|
// handle commands
|
||||||
$commandHandler = new \chat\system\command\CommandHandler($this->parameters['text']);
|
$commandHandler = new \chat\system\command\CommandHandler($this->parameters['text'], $this->parameters['room']);
|
||||||
if ($commandHandler->isCommand()) {
|
if ($commandHandler->isCommand()) {
|
||||||
try {
|
try {
|
||||||
$command = $commandHandler->loadCommand();
|
$command = $commandHandler->loadCommand();
|
||||||
@ -105,6 +105,9 @@ public function validateSend() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates sent message.
|
||||||
|
*/
|
||||||
public function send() {
|
public function send() {
|
||||||
\chat\util\ChatUtil::writeUserData(array('away' => null));
|
\chat\util\ChatUtil::writeUserData(array('away' => null));
|
||||||
|
|
||||||
|
@ -24,13 +24,21 @@ final class CommandHandler {
|
|||||||
*/
|
*/
|
||||||
private $text = '';
|
private $text = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* current room
|
||||||
|
* @var \chat\data\room\Room
|
||||||
|
*/
|
||||||
|
private $room = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialises the CommandHandler
|
* Initialises the CommandHandler
|
||||||
*
|
*
|
||||||
* @param string $text
|
* @param string $text
|
||||||
|
* @param \chat\data\room\Room $room
|
||||||
*/
|
*/
|
||||||
public function __construct($text) {
|
public function __construct($text, \chat\data\room\Room $room = null) {
|
||||||
$this->text = $text;
|
$this->text = $text;
|
||||||
|
$this->room = $room;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,6 +59,15 @@ public function getText() {
|
|||||||
return $this->text;
|
return $this->text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current room.
|
||||||
|
*
|
||||||
|
* @return \chat\data\room\Room
|
||||||
|
*/
|
||||||
|
public function getRoom() {
|
||||||
|
return $this->room;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the parameter-string.
|
* Returns the parameter-string.
|
||||||
*
|
*
|
||||||
|
@ -76,7 +76,7 @@ public function executeAction() {
|
|||||||
public function checkPermission() {
|
public function checkPermission() {
|
||||||
parent::checkPermission();
|
parent::checkPermission();
|
||||||
|
|
||||||
$this->room = \wcf\system\request\RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->request->room;
|
$this->room = $this->commandHandler->getRoom();
|
||||||
$ph = new \chat\system\permission\PermissionHandler();
|
$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();
|
if (!$ph->getPermission($this->room, 'mod.can'.str_replace(array('chat\system\command\commands\\', 'Command'), '', get_class($this)))) throw new \wcf\system\exception\PermissionDeniedException();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user