From bebe603a9bc632df6fa00698ba0e24a6203db6ee Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Mon, 1 Oct 2012 12:40:04 +0000 Subject: [PATCH] Add Thread object creation to /operator/history.php Replace direct work with thread table's fields by Thread object --- src/messenger/webim/operator/history.php | 12 ++++++++---- src/messenger/webim/view/thread_search.php | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/messenger/webim/operator/history.php b/src/messenger/webim/operator/history.php index c328a8c6..1b3efaa4 100644 --- a/src/messenger/webim/operator/history.php +++ b/src/messenger/webim/operator/history.php @@ -68,10 +68,9 @@ if ($query !== false) { $searchConditions[] = "({chatthread}.userName LIKE :query)"; $searchConditions[] = "({chatthread}.remote LIKE :query)"; } - select_with_pagintation("DISTINCT {chatthread}.dtmcreated as created, " . - "{chatthread}.dtmmodified as modified, {chatthread}.threadid, " . - "{chatthread}.remote, {chatthread}.agentName, {chatthread}.userName, groupid, " . - "messageCount as size", + + // Load threads + select_with_pagintation("DISTINCT {chatthread}.*", "{chatthread}, {chatmessage}", array( "{chatmessage}.threadid = {chatthread}.threadid", @@ -80,6 +79,11 @@ if ($query !== false) { "order by {chatthread}.dtmcreated DESC", "DISTINCT {chatthread}.dtmcreated", $values); + // Build Thread object + foreach ($page['pagination.items'] as $key => $item) { + $page['pagination.items'][$key] = Thread::createFromDbInfo($item); + } + $page['formq'] = topage($query); } else { setup_empty_pagination(); diff --git a/src/messenger/webim/view/thread_search.php b/src/messenger/webim/view/thread_search.php index da2d826d..68c0d2e7 100644 --- a/src/messenger/webim/view/thread_search.php +++ b/src/messenger/webim/view/thread_search.php @@ -84,24 +84,24 @@ if( $page['pagination.items'] ) { foreach( $page['pagination.items'] as $chatthread ) { ?> - + userName)) ?> - + remote)) ?> - + agentName ) { + echo topage(htmlspecialchars($chatthread->agentName)); + } else if($chatthread->groupId && $chatthread->groupId != 0 && isset($page['groupName'][$chatthread->groupId])) { + echo "- ".topage(htmlspecialchars($page['groupName'][$chatthread->groupId]))." -"; + } + ?> - + messageCount)) ?> - , + modified-$chatthread->created) ?>, created) ?>