1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

Commands return the receiver now as well

This commit is contained in:
Tim Düsterhus 2011-12-27 14:34:42 +01:00
parent 6046e40cc2
commit fd6739bd2d
3 changed files with 10 additions and 0 deletions

View File

@ -70,18 +70,22 @@ public function save() {
if ($command::ENABLE_SMILIES != \wcf\system\chat\commands\ICommand::SMILEY_USER) $this->enableSmilies = $command::ENABLE_SMILIES; if ($command::ENABLE_SMILIES != \wcf\system\chat\commands\ICommand::SMILEY_USER) $this->enableSmilies = $command::ENABLE_SMILIES;
$type = $command->getType(); $type = $command->getType();
$this->message = $command->getMessage(); $this->message = $command->getMessage();
$receiver = $command->getReceiver();
} }
catch (\wcf\system\chat\commands\NotFoundException $e) { catch (\wcf\system\chat\commands\NotFoundException $e) {
$this->message = WCF::getLanguage()->get('wcf.chat.command.error.notFound'); $this->message = WCF::getLanguage()->get('wcf.chat.command.error.notFound');
$type = chat\message\ChatMessage::TYPE_ERROR; $type = chat\message\ChatMessage::TYPE_ERROR;
$receiver = WCF::getUser()->userID;
} }
catch (\wcf\system\exception\PermissionDeniedException $e) { catch (\wcf\system\exception\PermissionDeniedException $e) {
$this->message = WCF::getLanguage()->get('wcf.chat.command.error.permissionDenied'); $this->message = WCF::getLanguage()->get('wcf.chat.command.error.permissionDenied');
$type = chat\message\ChatMessage::TYPE_ERROR; $type = chat\message\ChatMessage::TYPE_ERROR;
$receiver = WCF::getUser()->userID;
} }
} }
else { else {
$type = chat\message\ChatMessage::TYPE_NORMAL; $type = chat\message\ChatMessage::TYPE_NORMAL;
$receiver = null;
} }
$messageAction = new chat\message\ChatMessageAction(array(), 'create', array( $messageAction = new chat\message\ChatMessageAction(array(), 'create', array(
@ -89,6 +93,7 @@ public function save() {
'roomID' => $this->room->roomID, 'roomID' => $this->room->roomID,
'sender' => WCF::getUser()->userID, 'sender' => WCF::getUser()->userID,
'username' => WCF::getUser()->username, 'username' => WCF::getUser()->username,
'receiver' => $receiver,
'time' => TIME_NOW, 'time' => TIME_NOW,
'type' => $type, 'type' => $type,
'message' => $this->message, 'message' => $this->message,

View File

@ -19,4 +19,8 @@ public function __construct(CommandHandler $commandHandler) {
$this->commandHandler = $commandHandler; $this->commandHandler = $commandHandler;
EventHandler::getInstance()->fireAction($this, 'didInit'); EventHandler::getInstance()->fireAction($this, 'didInit');
} }
public function getReceiver() {
return null;
}
} }

View File

@ -17,4 +17,5 @@ interface ICommand {
public function getType(); public function getType();
public function getMessage(); public function getMessage();
public function getReceiver();
} }