Update state action, replacing Function with Recording, Analysing, Capturing. Redirect to console instead of switching view.

This commit is contained in:
Isaac Connor 2022-02-08 11:20:27 -05:00
parent aad79d3407
commit 38c9ac1521
1 changed files with 11 additions and 12 deletions

View File

@ -19,31 +19,30 @@
// //
// System edit actions // System edit actions
if ( !canEdit('System') ) { if (!canEdit('System')) {
ZM\Warning('Need System Permission to edit states'); ZM\Warning('Need System Permission to edit states');
return; return;
} }
if ( $action == 'state' ) { if ($action == 'state') {
if ( !empty($_REQUEST['runState']) ) { if (!empty($_REQUEST['runState'])) {
//if ( $cookies ) session_write_close();
packageControl($_REQUEST['runState']); packageControl($_REQUEST['runState']);
$refreshParent = true; $refreshParent = true;
} }
} else if ( $action == 'save' ) { } else if ($action == 'save') {
if ( !empty($_REQUEST['runState']) || !empty($_REQUEST['newState']) ) { if (!empty($_REQUEST['runState']) || !empty($_REQUEST['newState'])) {
$sql = 'SELECT `Id`,`Function`,`Enabled` FROM Monitors ORDER BY Id'; $sql = 'SELECT `Id`,`Capturing`,`Analysing`,`Recording` FROM `Monitors` ORDER BY `Id`';
$definitions = array(); $definitions = array();
foreach ( dbFetchAll($sql) as $monitor ) { foreach (dbFetchAll($sql) as $monitor ) {
$definitions[] = $monitor['Id'].':'.$monitor['Function'].':'.$monitor['Enabled']; $definitions[] = $monitor['Id'].':'.$monitor['Capturing'].':'.$monitor['Analysing'].':'.$monitor['Recording'];
} }
$definition = join(',', $definitions); $definition = join(',', $definitions);
if ( $_REQUEST['newState'] ) if ( $_REQUEST['newState'] )
$_REQUEST['runState'] = $_REQUEST['newState']; $_REQUEST['runState'] = $_REQUEST['newState'];
dbQuery('REPLACE INTO `States` SET `Name`=?, `Definition`=?', array($_REQUEST['runState'],$definition)); dbQuery('REPLACE INTO `States` SET `Name`=?, `Definition`=?', array($_REQUEST['runState'],$definition));
} }
} else if ( $action == 'delete' ) { } else if ($action == 'delete') {
if ( isset($_REQUEST['runState']) ) if (isset($_REQUEST['runState']))
dbQuery('DELETE FROM `States` WHERE `Name`=?', array($_REQUEST['runState'])); dbQuery('DELETE FROM `States` WHERE `Name`=?', array($_REQUEST['runState']));
} }
$view = 'console'; $redirect = '?view=console';
?> ?>