spaces/quotes

pull/3038/head
Isaac Connor 2017-06-08 13:37:26 -04:00
parent 84fd80b242
commit 81c2216eb6
1 changed files with 102 additions and 101 deletions

View File

@ -1,119 +1,120 @@
<?php <?php
if ( empty($_REQUEST['id']) && empty($_REQUEST['eids']) ) { if ( empty($_REQUEST['id']) && empty($_REQUEST['eids']) ) {
ajaxError( "No event id(s) supplied" ); ajaxError( 'No event id(s) supplied' );
} }
if ( canView( 'Events' ) ) { if ( canView( 'Events' ) ) {
switch ( $_REQUEST['action'] ) { switch ( $_REQUEST['action'] ) {
case 'video' : { case 'video' :
if ( empty($_REQUEST['videoFormat']) ) { {
ajaxError( "Video Generation Failure, no format given" ); if ( empty($_REQUEST['videoFormat']) ) {
} elseif ( empty($_REQUEST['rate']) ) { ajaxError( 'Video Generation Failure, no format given' );
ajaxError( "Video Generation Failure, no rate given" ); } elseif ( empty($_REQUEST['rate']) ) {
} elseif ( empty($_REQUEST['scale']) ) { ajaxError( 'Video Generation Failure, no rate given' );
ajaxError( "Video Generation Failure, no scale given" ); } elseif ( empty($_REQUEST['scale']) ) {
} else { ajaxError( 'Video Generation Failure, no scale given' );
$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(); } else {
if ( !($event = dbFetchOne( $sql, NULL, array( $_REQUEST['id'] ) )) ) $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();
ajaxError( "Video Generation Failure, can't load event" ); if ( !($event = dbFetchOne( $sql, NULL, array( $_REQUEST['id'] ) )) )
else ajaxError( "Video Generation Failure, can't load event" );
if ( $videoFile = createVideo( $event, $_REQUEST['videoFormat'], $_REQUEST['rate'], $_REQUEST['scale'], !empty($_REQUEST['overwrite']) ) ) else
ajaxResponse( array( 'response'=>$videoFile ) ); if ( $videoFile = createVideo( $event, $_REQUEST['videoFormat'], $_REQUEST['rate'], $_REQUEST['scale'], !empty($_REQUEST['overwrite']) ) )
else ajaxResponse( array( 'response'=>$videoFile ) );
ajaxError( "Video Generation Failed" ); else
} ajaxError( "Video Generation Failed" );
$ok = true;
break;
} }
case 'deleteVideo' : $ok = true;
{ break;
unlink( $videoFiles[$_REQUEST['id']] ); }
unset( $videoFiles[$_REQUEST['id']] ); case 'deleteVideo' :
ajaxResponse(); {
break; unlink( $videoFiles[$_REQUEST['id']] );
} unset( $videoFiles[$_REQUEST['id']] );
case "export" : ajaxResponse();
{ break;
require_once( ZM_SKIN_PATH.'/includes/export_functions.php' ); }
case 'export' :
{
require_once( ZM_SKIN_PATH.'/includes/export_functions.php' );
# We use session vars in here, so we need to restart the session because we stopped it in index.php to improve concurrency. # We use session vars in here, so we need to restart the session because we stopped it in index.php to improve concurrency.
session_start(); session_start();
if ( !empty($_REQUEST['exportDetail']) ) if ( !empty($_REQUEST['exportDetail']) )
$exportDetail = $_SESSION['export']['detail'] = $_REQUEST['exportDetail']; $exportDetail = $_SESSION['export']['detail'] = $_REQUEST['exportDetail'];
else else
$exportDetail = false; $exportDetail = false;
if ( !empty($_REQUEST['exportFrames']) ) if ( !empty($_REQUEST['exportFrames']) )
$exportFrames = $_SESSION['export']['frames'] = $_REQUEST['exportFrames']; $exportFrames = $_SESSION['export']['frames'] = $_REQUEST['exportFrames'];
else else
$exportFrames = false; $exportFrames = false;
if ( !empty($_REQUEST['exportImages']) ) if ( !empty($_REQUEST['exportImages']) )
$exportImages = $_SESSION['export']['images'] = $_REQUEST['exportImages']; $exportImages = $_SESSION['export']['images'] = $_REQUEST['exportImages'];
else else
$exportImages = false; $exportImages = false;
if ( !empty($_REQUEST['exportVideo']) ) if ( !empty($_REQUEST['exportVideo']) )
$exportVideo = $_SESSION['export']['video'] = $_REQUEST['exportVideo']; $exportVideo = $_SESSION['export']['video'] = $_REQUEST['exportVideo'];
else else
$exportVideo = false; $exportVideo = false;
if ( !empty($_REQUEST['exportMisc']) ) if ( !empty($_REQUEST['exportMisc']) )
$exportMisc = $_SESSION['export']['misc'] = $_REQUEST['exportMisc']; $exportMisc = $_SESSION['export']['misc'] = $_REQUEST['exportMisc'];
else else
$exportMisc = false; $exportMisc = false;
if ( !empty($_REQUEST['exportFormat']) ) if ( !empty($_REQUEST['exportFormat']) )
$exportFormat = $_SESSION['export']['format'] = $_REQUEST['exportFormat']; $exportFormat = $_SESSION['export']['format'] = $_REQUEST['exportFormat'];
else else
$exportFormat = ''; $exportFormat = '';
session_write_close(); session_write_close();
$exportIds = !empty($_REQUEST['eids'])?$_REQUEST['eids']:$_REQUEST['id']; $exportIds = !empty($_REQUEST['eids'])?$_REQUEST['eids']:$_REQUEST['id'];
if ( $exportFile = exportEvents( $exportIds, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc, $exportFormat ) ) if ( $exportFile = exportEvents( $exportIds, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc, $exportFormat ) )
ajaxResponse( array( 'exportFile'=>$exportFile ) ); ajaxResponse( array( 'exportFile'=>$exportFile ) );
else else
ajaxError( "Export Failed" ); ajaxError( 'Export Failed' );
break; break;
} }
} }
} }
if ( canEdit( 'Events' ) ) { if ( canEdit( 'Events' ) ) {
switch ( $_REQUEST['action'] ) { switch ( $_REQUEST['action'] ) {
case 'rename' : case 'rename' :
{ {
if ( !empty($_REQUEST['eventName']) ) if ( !empty($_REQUEST['eventName']) )
dbQuery( 'UPDATE Events SET Name = ? WHERE Id = ?', array( $_REQUEST['eventName'], $_REQUEST['id'] ) ); dbQuery( 'UPDATE Events SET Name = ? WHERE Id = ?', array( $_REQUEST['eventName'], $_REQUEST['id'] ) );
else else
ajaxError( "No new event name supplied" ); ajaxError( "No new event name supplied" );
ajaxResponse( array( 'refreshEvent'=>true, 'refreshParent'=>true ) ); ajaxResponse( array( 'refreshEvent'=>true, 'refreshParent'=>true ) );
break; break;
}
case 'eventdetail' :
{
dbQuery( 'UPDATE Events SET Cause = ?, Notes = ? WHERE Id = ?', array( $_REQUEST['newEvent']['Cause'], $_REQUEST['newEvent']['Notes'], $_REQUEST['id'] ) );
ajaxResponse( array( 'refreshEvent'=>true, 'refreshParent'=>true ) );
break;
}
case 'archive' :
case 'unarchive' :
{
$archiveVal = ($_REQUEST['action'] == 'archive')?1:0;
dbQuery( 'UPDATE Events SET Archived = ? WHERE Id = ?', array( $archiveVal, $_REQUEST['id']) );
ajaxResponse( array( 'refreshEvent'=>true, 'refreshParent'=>false ) );
break;
}
case 'delete' :
{
$Event = new Event( $_REQUEST['id'] );
if ( ! $Event->Id() ) {
ajaxResponse( array( 'refreshEvent'=>false, 'refreshParent'=>true, 'message'=> 'Event not found.' ) );
} else {
$Event->delete();
ajaxResponse( array( 'refreshEvent'=>false, 'refreshParent'=>true ) );
} }
case 'eventdetail' : break;
{ }
dbQuery( 'UPDATE Events SET Cause = ?, Notes = ? WHERE Id = ?', array( $_REQUEST['newEvent']['Cause'], $_REQUEST['newEvent']['Notes'], $_REQUEST['id'] ) ); }
ajaxResponse( array( 'refreshEvent'=>true, 'refreshParent'=>true ) );
break;
}
case 'archive' :
case 'unarchive' :
{
$archiveVal = ($_REQUEST['action'] == "archive")?1:0;
dbQuery( 'UPDATE Events SET Archived = ? WHERE Id = ?', array( $archiveVal, $_REQUEST['id']) );
ajaxResponse( array( 'refreshEvent'=>true, 'refreshParent'=>false ) );
break;
}
case 'delete' :
{
$Event = new Event( $_REQUEST['id'] );
if ( ! $Event->Id() ) {
ajaxResponse( array( 'refreshEvent'=>false, 'refreshParent'=>true, 'message'=> 'Event not found.' ) );
} else {
$Event->delete();
ajaxResponse( array( 'refreshEvent'=>false, 'refreshParent'=>true ) );
}
break;
}
}
} }
ajaxError( 'Unrecognised action or insufficient permissions' ); ajaxError( 'Unrecognised action or insufficient permissions' );