Skip to content

Commit

Permalink
Merge pull request #67 from xibosignage/develop
Browse files Browse the repository at this point in the history
Pre 5.4 support.
  • Loading branch information
dasgarner committed May 27, 2015
2 parents ac48531 + a660ffb commit e1504ff
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/pages/auditlog.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,16 @@ function Grid()

// Get the dates and times
if ($filterFromDt == '') {
$fromTimestamp = (new DateTime())->sub(new DateInterval("P1D"));
$fromTimestamp = new DateTime();
$fromTimestamp = $fromTimestamp->sub(new DateInterval("P1D"));
}
else {
$fromTimestamp = DateTime::createFromFormat('Y-m-d', $filterFromDt);
$fromTimestamp->setTime(0, 0, 0);
}

if ($filterToDt == '') {
$toTimestamp = (new DateTime());
$toTimestamp = new DateTime();
}
else {
$toTimestamp = DateTime::createFromFormat('Y-m-d', $filterToDt);
Expand Down Expand Up @@ -153,7 +154,7 @@ function Grid()
);
Theme::Set('table_cols', $cols);

$rows = \Xibo\Factory\AuditLogFactory::query('logId', ['search' => $search]);
$rows = \Xibo\Factory\AuditLogFactory::query('logId', array('search' => $search));

// Do some post processing
foreach ($rows as $row) {
Expand Down Expand Up @@ -212,16 +213,16 @@ public function outputCSV()
$toTimestamp->setTime(0, 0, 0);

$search = array(
['fromTimeStamp', $fromTimestamp->format('U')],
['toTimeStamp', $toTimestamp->format('U')]
array('fromTimeStamp', $fromTimestamp->format('U')),
array('toTimeStamp', $toTimestamp->format('U'))
);

// Build the search string
$search = implode(' ', array_map(function ($element) {
return implode('|', $element);
}, $search));

$rows = \Xibo\Factory\AuditLogFactory::query('logId', ['search' => $search]);
$rows = \Xibo\Factory\AuditLogFactory::query('logId', array('search' => $search));

// We want to output a load of stuff to the browser as a text file.
header('Content-Type: text/csv');
Expand All @@ -230,12 +231,12 @@ public function outputCSV()
header('Accept-Ranges: bytes');

$out = fopen('php://output', 'w');
fputcsv($out, ['ID', 'Date', 'User', 'Entity', 'Message', 'Object']);
fputcsv($out, array('ID', 'Date', 'User', 'Entity', 'Message', 'Object'));

// Do some post processing
foreach ($rows as $row) {
/* @var \Xibo\Entity\AuditLog $row */
fputcsv($out, [$row->logId, DateManager::getLocalDate($row->logDate), $row->userName, $row->entity, $row->message, $row->objectAfter]);
fputcsv($out, array($row->logId, DateManager::getLocalDate($row->logDate), $row->userName, $row->entity, $row->message, $row->objectAfter));
}

fclose($out);
Expand Down

0 comments on commit e1504ff

Please sign in to comment.