diff --git a/file/lib/data/message/Message.class.php b/file/lib/data/message/Message.class.php
index 559dd54..f4f70e6 100644
--- a/file/lib/data/message/Message.class.php
+++ b/file/lib/data/message/Message.class.php
@@ -43,6 +43,17 @@ class Message extends \chat\data\CHATDatabaseObject {
*/
protected static $users = array();
+ /**
+ * @see \wcf\data\DatabaseObject::handleData()
+ */
+ protected function handleData($data) {
+ parent::handleData($data);
+
+ if ($this->data['additionalData'] !== null) {
+ $this->data['additionalData'] = unserialize($this->data['additionalData']);
+ }
+ }
+
/**
* @see \chat\data\message\Message::getFormattedMessage()
*/
@@ -65,8 +76,10 @@ public function getFormattedMessage($type = 'text/html') {
case self::TYPE_JOIN:
case self::TYPE_LEAVE:
case self::TYPE_BACK:
+ $message = WCF::getLanguage()->getDynamicVariable('chat.message.'.$this->type, $this->data['additionalData'] ?: array());
+ break;
case self::TYPE_AWAY:
- $message = WCF::getLanguage()->getDynamicVariable('chat.message.'.$this->type, unserialize($message) ?: array());
+ $message = WCF::getLanguage()->getDynamicVariable('chat.message.'.$this->type, array('message' => $message));
break;
case self::TYPE_MODERATE:
$message = unserialize($message);
@@ -75,8 +88,6 @@ public function getFormattedMessage($type = 'text/html') {
$message = $messageParser->parse($message, false, false, true, false);
break;
case self::TYPE_WHISPER:
- $message = unserialize($message);
- $message = $message['message'];
case self::TYPE_NORMAL:
case self::TYPE_ME:
default:
@@ -103,11 +114,6 @@ public function getUsername($colored = false) {
$username = \chat\util\ChatUtil::gradient($username, $this->color1, $this->color2);
}
- if ($this->type == self::TYPE_WHISPER) {
- $message = unserialize($this->message);
- $username .= ' -> '.$message['username'];
- }
-
return $username;
}
@@ -119,9 +125,9 @@ public function getUsername($colored = false) {
*/
public function jsonify($raw = false) {
switch ($this->type) {
+ case self::TYPE_WHISPER:
case self::TYPE_NORMAL:
case self::TYPE_INFORMATION:
- case self::TYPE_WHISPER:
$separator = ':';
break;
default:
@@ -141,7 +147,8 @@ public function jsonify($raw = false) {
'receiver' => (int) $this->receiver,
'type' => (int) $this->type,
'roomID' => (int) $this->roomID,
- 'messageID' => (int) $this->messageID
+ 'messageID' => (int) $this->messageID,
+ 'additionalData' => $this->additionalData
);
if ($raw) return $array;
diff --git a/file/lib/data/message/MessageAction.class.php b/file/lib/data/message/MessageAction.class.php
index 4dcf7be..128d389 100644
--- a/file/lib/data/message/MessageAction.class.php
+++ b/file/lib/data/message/MessageAction.class.php
@@ -117,6 +117,7 @@ public function validateSend() {
$this->parameters['type'] = $command->getType();
$this->parameters['text'] = $command->getMessage();
$this->parameters['receiver'] = $command->getReceiver();
+ $this->parameters['additionalData'] = $command->getAdditionalData();
}
catch (\chat\system\command\NotFoundException $e) {
throw new UserInputException('text', WCF::getLanguage()->getDynamicVariable('chat.error.notFound', array('exception' => $e)));
@@ -128,6 +129,7 @@ public function validateSend() {
else {
$this->parameters['type'] = Message::TYPE_NORMAL;
$this->parameters['receiver'] = null;
+ $this->parameters['additionalData'] = null;
$this->parameters['text'] = \wcf\system\bbcode\PreParser::getInstance()->parse($this->parameters['text'], explode(',', WCF::getSession()->getPermission('user.chat.allowedBBCodes')));
}
@@ -149,7 +151,8 @@ public function send() {
'enableSmilies' => $this->parameters['enableSmilies'] ? 1 : 0,
'enableHTML' => $this->parameters['enableHTML'] ? 1 : 0,
'color1' => $this->parameters['userData']['color1'],
- 'color2' => $this->parameters['userData']['color2']
+ 'color2' => $this->parameters['userData']['color2'],
+ 'additionalData' => serialize($this->parameters['additionalData'])
)
));
$this->objectAction->executeAction();
diff --git a/file/lib/data/room/RoomAction.class.php b/file/lib/data/room/RoomAction.class.php
index 59cb51f..e05bc18 100644
--- a/file/lib/data/room/RoomAction.class.php
+++ b/file/lib/data/room/RoomAction.class.php
@@ -192,9 +192,10 @@ public function join() {
'username' => $this->parameters['user']->username,
'time' => TIME_NOW,
'type' => message\Message::TYPE_LEAVE,
- 'message' => serialize(array('room' => $room)),
+ 'message' => '',
'color1' => $this->parameters['user']->chatColor1,
- 'color2' => $this->parameters['user']->chatColor2
+ 'color2' => $this->parameters['user']->chatColor2,
+ 'additionalData' => serialize(array('room' => $room))
)
));
$messageAction->executeAction();
@@ -211,9 +212,10 @@ public function join() {
'username' => $this->parameters['user']->username,
'time' => TIME_NOW,
'type' => message\Message::TYPE_JOIN,
- 'message' => serialize(array('ipAddress' => $ipAddress)),
+ 'message' => '',
'color1' => $this->parameters['user']->chatColor1,
- 'color2' => $this->parameters['user']->chatColor2
+ 'color2' => $this->parameters['user']->chatColor2,
+ 'additionalData' => serialize(array('ipAddress' => $ipAddress))
)
));
$messageAction->executeAction();
@@ -286,7 +288,7 @@ public function leave() {
'username' => $this->parameters['user']->username,
'time' => TIME_NOW,
'type' => message\Message::TYPE_LEAVE,
- 'message' => serialize(array('room' => null)),
+ 'message' => '',
'color1' => $this->parameters['user']->chatColor1,
'color2' => $this->parameters['user']->chatColor2
)
diff --git a/file/lib/system/command/AbstractCommand.class.php b/file/lib/system/command/AbstractCommand.class.php
index 8658cf5..4c9348b 100644
--- a/file/lib/system/command/AbstractCommand.class.php
+++ b/file/lib/system/command/AbstractCommand.class.php
@@ -59,4 +59,11 @@ public function didInit() {
public function getReceiver() {
return null;
}
+
+ /**
+ * No additionaldata by default.
+ */
+ public function getAdditionalData() {
+ return null;
+ }
}
diff --git a/file/lib/system/command/ICommand.class.php b/file/lib/system/command/ICommand.class.php
index be3aaf6..aead8d1 100644
--- a/file/lib/system/command/ICommand.class.php
+++ b/file/lib/system/command/ICommand.class.php
@@ -42,6 +42,11 @@ public function getType();
*/
public function getMessage();
+ /**
+ * Returns additionalData to be saved within database
+ */
+ public function getAdditionalData();
+
/**
* Returns the receiver for this command.
*/
diff --git a/file/lib/system/command/commands/AwayCommand.class.php b/file/lib/system/command/commands/AwayCommand.class.php
index 1a2c2b8..b7d0518 100644
--- a/file/lib/system/command/commands/AwayCommand.class.php
+++ b/file/lib/system/command/commands/AwayCommand.class.php
@@ -1,5 +1,6 @@
\wcf\system\bbcode\PreParser::getInstance()->parse($this->commandHandler->getParameters(), explode(',', \wcf\system\WCF::getSession()->getPermission('user.chat.allowedBBCodes')))
- ));
+ return \wcf\system\bbcode\PreParser::getInstance()->parse($this->commandHandler->getParameters(), explode(',', WCF::getSession()->getPermission('user.chat.allowedBBCodes')));
}
/**
* @see \chat\system\command\ICommand::getReceiver()
*/
public function getReceiver() {
- return \wcf\system\WCF::getUser()->userID;
+ return WCF::getUser()->userID;
}
}
diff --git a/file/lib/system/command/commands/TemproomCommand.class.php b/file/lib/system/command/commands/TemproomCommand.class.php
index 92a2f11..76d4428 100644
--- a/file/lib/system/command/commands/TemproomCommand.class.php
+++ b/file/lib/system/command/commands/TemproomCommand.class.php
@@ -14,6 +14,7 @@
*/
class TemproomCommand extends \chat\system\command\AbstractRestrictedCommand {
public $roomName = '';
+ public $roomID = 0;
public function __construct(\chat\system\command\CommandHandler $commandHandler) {
parent::__construct($commandHandler);
@@ -28,8 +29,8 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
$this->objectAction->executeAction();
$returnValues = $this->objectAction->getReturnValues();
$chatRoomEditor = new \chat\data\room\RoomEditor($returnValues['returnValues']);
- $roomID = $returnValues['returnValues']->roomID;
- $this->roomName = WCF::getLanguage()->getDynamicVariable('chat.room.titleTemp', array('roomID' => $roomID));
+ $this->roomID = $returnValues['returnValues']->roomID;
+ $this->roomName = WCF::getLanguage()->getDynamicVariable('chat.room.titleTemp', array('roomID' => $this->roomID));
// set accurate title
$chatRoomEditor->update(array(
@@ -50,7 +51,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
)
);
- $acl->save($roomID, $acl->getObjectTypeID('be.bastelstu.chat.room'));
+ $acl->save($this->roomID, $acl->getObjectTypeID('be.bastelstu.chat.room'));
\chat\system\permission\PermissionHandler::clearCache();
$this->didInit();
}
@@ -84,4 +85,14 @@ public function getMessage() {
public function getReceiver() {
return \wcf\system\WCF::getUser()->userID;
}
+
+ /**
+ * @see \chat\system\command\ICommand::getAdditionalData()
+ */
+ public function getAdditionalData() {
+ return array(
+ 'roomID' => (int) $this->roomID,
+ 'roomName' => $this->roomName
+ );
+ }
}
diff --git a/file/lib/system/command/commands/WhisperCommand.class.php b/file/lib/system/command/commands/WhisperCommand.class.php
index 53ec0c6..04333c5 100644
--- a/file/lib/system/command/commands/WhisperCommand.class.php
+++ b/file/lib/system/command/commands/WhisperCommand.class.php
@@ -48,7 +48,7 @@ public function getType() {
public function getMessage() {
$this->message = \wcf\system\bbcode\PreParser::getInstance()->parse($this->message, explode(',', \wcf\system\WCF::getSession()->getPermission('user.chat.allowedBBCodes')));
- return serialize(array('message' => $this->message, 'username' => $this->user->username));
+ return $this->message;
}
/**
@@ -57,4 +57,13 @@ public function getMessage() {
public function getReceiver() {
return $this->user->userID;
}
+
+ /**
+ * @see \chat\system\command\ICommand::getAdditionalData()
+ */
+ public function getAdditionalData() {
+ return array(
+ 'receiverUsername' => $this->user->username
+ );
+ }
}
diff --git a/install.sql b/install.sql
index 36afe5b..7b05374 100644
--- a/install.sql
+++ b/install.sql
@@ -21,6 +21,7 @@ CREATE TABLE chat1_message (
enableHTML TINYINT(1) NOT NULL DEFAULT 0,
color1 INT(10) NOT NULL DEFAULT 0,
color2 INT(10) NOT NULL DEFAULT 0,
+ additionalData TEXT DEFAULT NULL,
KEY (roomID),
KEY (sender),
diff --git a/language/de.xml b/language/de.xml
index 2d5dad1..d49252d 100644
--- a/language/de.xml
+++ b/language/de.xml
@@ -110,7 +110,7 @@
- session->getPermission('admin.user.canViewIpAddress') && $ipAddress} ({$ipAddress}){/if}]]>
-
+
diff --git a/template/message.tpl b/template/message.tpl
index 1f43e46..d6e1eb2 100644
--- a/template/message.tpl
+++ b/template/message.tpl
@@ -1 +1 @@
-{literal} {@$formattedUsername}{$separator} {@$formattedMessage} {/literal}
\ No newline at end of file
+{literal} {if $type != 7}{@$formattedUsername}{else}{if $receiver == WCF.User.userID}{@$formattedUsername} {/if}->{if $receiver != WCF.User.userID} {$additionalData.receiverUsername}{/if}{/if}{$separator} {@$formattedMessage} {/literal}
\ No newline at end of file