2012-05-19 21:03:35 +00:00
|
|
|
<?php
|
2013-01-26 21:46:54 +00:00
|
|
|
namespace chat\system\command\commands;
|
2012-05-19 21:03:35 +00:00
|
|
|
use \wcf\data\user\User;
|
2012-10-20 14:23:00 +00:00
|
|
|
use \wcf\system\WCF;
|
2012-05-19 21:03:35 +00:00
|
|
|
use \wcf\util\ChatUtil;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resets the color of a user
|
|
|
|
*
|
|
|
|
* @author Tim Düsterhus
|
2013-01-19 19:36:40 +00:00
|
|
|
* @copyright 2010-2013 Tim Düsterhus
|
2012-05-19 21:03:35 +00:00
|
|
|
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
2013-01-19 19:36:40 +00:00
|
|
|
* @package be.bastelstu.chat
|
2012-05-19 21:03:35 +00:00
|
|
|
* @subpackage system.chat.command.commands
|
|
|
|
*/
|
2013-01-26 21:46:54 +00:00
|
|
|
class RestoreCommand extends \chat\system\command\AbstractRestrictedCommand {
|
2012-05-19 21:03:35 +00:00
|
|
|
public $enableHTML = 1;
|
|
|
|
public $user = null;
|
|
|
|
public $link = '';
|
|
|
|
|
2013-01-26 21:46:54 +00:00
|
|
|
public function __construct(\chat\system\command\CommandHandler $commandHandler) {
|
2012-05-19 21:03:35 +00:00
|
|
|
parent::__construct($commandHandler);
|
|
|
|
|
2013-05-23 23:40:56 +00:00
|
|
|
$username = rtrim($commandHandler->getParameters(), ',');
|
|
|
|
$this->user = User::getUserByUsername($username);
|
|
|
|
if (!$this->user->userID) throw new \chat\system\command\UserNotFoundException($username);
|
2012-05-19 21:03:35 +00:00
|
|
|
|
2013-05-23 23:40:56 +00:00
|
|
|
$profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array(
|
|
|
|
'object' => $this->user
|
|
|
|
));
|
|
|
|
$this->link = "[url='".$profile."']".$this->user->username.'[/url]';
|
2012-05-19 21:03:35 +00:00
|
|
|
|
2013-05-26 15:24:44 +00:00
|
|
|
$editor = new \wcf\data\user\UserEditor($this->user);
|
|
|
|
$editor->update(array(
|
|
|
|
'chatColor1' => 0,
|
|
|
|
'chatColor2' => 0
|
|
|
|
));
|
2012-05-19 21:03:35 +00:00
|
|
|
$this->didInit();
|
|
|
|
}
|
|
|
|
|
2012-10-20 14:23:00 +00:00
|
|
|
/**
|
2013-01-26 21:46:54 +00:00
|
|
|
* @see \chat\system\command\IRestrictedChatCommand::checkPermission()
|
2012-10-20 14:23:00 +00:00
|
|
|
*/
|
|
|
|
public function checkPermission() {
|
2012-10-20 16:04:46 +00:00
|
|
|
parent::checkPermission();
|
2012-10-20 14:57:34 +00:00
|
|
|
|
|
|
|
WCF::getSession()->checkPermissions(array('mod.chat.canRestore'));
|
2012-10-20 14:23:00 +00:00
|
|
|
}
|
|
|
|
|
2012-05-19 21:03:35 +00:00
|
|
|
/**
|
2013-01-26 21:46:54 +00:00
|
|
|
* @see \chat\system\command\ICommand::getType()
|
2012-05-19 21:03:35 +00:00
|
|
|
*/
|
|
|
|
public function getType() {
|
2013-01-27 20:58:10 +00:00
|
|
|
return \chat\data\message\Message::TYPE_MODERATE;
|
2012-05-19 21:03:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-26 21:46:54 +00:00
|
|
|
* @see \chat\system\command\ICommand::getMessage()
|
2012-05-19 21:03:35 +00:00
|
|
|
*/
|
|
|
|
public function getMessage() {
|
2012-10-20 16:04:46 +00:00
|
|
|
return serialize(array(
|
|
|
|
'link' => $this->link,
|
2013-01-26 21:46:54 +00:00
|
|
|
'type' => str_replace(array('chat\system\command\commands\\', 'command'), '', strtolower(get_class($this)))
|
2012-10-20 16:04:46 +00:00
|
|
|
));
|
2012-05-19 21:03:35 +00:00
|
|
|
}
|
|
|
|
}
|