Bug 238 - Added support for enabled flag.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1722 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
52870d6670
commit
e8101a231e
|
@ -998,16 +998,18 @@ if ( isset($action) )
|
||||||
$monitor = mysql_fetch_assoc( $result );
|
$monitor = mysql_fetch_assoc( $result );
|
||||||
|
|
||||||
$old_function = $monitor['Function'];
|
$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['Function'] = $new_function;
|
||||||
|
$monitor['Enabled'] = $new_enabled;
|
||||||
if ( $cookies ) session_write_close();
|
if ( $cookies ) session_write_close();
|
||||||
if ( daemonCheck() )
|
if ( daemonCheck() )
|
||||||
{
|
{
|
||||||
zmcControl( $monitor, true );
|
zmcControl( $monitor );
|
||||||
zmaControl( $monitor, true );
|
zmaControl( $monitor, "reload" );
|
||||||
}
|
}
|
||||||
$refresh_parent = true;
|
$refresh_parent = true;
|
||||||
}
|
}
|
||||||
|
@ -1066,7 +1068,7 @@ if ( isset($action) )
|
||||||
if ( $cookies ) session_write_close();
|
if ( $cookies ) session_write_close();
|
||||||
if ( daemonCheck() )
|
if ( daemonCheck() )
|
||||||
{
|
{
|
||||||
zmaControl( $mid, true );
|
zmaControl( $mid, "restart" );
|
||||||
}
|
}
|
||||||
$refresh_parent = true;
|
$refresh_parent = true;
|
||||||
}
|
}
|
||||||
|
@ -1237,8 +1239,8 @@ if ( isset($action) )
|
||||||
if ( $cookies ) session_write_close();
|
if ( $cookies ) session_write_close();
|
||||||
if ( daemonCheck() )
|
if ( daemonCheck() )
|
||||||
{
|
{
|
||||||
zmcControl( $monitor, true );
|
zmcControl( $monitor, "restart" );
|
||||||
zmaControl( $monitor, true );
|
zmaControl( $monitor, "restart" );
|
||||||
}
|
}
|
||||||
//daemonControl( 'restart', 'zmwatch.pl' );
|
//daemonControl( 'restart', 'zmwatch.pl' );
|
||||||
$refresh_parent = true;
|
$refresh_parent = true;
|
||||||
|
@ -1284,7 +1286,7 @@ if ( isset($action) )
|
||||||
if ( $cookies ) session_write_close();
|
if ( $cookies ) session_write_close();
|
||||||
if ( daemonCheck() )
|
if ( daemonCheck() )
|
||||||
{
|
{
|
||||||
zmaControl( $mid, true );
|
zmaControl( $mid, "restart" );
|
||||||
}
|
}
|
||||||
$refresh_parent = true;
|
$refresh_parent = true;
|
||||||
}
|
}
|
||||||
|
@ -1570,7 +1572,7 @@ if ( isset($action) )
|
||||||
$definitions = array();
|
$definitions = array();
|
||||||
while( $monitor = mysql_fetch_assoc( $result ) )
|
while( $monitor = mysql_fetch_assoc( $result ) )
|
||||||
{
|
{
|
||||||
$definitions[] = $monitor['Id'].":".$monitor['Function'];
|
$definitions[] = $monitor['Id'].":".$monitor['Function'].":".$monitor['Enabled'];
|
||||||
}
|
}
|
||||||
$definition = join( ',', $definitions );
|
$definition = join( ',', $definitions );
|
||||||
if ( $new_state )
|
if ( $new_state )
|
||||||
|
|
|
@ -707,7 +707,7 @@ function daemonControl( $command, $daemon=false, $args=false )
|
||||||
exec( $string );
|
exec( $string );
|
||||||
}
|
}
|
||||||
|
|
||||||
function zmcControl( $monitor, $restart=false )
|
function zmcControl( $monitor, $mode=false )
|
||||||
{
|
{
|
||||||
if ( $monitor['Type'] == "Local" )
|
if ( $monitor['Type'] == "Local" )
|
||||||
{
|
{
|
||||||
|
@ -731,7 +731,7 @@ function zmcControl( $monitor, $restart=false )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( $restart )
|
if ( $mode == "restart" )
|
||||||
{
|
{
|
||||||
daemonControl( "stop", "zmc", $zmc_args );
|
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 ) )
|
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 );
|
$result = mysql_query( $sql );
|
||||||
if ( !$result )
|
if ( !$result )
|
||||||
echo mysql_error();
|
echo mysql_error();
|
||||||
$monitor = mysql_fetch_assoc( $result );
|
$monitor = mysql_fetch_assoc( $result );
|
||||||
}
|
}
|
||||||
if ( $monitor['RunMode'] == 'Triggered' )
|
|
||||||
{
|
|
||||||
// Don't touch anything that's triggered
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch ( $monitor['Function'] )
|
switch ( $monitor['Function'] )
|
||||||
{
|
{
|
||||||
case 'Modect' :
|
case 'Modect' :
|
||||||
|
@ -761,7 +756,7 @@ function zmaControl( $monitor, $restart=false )
|
||||||
case 'Mocord' :
|
case 'Mocord' :
|
||||||
case 'Nodect' :
|
case 'Nodect' :
|
||||||
{
|
{
|
||||||
if ( $restart )
|
if ( $mode == restart )
|
||||||
{
|
{
|
||||||
if ( ZM_OPT_CONTROL )
|
if ( ZM_OPT_CONTROL )
|
||||||
{
|
{
|
||||||
|
@ -782,6 +777,10 @@ function zmaControl( $monitor, $restart=false )
|
||||||
{
|
{
|
||||||
daemonControl( "start", "zmtrack.pl", "-m ".$monitor['Id'] );
|
daemonControl( "start", "zmtrack.pl", "-m ".$monitor['Id'] );
|
||||||
}
|
}
|
||||||
|
if ( $mode == "reload" )
|
||||||
|
{
|
||||||
|
daemonControl( "reload", "zma", "-m ".$monitor['Id'] );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default :
|
default :
|
||||||
|
|
|
@ -331,7 +331,7 @@ foreach( $monitors as $monitor )
|
||||||
{
|
{
|
||||||
$fclass = "gretext";
|
$fclass = "gretext";
|
||||||
}
|
}
|
||||||
if ( $monitor['RunMode'] == 'Triggered' )
|
if ( !$monitor['Enabled'] )
|
||||||
{
|
{
|
||||||
$fclass .= "em";
|
$fclass .= "em";
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,16 +55,16 @@ function closeWindow()
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<form method="get" action="<?= $PHP_SELF ?>">
|
||||||
|
<input type="hidden" name="view" value="none">
|
||||||
|
<input type="hidden" name="action" value="function">
|
||||||
|
<input type="hidden" name="mid" value="<?= $mid ?>">
|
||||||
<table border="0" cellspacing="0" cellpadding="4" width="100%">
|
<table border="0" cellspacing="0" cellpadding="4" width="100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" align="center" class="head"><?= sprintf( $zmClangMonitorFunction, $monitor['Name'] ) ?></td>
|
<td colspan="2" align="center" class="head"><?= sprintf( $zmClangMonitorFunction, $monitor['Name'] ) ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<form method="get" action="<?= $PHP_SELF ?>">
|
<td colspan="2" align="center" valign="middle" class="text"><select name="new_function" class="form">
|
||||||
<input type="hidden" name="view" value="none">
|
|
||||||
<input type="hidden" name="action" value="function">
|
|
||||||
<input type="hidden" name="mid" value="<?= $mid ?>">
|
|
||||||
<td colspan="2" align="center"><select name="new_function" class="form">
|
|
||||||
<?php
|
<?php
|
||||||
foreach ( getEnumValues( 'Monitors', 'Function' ) as $opt_function )
|
foreach ( getEnumValues( 'Monitors', 'Function' ) as $opt_function )
|
||||||
{
|
{
|
||||||
|
@ -73,12 +73,13 @@ foreach ( getEnumValues( 'Monitors', 'Function' ) as $opt_function )
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select></td>
|
</select> <?= $zmSlangEnabled ?> <input type="checkbox" name="new_enabled" value="1" class="form-noborder"<?php if ( !empty($monitor['Enabled']) ) { ?> checked<?php } ?>></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center"><input type="submit" value="<?= $zmSlangSave ?>" class="form"></td>
|
<td align="center"><input type="submit" value="<?= $zmSlangSave ?>" class="form"></td>
|
||||||
<td align="center"><input type="button" value="<?= $zmSlangCancel ?>" class="form" onClick="closeWindow()"></td>
|
<td align="center"><input type="button" value="<?= $zmSlangCancel ?>" class="form" onClick="closeWindow()"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
</form>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -61,7 +61,7 @@ else
|
||||||
$monitor = array();
|
$monitor = array();
|
||||||
$monitor['Name'] = $zmSlangNew;
|
$monitor['Name'] = $zmSlangNew;
|
||||||
$monitor['Function'] = "None";
|
$monitor['Function'] = "None";
|
||||||
$monitor['RunMode'] = "Continuous";
|
$monitor['Enabled'] = true;
|
||||||
$monitor['Type'] = "Local";
|
$monitor['Type'] = "Local";
|
||||||
$monitor['Device'] = "";
|
$monitor['Device'] = "";
|
||||||
$monitor['Channel'] = "";
|
$monitor['Channel'] = "";
|
||||||
|
@ -261,9 +261,9 @@ if ( $tab != 'monitor' )
|
||||||
<input type="hidden" name="new_monitor[Name]" value="<?= $new_monitor['Name'] ?>">
|
<input type="hidden" name="new_monitor[Name]" value="<?= $new_monitor['Name'] ?>">
|
||||||
<input Type="hidden" name="new_monitor[Type]" value="<?= $new_monitor['Type'] ?>">
|
<input Type="hidden" name="new_monitor[Type]" value="<?= $new_monitor['Type'] ?>">
|
||||||
<input type="hidden" name="new_monitor[Function]" value="<?= $new_monitor['Function'] ?>">
|
<input type="hidden" name="new_monitor[Function]" value="<?= $new_monitor['Function'] ?>">
|
||||||
|
<input type="hidden" name="new_monitor[Enabled]" value="<?= $new_monitor['Enabled'] ?>">
|
||||||
<input type="hidden" name="new_monitor[SectionLength]" value="<?= $new_monitor['SectionLength'] ?>">
|
<input type="hidden" name="new_monitor[SectionLength]" value="<?= $new_monitor['SectionLength'] ?>">
|
||||||
<input type="hidden" name="new_monitor[FrameSkip]" value="<?= $new_monitor['FrameSkip'] ?>">
|
<input type="hidden" name="new_monitor[FrameSkip]" value="<?= $new_monitor['FrameSkip'] ?>">
|
||||||
<input type="hidden" name="new_monitor[RunMode]" value="<?= $new_monitor['RunMode'] ?>">
|
|
||||||
<?php
|
<?php
|
||||||
if ( isset($new_monitor['Triggers']) )
|
if ( isset($new_monitor['Triggers']) )
|
||||||
{
|
{
|
||||||
|
@ -363,18 +363,9 @@ switch ( $tab )
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select></td></tr>
|
</select></td></tr>
|
||||||
|
<tr><td align="left" class="text"><?= $zmSlangEnabled ?></td><td align="left" class="text"><input type="checkbox" name="new_monitor[Enabled]" value="1" class="form-noborder"<?php if ( !empty($new_monitor['Enabled']) ) { ?> checked<?php } ?>></td></tr>
|
||||||
<tr><td align="left" class="text"><?= $zmSlangSectionlength ?></td><td align="left" class="text"><input type="text" name="new_monitor[SectionLength]" value="<?= $new_monitor['SectionLength'] ?>" size="6" class="form"></td></tr>
|
<tr><td align="left" class="text"><?= $zmSlangSectionlength ?></td><td align="left" class="text"><input type="text" name="new_monitor[SectionLength]" value="<?= $new_monitor['SectionLength'] ?>" size="6" class="form"></td></tr>
|
||||||
<tr><td align="left" class="text"><?= $zmSlangFrameSkip ?></td><td align="left" class="text"><input type="text" name="new_monitor[FrameSkip]" value="<?= $new_monitor['FrameSkip'] ?>" size="6" class="form"></td></tr>
|
<tr><td align="left" class="text"><?= $zmSlangFrameSkip ?></td><td align="left" class="text"><input type="text" name="new_monitor[FrameSkip]" value="<?= $new_monitor['FrameSkip'] ?>" size="6" class="form"></td></tr>
|
||||||
<tr><td align="left" class="text"><?= $zmSlangRunMode ?></td><td align="left" class="text"><select name="new_monitor[RunMode]" class="form">
|
|
||||||
<?php
|
|
||||||
foreach ( getEnumValues( 'Monitors', 'RunMode' ) as $opt_runmode )
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<option value="<?= $opt_runmode ?>"<?php if ( $opt_runmode == $new_monitor['RunMode'] ) { ?> selected<?php } ?>><?= $opt_runmode ?></option>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select></td></tr>
|
|
||||||
<tr><td align="left" class="text"><?= $zmSlangTriggers ?></td><td align="left" class="text">
|
<tr><td align="left" class="text"><?= $zmSlangTriggers ?></td><td align="left" class="text">
|
||||||
<?php
|
<?php
|
||||||
$opt_triggers = getSetValues( 'Monitors', 'Triggers' );
|
$opt_triggers = getSetValues( 'Monitors', 'Triggers' );
|
||||||
|
|
|
@ -111,7 +111,7 @@ foreach( $monitors as $monitor )
|
||||||
{
|
{
|
||||||
$fclass = "gretext";
|
$fclass = "gretext";
|
||||||
}
|
}
|
||||||
if ( $monitor['RunMode'] == 'Triggered' )
|
if ( !$monitor['Enabled'] )
|
||||||
{
|
{
|
||||||
$fclass .= "em";
|
$fclass .= "em";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue