mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Merge branch 'whisperRework'
This commit is contained in:
commit
ecf872e862
@ -43,6 +43,17 @@ class Message extends \chat\data\CHATDatabaseObject {
|
|||||||
*/
|
*/
|
||||||
protected static $users = array();
|
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()
|
* @see \chat\data\message\Message::getFormattedMessage()
|
||||||
*/
|
*/
|
||||||
@ -65,8 +76,10 @@ public function getFormattedMessage($type = 'text/html') {
|
|||||||
case self::TYPE_JOIN:
|
case self::TYPE_JOIN:
|
||||||
case self::TYPE_LEAVE:
|
case self::TYPE_LEAVE:
|
||||||
case self::TYPE_BACK:
|
case self::TYPE_BACK:
|
||||||
|
$message = WCF::getLanguage()->getDynamicVariable('chat.message.'.$this->type, $this->data['additionalData'] ?: array());
|
||||||
|
break;
|
||||||
case self::TYPE_AWAY:
|
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;
|
break;
|
||||||
case self::TYPE_MODERATE:
|
case self::TYPE_MODERATE:
|
||||||
$message = unserialize($message);
|
$message = unserialize($message);
|
||||||
@ -75,8 +88,6 @@ public function getFormattedMessage($type = 'text/html') {
|
|||||||
$message = $messageParser->parse($message, false, false, true, false);
|
$message = $messageParser->parse($message, false, false, true, false);
|
||||||
break;
|
break;
|
||||||
case self::TYPE_WHISPER:
|
case self::TYPE_WHISPER:
|
||||||
$message = unserialize($message);
|
|
||||||
$message = $message['message'];
|
|
||||||
case self::TYPE_NORMAL:
|
case self::TYPE_NORMAL:
|
||||||
case self::TYPE_ME:
|
case self::TYPE_ME:
|
||||||
default:
|
default:
|
||||||
@ -103,11 +114,6 @@ public function getUsername($colored = false) {
|
|||||||
$username = \chat\util\ChatUtil::gradient($username, $this->color1, $this->color2);
|
$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;
|
return $username;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,9 +125,9 @@ public function getUsername($colored = false) {
|
|||||||
*/
|
*/
|
||||||
public function jsonify($raw = false) {
|
public function jsonify($raw = false) {
|
||||||
switch ($this->type) {
|
switch ($this->type) {
|
||||||
|
case self::TYPE_WHISPER:
|
||||||
case self::TYPE_NORMAL:
|
case self::TYPE_NORMAL:
|
||||||
case self::TYPE_INFORMATION:
|
case self::TYPE_INFORMATION:
|
||||||
case self::TYPE_WHISPER:
|
|
||||||
$separator = ':';
|
$separator = ':';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -141,7 +147,8 @@ public function jsonify($raw = false) {
|
|||||||
'receiver' => (int) $this->receiver,
|
'receiver' => (int) $this->receiver,
|
||||||
'type' => (int) $this->type,
|
'type' => (int) $this->type,
|
||||||
'roomID' => (int) $this->roomID,
|
'roomID' => (int) $this->roomID,
|
||||||
'messageID' => (int) $this->messageID
|
'messageID' => (int) $this->messageID,
|
||||||
|
'additionalData' => $this->additionalData
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($raw) return $array;
|
if ($raw) return $array;
|
||||||
|
@ -117,6 +117,7 @@ public function validateSend() {
|
|||||||
$this->parameters['type'] = $command->getType();
|
$this->parameters['type'] = $command->getType();
|
||||||
$this->parameters['text'] = $command->getMessage();
|
$this->parameters['text'] = $command->getMessage();
|
||||||
$this->parameters['receiver'] = $command->getReceiver();
|
$this->parameters['receiver'] = $command->getReceiver();
|
||||||
|
$this->parameters['additionalData'] = $command->getAdditionalData();
|
||||||
}
|
}
|
||||||
catch (\chat\system\command\NotFoundException $e) {
|
catch (\chat\system\command\NotFoundException $e) {
|
||||||
throw new UserInputException('text', WCF::getLanguage()->getDynamicVariable('chat.error.notFound', array('exception' => $e)));
|
throw new UserInputException('text', WCF::getLanguage()->getDynamicVariable('chat.error.notFound', array('exception' => $e)));
|
||||||
@ -128,6 +129,7 @@ public function validateSend() {
|
|||||||
else {
|
else {
|
||||||
$this->parameters['type'] = Message::TYPE_NORMAL;
|
$this->parameters['type'] = Message::TYPE_NORMAL;
|
||||||
$this->parameters['receiver'] = null;
|
$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')));
|
$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,
|
'enableSmilies' => $this->parameters['enableSmilies'] ? 1 : 0,
|
||||||
'enableHTML' => $this->parameters['enableHTML'] ? 1 : 0,
|
'enableHTML' => $this->parameters['enableHTML'] ? 1 : 0,
|
||||||
'color1' => $this->parameters['userData']['color1'],
|
'color1' => $this->parameters['userData']['color1'],
|
||||||
'color2' => $this->parameters['userData']['color2']
|
'color2' => $this->parameters['userData']['color2'],
|
||||||
|
'additionalData' => serialize($this->parameters['additionalData'])
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
$this->objectAction->executeAction();
|
$this->objectAction->executeAction();
|
||||||
|
@ -192,9 +192,10 @@ public function join() {
|
|||||||
'username' => $this->parameters['user']->username,
|
'username' => $this->parameters['user']->username,
|
||||||
'time' => TIME_NOW,
|
'time' => TIME_NOW,
|
||||||
'type' => message\Message::TYPE_LEAVE,
|
'type' => message\Message::TYPE_LEAVE,
|
||||||
'message' => serialize(array('room' => $room)),
|
'message' => '',
|
||||||
'color1' => $this->parameters['user']->chatColor1,
|
'color1' => $this->parameters['user']->chatColor1,
|
||||||
'color2' => $this->parameters['user']->chatColor2
|
'color2' => $this->parameters['user']->chatColor2,
|
||||||
|
'additionalData' => serialize(array('room' => $room))
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
$messageAction->executeAction();
|
$messageAction->executeAction();
|
||||||
@ -211,9 +212,10 @@ public function join() {
|
|||||||
'username' => $this->parameters['user']->username,
|
'username' => $this->parameters['user']->username,
|
||||||
'time' => TIME_NOW,
|
'time' => TIME_NOW,
|
||||||
'type' => message\Message::TYPE_JOIN,
|
'type' => message\Message::TYPE_JOIN,
|
||||||
'message' => serialize(array('ipAddress' => $ipAddress)),
|
'message' => '',
|
||||||
'color1' => $this->parameters['user']->chatColor1,
|
'color1' => $this->parameters['user']->chatColor1,
|
||||||
'color2' => $this->parameters['user']->chatColor2
|
'color2' => $this->parameters['user']->chatColor2,
|
||||||
|
'additionalData' => serialize(array('ipAddress' => $ipAddress))
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
$messageAction->executeAction();
|
$messageAction->executeAction();
|
||||||
@ -286,7 +288,7 @@ public function leave() {
|
|||||||
'username' => $this->parameters['user']->username,
|
'username' => $this->parameters['user']->username,
|
||||||
'time' => TIME_NOW,
|
'time' => TIME_NOW,
|
||||||
'type' => message\Message::TYPE_LEAVE,
|
'type' => message\Message::TYPE_LEAVE,
|
||||||
'message' => serialize(array('room' => null)),
|
'message' => '',
|
||||||
'color1' => $this->parameters['user']->chatColor1,
|
'color1' => $this->parameters['user']->chatColor1,
|
||||||
'color2' => $this->parameters['user']->chatColor2
|
'color2' => $this->parameters['user']->chatColor2
|
||||||
)
|
)
|
||||||
|
@ -59,4 +59,11 @@ public function didInit() {
|
|||||||
public function getReceiver() {
|
public function getReceiver() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No additionaldata by default.
|
||||||
|
*/
|
||||||
|
public function getAdditionalData() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,11 @@ public function getType();
|
|||||||
*/
|
*/
|
||||||
public function getMessage();
|
public function getMessage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns additionalData to be saved within database
|
||||||
|
*/
|
||||||
|
public function getAdditionalData();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the receiver for this command.
|
* Returns the receiver for this command.
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace chat\system\command\commands;
|
namespace chat\system\command\commands;
|
||||||
|
use \wcf\system\WCF;
|
||||||
use \wcf\util\StringUtil;
|
use \wcf\util\StringUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,15 +34,13 @@ public function getType() {
|
|||||||
* @see \chat\system\command\ICommand::getMessage()
|
* @see \chat\system\command\ICommand::getMessage()
|
||||||
*/
|
*/
|
||||||
public function getMessage() {
|
public function getMessage() {
|
||||||
return serialize(array(
|
return \wcf\system\bbcode\PreParser::getInstance()->parse($this->commandHandler->getParameters(), explode(',', WCF::getSession()->getPermission('user.chat.allowedBBCodes')));
|
||||||
'message' => \wcf\system\bbcode\PreParser::getInstance()->parse($this->commandHandler->getParameters(), explode(',', \wcf\system\WCF::getSession()->getPermission('user.chat.allowedBBCodes')))
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see \chat\system\command\ICommand::getReceiver()
|
* @see \chat\system\command\ICommand::getReceiver()
|
||||||
*/
|
*/
|
||||||
public function getReceiver() {
|
public function getReceiver() {
|
||||||
return \wcf\system\WCF::getUser()->userID;
|
return WCF::getUser()->userID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
class TemproomCommand extends \chat\system\command\AbstractRestrictedCommand {
|
class TemproomCommand extends \chat\system\command\AbstractRestrictedCommand {
|
||||||
public $roomName = '';
|
public $roomName = '';
|
||||||
|
public $roomID = 0;
|
||||||
|
|
||||||
public function __construct(\chat\system\command\CommandHandler $commandHandler) {
|
public function __construct(\chat\system\command\CommandHandler $commandHandler) {
|
||||||
parent::__construct($commandHandler);
|
parent::__construct($commandHandler);
|
||||||
@ -28,8 +29,8 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
|
|||||||
$this->objectAction->executeAction();
|
$this->objectAction->executeAction();
|
||||||
$returnValues = $this->objectAction->getReturnValues();
|
$returnValues = $this->objectAction->getReturnValues();
|
||||||
$chatRoomEditor = new \chat\data\room\RoomEditor($returnValues['returnValues']);
|
$chatRoomEditor = new \chat\data\room\RoomEditor($returnValues['returnValues']);
|
||||||
$roomID = $returnValues['returnValues']->roomID;
|
$this->roomID = $returnValues['returnValues']->roomID;
|
||||||
$this->roomName = WCF::getLanguage()->getDynamicVariable('chat.room.titleTemp', array('roomID' => $roomID));
|
$this->roomName = WCF::getLanguage()->getDynamicVariable('chat.room.titleTemp', array('roomID' => $this->roomID));
|
||||||
|
|
||||||
// set accurate title
|
// set accurate title
|
||||||
$chatRoomEditor->update(array(
|
$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();
|
\chat\system\permission\PermissionHandler::clearCache();
|
||||||
$this->didInit();
|
$this->didInit();
|
||||||
}
|
}
|
||||||
@ -84,4 +85,14 @@ public function getMessage() {
|
|||||||
public function getReceiver() {
|
public function getReceiver() {
|
||||||
return \wcf\system\WCF::getUser()->userID;
|
return \wcf\system\WCF::getUser()->userID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \chat\system\command\ICommand::getAdditionalData()
|
||||||
|
*/
|
||||||
|
public function getAdditionalData() {
|
||||||
|
return array(
|
||||||
|
'roomID' => (int) $this->roomID,
|
||||||
|
'roomName' => $this->roomName
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public function getType() {
|
|||||||
public function getMessage() {
|
public function getMessage() {
|
||||||
$this->message = \wcf\system\bbcode\PreParser::getInstance()->parse($this->message, explode(',', \wcf\system\WCF::getSession()->getPermission('user.chat.allowedBBCodes')));
|
$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() {
|
public function getReceiver() {
|
||||||
return $this->user->userID;
|
return $this->user->userID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \chat\system\command\ICommand::getAdditionalData()
|
||||||
|
*/
|
||||||
|
public function getAdditionalData() {
|
||||||
|
return array(
|
||||||
|
'receiverUsername' => $this->user->username
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ CREATE TABLE chat1_message (
|
|||||||
enableHTML TINYINT(1) NOT NULL DEFAULT 0,
|
enableHTML TINYINT(1) NOT NULL DEFAULT 0,
|
||||||
color1 INT(10) NOT NULL DEFAULT 0,
|
color1 INT(10) NOT NULL DEFAULT 0,
|
||||||
color2 INT(10) NOT NULL DEFAULT 0,
|
color2 INT(10) NOT NULL DEFAULT 0,
|
||||||
|
additionalData TEXT DEFAULT NULL,
|
||||||
|
|
||||||
KEY (roomID),
|
KEY (roomID),
|
||||||
KEY (sender),
|
KEY (sender),
|
||||||
|
@ -110,7 +110,7 @@
|
|||||||
<!-- 1 = TYPE_JOIN -->
|
<!-- 1 = TYPE_JOIN -->
|
||||||
<item name="chat.message.1"><![CDATA[hat den Chat betreten.{if $__wcf->session->getPermission('admin.user.canViewIpAddress') && $ipAddress} ({$ipAddress}){/if}]]></item>
|
<item name="chat.message.1"><![CDATA[hat den Chat betreten.{if $__wcf->session->getPermission('admin.user.canViewIpAddress') && $ipAddress} ({$ipAddress}){/if}]]></item>
|
||||||
<!-- 2 = TYPE_LEAVE -->
|
<!-- 2 = TYPE_LEAVE -->
|
||||||
<item name="chat.message.2"><![CDATA[{if $room == null}hat den Chat verlassen.{else}ist in den Raum „{$room}“ gegangen.{/if}]]></item>
|
<item name="chat.message.2"><![CDATA[{if !$room|isset || $room === null}hat den Chat verlassen.{else}ist in den Raum „{$room}“ gegangen.{/if}]]></item>
|
||||||
<!-- 3 = TYPE_AWAY -->
|
<!-- 3 = TYPE_AWAY -->
|
||||||
<item name="chat.message.3"><![CDATA[ist jetzt abwesend{if $message}: {$message}{else}.{/if}]]></item>
|
<item name="chat.message.3"><![CDATA[ist jetzt abwesend{if $message}: {$message}{else}.{/if}]]></item>
|
||||||
<!-- 4 = TYPE_BACK -->
|
<!-- 4 = TYPE_BACK -->
|
||||||
|
@ -1 +1 @@
|
|||||||
{literal}<time>{@$formattedTime}</time> <span class="usernameContainer"><span class="username">{@$formattedUsername}</span><span class="separator">{$separator}</span></span> <span class="text">{@$formattedMessage}</span> <span class="markContainer"><input type="checkbox" value="{@$messageID}" /></span>{/literal}
|
{literal}<time>{@$formattedTime}</time> <span class="usernameContainer"><span class="username">{if $type != 7}{@$formattedUsername}{else}{if $receiver == WCF.User.userID}{@$formattedUsername} {/if}->{if $receiver != WCF.User.userID} {$additionalData.receiverUsername}{/if}{/if}</span><span class="separator">{$separator}</span></span> <span class="text">{@$formattedMessage}</span> <span class="markContainer"><input type="checkbox" value="{@$messageID}" /></span>{/literal}
|
Loading…
Reference in New Issue
Block a user