Alter code style, spacing

This commit is contained in:
Isaac Connor 2018-07-12 14:05:23 -04:00
parent ce22f207e3
commit e05604e4b3
1 changed files with 36 additions and 28 deletions

View File

@ -9,20 +9,20 @@ if ( canView('Events') ) {
case 'video' : case 'video' :
{ {
if ( empty($_REQUEST['videoFormat']) ) { if ( empty($_REQUEST['videoFormat']) ) {
ajaxError( 'Video Generation Failure, no format given' ); ajaxError('Video Generation Failure, no format given');
} elseif ( empty($_REQUEST['rate']) ) { } elseif ( empty($_REQUEST['rate']) ) {
ajaxError( 'Video Generation Failure, no rate given' ); ajaxError('Video Generation Failure, no rate given');
} elseif ( empty($_REQUEST['scale']) ) { } elseif ( empty($_REQUEST['scale']) ) {
ajaxError( 'Video Generation Failure, no scale given' ); ajaxError('Video Generation Failure, no scale given');
} else { } else {
$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(); $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();
if ( !($event = dbFetchOne( $sql, NULL, array( $_REQUEST['id'] ) )) ) if ( !($event = dbFetchOne($sql, NULL, array( $_REQUEST['id']))) ) {
ajaxError( 'Video Generation Failure, Unable to load event' ); ajaxError('Video Generation Failure, Unable to load event');
else { } else {
if ( $videoFile = createVideo( $event, $_REQUEST['videoFormat'], $_REQUEST['rate'], $_REQUEST['scale'], !empty($_REQUEST['overwrite']) ) ) if ( $videoFile = createVideo($event, $_REQUEST['videoFormat'], $_REQUEST['rate'], $_REQUEST['scale'], !empty($_REQUEST['overwrite'])) )
ajaxResponse( array( 'response'=>$videoFile ) ); ajaxResponse(array('response'=>$videoFile));
else else
ajaxError( 'Video Generation Failed' ); ajaxError('Video Generation Failed');
} }
} }
$ok = true; $ok = true;
@ -92,59 +92,67 @@ if ( canView('Events') ) {
} }
case 'download' : case 'download' :
{ {
require_once( ZM_SKIN_PATH.'/includes/export_functions.php' ); require_once(ZM_SKIN_PATH.'/includes/export_functions.php');
$exportVideo = 1; $exportVideo = 1;
$exportFormat = $_REQUEST['exportFormat']; $exportFormat = $_REQUEST['exportFormat'];
$exportStructure = 'flat'; $exportStructure = 'flat';
$exportIds = !empty($_REQUEST['eids'])?$_REQUEST['eids']:$_REQUEST['id']; $exportIds = !empty($_REQUEST['eids'])?$_REQUEST['eids']:$_REQUEST['id'];
if ( $exportFile = exportEvents( $exportIds, false, false, false, $exportVideo, false, $exportFormat, $exportStructure ) ) if ( $exportFile = exportEvents(
ajaxResponse( array( 'exportFile'=>$exportFile ) ); $exportIds,
(isset($_REQUEST['connkey'])?$_REQUEST['connkey']:''),
false,false, false, $exportVideo, false, $exportFormat, $exportStructure ) )
ajaxResponse(array('exportFile'=>$exportFile));
else else
ajaxError( 'Export Failed' ); ajaxError('Export Failed');
break; break;
} }
} }
} } // end if canView('Events')
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' : case 'eventdetail' :
{ {
dbQuery( 'UPDATE Events SET Cause = ?, Notes = ? WHERE Id = ?', array( $_REQUEST['newEvent']['Cause'], $_REQUEST['newEvent']['Notes'], $_REQUEST['id'] ) ); dbQuery(
ajaxResponse( array( 'refreshEvent'=>true, 'refreshParent'=>true ) ); 'UPDATE Events SET Cause = ?, Notes = ? WHERE Id = ?',
array($_REQUEST['newEvent']['Cause'], $_REQUEST['newEvent']['Notes'], $_REQUEST['id'])
);
ajaxResponse(array('refreshEvent'=>true, 'refreshParent'=>true));
break; break;
} }
case 'archive' : case 'archive' :
case 'unarchive' : case 'unarchive' :
{ {
$archiveVal = ($_REQUEST['action'] == 'archive')?1:0; $archiveVal = ($_REQUEST['action'] == 'archive')?1:0;
dbQuery( 'UPDATE Events SET Archived = ? WHERE Id = ?', array( $archiveVal, $_REQUEST['id']) ); dbQuery(
ajaxResponse( array( 'refreshEvent'=>true, 'refreshParent'=>false ) ); 'UPDATE Events SET Archived = ? WHERE Id = ?',
array($archiveVal, $_REQUEST['id'])
);
ajaxResponse(array('refreshEvent'=>true, 'refreshParent'=>false));
break; break;
} }
case 'delete' : case 'delete' :
{ {
$Event = new Event( $_REQUEST['id'] ); $Event = new Event($_REQUEST['id']);
if ( ! $Event->Id() ) { if ( ! $Event->Id() ) {
ajaxResponse( array( 'refreshEvent'=>false, 'refreshParent'=>true, 'message'=> 'Event not found.' ) ); ajaxResponse(array('refreshEvent'=>false, 'refreshParent'=>true, 'message'=> 'Event not found.'));
} else { } else {
$Event->delete(); $Event->delete();
ajaxResponse( array( 'refreshEvent'=>false, 'refreshParent'=>true ) ); ajaxResponse(array('refreshEvent'=>false, 'refreshParent'=>true));
} }
break; break;
} }
} }
} } // end if canEdit('Events')
ajaxError( 'Unrecognised action or insufficient permissions' );
ajaxError('Unrecognised action or insufficient permissions');
?> ?>