From 50283a0b217a8a684b0afa876b489887c4151643 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Fri, 28 Sep 2012 14:35:34 +0000 Subject: [PATCH] Move kindToString() method from ThreadProcessor to Thread --- src/messenger/webim/libs/classes/thread.php | 22 +++++++++++++++++ .../webim/libs/classes/thread_processor.php | 24 +------------------ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/messenger/webim/libs/classes/thread.php b/src/messenger/webim/libs/classes/thread.php index 9f6c4819..a162d664 100644 --- a/src/messenger/webim/libs/classes/thread.php +++ b/src/messenger/webim/libs/classes/thread.php @@ -334,6 +334,28 @@ Class Thread { return false; } + /** + * Return message kind name corresponding to kind code + * + * @param int $message_kind Message kind. One of the Thread::KIND_* constants + * @return string kind's full name or its shortening + */ + public static function kindToString($message_kind) { + $kind_names = array( + Thread::KIND_USER => 'user', + Thread::KIND_AGENT => 'agent', + Thread::KIND_FOR_AGENT => 'hidden', + Thread::KIND_INFO => 'inf', + Thread::KIND_CONN => 'conn', + Thread::KIND_EVENTS => 'event', + Thread::KIND_AVATAR => 'avatar' + ); + if (! array_key_exists($message_kind, $kind_names)) { + return ''; + } + return $kind_names[$message_kind]; + } + /** * Return next revision number (last revision number plus one) * diff --git a/src/messenger/webim/libs/classes/thread_processor.php b/src/messenger/webim/libs/classes/thread_processor.php index 0df45fbf..a9b14ad3 100644 --- a/src/messenger/webim/libs/classes/thread_processor.php +++ b/src/messenger/webim/libs/classes/thread_processor.php @@ -224,28 +224,6 @@ class ThreadProcessor extends RequestProcessor { return $requests; } - /** - * Return message kind name corresponding to kind code - * - * @param int $message_kind Message kind. One of the Thread::KIND_* constants - * @return string kind name - */ - protected function kindToString($message_kind) { - $kind_names = array( - Thread::KIND_USER => 'user', - Thread::KIND_AGENT => 'agent', - Thread::KIND_FOR_AGENT => 'hidden', - Thread::KIND_INFO => 'inf', - Thread::KIND_CONN => 'conn', - Thread::KIND_EVENTS => 'event', - Thread::KIND_AVATAR => 'avatar' - ); - if (! array_key_exists($message_kind, $kind_names)) { - return ''; - } - return $kind_names[$message_kind]; - } - /** * Theme message to display in chat window * @@ -262,7 +240,7 @@ class ThreadProcessor extends RequestProcessor { // Prepare messages fields $creation_date = date("H:i:s", $message['created']); - $kind_name = $this->kindToString($message['ikind']); + $kind_name = Thread::kindToString($message['ikind']); $sender_name = $message['tname'] ? "" . htmlspecialchars($message['tname']) . ": " : '';