Translate ServerId to Server in Log record before sending back

This commit is contained in:
Isaac Connor 2016-01-01 16:33:28 -05:00
parent 8e25b80252
commit ec7504f925
1 changed files with 8 additions and 0 deletions

View File

@ -31,6 +31,13 @@ switch ( $_REQUEST['task'] )
if ( !canView( 'System' ) ) if ( !canView( 'System' ) )
ajaxError( 'Insufficient permissions to view log entries' ); ajaxError( 'Insufficient permissions to view log entries' );
$servers = Server::find_all();
$servers_by_Id = array();
# There is probably a better way to do this.
foreach ( $servers as $server ) {
$servers_by_Id[$server->Id()] = $server;
}
$minTime = isset($_POST['minTime'])?$_POST['minTime']:NULL; $minTime = isset($_POST['minTime'])?$_POST['minTime']:NULL;
$maxTime = isset($_POST['maxTime'])?$_POST['maxTime']:NULL; $maxTime = isset($_POST['maxTime'])?$_POST['maxTime']:NULL;
$limit = isset($_POST['limit'])?$_POST['limit']:100; $limit = isset($_POST['limit'])?$_POST['limit']:100;
@ -66,6 +73,7 @@ switch ( $_REQUEST['task'] )
$logs = array(); $logs = array();
foreach ( dbFetchAll( $sql, NULL, $values ) as $log ) { foreach ( dbFetchAll( $sql, NULL, $values ) as $log ) {
$log['DateTime'] = preg_replace( '/^\d+/', strftime( "%Y-%m-%d %H:%M:%S", intval($log['TimeKey']) ), $log['TimeKey'] ); $log['DateTime'] = preg_replace( '/^\d+/', strftime( "%Y-%m-%d %H:%M:%S", intval($log['TimeKey']) ), $log['TimeKey'] );
$log['Server'] = $log['ServerId'] ? $servers_by_Id[$log['ServerId']]->Name() : '';
$logs[] = $log; $logs[] = $log;
} }
$options = array(); $options = array();