Further PTZ preset tweaks

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2958 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2009-09-28 14:16:17 +00:00
parent 1e2ecf0947
commit 93b955813f
5 changed files with 17 additions and 19 deletions

View File

@ -11,9 +11,8 @@ if ( canView( 'Control', $_REQUEST['id'] ) )
$ctrlCommand = buildControlCommand( $monitor );
if ( $_REQUEST['control'] != 'null' )
if ( $ctrlCommand )
{
$ctrlCommand .= " --command=".$_REQUEST['control'];
$socket = socket_create( AF_UNIX, SOCK_STREAM, 0 );
if ( !$socket )
ajaxError( "socket_create() failed: ".socket_strerror(socket_last_error()) );

View File

@ -172,17 +172,12 @@ if ( !empty($action) )
$mid = validInt($_REQUEST['mid']);
if ( $action == "control" )
{
$control = validStr($_REQUEST['control']);
if ( !empty( $_REQUEST['controlParms'] ) )
$control .= $_REQUEST['controlParms'];
$monitor = dbFetchOne( "select C.*,M.* from Monitors as M inner join Controls as C on (M.ControlId = C.Id) where M.Id = '".dbEscape($mid)."'" );
$ctrlCommand = buildControlCommand( $monitor );
if ( $control != 'null' )
if ( $ctrlCommand )
{
$ctrlCommand .= " --command=".$control;
$socket = socket_create( AF_UNIX, SOCK_STREAM, 0 );
if ( $socket < 0 )
{

View File

@ -388,6 +388,7 @@ function buildControlCommand( $monitor )
{
// No command, probably in blind spot in middle
$_REQUEST['control'] = 'null';
return( false );
}
else
{
@ -935,24 +936,26 @@ function buildControlCommand( $monitor )
$_REQUEST['control'] = 'presetGoto';
$ctrlCommand .= " --preset=".$matches[1];
}
elseif ( $_REQUEST['control'] == "presetGoto" && !empty($_REQUEST['controlParm']) )
elseif ( $_REQUEST['control'] == "presetGoto" && !empty($_REQUEST['preset']) )
{
$ctrlCommand .= " --preset=".$_REQUEST['controlParm'];
$ctrlCommand .= " --preset=".$_REQUEST['preset'];
}
elseif ( $_REQUEST['control'] == "presetSet" )
{
if ( canEdit( 'Control' ) )
{
$sql = "select * from ControlPresets where MonitorId = '".$monitor['Id']."' and Preset = '".$preset."'";
$row = dbFetchOne( $sql );
if ( $new_label != $row['Label'] )
$preset = validInt($_REQUEST['preset']);
$newLabel = validJsStr($_REQUEST['newLabel']);
$row = dbFetchOne( "select * from ControlPresets where MonitorId = '".$monitor['Id']."' and Preset = '".dbEscape($preset)."'" );
if ( $newLabel != $row['Label'] )
{
if ( $new_label )
$sql = "replace into ControlPresets ( MonitorId, Preset, Label ) values ( '".$monitor['Id']."', '".$preset."', '".addslashes($new_label)."' )";
if ( $newLabel )
$sql = "replace into ControlPresets ( MonitorId, Preset, Label ) values ( '".$monitor['Id']."', '".dbEscape($preset)."', '".dbEscape($newLabel)."' )";
else
$sql = "delete from ControlPresets where MonitorId = '".$monitor['Id']."' and Preset = '".$preset."'";
$sql = "delete from ControlPresets where MonitorId = '".$monitor['Id']."' and Preset = '".dbEscape($preset)."'";
dbQuery( $sql );
}
$ctrlCommand .= " --preset=".$preset;
}
$ctrlCommand .= " --preset=".$preset;
}
@ -961,5 +964,6 @@ function buildControlCommand( $monitor )
$ctrlCommand .= " --xcoord=$x --ycoord=$y";
}
}
$ctrlCommand .= " --command=".$_REQUEST['control'];
return( $ctrlCommand );
}

View File

@ -55,7 +55,7 @@ xhtmlHeaders(__FILE__, $SLANG['SetPreset'] );
</div>
<div id="content">
<form name="contentForm" id="contentForm" method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
<input type="hidden" name="view" value="<?= $view ?>"/>
<input type="hidden" name="view" value="none"/>
<input type="hidden" name="mid" value="<?= $monitor['Id'] ?>"/>
<input type="hidden" name="action" value="control"/>
<input type="hidden" name="control" value="presetSet"/>

View File

@ -150,7 +150,7 @@ function controlPresets( $monitor, $cmds )
?>
<div class="presetControls">
<div>
<form method="get" action="<?= $_SERVER['PHP_SELF'] ?>">
<form method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
<div class="hidden">
<fieldset>
<input type="hidden" name="view" value="<?= $_REQUEST['view'] ?>"/>
@ -164,7 +164,7 @@ function controlPresets( $monitor, $cmds )
for ( $i = 1; $i <= min($monitor['NumPresets'],MAX_PRESETS); $i++ )
{
?>
<input type="submit" class="ptzNumBtn" title="<?= isset($labels[$i])?$labels[$i]:"" ?>" name="controlParm" value="<?= $i ?>"/>
<input type="submit" class="ptzNumBtn" title="<?= isset($labels[$i])?$labels[$i]:"" ?>" name="preset" value="<?= $i ?>"/>
<?php
}
?>