mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Adding Restore-Command
This commit is contained in:
parent
aec5ba361f
commit
961dbcc1f9
59
file/lib/system/chat/command/commands/Restore.class.php
Normal file
59
file/lib/system/chat/command/commands/Restore.class.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
namespace wcf\system\chat\command\commands;
|
||||
use \wcf\data\user\User;
|
||||
use \wcf\util\ChatUtil;
|
||||
|
||||
/**
|
||||
* Resets the color of a user
|
||||
*
|
||||
* @author Tim Düsterhus
|
||||
* @copyright 2010-2012 Tim Düsterhus
|
||||
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
||||
* @package timwolla.wcf.chat
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class Restore extends \wcf\system\chat\command\AbstractRestrictedCommand {
|
||||
public $enableSmilies = \wcf\system\chat\command\ICommand::SMILEY_OFF;
|
||||
public $enableHTML = 1;
|
||||
public $user = null;
|
||||
public $link = '';
|
||||
|
||||
public function __construct(\wcf\system\chat\command\CommandHandler $commandHandler) {
|
||||
parent::__construct($commandHandler);
|
||||
|
||||
$this->user = User::getUserByUsername(rtrim($commandHandler->getParameters(), ','));
|
||||
if (!$this->user->userID) throw new \wcf\system\chat\command\UserNotFoundException(rtrim($commandHandler->getParameters(), ','));
|
||||
|
||||
// Username + link to profile
|
||||
$color = array(1 => ChatUtil::getRandomNumber(), 2 => ChatUtil::getRandomNumber() * 0xFFFF);
|
||||
ChatUtil::writeUserData(array('color' => $color), $this->user);
|
||||
|
||||
$profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array(
|
||||
'object' => $this->user
|
||||
));
|
||||
$this->link = '<a href="'.$profile.'">'.ChatUtil::gradient($this->user->username, $color[1], $color[2]).'</a>';
|
||||
|
||||
$this->didInit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\command\ICommand::getType()
|
||||
*/
|
||||
public function getType() {
|
||||
return \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\command\ICommand::getMessage()
|
||||
*/
|
||||
public function getMessage() {
|
||||
return 'restored '.$this->link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\command\ICommand::getReceiver()
|
||||
*/
|
||||
public function getReceiver() {
|
||||
return \wcf\system\WCF::getUser()->userID;
|
||||
}
|
||||
}
|
@ -42,7 +42,13 @@
|
||||
<categoryname>mod.chat</categoryname>
|
||||
<optiontype>boolean</optiontype>
|
||||
<defaultvalue>0</defaultvalue>
|
||||
<admindefaultvalue>0</admindefaultvalue>
|
||||
<admindefaultvalue>1</admindefaultvalue>
|
||||
</option>
|
||||
<option name="mod.chat.canRestore">
|
||||
<categoryname>mod.chat</categoryname>
|
||||
<optiontype>boolean</optiontype>
|
||||
<defaultvalue>0</defaultvalue>
|
||||
<admindefaultvalue>1</admindefaultvalue>
|
||||
</option>
|
||||
<option name="admin.content.chat.canAddRoom">
|
||||
<categoryname>admin.content.chat</categoryname>
|
||||
|
Loading…
Reference in New Issue
Block a user