Add Thread object creation to /operator/history.php

Replace direct work with thread table's fields by Thread object
This commit is contained in:
Dmitriy Simushev 2012-10-01 12:40:04 +00:00
parent 0b2a379dd8
commit bebe603a9b
2 changed files with 18 additions and 14 deletions

View File

@ -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();

View File

@ -84,24 +84,24 @@ if( $page['pagination.items'] ) {
foreach( $page['pagination.items'] as $chatthread ) { ?>
<tr>
<td>
<a href="<?php echo $webimroot ?>/operator/threadprocessor.php?threadid=<?php echo $chatthread['threadid'] ?>" target="_blank" onclick="this.newWindow = window.open('<?php echo $webimroot ?>/operator/threadprocessor.php?threadid=<?php echo $chatthread['threadid'] ?>', '', 'toolbar=0,scrollbars=1,location=0,status=1,menubar=0,width=720,height=520,resizable=1');this.newWindow.focus();this.newWindow.opener=window;return false;"><?php echo topage(htmlspecialchars($chatthread['userName'])) ?></a>
<a href="<?php echo $webimroot ?>/operator/threadprocessor.php?threadid=<?php echo $chatthread->id ?>" target="_blank" onclick="this.newWindow = window.open('<?php echo $webimroot ?>/operator/threadprocessor.php?threadid=<?php echo $chatthread->id ?>', '', 'toolbar=0,scrollbars=1,location=0,status=1,menubar=0,width=720,height=520,resizable=1');this.newWindow.focus();this.newWindow.opener=window;return false;"><?php echo topage(htmlspecialchars($chatthread->userName)) ?></a>
</td>
<td>
<?php echo get_user_addr(topage($chatthread['remote'])) ?>
<?php echo get_user_addr(topage($chatthread->remote)) ?>
</td>
<td>
<?php if( $chatthread['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']]))." -";
}
?>
<?php if( $chatthread->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]))." -";
}
?>
</td>
<td>
<?php echo topage(htmlspecialchars($chatthread['size'])) ?>
<?php echo topage(htmlspecialchars($chatthread->messageCount)) ?>
</td>
<td>
<?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) ?>
</td>
</tr>
<?php