mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-01-25 14:38:58 -05:00
Update function action to use Monitor object
This commit is contained in:
@@ -31,20 +31,21 @@ if ( !canEdit('Monitors', $mid) ) {
|
||||
}
|
||||
|
||||
if ( $action == 'function' ) {
|
||||
$monitor = dbFetchOne('SELECT * FROM Monitors WHERE Id=?', NULL, array($mid));
|
||||
$monitor = new ZM\Monitor($mid);
|
||||
if ( !$monitor ) {
|
||||
ZM\Error("Monitor not found with Id=$mid");
|
||||
return;
|
||||
}
|
||||
|
||||
$newFunction = validStr($_REQUEST['newFunction']);
|
||||
# Because we use a checkbox, it won't get passed in the request. So not being in _REQUEST means 0
|
||||
$newEnabled = ( !isset($_REQUEST['newEnabled']) or $_REQUEST['newEnabled'] != '1' ) ? '0' : '1';
|
||||
$oldFunction = $monitor['Function'];
|
||||
$oldEnabled = $monitor['Enabled'];
|
||||
$oldFunction = $monitor->Function();
|
||||
$oldEnabled = $monitor->Enabled();
|
||||
if ( $newFunction != $oldFunction || $newEnabled != $oldEnabled ) {
|
||||
dbQuery('UPDATE Monitors SET `Function`=?, `Enabled`=? WHERE `Id`=?',
|
||||
array($newFunction, $newEnabled, $mid));
|
||||
$monitor->save(array('Function'=>$newFunction, 'Enabled'=>$newEnabled));
|
||||
|
||||
$monitor['Function'] = $newFunction;
|
||||
$monitor['Enabled'] = $newEnabled;
|
||||
if ( daemonCheck() && ($monitor['Type'] != 'WebSite') ) {
|
||||
if ( daemonCheck() && ($monitor->Type() != 'WebSite') ) {
|
||||
zmaControl($monitor, 'stop');
|
||||
zmcControl($monitor, ($newFunction != 'None') ? 'restart' : 'stop');
|
||||
if ( $newFunction != 'None' && $newFunction != 'NoDect' )
|
||||
|
||||
Reference in New Issue
Block a user