Bug 163 - Added control permissions
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1506 e3e1d417-86f3-4887-817a-d78f3d33393fpull/27/merge
parent
b29b9866aa
commit
044450901b
|
@ -31,21 +31,23 @@ User::User()
|
|||
{
|
||||
username[0] = password[0] = 0;
|
||||
enabled = false;
|
||||
stream = events = monitors = system = PERM_NONE;
|
||||
stream = events = control = monitors = system = PERM_NONE;
|
||||
monitor_ids = 0;
|
||||
}
|
||||
|
||||
User::User( MYSQL_ROW &dbrow )
|
||||
{
|
||||
strncpy( username, dbrow[0], sizeof(username) );
|
||||
strncpy( password, dbrow[1], sizeof(password) );
|
||||
enabled = (bool)atoi( dbrow[2] );
|
||||
stream = (Permission)atoi( dbrow[3] );
|
||||
events = (Permission)atoi( dbrow[4] );
|
||||
monitors = (Permission)atoi( dbrow[5] );
|
||||
system = (Permission)atoi( dbrow[6] );
|
||||
int index = 0;
|
||||
strncpy( username, dbrow[index++], sizeof(username) );
|
||||
strncpy( password, dbrow[index++], sizeof(password) );
|
||||
enabled = (bool)atoi( dbrow[index++] );
|
||||
stream = (Permission)atoi( dbrow[index++] );
|
||||
events = (Permission)atoi( dbrow[index++] );
|
||||
control = (Permission)atoi( dbrow[index++] );
|
||||
monitors = (Permission)atoi( dbrow[index++] );
|
||||
system = (Permission)atoi( dbrow[index++] );
|
||||
monitor_ids = 0;
|
||||
char *monitor_ids_str = dbrow[7];
|
||||
char *monitor_ids_str = dbrow[index++];
|
||||
if ( monitor_ids_str && *monitor_ids_str )
|
||||
{
|
||||
monitor_ids = new int[strlen(monitor_ids_str)];
|
||||
|
@ -102,7 +104,7 @@ bool User::canAccess( int monitor_id )
|
|||
User *zmLoadUser( const char *username, const char *password )
|
||||
{
|
||||
char sql[BUFSIZ] = "";
|
||||
snprintf( sql, sizeof(sql), "select Username, Password, Enabled, Stream+0, Events+0, Monitors+0, System+0, MonitorIds from Users where Username = '%s' and Password = password('%s') and Enabled = 1", username, password );
|
||||
snprintf( sql, sizeof(sql), "select Username, Password, Enabled, Stream+0, Events+0, Control+0, Monitors+0, System+0, MonitorIds from Users where Username = '%s' and Password = password('%s') and Enabled = 1", username, password );
|
||||
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
|
@ -149,7 +151,7 @@ User *zmLoadAuthUser( const char *auth, bool use_remote_addr )
|
|||
|
||||
Debug( 1, ( "Attempting to authenticate user from auth string '%s'", auth ));
|
||||
char sql[BUFSIZ] = "";
|
||||
snprintf( sql, sizeof(sql), "select Username, Password, Enabled, Stream+0, Events+0, Monitors+0, System+0, MonitorIds from Users where Enabled = 1" );
|
||||
snprintf( sql, sizeof(sql), "select Username, Password, Enabled, Stream+0, Events+0, Control+0, Monitors+0, System+0, MonitorIds from Users where Enabled = 1" );
|
||||
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@ protected:
|
|||
bool enabled;
|
||||
Permission stream;
|
||||
Permission events;
|
||||
Permission control;
|
||||
Permission monitors;
|
||||
Permission system;
|
||||
int *monitor_ids;
|
||||
|
@ -52,6 +53,7 @@ public:
|
|||
bool isEnabled() const { return( enabled ); }
|
||||
Permission getStream() const { return( stream ); }
|
||||
Permission getEvents() const { return( events ); }
|
||||
Permission getControl() const { return( control ); }
|
||||
Permission getMonitors() const { return( monitors ); }
|
||||
Permission getSystem() const { return( system ); }
|
||||
bool canAccess( int monitor_id );
|
||||
|
|
|
@ -151,193 +151,9 @@ if ( isset($action) )
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( canEdit( 'Monitors', $mid ) )
|
||||
if ( canView( 'Control', $mid ) )
|
||||
{
|
||||
if ( $action == "function" && isset( $mid ) )
|
||||
{
|
||||
$sql = "select * from Monitors where Id = '$mid'";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$monitor = mysql_fetch_assoc( $result );
|
||||
|
||||
$old_function = $monitor['Function'];
|
||||
if ( $new_function != $old_function )
|
||||
{
|
||||
simpleQuery( "update Monitors set Function = '$new_function' where Id = '$mid'" );
|
||||
|
||||
$monitor['Function'] = $new_function;
|
||||
if ( $cookies ) session_write_close();
|
||||
zmcControl( $monitor, true );
|
||||
zmaControl( $monitor, true );
|
||||
$refresh_parent = true;
|
||||
}
|
||||
}
|
||||
elseif ( $action == "zone" && isset( $mid ) && isset( $zid ) )
|
||||
{
|
||||
$result = mysql_query( "select * from Monitors where Id = '$mid'" );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$monitor = mysql_fetch_assoc( $result );
|
||||
|
||||
if ( $zid > 0 )
|
||||
{
|
||||
$result = mysql_query( "select * from Zones where MonitorId = '$mid' and Id = '$zid'" );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$zone = mysql_fetch_assoc( $result );
|
||||
}
|
||||
else
|
||||
{
|
||||
$zone = array();
|
||||
}
|
||||
|
||||
$types = array();
|
||||
$changes = getFormChanges( $zone, $new_zone, $types );
|
||||
|
||||
if ( count( $changes ) )
|
||||
{
|
||||
if ( $zid > 0 )
|
||||
{
|
||||
$sql = "update Zones set ".implode( ", ", $changes )." where MonitorId = '$mid' and Id = '$zid'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "insert into Zones set MonitorId = '$mid', ".implode( ", ", $changes );
|
||||
$view = 'none';
|
||||
}
|
||||
//echo "<html>$sql</html>";
|
||||
simpleQuery( $sql );
|
||||
if ( $cookies ) session_write_close();
|
||||
zmaControl( $mid, true );
|
||||
$refresh_parent = true;
|
||||
}
|
||||
}
|
||||
elseif ( $action == "monitor" && isset( $mid ) )
|
||||
{
|
||||
if ( $mid > 0 )
|
||||
{
|
||||
$result = mysql_query( "select * from Monitors where Id = '$mid'" );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$monitor = mysql_fetch_assoc( $result );
|
||||
|
||||
if ( ZM_OPT_X10 )
|
||||
{
|
||||
$result = mysql_query( "select * from TriggersX10 where MonitorId = '$mid'" );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$x10_monitor = mysql_fetch_assoc( $result );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$monitor = array();
|
||||
if ( ZM_OPT_X10 )
|
||||
{
|
||||
$x10_monitor = array();
|
||||
}
|
||||
}
|
||||
|
||||
// Define a field type for anything that's not simple text equivalent
|
||||
$types = array(
|
||||
'Triggers' => 'set',
|
||||
'Controllable' => 'toggle',
|
||||
'TrackMotion' => 'toggle',
|
||||
);
|
||||
|
||||
$columns = getTableColumns( 'Monitors' );
|
||||
$changes = getFormChanges( $monitor, $new_monitor, $types, $columns );
|
||||
|
||||
if ( count( $changes ) )
|
||||
{
|
||||
if ( $mid > 0 )
|
||||
{
|
||||
simpleQuery( "update Monitors set ".implode( ", ", $changes )." where Id = '$mid'" );
|
||||
if ( $changes['Name'] )
|
||||
{
|
||||
exec( escapeshellcmd( "mv ".ZM_DIR_EVENTS."/".$monitor['Name']." ".ZM_DIR_EVENTS."/".$new_monitor['Name'] ) );
|
||||
}
|
||||
}
|
||||
elseif ( !$user['MonitorIds'] )
|
||||
{
|
||||
$sql = "insert into Monitors set ".implode( ", ", $changes );
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$mid = mysql_insert_id();
|
||||
$sql = "insert into Zones set MonitorId = $mid, Name = 'All', Type = 'Active', Units = 'Percent', LoX = 0, LoY = 0, HiX = 100, HiY = 100, AlarmRGB = 0xff0000, CheckMethod = 'Blobs', MinPixelThreshold = 25, MaxPixelThreshold = 0, MinAlarmPixels = 3, MaxAlarmPixels = 75, FilterX = 3, FilterY = 3, MinFilterPixels = 3, MaxFilterPixels = 75, MinBlobPixels = 2, MaxBlobPixels = 0, MinBlobs = 1, MaxBlobs = 0";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
//$view = 'none';
|
||||
mkdir( ZM_DIR_EVENTS."/".$mid, 0755 );
|
||||
chdir( ZM_DIR_EVENTS );
|
||||
symlink( $mid, $new_monitor['Name'] );
|
||||
chdir( ".." );
|
||||
}
|
||||
$restart = true;
|
||||
}
|
||||
|
||||
if ( ZM_OPT_X10 )
|
||||
{
|
||||
$x10_changes = getFormChanges( $x10_monitor, $new_x10_monitor );
|
||||
|
||||
if ( count( $x10_changes ) )
|
||||
{
|
||||
if ( $x10_monitor && $new_x10_monitor )
|
||||
{
|
||||
$sql = "update TriggersX10 set ".implode( ", ", $x10_changes )." where MonitorId = '$mid'";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
}
|
||||
elseif ( !$user['MonitorIds'] )
|
||||
{
|
||||
if ( !$x10_monitor )
|
||||
{
|
||||
$sql = "insert into TriggersX10 set MonitorId = '$mid', ".implode( ", ", $x10_changes );
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "delete from TriggersX10 where MonitorId = '$mid'";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
}
|
||||
}
|
||||
$restart = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $restart )
|
||||
{
|
||||
$result = mysql_query( "select * from Monitors where Id = '$mid'" );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$monitor = mysql_fetch_assoc( $result );
|
||||
fixDevices();
|
||||
if ( $cookies ) session_write_close();
|
||||
zmcControl( $monitor, true );
|
||||
zmaControl( $monitor, true );
|
||||
//daemonControl( 'restart', 'zmwatch.pl' );
|
||||
$refresh_parent = true;
|
||||
}
|
||||
}
|
||||
elseif ( $action == "settings" && isset( $mid ) )
|
||||
{
|
||||
$zmu_command = getZmuCommand( " -m $mid -B$new_brightness -C$new_contrast -H$new_hue -O$new_colour" );
|
||||
$zmu_output = exec( escapeshellcmd( $zmu_command ) );
|
||||
list( $brightness, $contrast, $hue, $colour ) = split( ' ', $zmu_output );
|
||||
$sql = "update Monitors set Brightness = '$brightness', Contrast = '$contrast', Hue = '$hue', Colour = '$colour' where Id = '$mid'";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
}
|
||||
elseif ( $action == "control" && isset( $mid ) )
|
||||
if ( $action == "control" && isset( $mid ) )
|
||||
{
|
||||
$result = mysql_query( "select * from Monitors as M inner join Controls as C on (M.ControlId = C.Id ) where M.Id = '$mid'" );
|
||||
if ( !$result )
|
||||
|
@ -893,17 +709,267 @@ if ( isset($action) )
|
|||
}
|
||||
if ( $control != 'null' )
|
||||
{
|
||||
if ( $monitor['Function'] == 'Modect' || $monitor['Function'] == 'Mocord' )
|
||||
{
|
||||
$zmu_command = getZmuCommand( " -m $mid -r" );
|
||||
$zmu_output = exec( escapeshellcmd( $zmu_command ) );
|
||||
}
|
||||
//if ( $monitor['Function'] == 'Modect' || $monitor['Function'] == 'Mocord' )
|
||||
//{
|
||||
//$zmu_command = getZmuCommand( " -m $mid -r" );
|
||||
//$zmu_output = exec( escapeshellcmd( $zmu_command ) );
|
||||
//}
|
||||
$ctrl_command .= " --command=".$control;
|
||||
//echo $ctrl_command;
|
||||
$ctrl_output = exec( escapeshellcmd( $ctrl_command ) );
|
||||
//echo $ctrl_output;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( canEdit( 'Control' ) )
|
||||
{
|
||||
if ( $action == "controlcap" && isset( $cid ) )
|
||||
{
|
||||
if ( $cid > 0 )
|
||||
{
|
||||
$result = mysql_query( "select * from Controls where Id = '$cid'" );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$control = mysql_fetch_assoc( $result );
|
||||
}
|
||||
else
|
||||
{
|
||||
$control = array();
|
||||
}
|
||||
|
||||
// Define a field type for anything that's not simple text equivalent
|
||||
$types = array(
|
||||
// Empty
|
||||
);
|
||||
|
||||
$columns = getTableColumns( 'Controls' );
|
||||
foreach ( $columns as $name=>$type )
|
||||
{
|
||||
if ( preg_match( '/^(Can|Has)/', $name ) )
|
||||
{
|
||||
$types[$name] = 'toggle';
|
||||
}
|
||||
}
|
||||
$changes = getFormChanges( $control, $new_control, $types, $columns );
|
||||
|
||||
if ( count( $changes ) )
|
||||
{
|
||||
if ( $cid > 0 )
|
||||
{
|
||||
simpleQuery( "update Controls set ".implode( ", ", $changes )." where Id = '$cid'" );
|
||||
$refresh_parent = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$sql = "insert into Controls set ".implode( ", ", $changes );
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$cid = mysql_insert_id();
|
||||
}
|
||||
$refresh_parent = true;
|
||||
}
|
||||
}
|
||||
elseif ( $action == "delete" )
|
||||
{
|
||||
if ( $mark_cids )
|
||||
{
|
||||
foreach( $mark_cids as $mark_cid )
|
||||
{
|
||||
simpleQuery( "delete from Controls where Id = '$mark_cid'" );
|
||||
simpleQuery( "update Monitors set Controllable = 0, ControlId = 0 where ControlId = '$mark_cid'" );
|
||||
$refresh_parent = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( canEdit( 'Monitors', $mid ) )
|
||||
{
|
||||
if ( $action == "function" && isset( $mid ) )
|
||||
{
|
||||
$sql = "select * from Monitors where Id = '$mid'";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$monitor = mysql_fetch_assoc( $result );
|
||||
|
||||
$old_function = $monitor['Function'];
|
||||
if ( $new_function != $old_function )
|
||||
{
|
||||
simpleQuery( "update Monitors set Function = '$new_function' where Id = '$mid'" );
|
||||
|
||||
$monitor['Function'] = $new_function;
|
||||
if ( $cookies ) session_write_close();
|
||||
zmcControl( $monitor, true );
|
||||
zmaControl( $monitor, true );
|
||||
$refresh_parent = true;
|
||||
}
|
||||
}
|
||||
elseif ( $action == "zone" && isset( $mid ) && isset( $zid ) )
|
||||
{
|
||||
$result = mysql_query( "select * from Monitors where Id = '$mid'" );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$monitor = mysql_fetch_assoc( $result );
|
||||
|
||||
if ( $zid > 0 )
|
||||
{
|
||||
$result = mysql_query( "select * from Zones where MonitorId = '$mid' and Id = '$zid'" );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$zone = mysql_fetch_assoc( $result );
|
||||
}
|
||||
else
|
||||
{
|
||||
$zone = array();
|
||||
}
|
||||
|
||||
$types = array();
|
||||
$changes = getFormChanges( $zone, $new_zone, $types );
|
||||
|
||||
if ( count( $changes ) )
|
||||
{
|
||||
if ( $zid > 0 )
|
||||
{
|
||||
$sql = "update Zones set ".implode( ", ", $changes )." where MonitorId = '$mid' and Id = '$zid'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "insert into Zones set MonitorId = '$mid', ".implode( ", ", $changes );
|
||||
$view = 'none';
|
||||
}
|
||||
//echo "<html>$sql</html>";
|
||||
simpleQuery( $sql );
|
||||
if ( $cookies ) session_write_close();
|
||||
zmaControl( $mid, true );
|
||||
$refresh_parent = true;
|
||||
}
|
||||
}
|
||||
elseif ( $action == "monitor" && isset( $mid ) )
|
||||
{
|
||||
if ( $mid > 0 )
|
||||
{
|
||||
$result = mysql_query( "select * from Monitors where Id = '$mid'" );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$monitor = mysql_fetch_assoc( $result );
|
||||
|
||||
if ( ZM_OPT_X10 )
|
||||
{
|
||||
$result = mysql_query( "select * from TriggersX10 where MonitorId = '$mid'" );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$x10_monitor = mysql_fetch_assoc( $result );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$monitor = array();
|
||||
if ( ZM_OPT_X10 )
|
||||
{
|
||||
$x10_monitor = array();
|
||||
}
|
||||
}
|
||||
|
||||
// Define a field type for anything that's not simple text equivalent
|
||||
$types = array(
|
||||
'Triggers' => 'set',
|
||||
'Controllable' => 'toggle',
|
||||
'TrackMotion' => 'toggle',
|
||||
);
|
||||
|
||||
$columns = getTableColumns( 'Monitors' );
|
||||
$changes = getFormChanges( $monitor, $new_monitor, $types, $columns );
|
||||
|
||||
if ( count( $changes ) )
|
||||
{
|
||||
if ( $mid > 0 )
|
||||
{
|
||||
simpleQuery( "update Monitors set ".implode( ", ", $changes )." where Id = '$mid'" );
|
||||
if ( $changes['Name'] )
|
||||
{
|
||||
exec( escapeshellcmd( "mv ".ZM_DIR_EVENTS."/".$monitor['Name']." ".ZM_DIR_EVENTS."/".$new_monitor['Name'] ) );
|
||||
}
|
||||
}
|
||||
elseif ( !$user['MonitorIds'] )
|
||||
{
|
||||
$sql = "insert into Monitors set ".implode( ", ", $changes );
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$mid = mysql_insert_id();
|
||||
$sql = "insert into Zones set MonitorId = $mid, Name = 'All', Type = 'Active', Units = 'Percent', LoX = 0, LoY = 0, HiX = 100, HiY = 100, AlarmRGB = 0xff0000, CheckMethod = 'Blobs', MinPixelThreshold = 25, MaxPixelThreshold = 0, MinAlarmPixels = 3, MaxAlarmPixels = 75, FilterX = 3, FilterY = 3, MinFilterPixels = 3, MaxFilterPixels = 75, MinBlobPixels = 2, MaxBlobPixels = 0, MinBlobs = 1, MaxBlobs = 0";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
//$view = 'none';
|
||||
mkdir( ZM_DIR_EVENTS."/".$mid, 0755 );
|
||||
chdir( ZM_DIR_EVENTS );
|
||||
symlink( $mid, $new_monitor['Name'] );
|
||||
chdir( ".." );
|
||||
}
|
||||
$restart = true;
|
||||
}
|
||||
|
||||
if ( ZM_OPT_X10 )
|
||||
{
|
||||
$x10_changes = getFormChanges( $x10_monitor, $new_x10_monitor );
|
||||
|
||||
if ( count( $x10_changes ) )
|
||||
{
|
||||
if ( $x10_monitor && $new_x10_monitor )
|
||||
{
|
||||
$sql = "update TriggersX10 set ".implode( ", ", $x10_changes )." where MonitorId = '$mid'";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
}
|
||||
elseif ( !$user['MonitorIds'] )
|
||||
{
|
||||
if ( !$x10_monitor )
|
||||
{
|
||||
$sql = "insert into TriggersX10 set MonitorId = '$mid', ".implode( ", ", $x10_changes );
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "delete from TriggersX10 where MonitorId = '$mid'";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
}
|
||||
}
|
||||
$restart = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $restart )
|
||||
{
|
||||
$result = mysql_query( "select * from Monitors where Id = '$mid'" );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$monitor = mysql_fetch_assoc( $result );
|
||||
fixDevices();
|
||||
if ( $cookies ) session_write_close();
|
||||
zmcControl( $monitor, true );
|
||||
zmaControl( $monitor, true );
|
||||
//daemonControl( 'restart', 'zmwatch.pl' );
|
||||
$refresh_parent = true;
|
||||
}
|
||||
}
|
||||
elseif ( $action == "settings" && isset( $mid ) )
|
||||
{
|
||||
$zmu_command = getZmuCommand( " -m $mid -B$new_brightness -C$new_contrast -H$new_hue -O$new_colour" );
|
||||
$zmu_output = exec( escapeshellcmd( $zmu_command ) );
|
||||
list( $brightness, $contrast, $hue, $colour ) = split( ' ', $zmu_output );
|
||||
$sql = "update Monitors set Brightness = '$brightness', Contrast = '$contrast', Hue = '$hue', Colour = '$colour' where Id = '$mid'";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
}
|
||||
elseif ( $action == "delete" )
|
||||
{
|
||||
if ( $mark_zids )
|
||||
|
@ -1155,6 +1221,7 @@ if ( isset($action) )
|
|||
if ( $new_enabled != $row['Enabled'] ) $changes[] = "Enabled = '$new_enabled'";
|
||||
if ( $new_stream != $row['Stream'] ) $changes[] = "Stream = '$new_stream'";
|
||||
if ( $new_events != $row['Events'] ) $changes[] = "Events = '$new_events'";
|
||||
if ( $new_control != $row['Control'] ) $changes[] = "Control = '$new_control'";
|
||||
if ( $new_monitors != $row['Monitors'] ) $changes[] = "Monitors = '$new_monitors'";
|
||||
if ( $new_system != $row['System'] ) $changes[] = "System = '$new_system'";
|
||||
if ( $new_monitor_ids != $row['MonitorIds'] ) $changes[] = "MonitorIds = '$new_monitor_ids'";
|
||||
|
@ -1224,54 +1291,6 @@ if ( isset($action) )
|
|||
}
|
||||
$refresh_parent = true;
|
||||
}
|
||||
elseif ( $action == "controlcap" && isset( $cid ) )
|
||||
{
|
||||
if ( $cid > 0 )
|
||||
{
|
||||
$result = mysql_query( "select * from Controls where Id = '$cid'" );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$control = mysql_fetch_assoc( $result );
|
||||
}
|
||||
else
|
||||
{
|
||||
$control = array();
|
||||
}
|
||||
|
||||
// Define a field type for anything that's not simple text equivalent
|
||||
$types = array(
|
||||
// Empty
|
||||
);
|
||||
|
||||
$columns = getTableColumns( 'Controls' );
|
||||
foreach ( $columns as $name=>$type )
|
||||
{
|
||||
if ( preg_match( '/^(Can|Has)/', $name ) )
|
||||
{
|
||||
$types[$name] = 'toggle';
|
||||
}
|
||||
}
|
||||
$changes = getFormChanges( $control, $new_control, $types, $columns );
|
||||
|
||||
if ( count( $changes ) )
|
||||
{
|
||||
if ( $cid > 0 )
|
||||
{
|
||||
simpleQuery( "update Controls set ".implode( ", ", $changes )." where Id = '$cid'" );
|
||||
$refresh_parent = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$sql = "insert into Controls set ".implode( ", ", $changes );
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$cid = mysql_insert_id();
|
||||
}
|
||||
$refresh_parent = true;
|
||||
}
|
||||
}
|
||||
elseif ( $action == "delete" )
|
||||
{
|
||||
if ( $run_state )
|
||||
|
@ -1302,15 +1321,6 @@ if ( isset($action) )
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( $mark_cids )
|
||||
{
|
||||
foreach( $mark_cids as $mark_cid )
|
||||
{
|
||||
simpleQuery( "delete from Controls where Id = '$mark_cid'" );
|
||||
simpleQuery( "update Monitors set Controllable = 0, ControlId = 0 where ControlId = '$mark_cid'" );
|
||||
$refresh_parent = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $action == "learn" )
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
if ( !canEdit( 'Monitors' ) )
|
||||
if ( !canView( 'Control' ) )
|
||||
{
|
||||
$view = "error";
|
||||
return;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
if ( !canEdit( 'System' ) )
|
||||
if ( !canEdit( 'Control' ) )
|
||||
{
|
||||
$view = "error";
|
||||
return;
|
||||
|
@ -456,7 +456,7 @@ switch ( $tab )
|
|||
?>
|
||||
<tr><td colspan="2" align="left" class="text"> </td></tr>
|
||||
<tr>
|
||||
<td colspan="2" align="right"><input type="submit" value="<?= $zmSlangSave ?>" class="form"<?php if ( !canEdit( 'System' ) ) { ?> disabled<?php } ?>> <input type="button" value="<?= $zmSlangCancel ?>" class="form" onClick="closeWindow()"></td>
|
||||
<td colspan="2" align="right"><input type="submit" value="<?= $zmSlangSave ?>" class="form"<?php if ( !canEdit( 'Control' ) ) { ?> disabled<?php } ?>> <input type="button" value="<?= $zmSlangCancel ?>" class="form" onClick="closeWindow()"></td>
|
||||
</tr>
|
||||
</form>
|
||||
</table>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
if ( !canView( 'System' ) )
|
||||
if ( !canView( 'Control' ) )
|
||||
{
|
||||
$view = "error";
|
||||
return;
|
||||
|
@ -99,8 +99,8 @@ foreach( $controls as $control )
|
|||
{
|
||||
?>
|
||||
<tr>
|
||||
<td align="center" class="text"><?= makeLink( "javascript: newWindow( '$PHP_SELF?view=controlcap&cid=".$control['Id']."', 'zmControlCap', ".$jws['controlcap']['w'].", ".$jws['controlcap']['h']." );", $control['Id'].'.', canView( 'System' ) ) ?></td>
|
||||
<td align="center" class="text"><?= makeLink( "javascript: newWindow( '$PHP_SELF?view=controlcap&cid=".$control['Id']."', 'zmControlCap', ".$jws['controlcap']['w'].", ".$jws['controlcap']['h']." );", $control['Name'], canView( 'System' ) ) ?></td>
|
||||
<td align="center" class="text"><?= makeLink( "javascript: newWindow( '$PHP_SELF?view=controlcap&cid=".$control['Id']."', 'zmControlCap', ".$jws['controlcap']['w'].", ".$jws['controlcap']['h']." );", $control['Id'].'.', canView( 'Control' ) ) ?></td>
|
||||
<td align="center" class="text"><?= makeLink( "javascript: newWindow( '$PHP_SELF?view=controlcap&cid=".$control['Id']."', 'zmControlCap', ".$jws['controlcap']['w'].", ".$jws['controlcap']['h']." );", $control['Name'], canView( 'Control' ) ) ?></td>
|
||||
<td align="center" class="text"><?= $control['Type'] ?></td>
|
||||
<td align="center" class="text"><?= $control['CanMove']?$zmSlangYes:$zmSlangNo ?></td>
|
||||
<td align="center" class="text"><?= $control['CanZoom']?$zmSlangYes:$zmSlangNo ?></td>
|
||||
|
@ -108,7 +108,7 @@ foreach( $controls as $control )
|
|||
<td align="center" class="text"><?= $control['CanIris']?$zmSlangYes:$zmSlangNo ?></td>
|
||||
<td align="center" class="text"><?= $control['CanWhite']?$zmSlangYes:$zmSlangNo ?></td>
|
||||
<td align="center" class="text"><?= $control['HasHomePreset']?'H':'' ?><?= $control['HasPresets']?$control['NumPresets']:'0' ?></td>
|
||||
<td align="center" class="text"><input type="checkbox" name="mark_cids[]" value="<?= $control['Id'] ?>" onClick="configureButton( document.control_form, 'mark_cids' );"<?php if ( !canEdit( 'System' ) ) {?> disabled<?php } ?>></td>
|
||||
<td align="center" class="text"><input type="checkbox" name="mark_cids[]" value="<?= $control['Id'] ?>" onClick="configureButton( document.control_form, 'mark_cids' );"<?php if ( !canEdit( 'Control' ) ) {?> disabled<?php } ?>></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ foreach( $controls as $control )
|
|||
<input type="button" value="<?= $zmSlangRefresh ?>" class="form" onClick="javascript: location.reload(true);">
|
||||
</td>
|
||||
<td colspan="2" align="center">
|
||||
<input type="button" value="<?= $zmSlangAddNewControl ?>" class="form" onClick="javascript: newWindow( '<?= $PHP_SELF ?>?view=controlcap', 'zmControlCap', <?= $jws['controlcap']['w'] ?>, <?= $jws['controlcap']['h'] ?>);"<?php if ( !canEdit( 'System' ) ) {?> disabled<?php } ?>>
|
||||
<input type="button" value="<?= $zmSlangAddNewControl ?>" class="form" onClick="javascript: newWindow( '<?= $PHP_SELF ?>?view=controlcap', 'zmControlCap', <?= $jws['controlcap']['w'] ?>, <?= $jws['controlcap']['h'] ?>);"<?php if ( !canEdit( 'Control' ) ) {?> disabled<?php } ?>>
|
||||
</td>
|
||||
<td colspan="5" align="center"> </td>
|
||||
<td align="center"><input type="submit" name="delete_btn" value="<?= $zmSlangDelete ?>" class="form" disabled></td>
|
||||
|
|
|
@ -43,7 +43,7 @@ $cmds = getControlCommands( $monitor );
|
|||
<script type="text/javascript">
|
||||
function newWindow(Url,Name,Width,Height)
|
||||
{
|
||||
var Name = window.open(Url,Name,"resizable,scrollbars,width="+Width+",height="+Height);
|
||||
var Win = window.open(Url,Name,"resizable,scrollbars,width="+Width+",height="+Height);
|
||||
}
|
||||
function closeWindow()
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@ $tabs["source"] = $zmSlangSource;
|
|||
$tabs["timestamp"] = $zmSlangTimestamp;
|
||||
$tabs["buffers"] = $zmSlangBuffers;
|
||||
$tabs["misc"] = $zmSlangMisc;
|
||||
if ( ZM_OPT_CONTROL )
|
||||
if ( ZM_OPT_CONTROL && canView( 'Control' ) )
|
||||
{
|
||||
$tabs["control"] = $zmSlangControl;
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ else
|
|||
{
|
||||
?>
|
||||
<td width="25%" align="left" class="text"><b><?= $zmSlangMontage ?></b></td>
|
||||
<?php if ( ZM_OPT_CONTROL && $control_mid ) { ?>
|
||||
<?php if ( ZM_OPT_CONTROL && $control_mid && canView( 'Control' ) ) { ?>
|
||||
<td width="25%" align="center" class="text"><a href="javascript: newWindow( '<?= $PHP_SELF ?>?view=control&menu=1&mid=<?= $control_mid ?>', 'Control', <?= $jws['control']['w'] ?>, <?= $jws['control']['h'] ?> )"><?= $zmSlangControl ?></a></td>
|
||||
<?php } else { ?>
|
||||
<td width="25%" align="center" class="text"> </td>
|
||||
|
|
|
@ -168,6 +168,7 @@ if ( $tab == "users" )
|
|||
<td align="left" class="smallhead"><?= $zmSlangEnabled ?></td>
|
||||
<td align="left" class="smallhead"><?= $zmSlangStream ?></td>
|
||||
<td align="left" class="smallhead"><?= $zmSlangEvents ?></td>
|
||||
<td align="left" class="smallhead"><?= $zmSlangControl ?></td>
|
||||
<td align="left" class="smallhead"><?= $zmSlangMonitors ?></td>
|
||||
<td align="left" class="smallhead"><?= $zmSlangSystem ?></td>
|
||||
<td align="left" class="smallhead"><?= $zmSlangMonitor ?></td>
|
||||
|
@ -187,6 +188,7 @@ if ( $tab == "users" )
|
|||
<td align="left" class="ruled"><?= $row['Enabled']?$zmSlangYes:$zmSlangNo ?></td>
|
||||
<td align="left" class="ruled"><?= $row['Stream'] ?></td>
|
||||
<td align="left" class="ruled"><?= $row['Events'] ?></td>
|
||||
<td align="left" class="ruled"><?= $row['Control'] ?></td>
|
||||
<td align="left" class="ruled"><?= $row['Monitors'] ?></td>
|
||||
<td align="left" class="ruled"><?= $row['System'] ?></td>
|
||||
<td align="left" class="ruled"><?= $row['MonitorIds']?$row['MonitorIds']:" " ?></td>
|
||||
|
@ -233,7 +235,7 @@ else
|
|||
elseif ( preg_match( "/\|/", $value['Hint'] ) )
|
||||
{
|
||||
?>
|
||||
<td align="left" class="text">
|
||||
<td align="left" class="text"><nobr>
|
||||
<?php
|
||||
foreach ( split( "\|", $value['Hint'] ) as $option )
|
||||
{
|
||||
|
@ -242,7 +244,7 @@ else
|
|||
<?php
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</nobr></td>
|
||||
<?php
|
||||
}
|
||||
elseif ( $value['Type'] == "text" )
|
||||
|
|
|
@ -110,11 +110,13 @@ $nv = array( 'None'=>$zmSlangNone, 'View'=>$zmSlangView );
|
|||
<tr><td align="right" class="text">Stream</td><td align="left" class="text"><?= buildSelect( "new_stream", $nv ) ?></td></tr>
|
||||
<?php
|
||||
$new_events = $row['Events'];
|
||||
$new_control = $row['Control'];
|
||||
$new_monitors = $row['Monitors'];
|
||||
$new_system = $row['System'];
|
||||
$nve = array( 'None'=>$zmSlangNone, 'View'=>$zmSlangView, 'Edit'=>$zmSlangEdit );
|
||||
?>
|
||||
<tr><td align="right" class="text"><?= $zmSlangEvents ?></td><td align="left" class="text"><?= buildSelect( "new_events", $nve ) ?></td></tr>
|
||||
<tr><td align="right" class="text"><?= $zmSlangControl ?></td><td align="left" class="text"><?= buildSelect( "new_control", $nve ) ?></td></tr>
|
||||
<tr><td align="right" class="text"><?= $zmSlangMonitors ?></td><td align="left" class="text"><?= buildSelect( "new_monitors", $nve ) ?></td></tr>
|
||||
<tr><td align="right" class="text"><?= $zmSlangSystem ?></td><td align="left" class="text"><?= buildSelect( "new_system", $nve ) ?></td></tr>
|
||||
<tr><td align="right" class="text"><?= $zmSlangRestrictedCameraIds ?></td><td align="left" class="text"><input type="text" name="new_monitor_ids" value="<?= $row['MonitorIds'] ?>" size="16" class="form"></td></tr>
|
||||
|
|
|
@ -48,7 +48,7 @@ if ( !isset( $scale ) )
|
|||
<script type="text/javascript">
|
||||
function newWindow(Url,Name,Width,Height)
|
||||
{
|
||||
var Name = window.open(Url,Name,"resizable,width="+Width+",height="+Height);
|
||||
var Win = window.open(Url,Name,"resizable,width="+Width+",height="+Height);
|
||||
}
|
||||
function closeWindow()
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ if ( ZM_OPT_CONTROL && $monitor['Controllable'] )
|
|||
{
|
||||
if ( !$control )
|
||||
{
|
||||
if ( canEdit( 'Monitors' ) )
|
||||
if ( canView( 'Control' ) )
|
||||
{
|
||||
?>
|
||||
<td align="center" class="text"><a href="<?= $php_self ?>?view=watch&mid=<?= $mid ?>&mode=<?= $mode ?>&scale=<?= $scale ?>&control=1" target="_parent"><?= $zmSlangControl ?></a></td>
|
||||
|
|
Loading…
Reference in New Issue