Merge pull request #782 from onlyjob/export

skins/classic: fix HTML export with USE_DEEP_STORAGE (Closes: #506).
This commit is contained in:
Andrew Bauer 2015-04-04 08:37:06 -05:00
commit d25f7ed362
1 changed files with 11 additions and 7 deletions

View File

@ -181,7 +181,7 @@ function exportEventFrames( $event, $exportDetail, $exportImages )
<?php <?php
if ( count($frames) ) if ( count($frames) )
{ {
$eventPath = mygetEventPath( $event ); $eventPath = ZM_DIR_EVENTS.'/'.mygetEventPath( $event );
foreach ( $frames as $frame ) foreach ( $frames as $frame )
{ {
$imageFile = sprintf( "%0".ZM_EVENT_IMAGE_DIGITS."d-capture.jpg", $frame['FrameId'] ); $imageFile = sprintf( "%0".ZM_EVENT_IMAGE_DIGITS."d-capture.jpg", $frame['FrameId'] );
@ -600,9 +600,13 @@ function exportEventImagesMaster( $eids )
<?php <?php
foreach ($eids as $eid) { foreach ($eids as $eid) {
//get monitor id and event id //get monitor id and event id
$sql = 'SELECT E.MonitorId FROM Monitors AS M INNER JOIN Events AS E ON (M.Id = E.MonitorId) WHERE E.Id = ?'; $sql = 'SELECT E.MonitorId, E.StartTime, E.Id
FROM Monitors AS M INNER JOIN Events AS E ON (M.Id = E.MonitorId)
WHERE E.Id = ?
';
$event = dbFetchOne( $sql, NULL, array( $eid ) ); $event = dbFetchOne( $sql, NULL, array( $eid ) );
$eventMonitorId[$eid] = $event['MonitorId']; $eventMonitorId[$eid] = $event['MonitorId'];
$eventPath[$eid] = mygetEventPath( $event );
} }
$monitors = array_values(array_flip(array_flip($eventMonitorId))); //unique monitors and reindex the array $monitors = array_values(array_flip(array_flip($eventMonitorId))); //unique monitors and reindex the array
@ -644,7 +648,7 @@ function exportEventImagesMaster( $eids )
<?php foreach($eids as $eid) <?php foreach($eids as $eid)
{ {
?> ?>
<div><a href="javascript:switchevent('<?php echo $eventMonitorId[$eid].'/' . $eid; ?>/zmEventImages.html');"><?php echo$eid?></a></div> <div><a href="javascript:switchevent('<?php echo $eventPath[$eid]; ?>/zmEventImages.html');"><?php echo$eid?></a></div>
<?php <?php
} }
?> ?>
@ -660,7 +664,7 @@ function exportEventImagesMaster( $eids )
if ($eventMonitorId[$eid] == $monitor) if ($eventMonitorId[$eid] == $monitor)
{ {
?> ?>
<div><a href="javascript:switchevent('<?php echo $eventMonitorId[$eid].'/' . $eid; ?>/zmEventImages.html');"><?php echo$eid?></a></div> <div><a href="javascript:switchevent('<?php echo $eventPath[$eid]; ?>/zmEventImages.html');"><?php echo$eid?></a></div>
<?php <?php
} }
} }
@ -763,7 +767,7 @@ function exportFileList( $eid, $exportDetail, $exportFrames, $exportImages, $exp
{ {
$sql = 'SELECT E.Id,E.MonitorId,M.Name AS MonitorName,M.Width,M.Height,E.Name,E.Cause,E.Notes,E.StartTime,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived FROM Monitors AS M INNER JOIN Events AS E ON (M.Id = E.MonitorId) WHERE E.Id = ?'; $sql = 'SELECT E.Id,E.MonitorId,M.Name AS MonitorName,M.Width,M.Height,E.Name,E.Cause,E.Notes,E.StartTime,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived FROM Monitors AS M INNER JOIN Events AS E ON (M.Id = E.MonitorId) WHERE E.Id = ?';
$event = dbFetchOne( $sql, NULL, array( $eid ) ); $event = dbFetchOne( $sql, NULL, array( $eid ) );
$eventPath = mygetEventPath( $event ); $eventPath = ZM_DIR_EVENTS.'/'.mygetEventPath( $event );
$files = array(); $files = array();
if ( $dir = opendir( $eventPath ) ) if ( $dir = opendir( $eventPath ) )
{ {
@ -956,8 +960,8 @@ function exportEvents( $eids, $exportDetail, $exportFrames, $exportImages, $expo
function mygetEventPath( $event ) function mygetEventPath( $event )
{ {
if ( ZM_USE_DEEP_STORAGE ) if ( ZM_USE_DEEP_STORAGE )
$eventPath = ZM_DIR_EVENTS.'/'.$event['MonitorId'].'/'.strftime( "%y/%m/%d/%H/%M/%S", strtotime($event['StartTime']) ); $eventPath = $event['MonitorId'].'/'.strftime( "%y/%m/%d/%H/%M/%S", strtotime($event['StartTime']) );
else else
$eventPath = ZM_DIR_EVENTS.'/'.$event['MonitorId'].'/'.$event['Id']; $eventPath = $event['MonitorId'].'/'.$event['Id'];
return( $eventPath ); return( $eventPath );
} }