Add Thread object creation to /operator/userhistory.php

Replace direct work with thread table's fields by Thread object
This commit is contained in:
Dmitriy Simushev 2012-10-01 11:52:03 +00:00
parent 898ecc3055
commit 0b2a379dd8
2 changed files with 10 additions and 8 deletions

View File

@ -38,12 +38,11 @@ function threads_by_userid($userid)
if ($userid == "") {
return null;
}
return $db->query(
"select dtmcreated as created, " .
"dtmmodified as modified, threadid, remote, agentName, userName " .
"select {chatthread}.* " .
"from {chatthread} " .
"where userid=? order by created DESC",
"where userid=? order by dtmcreated DESC",
array($userid),
array('return_rows' => Database::RETURN_ALL_ROWS)
);
@ -53,6 +52,9 @@ $found = threads_by_userid($userid);
prepare_menu($operator);
setup_pagination($found, 6);
foreach ($page['pagination.items'] as $key => $item) {
$page['pagination.items'][$key] = Thread::createFromDbInfo($item);
}
start_html_output();
require('../view/userhistory.php');
?>

View File

@ -46,16 +46,16 @@ 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'] ) { ?><?php echo topage(htmlspecialchars($chatthread['agentName'])) ?><?php } ?>
<?php if( $chatthread->agentName ) { ?><?php echo topage(htmlspecialchars($chatthread->agentName)) ?><?php } ?>
</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