From fd6739bd2d1a8087961a98ab2c809eb9059c828e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 27 Dec 2011 14:34:42 +0100 Subject: [PATCH] Commands return the receiver now as well --- file/lib/form/ChatForm.class.php | 5 +++++ file/lib/system/chat/commands/AbstractCommand.class.php | 4 ++++ file/lib/system/chat/commands/ICommand.class.php | 1 + 3 files changed, 10 insertions(+) diff --git a/file/lib/form/ChatForm.class.php b/file/lib/form/ChatForm.class.php index 283fe38..25b29af 100644 --- a/file/lib/form/ChatForm.class.php +++ b/file/lib/form/ChatForm.class.php @@ -70,18 +70,22 @@ public function save() { if ($command::ENABLE_SMILIES != \wcf\system\chat\commands\ICommand::SMILEY_USER) $this->enableSmilies = $command::ENABLE_SMILIES; $type = $command->getType(); $this->message = $command->getMessage(); + $receiver = $command->getReceiver(); } catch (\wcf\system\chat\commands\NotFoundException $e) { $this->message = WCF::getLanguage()->get('wcf.chat.command.error.notFound'); $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; + $receiver = WCF::getUser()->userID; } } else { $type = chat\message\ChatMessage::TYPE_NORMAL; + $receiver = null; } $messageAction = new chat\message\ChatMessageAction(array(), 'create', array( @@ -89,6 +93,7 @@ public function save() { 'roomID' => $this->room->roomID, 'sender' => WCF::getUser()->userID, 'username' => WCF::getUser()->username, + 'receiver' => $receiver, 'time' => TIME_NOW, 'type' => $type, 'message' => $this->message, diff --git a/file/lib/system/chat/commands/AbstractCommand.class.php b/file/lib/system/chat/commands/AbstractCommand.class.php index 5fd3494..3539b9d 100644 --- a/file/lib/system/chat/commands/AbstractCommand.class.php +++ b/file/lib/system/chat/commands/AbstractCommand.class.php @@ -19,4 +19,8 @@ public function __construct(CommandHandler $commandHandler) { $this->commandHandler = $commandHandler; EventHandler::getInstance()->fireAction($this, 'didInit'); } + + public function getReceiver() { + return null; + } } diff --git a/file/lib/system/chat/commands/ICommand.class.php b/file/lib/system/chat/commands/ICommand.class.php index 8cb458d..a94ca4c 100644 --- a/file/lib/system/chat/commands/ICommand.class.php +++ b/file/lib/system/chat/commands/ICommand.class.php @@ -17,4 +17,5 @@ interface ICommand { public function getType(); public function getMessage(); + public function getReceiver(); }