diff --git a/src/messenger/tests/server_side/webim/libs/classes/ThreadTest.php b/src/messenger/tests/server_side/webim/libs/classes/ThreadTest.php
index be7bfe3c..8697cdc0 100644
--- a/src/messenger/tests/server_side/webim/libs/classes/ThreadTest.php
+++ b/src/messenger/tests/server_side/webim/libs/classes/ThreadTest.php
@@ -607,48 +607,48 @@ class ThreadTest extends PHPUnit_Framework_TestCase {
// Create messages
// The first
$first_message = array(
- 'ikind' => Thread::KIND_USER,
- 'tmessage' => 'The first message',
+ 'kind' => Thread::KIND_USER,
+ 'message' => 'The first message',
'created' => time(),
- 'tname' => 'System message only for agent'
+ 'name' => 'System message only for agent'
);
// The second
$second_message = array(
- 'ikind' => Thread::KIND_AGENT,
- 'tmessage' => 'The second message',
+ 'kind' => Thread::KIND_AGENT,
+ 'message' => 'The second message',
'created' => time(),
- 'tname' => 'User'
+ 'name' => 'User'
);
// The third
$third_message = array(
- 'ikind' => Thread::KIND_FOR_AGENT,
- 'tmessage' => 'The third message',
+ 'kind' => Thread::KIND_FOR_AGENT,
+ 'message' => 'The third message',
'created' => time(),
- 'tname' => 'Agent'
+ 'name' => 'Agent'
);
// Send messages
// The first
- $first_message['messageid'] = $thread->postMessage(
- $first_message['ikind'],
- $first_message['tmessage'],
- $first_message['tname'],
+ $first_message['id'] = $thread->postMessage(
+ $first_message['kind'],
+ $first_message['message'],
+ $first_message['name'],
12,
$first_message['created']
);
// The second
- $second_message['messageid'] = $thread->postMessage(
- $second_message['ikind'],
- $second_message['tmessage'],
- $second_message['tname'],
+ $second_message['id'] = $thread->postMessage(
+ $second_message['kind'],
+ $second_message['message'],
+ $second_message['name'],
14,
$second_message['created']
);
// The third
- $third_message['messageid'] = $thread->postMessage(
- $third_message['ikind'],
- $third_message['tmessage'],
- $third_message['tname'],
+ $third_message['id'] = $thread->postMessage(
+ $third_message['kind'],
+ $third_message['message'],
+ $third_message['name'],
16,
$third_message['created']
);
@@ -660,7 +660,7 @@ class ThreadTest extends PHPUnit_Framework_TestCase {
$thread->getMessages(false, $last_id)
);
// Check last message id
- $this->assertEquals($third_message['messageid'], $last_id);
+ $this->assertEquals($third_message['id'], $last_id);
// Check messages for user with ids starts from $msg_id
$last_id = $msg_id;
@@ -669,16 +669,16 @@ class ThreadTest extends PHPUnit_Framework_TestCase {
$thread->getMessages(true, $last_id)
);
// Check last message id
- $this->assertEquals($second_message['messageid'], $last_id);
+ $this->assertEquals($second_message['id'], $last_id);
// Check messages for agent with ids starts from first message's id
- $last_id = $first_message['messageid'];
+ $last_id = $first_message['id'];
$this->assertEquals(
array($second_message, $third_message),
$thread->getMessages(false, $last_id)
);
// Check last message id
- $this->assertEquals($third_message['messageid'], $last_id);
+ $this->assertEquals($third_message['id'], $last_id);
// Delete thread
$thread->delete();
diff --git a/src/messenger/webim/libs/chat.php b/src/messenger/webim/libs/chat.php
index 3cbc177e..43cdc27f 100644
--- a/src/messenger/webim/libs/chat.php
+++ b/src/messenger/webim/libs/chat.php
@@ -28,19 +28,19 @@ function get_user_id()
function message_to_text($msg)
{
- if ($msg['ikind'] == Thread::KIND_AVATAR) {
+ if ($msg['kind'] == Thread::KIND_AVATAR) {
return "";
}
$message_time = date("H:i:s ", $msg['created']);
- if ($msg['ikind'] == Thread::KIND_USER || $msg['ikind'] == Thread::KIND_AGENT) {
- if ($msg['tname'])
- return $message_time . $msg['tname'] . ": " . $msg['tmessage'] . "\n";
+ if ($msg['kind'] == Thread::KIND_USER || $msg['kind'] == Thread::KIND_AGENT) {
+ if ($msg['name'])
+ return $message_time . $msg['name'] . ": " . $msg['message'] . "\n";
else
- return $message_time . $msg['tmessage'] . "\n";
- } else if ($msg['ikind'] == Thread::KIND_INFO) {
- return $message_time . $msg['tmessage'] . "\n";
+ return $message_time . $msg['message'] . "\n";
+ } else if ($msg['kind'] == Thread::KIND_INFO) {
+ return $message_time . $msg['message'] . "\n";
} else {
- return $message_time . "[" . $msg['tmessage'] . "]\n";
+ return $message_time . "[" . $msg['message'] . "]\n";
}
}
diff --git a/src/messenger/webim/libs/classes/thread.php b/src/messenger/webim/libs/classes/thread.php
index e4a9da10..711ab303 100644
--- a/src/messenger/webim/libs/classes/thread.php
+++ b/src/messenger/webim/libs/classes/thread.php
@@ -391,26 +391,26 @@ Class Thread {
global $webim_encoding;
// No theming for avatars
- if ($message['ikind'] == Thread::KIND_AVATAR) {
+ if ($message['kind'] == Thread::KIND_AVATAR) {
return '';
}
// Prepare messages fields
$creation_date = date("H:i:s", $message['created']);
- $kind_name = Thread::kindToString($message['ikind']);
- $sender_name = $message['tname']
- ? "" . htmlspecialchars($message['tname']) . ": "
+ $kind_name = Thread::kindToString($message['kind']);
+ $sender_name = $message['name']
+ ? "" . htmlspecialchars($message['name']) . ": "
: '';
// Prepare message text
// Escape special chars
- $text = htmlspecialchars($message['tmessage']);
+ $text = htmlspecialchars($message['message']);
// Replace URL's by tags
$text = preg_replace('/(https?|ftp):\/\/\S*/', '$0', $text);
// Add
tags instead of \n chars
$text = str_replace("\n", "
", $text);
// Span and storng tags available for system messages
- if ($message['ikind'] != Thread::KIND_USER && $message['ikind'] != Thread::KIND_AGENT) {
+ if ($message['kind'] != Thread::KIND_USER && $message['kind'] != Thread::KIND_AGENT) {
$text = preg_replace('/<(span|strong)>(.*)<\/\1>/U', '<$1>$2$1>', $text);
$text = preg_replace(
'/<span class="(.*)">(.*)<\/span>/U',
@@ -675,7 +675,8 @@ Class Thread {
// Load messages
$messages = $db->query(
- "select messageid,ikind,dtmcreated as created,tname,tmessage from {chatmessage} " .
+ "select messageid as id, ikind as kind, dtmcreated as created, tname as name, tmessage as message " .
+ "from {chatmessage} " .
"where threadid = :threadid and messageid > :lastid " .
($is_user ? "and ikind <> " . self::KIND_FOR_AGENT : "") .
" order by messageid",
@@ -688,8 +689,8 @@ Class Thread {
foreach ($messages as $msg) {
// Get last message ID
- if ($msg['messageid'] > $last_id) {
- $last_id = $msg['messageid'];
+ if ($msg['id'] > $last_id) {
+ $last_id = $msg['id'];
}
}
diff --git a/src/messenger/webim/libs/classes/thread_processor.php b/src/messenger/webim/libs/classes/thread_processor.php
index cd974146..fe8f20c1 100644
--- a/src/messenger/webim/libs/classes/thread_processor.php
+++ b/src/messenger/webim/libs/classes/thread_processor.php
@@ -239,7 +239,7 @@ class ThreadProcessor extends RequestProcessor {
if (! empty($messages)) {
foreach($messages as $key => $msg) {
// Check if message is avatar
- if ($msg['ikind'] == Thread::KIND_AVATAR) {
+ if ($msg['kind'] == Thread::KIND_AVATAR) {
// Update avatar
$this->responses[] = array(
'token' => md5(time() . rand()),
@@ -251,7 +251,7 @@ class ThreadProcessor extends RequestProcessor {
'token' => $thread->lastToken,
'return' => array(),
'references' => array(),
- 'imageLink' => $msg['tmessage']
+ 'imageLink' => $msg['message']
)
)
)
diff --git a/src/messenger/webim/operator/threadprocessor.php b/src/messenger/webim/operator/threadprocessor.php
index 02cb9f2f..dd5f8ecb 100644
--- a/src/messenger/webim/operator/threadprocessor.php
+++ b/src/messenger/webim/operator/threadprocessor.php
@@ -54,7 +54,7 @@ if (isset($_GET['threadid'])) {
$lastid = -1;
$messages = $thread_info['thread']->getMessages(false, $lastid);
foreach ($messages as $msg) {
- if ($msg['ikind'] == Thread::KIND_AVATAR) {
+ if ($msg['kind'] == Thread::KIND_AVATAR) {
continue;
}
$page['threadMessages'][] = Thread::themeMessage($msg);