Add Thread object creation to /operator/threadprocessor.php

Replace direct work with thread table's fields by Thread object
This commit is contained in:
Dmitriy Simushev 2012-10-01 11:14:03 +00:00
parent 69477cea8d
commit f553f42460
2 changed files with 19 additions and 15 deletions

View File

@ -29,15 +29,18 @@ setlocale(LC_TIME, getstring("time.locale"));
function thread_info($id)
{
$db = Database::getInstance();
return $db->query(
"select userName,agentName,remote,userAgent," .
"dtmmodified as modified, dtmcreated as created," .
"vclocalname as groupName " .
$thread_info = $db->query(
"select {chatthread}.*, {chatgroup}.vclocalname as groupName " .
"from {chatthread} left join {chatgroup} on {chatthread}.groupid = {chatgroup}.groupid " .
"where threadid = ?",
array($id),
array('return_rows' => Database::RETURN_ONE_ROW)
);
$thread = Thread::createFromDbInfo($thread_info);
return array(
'thread' => $thread,
'groupName' => $thread_info['groupName']
);
}
@ -45,7 +48,7 @@ if (isset($_GET['threadid'])) {
$threadid = verifyparam("threadid", "/^(\d{1,9})?$/", "");
$lastid = -1;
$page['threadMessages'] = get_messages($threadid, "html", false, $lastid);
$page['thread'] = thread_info($threadid);
$page['thread_info'] = thread_info($threadid);
}
prepare_menu($operator, false);

View File

@ -18,7 +18,8 @@
$page['title'] = getlocal("thread.chat_log");
function tpl_content() { global $page, $webimroot, $errors;
$chatthread = $page['thread'];
$chatthreadinfo = $page['thread_info'];
$chatthread = $page['thread_info']['thread'];
?>
<?php echo getlocal("thread.intro") ?>
@ -32,7 +33,7 @@ $chatthread = $page['thread'];
<?php echo getlocal("page.analysis.search.head_name") ?>:
</div>
<div class="wvalue">
<?php echo topage(htmlspecialchars($chatthread['userName'])) ?>
<?php echo topage(htmlspecialchars($chatthread->userName)) ?>
</div>
<br clear="all"/>
@ -40,7 +41,7 @@ $chatthread = $page['thread'];
<?php echo getlocal("page.analysis.search.head_host") ?>:
</div>
<div class="wvalue">
<?php echo get_user_addr(topage($chatthread['remote'])) ?>
<?php echo get_user_addr(topage($chatthread->remote)) ?>
</div>
<br clear="all"/>
@ -48,26 +49,26 @@ $chatthread = $page['thread'];
<?php echo getlocal("page.analysis.search.head_browser") ?>:
</div>
<div class="wvalue">
<?php echo get_useragent_version(topage($chatthread['userAgent'])) ?>
<?php echo get_useragent_version(topage($chatthread->userAgent)) ?>
</div>
<br clear="all"/>
<?php if( $chatthread['groupName'] ) { ?>
<?php if( $chatthreadinfo['groupName'] ) { ?>
<div class="wlabel">
<?php echo getlocal("page.analysis.search.head_group") ?>:
</div>
<div class="wvalue">
<?php echo topage(htmlspecialchars($chatthread['groupName'])) ?>
<?php echo topage(htmlspecialchars($chatthreadinfo['groupName'])) ?>
</div>
<br clear="all"/>
<?php } ?>
<?php if( $chatthread['agentName'] ) { ?>
<?php if( $chatthread->agentName ) { ?>
<div class="wlabel">
<?php echo getlocal("page.analysis.search.head_operator") ?>:
</div>
<div class="wvalue">
<?php echo topage(htmlspecialchars($chatthread['agentName'])) ?>
<?php echo topage(htmlspecialchars($chatthread->agentName)) ?>
</div>
<br clear="all"/>
<?php } ?>
@ -76,8 +77,8 @@ $chatthread = $page['thread'];
<?php echo getlocal("page.analysis.search.head_time") ?>:
</div>
<div class="wvalue">
<?php echo date_diff_to_text($chatthread['modified']-$chatthread['created']) ?>
(<?php echo date_to_text($chatthread['created']) ?>)
<?php echo date_diff_to_text($chatthread->modified-$chatthread->created) ?>
(<?php echo date_to_text($chatthread->created) ?>)
</div>
<br clear="all"/>
</div>