From e8101a231e521940b95c3ffa60b835a343e05a58 Mon Sep 17 00:00:00 2001 From: stan Date: Thu, 22 Dec 2005 16:47:19 +0000 Subject: [PATCH] Bug 238 - Added support for enabled flag. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1722 e3e1d417-86f3-4887-817a-d78f3d33393f --- web/zm_actions.php | 20 +++++++++++--------- web/zm_funcs.php | 19 +++++++++---------- web/zm_html_view_console.php | 2 +- web/zm_html_view_function.php | 13 +++++++------ web/zm_html_view_monitor.php | 15 +++------------ web/zm_xhtml_view_console.php | 2 +- 6 files changed, 32 insertions(+), 39 deletions(-) diff --git a/web/zm_actions.php b/web/zm_actions.php index 608c72e52..6d539d67e 100644 --- a/web/zm_actions.php +++ b/web/zm_actions.php @@ -998,16 +998,18 @@ if ( isset($action) ) $monitor = mysql_fetch_assoc( $result ); $old_function = $monitor['Function']; - if ( $new_function != $old_function ) + $old_enabled = $monitor['Enabled']; + if ( $new_function != $old_function || $new_enabled != $old_enabled ) { - simpleQuery( "update Monitors set Function = '$new_function' where Id = '$mid'" ); + simpleQuery( "update Monitors set Function = '$new_function', Enabled = '$new_enabled' where Id = '$mid'" ); $monitor['Function'] = $new_function; + $monitor['Enabled'] = $new_enabled; if ( $cookies ) session_write_close(); if ( daemonCheck() ) { - zmcControl( $monitor, true ); - zmaControl( $monitor, true ); + zmcControl( $monitor ); + zmaControl( $monitor, "reload" ); } $refresh_parent = true; } @@ -1066,7 +1068,7 @@ if ( isset($action) ) if ( $cookies ) session_write_close(); if ( daemonCheck() ) { - zmaControl( $mid, true ); + zmaControl( $mid, "restart" ); } $refresh_parent = true; } @@ -1237,8 +1239,8 @@ if ( isset($action) ) if ( $cookies ) session_write_close(); if ( daemonCheck() ) { - zmcControl( $monitor, true ); - zmaControl( $monitor, true ); + zmcControl( $monitor, "restart" ); + zmaControl( $monitor, "restart" ); } //daemonControl( 'restart', 'zmwatch.pl' ); $refresh_parent = true; @@ -1284,7 +1286,7 @@ if ( isset($action) ) if ( $cookies ) session_write_close(); if ( daemonCheck() ) { - zmaControl( $mid, true ); + zmaControl( $mid, "restart" ); } $refresh_parent = true; } @@ -1570,7 +1572,7 @@ if ( isset($action) ) $definitions = array(); while( $monitor = mysql_fetch_assoc( $result ) ) { - $definitions[] = $monitor['Id'].":".$monitor['Function']; + $definitions[] = $monitor['Id'].":".$monitor['Function'].":".$monitor['Enabled']; } $definition = join( ',', $definitions ); if ( $new_state ) diff --git a/web/zm_funcs.php b/web/zm_funcs.php index 9670899ac..42e82e445 100644 --- a/web/zm_funcs.php +++ b/web/zm_funcs.php @@ -707,7 +707,7 @@ function daemonControl( $command, $daemon=false, $args=false ) exec( $string ); } -function zmcControl( $monitor, $restart=false ) +function zmcControl( $monitor, $mode=false ) { if ( $monitor['Type'] == "Local" ) { @@ -731,7 +731,7 @@ function zmcControl( $monitor, $restart=false ) } else { - if ( $restart ) + if ( $mode == "restart" ) { daemonControl( "stop", "zmc", $zmc_args ); } @@ -739,21 +739,16 @@ function zmcControl( $monitor, $restart=false ) } } -function zmaControl( $monitor, $restart=false ) +function zmaControl( $monitor, $mode=false ) { if ( !is_array( $monitor ) ) { - $sql = "select Id,Function,RunMode from Monitors where Id = '$monitor'"; + $sql = "select Id,Function,Enabled from Monitors where Id = '$monitor'"; $result = mysql_query( $sql ); if ( !$result ) echo mysql_error(); $monitor = mysql_fetch_assoc( $result ); } - if ( $monitor['RunMode'] == 'Triggered' ) - { - // Don't touch anything that's triggered - return; - } switch ( $monitor['Function'] ) { case 'Modect' : @@ -761,7 +756,7 @@ function zmaControl( $monitor, $restart=false ) case 'Mocord' : case 'Nodect' : { - if ( $restart ) + if ( $mode == restart ) { if ( ZM_OPT_CONTROL ) { @@ -782,6 +777,10 @@ function zmaControl( $monitor, $restart=false ) { daemonControl( "start", "zmtrack.pl", "-m ".$monitor['Id'] ); } + if ( $mode == "reload" ) + { + daemonControl( "reload", "zma", "-m ".$monitor['Id'] ); + } break; } default : diff --git a/web/zm_html_view_console.php b/web/zm_html_view_console.php index 2250258b5..ed876c6e0 100644 --- a/web/zm_html_view_console.php +++ b/web/zm_html_view_console.php @@ -331,7 +331,7 @@ foreach( $monitors as $monitor ) { $fclass = "gretext"; } - if ( $monitor['RunMode'] == 'Triggered' ) + if ( !$monitor['Enabled'] ) { $fclass .= "em"; } diff --git a/web/zm_html_view_function.php b/web/zm_html_view_function.php index c72cd9cfa..c82182b36 100644 --- a/web/zm_html_view_function.php +++ b/web/zm_html_view_function.php @@ -55,16 +55,16 @@ function closeWindow() +
+ + + - - - - - +    checked>
+
diff --git a/web/zm_html_view_monitor.php b/web/zm_html_view_monitor.php index b262b0a15..9e0bc368d 100644 --- a/web/zm_html_view_monitor.php +++ b/web/zm_html_view_monitor.php @@ -61,7 +61,7 @@ else $monitor = array(); $monitor['Name'] = $zmSlangNew; $monitor['Function'] = "None"; - $monitor['RunMode'] = "Continuous"; + $monitor['Enabled'] = true; $monitor['Type'] = "Local"; $monitor['Device'] = ""; $monitor['Channel'] = ""; @@ -261,9 +261,9 @@ if ( $tab != 'monitor' ) + - + checked> -