cleanup, whitespace
This commit is contained in:
parent
799b34eee8
commit
4b30ea7877
|
@ -210,11 +210,13 @@ if ( canView('Events') ) {
|
||||||
dbQuery('UPDATE Events SET Name=? WHERE Id=?', array($_REQUEST['eventName'], $_REQUEST['eid']));
|
dbQuery('UPDATE Events SET Name=? WHERE Id=?', array($_REQUEST['eventName'], $_REQUEST['eid']));
|
||||||
} else if ( $action == 'eventdetail' ) {
|
} else if ( $action == 'eventdetail' ) {
|
||||||
if ( !empty($_REQUEST['eid']) ) {
|
if ( !empty($_REQUEST['eid']) ) {
|
||||||
dbQuery( 'UPDATE Events SET Cause=?, Notes=? WHERE Id=?', array( $_REQUEST['newEvent']['Cause'], $_REQUEST['newEvent']['Notes'], $_REQUEST['eid'] ) );
|
dbQuery('UPDATE Events SET Cause=?, Notes=? WHERE Id=?',
|
||||||
|
array($_REQUEST['newEvent']['Cause'], $_REQUEST['newEvent']['Notes'], $_REQUEST['eid']) );
|
||||||
} else {
|
} else {
|
||||||
$dbConn->beginTransaction();
|
$dbConn->beginTransaction();
|
||||||
foreach( getAffectedIds('markEid') as $markEid ) {
|
foreach( getAffectedIds('markEid') as $markEid ) {
|
||||||
dbQuery( 'UPDATE Events SET Cause=?, Notes=? WHERE Id=?', array( $_REQUEST['newEvent']['Cause'], $_REQUEST['newEvent']['Notes'], $markEid ) );
|
dbQuery('UPDATE Events SET Cause=?, Notes=? WHERE Id=?',
|
||||||
|
array($_REQUEST['newEvent']['Cause'], $_REQUEST['newEvent']['Notes'], $markEid) );
|
||||||
}
|
}
|
||||||
$dbConn->commit();
|
$dbConn->commit();
|
||||||
}
|
}
|
||||||
|
@ -265,7 +267,9 @@ if ( !empty($_REQUEST['mid']) && canView( 'Control', $_REQUEST['mid'] ) ) {
|
||||||
|
|
||||||
$zmuOutput = exec($zmuCommand);
|
$zmuOutput = exec($zmuCommand);
|
||||||
list($brightness, $contrast, $hue, $colour) = explode(' ', $zmuOutput);
|
list($brightness, $contrast, $hue, $colour) = explode(' ', $zmuOutput);
|
||||||
dbQuery( 'UPDATE Monitors SET Brightness = ?, Contrast = ?, Hue = ?, Colour = ? WHERE Id = ?', array($brightness, $contrast, $hue, $colour, $mid));
|
dbQuery(
|
||||||
|
'UPDATE Monitors SET Brightness = ?, Contrast = ?, Hue = ?, Colour = ? WHERE Id = ?',
|
||||||
|
array($brightness, $contrast, $hue, $colour, $mid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,8 +286,8 @@ if ( canEdit('Control') ) {
|
||||||
} elseif ( $action == 'delete' ) {
|
} elseif ( $action == 'delete' ) {
|
||||||
if ( isset($_REQUEST['markCids']) ) {
|
if ( isset($_REQUEST['markCids']) ) {
|
||||||
foreach( $_REQUEST['markCids'] as $markCid ) {
|
foreach( $_REQUEST['markCids'] as $markCid ) {
|
||||||
dbQuery( 'delete from Controls where Id = ?', array($markCid) );
|
dbQuery('DELETE FROM Controls WHERE Id = ?', array($markCid));
|
||||||
dbQuery( 'update Monitors set Controllable = 0, ControlId = 0 where ControlId = ?', array($markCid) );
|
dbQuery('UPDATE Monitors SET Controllable = 0, ControlId = 0 WHERE ControlId = ?', array($markCid));
|
||||||
$refreshParent = true;
|
$refreshParent = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,7 +314,6 @@ if ( isset($_REQUEST['object']) and $_REQUEST['object'] == 'Monitor' ) {
|
||||||
$Monitor->zmaControl('start');
|
$Monitor->zmaControl('start');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end foreach mid
|
} // end foreach mid
|
||||||
$refreshParent = true;
|
$refreshParent = true;
|
||||||
} // end if action == save
|
} // end if action == save
|
||||||
|
@ -328,11 +331,12 @@ if ( !empty($_REQUEST['mid']) && canEdit( 'Monitors', $_REQUEST['mid'] ) ) {
|
||||||
$oldFunction = $monitor['Function'];
|
$oldFunction = $monitor['Function'];
|
||||||
$oldEnabled = $monitor['Enabled'];
|
$oldEnabled = $monitor['Enabled'];
|
||||||
if ( $newFunction != $oldFunction || $newEnabled != $oldEnabled ) {
|
if ( $newFunction != $oldFunction || $newEnabled != $oldEnabled ) {
|
||||||
dbQuery( 'UPDATE Monitors SET Function=?, Enabled=? WHERE Id=?', array( $newFunction, $newEnabled, $mid ) );
|
dbQuery('UPDATE Monitors SET Function=?, Enabled=? WHERE Id=?',
|
||||||
|
array($newFunction, $newEnabled, $mid));
|
||||||
|
|
||||||
$monitor['Function'] = $newFunction;
|
$monitor['Function'] = $newFunction;
|
||||||
$monitor['Enabled'] = $newEnabled;
|
$monitor['Enabled'] = $newEnabled;
|
||||||
if ( daemonCheck() && $monitor['Type'] != 'WebSite' ) {
|
if ( daemonCheck() && ($monitor['Type'] != 'WebSite') ) {
|
||||||
$restart = ($oldFunction == 'None') || ($newFunction == 'None') || ($newEnabled != $oldEnabled);
|
$restart = ($oldFunction == 'None') || ($newFunction == 'None') || ($newEnabled != $oldEnabled);
|
||||||
zmaControl($monitor, 'stop');
|
zmaControl($monitor, 'stop');
|
||||||
zmcControl($monitor, $restart?'restart':'');
|
zmcControl($monitor, $restart?'restart':'');
|
||||||
|
@ -373,16 +377,16 @@ if ( !empty($_REQUEST['mid']) && canEdit( 'Monitors', $_REQUEST['mid'] ) ) {
|
||||||
} else {
|
} else {
|
||||||
dbQuery('INSERT INTO Zones SET MonitorId=?, '.implode(', ', $changes), array($mid));
|
dbQuery('INSERT INTO Zones SET MonitorId=?, '.implode(', ', $changes), array($mid));
|
||||||
}
|
}
|
||||||
if ( daemonCheck() && $monitor['Type'] != 'WebSite' ) {
|
if ( daemonCheck() && ($monitor['Type'] != 'WebSite') ) {
|
||||||
if ( $_REQUEST['newZone']['Type'] == 'Privacy' ) {
|
if ( $_REQUEST['newZone']['Type'] == 'Privacy' ) {
|
||||||
zmaControl($monitor, 'stop');
|
zmaControl($monitor, 'stop');
|
||||||
zmcControl($monitor, 'restart');
|
zmcControl($monitor, 'restart');
|
||||||
zmaControl($monitor, 'start');
|
zmaControl($monitor, 'start');
|
||||||
} else {
|
} else {
|
||||||
zmaControl( $mid, 'restart' );
|
zmaControl($monitor, 'restart');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( $_REQUEST['newZone']['Type'] == 'Privacy' && $monitor['Controllable'] ) {
|
if ( ($_REQUEST['newZone']['Type'] == 'Privacy') && $monitor['Controllable'] ) {
|
||||||
require_once('control_functions.php');
|
require_once('control_functions.php');
|
||||||
sendControlCommand($mid, 'quit');
|
sendControlCommand($mid, 'quit');
|
||||||
}
|
}
|
||||||
|
@ -401,19 +405,19 @@ if ( !empty($_REQUEST['mid']) && canEdit( 'Monitors', $_REQUEST['mid'] ) ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( $changes > 0 ) {
|
if ( $changes > 0 ) {
|
||||||
if ( daemonCheck() && $monitor['Type'] != 'WebSite' ) {
|
if ( daemonCheck() && ($monitor['Type'] != 'WebSite') ) {
|
||||||
zmaControl($mid, 'restart');
|
zmaControl($mid, 'restart');
|
||||||
}
|
}
|
||||||
$refreshParent = true;
|
$refreshParent = true;
|
||||||
}
|
}
|
||||||
$view = 'none';
|
$view = 'none';
|
||||||
} elseif ( $action == 'sequence' && isset($_REQUEST['smid']) ) {
|
} elseif ( ($action == 'sequence') && isset($_REQUEST['smid']) ) {
|
||||||
$smid = validInt($_REQUEST['smid']);
|
$smid = validInt($_REQUEST['smid']);
|
||||||
$monitor = dbFetchOne( 'select * from Monitors where Id = ?', NULL, array($mid) );
|
$monitor = dbFetchOne('SELECT * FROM Monitors WHERE Id = ?', NULL, array($mid));
|
||||||
$smonitor = dbFetchOne( 'select * from Monitors where Id = ?', NULL, array($smid) );
|
$smonitor = dbFetchOne('SELECT * FROM Monitors WHERE Id = ?', NULL, array($smid));
|
||||||
|
|
||||||
dbQuery( 'update Monitors set Sequence=? where Id=?', array( $smonitor['Sequence'], $monitor['Id'] ) );
|
dbQuery('UPDATE Monitors SET Sequence=? WHERE Id=?', array($smonitor['Sequence'], $monitor['Id']));
|
||||||
dbQuery( 'update Monitors set Sequence=? WHERE Id=?', array( $monitor['Sequence'], $smonitor['Id'] ) );
|
dbQuery('UPDATE Monitors SET Sequence=? WHERE Id=?', array($monitor['Sequence'], $smonitor['Id']));
|
||||||
|
|
||||||
$refreshParent = true;
|
$refreshParent = true;
|
||||||
fixSequences();
|
fixSequences();
|
||||||
|
@ -421,8 +425,8 @@ if ( !empty($_REQUEST['mid']) && canEdit( 'Monitors', $_REQUEST['mid'] ) ) {
|
||||||
if ( isset($_REQUEST['markZids']) ) {
|
if ( isset($_REQUEST['markZids']) ) {
|
||||||
$deletedZid = 0;
|
$deletedZid = 0;
|
||||||
foreach ( $_REQUEST['markZids'] as $markZid ) {
|
foreach ( $_REQUEST['markZids'] as $markZid ) {
|
||||||
$zone = dbFetchOne( 'select * from Zones where Id=?', NULL, array($markZid) );
|
$zone = dbFetchOne('SELECT * FROM Zones WHERE Id=?', NULL, array($markZid));
|
||||||
dbQuery( 'delete from Zones WHERE MonitorId=? AND Id=?', array( $mid, $markZid) );
|
dbQuery('DELETE FROM Zones WHERE MonitorId=? AND Id=?', array($mid, $markZid));
|
||||||
$deletedZid = 1;
|
$deletedZid = 1;
|
||||||
}
|
}
|
||||||
if ( $deletedZid ) {
|
if ( $deletedZid ) {
|
||||||
|
@ -476,11 +480,12 @@ if ( canEdit( 'Monitors' ) ) {
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( $_REQUEST['newMonitor']['ServerId'] == 'auto' ) {
|
if ( $_REQUEST['newMonitor']['ServerId'] == 'auto' ) {
|
||||||
$_REQUEST['newMonitor']['ServerId'] = dbFetchOne('SELECT Id FROM Servers WHERE Status=\'Running\' ORDER BY FreeMem DESC, CpuLoad ASC LIMIT 1', 'Id');
|
$_REQUEST['newMonitor']['ServerId'] = dbFetchOne(
|
||||||
Logger::Debug("Auto selecting server: Got " . $_REQUEST['newMonitor']['ServerId'] );
|
'SELECT Id FROM Servers WHERE Status=\'Running\' ORDER BY FreeMem DESC, CpuLoad ASC LIMIT 1', 'Id');
|
||||||
|
Logger::Debug('Auto selecting server: Got ' . $_REQUEST['newMonitor']['ServerId'] );
|
||||||
if ( ( ! $_REQUEST['newMonitor'] ) and defined('ZM_SERVER_ID') ) {
|
if ( ( ! $_REQUEST['newMonitor'] ) and defined('ZM_SERVER_ID') ) {
|
||||||
$_REQUEST['newMonitor']['ServerId'] = ZM_SERVER_ID;
|
$_REQUEST['newMonitor']['ServerId'] = ZM_SERVER_ID;
|
||||||
Logger::Debug("Auto selecting server to " . ZM_SERVER_ID);
|
Logger::Debug('Auto selecting server to ' . ZM_SERVER_ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,12 +542,14 @@ if ( canEdit( 'Monitors' ) ) {
|
||||||
$changes = getFormChanges($zone, $newZone, $types);
|
$changes = getFormChanges($zone, $newZone, $types);
|
||||||
|
|
||||||
if ( count($changes) ) {
|
if ( count($changes) ) {
|
||||||
dbQuery( 'update Zones set '.implode( ', ', $changes ).' WHERE MonitorId=? AND Id=?', array( $mid, $zone['Id'] ) );
|
dbQuery('UPDATE Zones SET '.implode(', ', $changes).' WHERE MonitorId=? AND Id=?',
|
||||||
}
|
array($mid, $zone['Id']));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} // end foreach zone
|
||||||
|
} // end if width and height
|
||||||
$restart = true;
|
$restart = true;
|
||||||
} else if ( ! $user['MonitorIds'] ) { // Can only create new monitors if we are not restricted to specific monitors
|
} else if ( ! $user['MonitorIds'] ) {
|
||||||
|
// Can only create new monitors if we are not restricted to specific monitors
|
||||||
# FIXME This is actually a race condition. Should lock the table.
|
# FIXME This is actually a race condition. Should lock the table.
|
||||||
$maxSeq = dbFetchOne('SELECT MAX(Sequence) AS MaxSequence FROM Monitors', 'MaxSequence');
|
$maxSeq = dbFetchOne('SELECT MAX(Sequence) AS MaxSequence FROM Monitors', 'MaxSequence');
|
||||||
$changes[] = 'Sequence = '.($maxSeq+1);
|
$changes[] = 'Sequence = '.($maxSeq+1);
|
||||||
|
@ -550,7 +557,7 @@ if ( canEdit( 'Monitors' ) ) {
|
||||||
if ( dbQuery('INSERT INTO Monitors SET '.implode(', ', $changes)) ) {
|
if ( dbQuery('INSERT INTO Monitors SET '.implode(', ', $changes)) ) {
|
||||||
$mid = dbInsertId();
|
$mid = dbInsertId();
|
||||||
$zoneArea = $_REQUEST['newMonitor']['Width'] * $_REQUEST['newMonitor']['Height'];
|
$zoneArea = $_REQUEST['newMonitor']['Width'] * $_REQUEST['newMonitor']['Height'];
|
||||||
dbQuery( "insert into Zones set MonitorId = ?, Name = 'All', Type = 'Active', Units = 'Percent', NumCoords = 4, Coords = ?, Area=?, AlarmRGB = 0xff0000, CheckMethod = 'Blobs', MinPixelThreshold = 25, MinAlarmPixels=?, MaxAlarmPixels=?, FilterX = 3, FilterY = 3, MinFilterPixels=?, MaxFilterPixels=?, MinBlobPixels=?, MinBlobs = 1", array( $mid, sprintf( "%d,%d %d,%d %d,%d %d,%d", 0, 0, $_REQUEST['newMonitor']['Width']-1, 0, $_REQUEST['newMonitor']['Width']-1, $_REQUEST['newMonitor']['Height']-1, 0, $_REQUEST['newMonitor']['Height']-1 ), $zoneArea, intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*2)/100) ) );
|
dbQuery("INSERT INTO Zones SET MonitorId = ?, Name = 'All', Type = 'Active', Units = 'Percent', NumCoords = 4, Coords = ?, Area=?, AlarmRGB = 0xff0000, CheckMethod = 'Blobs', MinPixelThreshold = 25, MinAlarmPixels=?, MaxAlarmPixels=?, FilterX = 3, FilterY = 3, MinFilterPixels=?, MaxFilterPixels=?, MinBlobPixels=?, MinBlobs = 1", array( $mid, sprintf( "%d,%d %d,%d %d,%d %d,%d", 0, 0, $_REQUEST['newMonitor']['Width']-1, 0, $_REQUEST['newMonitor']['Width']-1, $_REQUEST['newMonitor']['Height']-1, 0, $_REQUEST['newMonitor']['Height']-1 ), $zoneArea, intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*2)/100) ) );
|
||||||
//$view = 'none';
|
//$view = 'none';
|
||||||
$Storage = new Storage($_REQUEST['newMonitor']['StorageId']);
|
$Storage = new Storage($_REQUEST['newMonitor']['StorageId']);
|
||||||
mkdir($Storage->Path().'/'.$mid, 0755);
|
mkdir($Storage->Path().'/'.$mid, 0755);
|
||||||
|
@ -558,17 +565,17 @@ if ( canEdit( 'Monitors' ) ) {
|
||||||
symlink($mid, $Storage->Path().'/'.$saferName);
|
symlink($mid, $Storage->Path().'/'.$saferName);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Error("Error saving new Monitor.");
|
Error('Error saving new Monitor.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Error("Users with Monitors restrictions cannot create new monitors.");
|
Error('Users with Monitors restrictions cannot create new monitors.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$restart = true;
|
$restart = true;
|
||||||
} else {
|
} else {
|
||||||
Logger::Debug("No action due to no changes to Monitor");
|
Logger::Debug('No action due to no changes to Monitor');
|
||||||
} # end if count(changes)
|
} # end if count(changes)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -593,17 +600,17 @@ if ( canEdit( 'Monitors' ) ) {
|
||||||
|
|
||||||
if ( count($x10Changes) ) {
|
if ( count($x10Changes) ) {
|
||||||
if ( $x10Monitor && isset($_REQUEST['newX10Monitor']) ) {
|
if ( $x10Monitor && isset($_REQUEST['newX10Monitor']) ) {
|
||||||
dbQuery( 'update TriggersX10 set '.implode( ', ', $x10Changes ).' where MonitorId=?', array($mid) );
|
dbQuery('UPDATE TriggersX10 SET '.implode(', ', $x10Changes).' WHERE MonitorId=?', array($mid));
|
||||||
} elseif ( !$user['MonitorIds'] ) {
|
} elseif ( !$user['MonitorIds'] ) {
|
||||||
if ( !$x10Monitor ) {
|
if ( !$x10Monitor ) {
|
||||||
dbQuery( 'insert into TriggersX10 set MonitorId = ?, '.implode( ', ', $x10Changes ), array( $mid ) );
|
dbQuery('INSERT INTO TriggersX10 SET MonitorId = ?, '.implode(', ', $x10Changes), array($mid));
|
||||||
} else {
|
} else {
|
||||||
dbQuery( 'delete from TriggersX10 where MonitorId = ?', array($mid) );
|
dbQuery('DELETE FROM TriggersX10 WHERE MonitorId = ?', array($mid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$restart = true;
|
$restart = true;
|
||||||
}
|
} # end if has x10Changes
|
||||||
}
|
} # end if ZM_OPT_X10
|
||||||
|
|
||||||
if ( $restart ) {
|
if ( $restart ) {
|
||||||
|
|
||||||
|
@ -647,9 +654,11 @@ if ( canEdit( 'Devices' ) ) {
|
||||||
setDeviceStatusX10($_REQUEST['key'], $_REQUEST['command']);
|
setDeviceStatusX10($_REQUEST['key'], $_REQUEST['command']);
|
||||||
} else if ( isset($_REQUEST['newDevice']) ) {
|
} else if ( isset($_REQUEST['newDevice']) ) {
|
||||||
if ( isset($_REQUEST['did']) ) {
|
if ( isset($_REQUEST['did']) ) {
|
||||||
dbQuery( 'update Devices set Name=?, KeyString=? where Id=?', array($_REQUEST['newDevice']['Name'], $_REQUEST['newDevice']['KeyString'], $_REQUEST['did']) );
|
dbQuery('UPDATE Devices SET Name=?, KeyString=? WHERE Id=?',
|
||||||
|
array($_REQUEST['newDevice']['Name'], $_REQUEST['newDevice']['KeyString'], $_REQUEST['did']) );
|
||||||
} else {
|
} else {
|
||||||
dbQuery( 'insert into Devices set Name=?, KeyString=?', array( $_REQUEST['newDevice']['Name'], $_REQUEST['newDevice']['KeyString'] ) );
|
dbQuery('INSERT INTO Devices SET Name=?, KeyString=?',
|
||||||
|
array($_REQUEST['newDevice']['Name'], $_REQUEST['newDevice']['KeyString']) );
|
||||||
}
|
}
|
||||||
$refreshParent = true;
|
$refreshParent = true;
|
||||||
$view = 'none';
|
$view = 'none';
|
||||||
|
@ -657,7 +666,7 @@ if ( canEdit( 'Devices' ) ) {
|
||||||
} elseif ( $action == 'delete' ) {
|
} elseif ( $action == 'delete' ) {
|
||||||
if ( isset($_REQUEST['markDids']) ) {
|
if ( isset($_REQUEST['markDids']) ) {
|
||||||
foreach( $_REQUEST['markDids'] as $markDid ) {
|
foreach( $_REQUEST['markDids'] as $markDid ) {
|
||||||
dbQuery( 'delete from Devices where Id=?', array($markDid) );
|
dbQuery('DELETE FROM Devices WHERE Id=?', array($markDid));
|
||||||
$refreshParent = true;
|
$refreshParent = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -665,7 +674,7 @@ if ( canEdit( 'Devices' ) ) {
|
||||||
} // end if canedit devices
|
} // end if canedit devices
|
||||||
|
|
||||||
// Group view actions
|
// Group view actions
|
||||||
if ( canView( 'Groups' ) && $action == 'setgroup' ) {
|
if ( canView('Groups') && ($action == 'setgroup') ) {
|
||||||
if ( !empty($_REQUEST['gid']) ) {
|
if ( !empty($_REQUEST['gid']) ) {
|
||||||
setcookie('zmGroup', validInt($_REQUEST['gid']), time()+3600*24*30*12*10);
|
setcookie('zmGroup', validInt($_REQUEST['gid']), time()+3600*24*30*12*10);
|
||||||
} else {
|
} else {
|
||||||
|
@ -675,19 +684,31 @@ if ( canView( 'Groups' ) && $action == 'setgroup' ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Group edit actions
|
// Group edit actions
|
||||||
# Should probably verify that each monitor id is a valid monitor, that we have access to. However at the moment, you have to have System permissions to do this
|
# Should probably verify that each monitor id is a valid monitor, that we have access to.
|
||||||
|
# However at the moment, you have to have System permissions to do this
|
||||||
if ( canEdit('Groups') ) {
|
if ( canEdit('Groups') ) {
|
||||||
if ( $action == 'group' ) {
|
if ( $action == 'group' ) {
|
||||||
$monitors = empty($_POST['newGroup']['MonitorIds']) ? '' : implode(',', $_POST['newGroup']['MonitorIds']);
|
$monitors = empty($_POST['newGroup']['MonitorIds']) ? '' : implode(',', $_POST['newGroup']['MonitorIds']);
|
||||||
$group_id = null;
|
$group_id = null;
|
||||||
if ( !empty($_POST['gid']) ) {
|
if ( !empty($_POST['gid']) ) {
|
||||||
$group_id = $_POST['gid'];
|
$group_id = $_POST['gid'];
|
||||||
dbQuery( 'UPDATE Groups SET Name=?, ParentId=? WHERE Id=?',
|
dbQuery(
|
||||||
array($_POST['newGroup']['Name'], ( $_POST['newGroup']['ParentId'] == '' ? null : $_POST['newGroup']['ParentId'] ), $group_id) );
|
'UPDATE Groups SET Name=?, ParentId=? WHERE Id=?',
|
||||||
|
array(
|
||||||
|
$_POST['newGroup']['Name'],
|
||||||
|
( $_POST['newGroup']['ParentId'] == '' ? null : $_POST['newGroup']['ParentId'] ),
|
||||||
|
$group_id,
|
||||||
|
)
|
||||||
|
);
|
||||||
dbQuery('DELETE FROM Groups_Monitors WHERE GroupId=?', array($group_id));
|
dbQuery('DELETE FROM Groups_Monitors WHERE GroupId=?', array($group_id));
|
||||||
} else {
|
} else {
|
||||||
dbQuery( 'INSERT INTO Groups (Name,ParentId) VALUES (?,?)',
|
dbQuery(
|
||||||
array( $_POST['newGroup']['Name'], ( $_POST['newGroup']['ParentId'] == '' ? null : $_POST['newGroup']['ParentId'] ) ) );
|
'INSERT INTO Groups (Name,ParentId) VALUES (?,?)',
|
||||||
|
array(
|
||||||
|
$_POST['newGroup']['Name'],
|
||||||
|
( $_POST['newGroup']['ParentId'] == '' ? null : $_POST['newGroup']['ParentId'] ),
|
||||||
|
)
|
||||||
|
);
|
||||||
$group_id = dbInsertId();
|
$group_id = dbInsertId();
|
||||||
}
|
}
|
||||||
if ( $group_id ) {
|
if ( $group_id ) {
|
||||||
|
@ -738,19 +759,24 @@ if ( canEdit( 'System' ) ) {
|
||||||
} else if ( $_REQUEST['object'] == 'server' ) {
|
} else if ( $_REQUEST['object'] == 'server' ) {
|
||||||
|
|
||||||
if ( $action == 'Save' ) {
|
if ( $action == 'Save' ) {
|
||||||
if ( !empty($_REQUEST['id']) )
|
if ( !empty($_REQUEST['id']) ) {
|
||||||
$dbServer = dbFetchOne( 'SELECT * FROM Servers WHERE Id=?', NULL, array($_REQUEST['id']) );
|
$dbServer = dbFetchOne(
|
||||||
else
|
'SELECT * FROM Servers WHERE Id=?',
|
||||||
|
NULL,
|
||||||
|
array($_REQUEST['id']) );
|
||||||
|
} else {
|
||||||
$dbServer = array();
|
$dbServer = array();
|
||||||
|
}
|
||||||
|
|
||||||
$types = array();
|
$types = array();
|
||||||
$changes = getFormChanges($dbServer, $_REQUEST['newServer'], $types);
|
$changes = getFormChanges($dbServer, $_REQUEST['newServer'], $types);
|
||||||
|
|
||||||
if ( count($changes) ) {
|
if ( count($changes) ) {
|
||||||
if ( !empty($_REQUEST['id']) ) {
|
if ( !empty($_REQUEST['id']) ) {
|
||||||
dbQuery( 'UPDATE Servers SET '.implode( ', ', $changes ).' WHERE Id = ?', array($_REQUEST['id']) );
|
dbQuery('UPDATE Servers SET '.implode(', ', $changes).' WHERE Id = ?',
|
||||||
|
array($_REQUEST['id']) );
|
||||||
} else {
|
} else {
|
||||||
dbQuery( 'INSERT INTO Servers set '.implode( ', ', $changes ) );
|
dbQuery('INSERT INTO Servers SET '.implode(', ', $changes));
|
||||||
}
|
}
|
||||||
$refreshParent = true;
|
$refreshParent = true;
|
||||||
}
|
}
|
||||||
|
@ -804,7 +830,7 @@ if ( canEdit( 'System' ) ) {
|
||||||
}
|
}
|
||||||
case 'ignore' :
|
case 'ignore' :
|
||||||
{
|
{
|
||||||
dbQuery( "update Config set Value = '".ZM_DYN_LAST_VERSION."' where Name = 'ZM_DYN_CURR_VERSION'" );
|
dbQuery("UPDATE Config SET Value = '".ZM_DYN_LAST_VERSION."' WHERE Name = 'ZM_DYN_CURR_VERSION'");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'hour' :
|
case 'hour' :
|
||||||
|
@ -819,12 +845,12 @@ if ( canEdit( 'System' ) ) {
|
||||||
} elseif ( $option == 'week' ) {
|
} elseif ( $option == 'week' ) {
|
||||||
$nextReminder += 7*24*60*60;
|
$nextReminder += 7*24*60*60;
|
||||||
}
|
}
|
||||||
dbQuery( "update Config set Value = '".$nextReminder."' where Name = 'ZM_DYN_NEXT_REMINDER'" );
|
dbQuery("UPDATE Config SET Value = '".$nextReminder."' WHERE Name = 'ZM_DYN_NEXT_REMINDER'");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'never' :
|
case 'never' :
|
||||||
{
|
{
|
||||||
dbQuery( "update Config set Value = '0' where Name = 'ZM_CHECK_FOR_UPDATES'" );
|
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_CHECK_FOR_UPDATES'");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -852,39 +878,37 @@ if ( canEdit( 'System' ) ) {
|
||||||
} elseif ( $option == 'month' ) {
|
} elseif ( $option == 'month' ) {
|
||||||
$nextReminder += 30*24*60*60;
|
$nextReminder += 30*24*60*60;
|
||||||
}
|
}
|
||||||
dbQuery( "update Config set Value = '".$nextReminder."' where Name = 'ZM_DYN_DONATE_REMINDER_TIME'" );
|
dbQuery("UPDATE Config SET Value = '".$nextReminder."' WHERE Name = 'ZM_DYN_DONATE_REMINDER_TIME'");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'never' :
|
case 'never' :
|
||||||
case 'already' :
|
case 'already' :
|
||||||
{
|
{
|
||||||
dbQuery( "update Config set Value = '0' where Name = 'ZM_DYN_SHOW_DONATE_REMINDER'" );
|
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_DYN_SHOW_DONATE_REMINDER'");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} // end switch option
|
} // end switch option
|
||||||
}
|
}
|
||||||
if ( $action == 'privacy' && isset($_REQUEST['option'] ) ) {
|
if ( ($action == 'privacy') && isset($_REQUEST['option']) ) {
|
||||||
$option = $_REQUEST['option'];
|
switch( $_REQUEST['option'] ) {
|
||||||
switch( $option ) {
|
|
||||||
case 'decline' :
|
case 'decline' :
|
||||||
{
|
{
|
||||||
dbQuery( "update Config set Value = '0' where Name = 'ZM_SHOW_PRIVACY'" );
|
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_SHOW_PRIVACY'");
|
||||||
dbQuery( "update Config set Value = '0' where Name = 'ZM_TELEMETRY_DATA'" );
|
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_TELEMETRY_DATA'");
|
||||||
$view = 'console';
|
|
||||||
$redirect = ZM_BASE_URL.$_SERVER['PHP_SELF'].'?view=console';
|
$redirect = ZM_BASE_URL.$_SERVER['PHP_SELF'].'?view=console';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'accept' :
|
case 'accept' :
|
||||||
{
|
{
|
||||||
dbQuery( "update Config set Value = '0' where Name = 'ZM_SHOW_PRIVACY'" );
|
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_SHOW_PRIVACY'");
|
||||||
dbQuery( "update Config set Value = '1' where Name = 'ZM_TELEMETRY_DATA'" );
|
dbQuery("UPDATE Config SET Value = '1' WHERE Name = 'ZM_TELEMETRY_DATA'");
|
||||||
$view = 'console';
|
|
||||||
$redirect = ZM_BASE_URL.$_SERVER['PHP_SELF'].'?view=console';
|
$redirect = ZM_BASE_URL.$_SERVER['PHP_SELF'].'?view=console';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: # Enable the privacy statement if we somehow submit something other than accept or decline
|
default: # Enable the privacy statement if we somehow submit something other than accept or decline
|
||||||
dbQuery( "update Config set Value = '1' where Name = 'ZM_SHOW_PRIVACY'" );
|
dbQuery("UPDATE Config SET Value = '1' WHERE Name = 'ZM_SHOW_PRIVACY'");
|
||||||
} // end switch option
|
} // end switch option
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if ( $action == 'options' && isset($_REQUEST['tab']) ) {
|
if ( $action == 'options' && isset($_REQUEST['tab']) ) {
|
||||||
$configCat = $configCats[$_REQUEST['tab']];
|
$configCat = $configCats[$_REQUEST['tab']];
|
||||||
|
@ -925,9 +949,10 @@ if ( canEdit( 'System' ) ) {
|
||||||
$redirect = ZM_BASE_URL.$_SERVER['PHP_SELF'].'?view=options&tab='.$_REQUEST['tab'];
|
$redirect = ZM_BASE_URL.$_SERVER['PHP_SELF'].'?view=options&tab='.$_REQUEST['tab'];
|
||||||
}
|
}
|
||||||
loadConfig(false);
|
loadConfig(false);
|
||||||
|
return;
|
||||||
} elseif ( $action == 'user' ) {
|
} elseif ( $action == 'user' ) {
|
||||||
if ( !empty($_REQUEST['uid']) )
|
if ( !empty($_REQUEST['uid']) )
|
||||||
$dbUser = dbFetchOne( "SELECT * FROM Users WHERE Id=?", NULL, array($_REQUEST['uid']) );
|
$dbUser = dbFetchOne('SELECT * FROM Users WHERE Id=?', NULL, array($_REQUEST['uid']));
|
||||||
else
|
else
|
||||||
$dbUser = array();
|
$dbUser = array();
|
||||||
|
|
||||||
|
@ -941,12 +966,12 @@ if ( canEdit( 'System' ) ) {
|
||||||
|
|
||||||
if ( count($changes) ) {
|
if ( count($changes) ) {
|
||||||
if ( !empty($_REQUEST['uid']) ) {
|
if ( !empty($_REQUEST['uid']) ) {
|
||||||
dbQuery( 'update Users set '.implode( ', ', $changes ).' where Id = ?', array($_REQUEST['uid']) );
|
dbQuery('UPDATE Users SET '.implode(', ', $changes).' WHERE Id = ?', array($_REQUEST['uid']));
|
||||||
# If we are updating the logged in user, then update our session user data.
|
# If we are updating the logged in user, then update our session user data.
|
||||||
if ( $user and ( $dbUser['Username'] == $user['Username'] ) )
|
if ( $user and ( $dbUser['Username'] == $user['Username'] ) )
|
||||||
userLogin($dbUser['Username'], $dbUser['Password']);
|
userLogin($dbUser['Username'], $dbUser['Password']);
|
||||||
} else {
|
} else {
|
||||||
dbQuery( 'insert into Users set '.implode( ', ', $changes ) );
|
dbQuery('INSERT INTO Users SET '.implode(', ', $changes));
|
||||||
}
|
}
|
||||||
$refreshParent = true;
|
$refreshParent = true;
|
||||||
}
|
}
|
||||||
|
@ -961,22 +986,21 @@ if ( canEdit( 'System' ) ) {
|
||||||
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,Function,Enabled 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['Function'].':'.$monitor['Enabled'];
|
||||||
}
|
}
|
||||||
$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));
|
||||||
}
|
}
|
||||||
} elseif ( $action == 'delete' ) {
|
} elseif ( $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']));
|
||||||
|
|
||||||
if ( isset($_REQUEST['markUids']) ) {
|
if ( isset($_REQUEST['markUids']) ) {
|
||||||
foreach( $_REQUEST['markUids'] as $markUid )
|
foreach( $_REQUEST['markUids'] as $markUid )
|
||||||
dbQuery( 'delete from Users where Id = ?', array($markUid) );
|
dbQuery('DELETE FROM Users WHERE Id = ?', array($markUid));
|
||||||
if ( $markUid == $user['Id'] )
|
if ( $markUid == $user['Id'] )
|
||||||
userLogout();
|
userLogout();
|
||||||
}
|
}
|
||||||
|
@ -995,7 +1019,7 @@ if ( canEdit( 'System' ) ) {
|
||||||
else
|
else
|
||||||
unset($changes['Password']);
|
unset($changes['Password']);
|
||||||
if ( count($changes) ) {
|
if ( count($changes) ) {
|
||||||
dbQuery( 'update Users set '.implode( ', ', $changes ).' where Id=?', array($uid) );
|
dbQuery('UPDATE Users SET '.implode(', ', $changes).' WHERE Id=?', array($uid));
|
||||||
$refreshParent = true;
|
$refreshParent = true;
|
||||||
}
|
}
|
||||||
$view = 'none';
|
$view = 'none';
|
||||||
|
|
Loading…
Reference in New Issue