diff --git a/file/lib/form/ChatForm.class.php b/file/lib/form/ChatForm.class.php index 4c53800..2666574 100644 --- a/file/lib/form/ChatForm.class.php +++ b/file/lib/form/ChatForm.class.php @@ -15,6 +15,7 @@ * @subpackage form */ class ChatForm extends AbstractForm { + public $enableHTML = 0; public $enableSmilies = 1; public $neededPermissions = array('user.chat.canEnter'); public $message = ''; @@ -79,6 +80,7 @@ public function save() { $command = $commandHandler->loadCommand(); if ($command->enableSmilies != \wcf\system\chat\commands\ICommand::SMILEY_USER) $this->enableSmilies = $command->enableSmilies; + $this->enableHTML = $command->enableHTML; $type = $command->getType(); $this->message = $command->getMessage(); $receiver = $command->getReceiver(); @@ -88,6 +90,11 @@ public function save() { $type = chat\message\ChatMessage::TYPE_ERROR; $receiver = WCF::getUser()->userID; } + catch (\wcf\system\chat\commands\UserNotFoundException $e) { + $this->message = WCF::getLanguage()->get('wcf.chat.command.error.userNotFound'); + $type = chat\message\ChatMessage::TYPE_ERROR; + $receiver = WCF::getUser()->userID; + } catch (\wcf\system\exception\PermissionDeniedException $e) { $this->message = WCF::getLanguage()->get('wcf.chat.command.error.permissionDenied'); $type = chat\message\ChatMessage::TYPE_ERROR; @@ -131,6 +138,7 @@ public function save() { 'type' => $type, 'message' => $this->message, 'enableSmilies' => $this->enableSmilies, + 'enableHTML' => $this->enableHTML, 'color1' => $this->userData['color'][1], 'color2' => $this->userData['color'][2] ) @@ -144,7 +152,7 @@ public function save() { * @see \wcf\page\IPage::show() */ public function show() { - //header("HTTP/1.0 204 No Content"); + header("HTTP/1.0 204 No Content"); parent::show(); } } diff --git a/file/lib/system/chat/commands/AbstractCommand.class.php b/file/lib/system/chat/commands/AbstractCommand.class.php index 8c994ad..18d0b61 100644 --- a/file/lib/system/chat/commands/AbstractCommand.class.php +++ b/file/lib/system/chat/commands/AbstractCommand.class.php @@ -13,6 +13,7 @@ */ abstract class AbstractCommand implements ICommand { public $commandHandler = null; + public $enableHTML = 0; public function __construct(CommandHandler $commandHandler) { EventHandler::getInstance()->fireAction($this, 'shouldInit'); diff --git a/file/lib/system/chat/commands/UserNotFoundException.class.php b/file/lib/system/chat/commands/UserNotFoundException.class.php new file mode 100644 index 0000000..2c6f14f --- /dev/null +++ b/file/lib/system/chat/commands/UserNotFoundException.class.php @@ -0,0 +1,23 @@ + + * @package timwolla.wcf.chat + * @subpackage system.chat.commands + */ +class UserNotFoundException extends \Exception { + private $username = ''; + + public function __construct($username) { + $this->username = $username; + } + + public function getUsername() { + return $this->username; + } +} \ No newline at end of file diff --git a/file/lib/system/chat/commands/commands/Info.class.php b/file/lib/system/chat/commands/commands/Info.class.php new file mode 100644 index 0000000..66509ac --- /dev/null +++ b/file/lib/system/chat/commands/commands/Info.class.php @@ -0,0 +1,53 @@ + + * @package timwolla.wcf.chat + * @subpackage system.chat.commands.commands + */ +class Info extends \wcf\system\chat\commands\AbstractCommand { + public $enableSmilies = \wcf\system\chat\commands\ICommand::SMILEY_OFF; + public $enableHTML = 1; + private $lines = array(); + + public function __construct(\wcf\system\chat\commands\CommandHandler $commandHandler) { + parent::__construct($commandHandler); + + $user = \wcf\data\user\User::getUserByUsername(rtrim($commandHandler->getParameters(), ',')); + if (!$user->userID) throw new \wcf\system\chat\commands\UserNotFoundException(rtrim($commandHandler->getParameters(), ',')); + $color = \wcf\util\ChatUtil::readUserData('color', $user); + $this->lines[WCF::getLanguage()->get('wcf.user.username')] = \wcf\util\ChatUtil::gradient($user->username, $color[1], $color[2]); + } + + /** + * @see \wcf\system\chat\commands\ICommand::getType() + */ + public function getType() { + return \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION; + } + + /** + * @see \wcf\system\chat\commands\ICommand::getMessage() + */ + public function getMessage() { + $lines = array(); + foreach ($this->lines as $key => $val) { + $lines[] = ''.$key.': '.$val; + } + return '