diff --git a/file/js/be.bastelstu.Chat.litcoffee b/file/js/be.bastelstu.Chat.litcoffee
index 41de5c9..096fb9d 100644
--- a/file/js/be.bastelstu.Chat.litcoffee
+++ b/file/js/be.bastelstu.Chat.litcoffee
@@ -909,7 +909,7 @@ Create a message containing the uploaded attachment
$('#timsChatUpload > span.icon-spinner').removeClass('icon-spinner').addClass 'icon-ban-circle'
# error message
- $('#timsChatUploadContainer').append """#{WCF.Language.get('wcf.attachment.upload.error.tooLarge')}"""
+ $('#timsChatUpload').addClass('uploadFailed').after """#{WCF.Language.get('wcf.attachment.upload.error.tooLarge')}"""
do @_error
li.addClass 'uploadFailed'
@@ -979,6 +979,7 @@ Create a message containing the uploaded attachment
"""
li.parent().append deleteButton
+ fileUploaded = yes
else
$('#timsChatUpload .icon-spinner').removeClass('icon-spinner').addClass 'icon-ban-circle'
@@ -990,20 +991,22 @@ Create a message containing the uploaded attachment
$('#timsChatUpload').addClass('uploadFailed').after """#{WCF.Language.get('wcf.attachment.upload.error.' + errorMessage)}"""
do $('#timsChatUploadDropdownMenu .sendAttachmentButton').remove
do $('#timsChatUploadDropdownMenu .uploadButton').show
-
+ fileUploaded = no
+
do WCF.DOMNodeInsertedHandler.execute
- fileUploaded = yes
$('#timsChatUpload > span.icon').removeClass('icon-spinner').addClass 'icon-ok-sign'
do $('#timsChatUploadDropdownMenu .uploadProgress').remove
do $('#timsChatUploadDropdownMenu .sendAttachmentButton').show
_error: (jqXHR, textStatus, errorThrown) ->
$('#timsChatUpload > .icon-spinner').removeClass('icon-spinner').addClass 'icon-ban-circle'
- $('#timsChatUpload').addClass('uploadFailed').after """#{WCF.Language.get('wcf.attachment.upload.error.uploadFailed')}"""
+ unless $('#timsChatUpload').hasClass('uploadFailed')
+ $('#timsChatUpload').addClass('uploadFailed').after """#{WCF.Language.get('wcf.attachment.upload.error.uploadFailed')}"""
do $('#timsChatUploadDropdownMenu .uploadProgress').remove
do $('#timsChatUploadDropdownMenu .uploadButton').show
+ fileUploaded = no
Action = {}
Action.Delete = WCF.Action.Delete.extend
diff --git a/file/lib/data/message/Message.class.php b/file/lib/data/message/Message.class.php
index c6aaf0b..5f13b84 100644
--- a/file/lib/data/message/Message.class.php
+++ b/file/lib/data/message/Message.class.php
@@ -69,7 +69,7 @@ public function __toString() {
* @param string $outputType outputtype for messageparser
* @return string
*/
- public function getFormattedMessage($type = 'text/html') {
+ public function getFormattedMessage($type = 'text/html', $attachmentList = null) {
$message = $this->message;
$messageParser = \wcf\system\bbcode\MessageParser::getInstance();
$messageParser->setOutputType($type);
@@ -90,14 +90,16 @@ public function getFormattedMessage($type = 'text/html') {
$message = $messageParser->parse($message, false, false, true, false);
break;
case self::TYPE_ATTACHMENT:
- $attachmentList = new \wcf\data\attachment\GroupedAttachmentList('be.bastelstu.chat.message');
- $attachmentList->getConditionBuilder()->add('attachment.objectID IN (?)', array($this->messageID));
- $attachmentList->readObjects();
+ if ($attachmentList === null) {
+ $attachmentList = new \wcf\data\attachment\GroupedAttachmentList('be.bastelstu.chat.message');
+ $attachmentList->getConditionBuilder()->add('attachment.objectID IN (?)', array($this->messageID));
+ $attachmentList->readObjects();
+ }
AttachmentBBCode::setAttachmentList($attachmentList);
AttachmentBBCode::setObjectID($this->messageID);
- $message = $messageParser->parse('[attach]'. $message .'[/attach]', 0, 0, true, false);
+ $message = $messageParser->parse($message, false, false, true, false);
break;
case self::TYPE_WHISPER:
case self::TYPE_NORMAL:
@@ -147,12 +149,28 @@ public function jsonify($raw = false) {
break;
}
+ $attachment = null;
+ $attachmentList = null;
+
+ if ($this->attachmentID !== 0) {
+ $attachmentList = new \wcf\data\attachment\GroupedAttachmentList('be.bastelstu.chat.message');
+ $attachmentList->getConditionBuilder()->add('attachment.attachmentID = ?', array($this->attachmentID));
+ $attachmentList->getConditionBuilder()->add('attachment.objectID = ?', array($this->messageID));
+ $attachmentList->readObjects();
+
+ if (isset($attachmentList->objectIDs[0]) && $attachmentList->objectIDs[0] != 0) {
+ $attachment = $attachmentList->objects[$attachmentList->objectIDs[0]];
+ $attachment->data['imageinfo'] = WCF::getLanguage()->getDynamicVariable('wcf.attachment.image.info', array('attachment' => $attachment));
+ $attachment = $attachment->data;
+ }
+ }
+
$array = array(
'formattedUsername' => $this->getUsername(true),
- 'formattedMessage' => $this->getFormattedMessage(),
+ 'formattedMessage' => $this->getFormattedMessage('text/html', ($attachmentList !== null) ? $attachmentList : null),
'formattedTime' => \wcf\util\DateUtil::format(\wcf\util\DateUtil::getDateTimeByTimestamp($this->time), 'H:i:s'),
'separator' => $separator,
- 'message' => $this->getFormattedMessage('text/plain'),
+ 'message' => $this->getFormattedMessage('text/plain', ($attachmentList !== null) ? $attachmentList : null),
'sender' => (int) $this->sender,
'username' => $this->getUsername(),
'time' => (int) $this->time,
@@ -160,7 +178,8 @@ public function jsonify($raw = false) {
'type' => (int) $this->type,
'roomID' => (int) $this->roomID,
'messageID' => (int) $this->messageID,
- 'additionalData' => $this->additionalData
+ 'additionalData' => $this->additionalData,
+ 'attachment' => $attachment
);
if ($raw) return $array;
diff --git a/file/lib/data/message/MessageAction.class.php b/file/lib/data/message/MessageAction.class.php
index 223b6af..5b15238 100644
--- a/file/lib/data/message/MessageAction.class.php
+++ b/file/lib/data/message/MessageAction.class.php
@@ -247,15 +247,12 @@ public function sendAttachment() {
'roomID' => $this->parameters['room']->roomID,
'sender' => WCF::getUser()->userID,
'username' => WCF::getUser()->username,
- 'receiver' => null,
'time' => TIME_NOW,
'type' => Message::TYPE_ATTACHMENT,
- 'message' => $this->parameters['objectID'],
- 'enableSmilies' => 0,
- 'enableHTML' => 0,
+ 'message' => '[attach]'. $this->parameters['objectID'] .'[/attach]',
'color1' => $this->parameters['userData']['color1'],
'color2' => $this->parameters['userData']['color2'],
- 'additionalData' => null
+ 'attachmentID' => $this->parameters['objectID']
)
));
diff --git a/file/style/be.bastelstu.chat.less b/file/style/be.bastelstu.chat.less
index b58abef..32030b1 100644
--- a/file/style/be.bastelstu.chat.less
+++ b/file/style/be.bastelstu.chat.less
@@ -10,7 +10,7 @@
from {
border-color: @wcfContainerBorderColor;
}
-
+
to {
border-color: @wcfInputHoverBorderColor;
}
@@ -92,7 +92,7 @@
> .userAvatar, .userAvatar > .icon {
cursor: pointer;
}
-
+
> .userAvatar {
&.large {
display: none;
@@ -102,7 +102,7 @@
display: block;
}
}
-
+
&.active {
> .userAvatar {
&.large {
diff --git a/install.sql b/install.sql
index d064d8f..03619ae 100644
--- a/install.sql
+++ b/install.sql
@@ -22,10 +22,12 @@ CREATE TABLE chat1_message (
color1 INT(10) NOT NULL DEFAULT 0,
color2 INT(10) NOT NULL DEFAULT 0,
additionalData TEXT DEFAULT NULL,
+ attachmentID INT(10) DEFAULT NULL,
KEY (roomID),
KEY (sender),
- KEY (receiver)
+ KEY (receiver),
+ KEY (attachmentID)
);
DROP TABLE IF EXISTS chat1_room;
@@ -69,6 +71,7 @@ ALTER TABLE wcf1_user ADD COLUMN chatLastSeen INT(10) NOT NULL DEFAULT 0;
ALTER TABLE chat1_message ADD FOREIGN KEY (receiver) REFERENCES wcf1_user (userID) ON DELETE CASCADE;
ALTER TABLE chat1_message ADD FOREIGN KEY (roomID) REFERENCES chat1_room (roomID) ON DELETE CASCADE;
ALTER TABLE chat1_message ADD FOREIGN KEY (sender) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
+ALTER TABLE chat1_message ADD FOREIGN KEY (attachmentID) REFERENCES wcf1_attachment (attachmentID) ON DELETE CASCADE;
ALTER TABLE chat1_room ADD FOREIGN KEY (owner) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
diff --git a/language/de.xml b/language/de.xml
index 93e9e25..fbbfb90 100644
--- a/language/de.xml
+++ b/language/de.xml
@@ -194,6 +194,8 @@ Probieren Sie den Chat neu zu laden
+