From 85bb66a3ea00fef4181fa1749dfee235d7891fd4 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 21 Sep 2022 09:56:55 -0400 Subject: [PATCH] Change from newUser[] to user[] in form elements. Add Group permissions --- web/skins/classic/views/user.php | 106 ++++++++++++++++++++++++------- 1 file changed, 84 insertions(+), 22 deletions(-) diff --git a/web/skins/classic/views/user.php b/web/skins/classic/views/user.php index dbf3a40c5..259f6cbdf 100644 --- a/web/skins/classic/views/user.php +++ b/web/skins/classic/views/user.php @@ -26,15 +26,16 @@ if (!canEdit('System') && !$selfEdit) { } require_once('includes/User.php'); +require_once('includes/Group_Permission.php'); if (isset($_REQUEST['uid']) and $_REQUEST['uid']) { - if ( !($newUser = new ZM\User($_REQUEST['uid'])) ) { + if ( !($User = new ZM\User($_REQUEST['uid'])) ) { $view = 'error'; return; } } else { - $newUser = new ZM\User(); - $newUser->Username(translate('NewUser')); + $User = new ZM\User(); + $User->Username(translate('NewUser')); } $yesno = array( 0=>translate('No'), 1=>translate('Yes') ); @@ -53,7 +54,7 @@ foreach ( dbFetchAll($sql) as $monitor ) { $focusWindow = true; -xhtmlHeaders(__FILE__, translate('User').' - '.$newUser->Username()); +xhtmlHeaders(__FILE__, translate('User').' - '.$User->Username()); echo getBodyTopHTML(); echo getNavBarHTML(); ?> @@ -64,7 +65,7 @@ echo getNavBarHTML();
-

Username()); ?>

+

Username()); ?>

@@ -80,14 +81,14 @@ if (canEdit('System')) { ?> - Username() == 'admin' ? ' readonly="readonly"':''?>/> + Username() == 'admin' ? ' readonly="readonly"':''?>/> - + @@ -95,22 +96,22 @@ if (canEdit('System')) { - Language()) ?> + Language()) ?> - + - Enabled()) ?> + Enabled()) ?> - MaxBandwidth()) ?> + MaxBandwidth()) ?> - Stream()) ?> + Stream()) ?> - Events()) ?> + Events()) ?> - Snapshots()) ?> + Snapshots()) ?> - Control()) ?> + Control()) ?> - Monitors()) ?> + Monitors()) ?> - Groups()) ?> + Groups()) ?> - System()) ?> + System()) ?> - Devices()) ?> + Devices()) ?> MonitorIds() ? explode(',', $newUser->MonitorIds()) : array()), + echo htmlSelect('user[MonitorIds][]', $monitors, + ($User->MonitorIds() ? explode(',', $User->MonitorIds()) : array()), array('multiple'=>'multiple')); ?> @@ -172,7 +173,7 @@ if (canEdit('System')) { - APIEnabled()) ?> + APIEnabled()) ?>
Id()] = $Group; + } + + $max_depth = 0; + # This array is indexed by parent_id + $children = array(); + foreach ( $Groups as $id=>$Group ) { + if ( ! isset( $children[$Group->ParentId()] ) ) + $children[$Group->ParentId()] = array(); + $children[$Group->ParentId()][] = $Group; + if ( $max_depth < $Group->depth() ) + $max_depth = $Group->depth(); + } + + $permissions = array(); + foreach (ZM\Group_Permission::find(array('UserId'=>$User->Id())) as $P) { + $permissions[$p->GroupId()] = $P; + } +?> + + + + + + + + + +'; + $html .= str_repeat('', $Group->depth()); + $html .= ''; + $html .= ''; + $html .= ''; + if (isset($children[$Group->Id()])) { + foreach ($children[$Group->Id()] as $G) { + $html .= group_line($G); + } + } + return $html; + } + if (isset($children[null])) { + foreach ($children[null] as $Group) { + echo group_line($Group); + } + } +?> + +
 '; + $html .= ''.validHtmlStr($Group->Id().' '.$Group->Name()).''; + $html .= ''. validHtmlStr(monitorIdsToNames($Group->MonitorIds(), 30)).''.html_radio('group['.$Group->Id().']', $nve, isset($permissions[$Group->Id()]) ? $permissions[$Group->Id()] : 'None').'
+