"; $pagetitle[] = 'Edit user'; if (! Auth::user()->hasGlobalAdmin()) { include 'includes/html/error-no-perm.inc.php'; } else { if ($vars['user_id'] && ! $vars['edit']) { /** @var User $user */ $user = User::find($vars['user_id']); $user_data = $user->toArray(); // for compatibility with current code echo '

' . $user_data['realname'] . '

'; // Perform actions if requested if ($vars['action'] == 'deldevperm') { if (dbFetchCell('SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?', [$vars['device_id'], $user_data['user_id']])) { dbDelete('devices_perms', '`device_id` = ? AND `user_id` = ?', [$vars['device_id'], $user_data['user_id']]); } } if ($vars['action'] == 'adddevperm') { if (! dbFetchCell('SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?', [$vars['device_id'], $user_data['user_id']])) { dbInsert(['device_id' => $vars['device_id'], 'user_id' => $user_data['user_id']], 'devices_perms'); } } if ($vars['action'] == 'deldevgroupperm') { $user->deviceGroups()->detach($vars['device_group_id']); } if ($vars['action'] == 'adddevgroupperm') { $user->deviceGroups()->syncWithoutDetaching($vars['device_group_id']); } if ($vars['action'] == 'delifperm') { if (dbFetchCell('SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?', [$vars['port_id'], $user_data['user_id']])) { dbDelete('ports_perms', '`port_id` = ? AND `user_id` = ?', [$vars['port_id'], $user_data['user_id']]); } } if ($vars['action'] == 'addifperm') { if (! dbFetchCell('SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?', [$vars['port_id'], $user_data['user_id']])) { dbInsert(['port_id' => $vars['port_id'], 'user_id' => $user_data['user_id']], 'ports_perms'); } } if ($vars['action'] == 'delbillperm') { if (dbFetchCell('SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?', [$vars['bill_id'], $user_data['user_id']])) { dbDelete('bill_perms', '`bill_id` = ? AND `user_id` = ?', [$vars['bill_id'], $user_data['user_id']]); } } if ($vars['action'] == 'addbillperm') { if (! dbFetchCell('SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?', [$vars['bill_id'], $user_data['user_id']])) { dbInsert(['bill_id' => $vars['bill_id'], 'user_id' => $user_data['user_id']], 'bill_perms'); } } echo '
'; // Display devices this users has access to echo '

Device Access

'; echo "
"; $device_perms = dbFetchRows('SELECT * from devices_perms as P, devices as D WHERE `user_id` = ? AND D.device_id = P.device_id', [$user_data['user_id']]); foreach ($device_perms as $device_perm) { echo '"; $access_list[] = $device_perm['device_id']; $permdone = 'yes'; } echo '
Device Action
' . format_hostname($device_perm) . "
'; if (! $permdone) { echo 'None Configured'; } // Display devices this user doesn't have access to echo '

Grant access to new device

'; echo "
" . csrf_field() . "
"; echo '
'; // Display devices this users has access to echo '

Device access via Device Group (beta)

'; echo "
"; foreach ($user->deviceGroups as $device_group_perm) { echo '"; } echo '
Device Group Action
' . $device_group_perm->name . "
'; if ($user->deviceGroups->isEmpty()) { echo 'None Configured'; } // Display device groups this user doesn't have access to echo '

Grant access to new Device Group

'; $allow_dynamic = \LibreNMS\Config::get('permission.device_group.allow_dynamic'); if (! $allow_dynamic) { echo 'Dynamic groups are disabled, set permission.device_group.allow_dynamic to enable.'; } echo "
" . csrf_field() . "
"; echo "
"; echo '

Interface Access

'; $interface_perms = dbFetchRows('SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = ? AND I.port_id = P.port_id AND D.device_id = I.device_id', [$user_data['user_id']]); echo "
"; foreach ($interface_perms as $interface_perm) { echo '"; $ipermdone = 'yes'; } echo '
Interface name Action
' . $interface_perm['hostname'] . ' - ' . $interface_perm['ifDescr'] . '' . '' . \LibreNMS\Util\Clean::html($interface_perm['ifAlias'], []) . "   
'; if (! $ipermdone) { echo 'None Configured'; } // Display interfaces this user doesn't have access to echo '

Grant access to new interface

'; echo "
" . csrf_field() . "
"; echo "
"; echo '

Bill Access

'; $bill_perms = dbFetchRows('SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = ? AND P.bill_id = B.bill_id', [$user_data['user_id']]); echo "
"; foreach ($bill_perms as $bill_perm) { echo '"; $bill_access_list[] = $bill_perm['bill_id']; $bpermdone = 'yes'; } echo '
Bill name Action
' . $bill_perm['bill_name'] . "  
'; if (! $bpermdone) { echo 'None Configured'; } // Display devices this user doesn't have access to echo '

Grant access to new bill

'; echo "
" . csrf_field() . "
"; } else { echo ''; }//end if }//end if echo '
';