From 961dbcc1f983c6f45d9bfc9f41789331a1e677ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 19 May 2012 23:03:35 +0200 Subject: [PATCH] Adding Restore-Command --- .../chat/command/commands/Restore.class.php | 59 +++++++++++++++++++ userGroupOption.xml | 8 ++- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 file/lib/system/chat/command/commands/Restore.class.php diff --git a/file/lib/system/chat/command/commands/Restore.class.php b/file/lib/system/chat/command/commands/Restore.class.php new file mode 100644 index 0000000..a0dfe89 --- /dev/null +++ b/file/lib/system/chat/command/commands/Restore.class.php @@ -0,0 +1,59 @@ + + * @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 = ''.ChatUtil::gradient($this->user->username, $color[1], $color[2]).''; + + $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; + } +} diff --git a/userGroupOption.xml b/userGroupOption.xml index 6b28ff5..b0dc50c 100644 --- a/userGroupOption.xml +++ b/userGroupOption.xml @@ -42,7 +42,13 @@ mod.chat boolean 0 - 0 + 1 + +