2008-07-14 21:54:50 +08:00
< ? php
2013-12-18 00:07:19 +08:00
if ( empty ( $_REQUEST [ 'id' ]) && empty ( $_REQUEST [ 'eids' ]) ) {
2008-10-17 00:12:23 +08:00
ajaxError ( " No event id(s) supplied " );
2008-07-14 21:54:50 +08:00
}
2013-12-18 00:07:19 +08:00
if ( canView ( 'Events' ) ) {
switch ( $_REQUEST [ 'action' ] ) {
case " video " : {
if ( empty ( $_REQUEST [ 'videoFormat' ]) ) {
2008-10-17 00:12:23 +08:00
ajaxError ( " Video Generation Failure, no format given " );
2013-12-18 00:07:19 +08:00
} elseif ( empty ( $_REQUEST [ 'rate' ]) ) {
2008-10-17 00:12:23 +08:00
ajaxError ( " Video Generation Failure, no rate given " );
2013-12-18 00:07:19 +08:00
} elseif ( empty ( $_REQUEST [ 'scale' ]) ) {
2008-10-17 00:12:23 +08:00
ajaxError ( " Video Generation Failure, no scale given " );
2013-12-18 00:07:19 +08:00
} else {
2014-09-27 02:43:58 +08:00
$sql = 'SELECT E.*,M.Name AS MonitorName,M.DefaultRate,M.DefaultScale FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE E.Id = ?' . monitorLimitSql ();
2013-12-18 00:07:19 +08:00
if ( ! ( $event = dbFetchOne ( $sql , NULL , array ( $_REQUEST [ 'id' ] ) )) )
2008-10-17 00:12:23 +08:00
ajaxError ( " Video Generation Failure, can't load event " );
2008-07-14 21:54:50 +08:00
else
2008-10-17 00:12:23 +08:00
if ( $videoFile = createVideo ( $event , $_REQUEST [ 'videoFormat' ], $_REQUEST [ 'rate' ], $_REQUEST [ 'scale' ], ! empty ( $_REQUEST [ 'overwrite' ]) ) )
ajaxResponse ( array ( 'response' => $videoFile ) );
2008-07-14 21:54:50 +08:00
else
2008-10-17 00:12:23 +08:00
ajaxError ( " Video Generation Failed " );
2008-07-14 21:54:50 +08:00
}
2008-10-17 00:12:23 +08:00
$ok = true ;
break ;
}
case 'deleteVideo' :
{
unlink ( $videoFiles [ $_REQUEST [ 'id' ]] );
unset ( $videoFiles [ $_REQUEST [ 'id' ]] );
ajaxResponse ();
break ;
}
case " export " :
{
require_once ( ZM_SKIN_PATH . '/includes/export_functions.php' );
2008-07-14 21:54:50 +08:00
2008-10-17 00:12:23 +08:00
if ( ! empty ( $_REQUEST [ 'exportDetail' ]) )
$exportDetail = $_SESSION [ 'export' ][ 'detail' ] = $_REQUEST [ 'exportDetail' ];
else
$exportDetail = false ;
if ( ! empty ( $_REQUEST [ 'exportFrames' ]) )
$exportFrames = $_SESSION [ 'export' ][ 'frames' ] = $_REQUEST [ 'exportFrames' ];
else
$exportFrames = false ;
if ( ! empty ( $_REQUEST [ 'exportImages' ]) )
$exportImages = $_SESSION [ 'export' ][ 'images' ] = $_REQUEST [ 'exportImages' ];
else
$exportImages = false ;
if ( ! empty ( $_REQUEST [ 'exportVideo' ]) )
$exportVideo = $_SESSION [ 'export' ][ 'video' ] = $_REQUEST [ 'exportVideo' ];
else
$exportVideo = false ;
if ( ! empty ( $_REQUEST [ 'exportMisc' ]) )
$exportMisc = $_SESSION [ 'export' ][ 'misc' ] = $_REQUEST [ 'exportMisc' ];
else
$exportMisc = false ;
if ( ! empty ( $_REQUEST [ 'exportFormat' ]) )
$exportFormat = $_SESSION [ 'export' ][ 'format' ] = $_REQUEST [ 'exportFormat' ];
else
$exportFormat = '' ;
2008-07-14 21:54:50 +08:00
2009-03-27 17:14:54 +08:00
$exportIds = ! empty ( $_REQUEST [ 'eids' ]) ? $_REQUEST [ 'eids' ] : $_REQUEST [ 'id' ];
if ( $exportFile = exportEvents ( $exportIds , $exportDetail , $exportFrames , $exportImages , $exportVideo , $exportMisc , $exportFormat ) )
2008-10-17 00:12:23 +08:00
ajaxResponse ( array ( 'exportFile' => $exportFile ) );
else
ajaxError ( " Export Failed " );
break ;
2008-07-14 21:54:50 +08:00
}
}
2008-10-17 00:12:23 +08:00
}
2009-03-27 17:14:54 +08:00
2008-10-17 00:12:23 +08:00
if ( canEdit ( 'Events' ) )
{
switch ( $_REQUEST [ 'action' ] )
2008-07-14 21:54:50 +08:00
{
2008-10-17 00:12:23 +08:00
case " rename " :
{
if ( ! empty ( $_REQUEST [ 'eventName' ]) )
2013-12-18 00:07:19 +08:00
dbQuery ( 'UPDATE Events SET Name = ? WHERE Id = ?' , array ( $_REQUEST [ 'eventName' ], $_REQUEST [ 'id' ] ) );
2008-10-17 00:12:23 +08:00
else
ajaxError ( " No new event name supplied " );
ajaxResponse ( array ( 'refreshEvent' => true , 'refreshParent' => true ) );
break ;
}
case " eventdetail " :
{
2013-12-18 00:07:19 +08:00
dbQuery ( 'UPDATE Events SET Cause = ?, Notes = ? WHERE Id = ?' , array ( $_REQUEST [ 'newEvent' ][ 'Cause' ], $_REQUEST [ 'newEvent' ][ 'Notes' ], $_REQUEST [ 'id' ] ) );
2008-10-17 00:12:23 +08:00
ajaxResponse ( array ( 'refreshEvent' => true , 'refreshParent' => true ) );
break ;
}
case " archive " :
case " unarchive " :
{
$archiveVal = ( $_REQUEST [ 'action' ] == " archive " ) ? 1 : 0 ;
2013-12-18 00:07:19 +08:00
dbQuery ( 'UPDATE Events SET Archived = ? WHERE Id = ?' , array ( $archiveVal , $_REQUEST [ 'id' ]) );
2008-10-17 00:12:23 +08:00
ajaxResponse ( array ( 'refreshEvent' => true , 'refreshParent' => false ) );
break ;
}
case " delete " :
{
2013-12-18 00:07:19 +08:00
deleteEvent ( $_REQUEST [ 'id' ] );
2008-10-17 00:12:23 +08:00
ajaxResponse ( array ( 'refreshEvent' => false , 'refreshParent' => true ) );
break ;
}
2008-07-14 21:54:50 +08:00
}
}
2008-10-17 00:12:23 +08:00
ajaxError ( 'Unrecognised action or insufficient permissions' );
2008-07-14 21:54:50 +08:00
?>