1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-26 22:20:08 +00:00
Tims-Chat/file/lib/system/chat/command/commands/RestoreCommand.class.php

65 lines
2.1 KiB
PHP
Raw Normal View History

2012-05-19 21:03:35 +00:00
<?php
namespace wcf\system\chat\command\commands;
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
* @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package be.bastelstu.wcf.chat
2012-05-19 21:03:35 +00:00
* @subpackage system.chat.command.commands
*/
2012-09-07 20:23:27 +00:00
class RestoreCommand extends \wcf\system\chat\command\AbstractRestrictedCommand {
2012-05-19 21:03:35 +00:00
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
));
2012-10-20 16:04:46 +00:00
$this->link = '<a href="'.$profile.'" class="userLink" data-user-id="'.$this->user->userID.'">'.ChatUtil::gradient($this->user->username, $color[1], $color[2]).'</a>';
2012-05-19 21:03:35 +00:00
$this->didInit();
}
2012-10-20 14:23:00 +00:00
/**
* @see \wcf\system\chat\command\IRestrictedChatCommand::checkPermission()
*/
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
/**
* @see \wcf\system\chat\command\ICommand::getType()
*/
public function getType() {
2012-10-20 16:04:46 +00:00
return \wcf\data\chat\message\ChatMessage::TYPE_MODERATE;
2012-05-19 21:03:35 +00:00
}
/**
* @see \wcf\system\chat\command\ICommand::getMessage()
*/
public function getMessage() {
2012-10-20 16:04:46 +00:00
return serialize(array(
'link' => $this->link,
'type' => str_replace(array('wcf\system\chat\command\commands\\', 'command'), '', strtolower(get_class($this)))
));
2012-05-19 21:03:35 +00:00
}
}