Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
2.2 KiB
PHP
Raw Permalink Normal View History

2008-03-09 22:49:53 +00:00
<?php
2018-09-11 07:51:35 -05:00
use LibreNMS\Authentication\LegacyAuth;
echo '<div style="margin: 10px;">';
2008-03-09 22:49:53 +00:00
if (! Auth::user()->isAdmin()) {
2019-04-11 23:26:42 -05:00
include 'includes/html/error-no-perm.inc.php';
2016-08-18 20:28:22 -05:00
} else {
2008-03-09 22:49:53 +00:00
echo '<h3>Delete User</h3>';
2011-10-18 14:41:19 +00:00
$pagetitle[] = 'Delete user';
2018-09-11 07:51:35 -05:00
if (LegacyAuth::get()->canManageUsers()) {
if ($vars['action'] == 'del') {
2018-08-25 06:10:00 -05:00
$id = (int) $vars['id'];
2018-09-11 07:51:35 -05:00
$user = LegacyAuth::get()->getUser($id);
2008-03-09 22:49:53 +00:00
if ($vars['confirm'] == 'yes') {
2018-09-11 07:51:35 -05:00
if (LegacyAuth::get()->deleteUser($id) >= 0) {
print_message('<div class="infobox">User "' . $user['username'] . '" deleted!');
2016-08-18 20:28:22 -05:00
} else {
2018-09-11 07:51:35 -05:00
print_error('Error deleting user "' . $user['username'] . '"!');
2015-07-13 20:10:26 +02:00
}
2016-08-18 20:28:22 -05:00
} else {
2018-09-11 07:51:35 -05:00
print_error('You have requested deletion of the user "' . $user['username'] . '". This action can not be reversed.<br /><a class="btn btn-danger" href="deluser/action=del/id=' . $id . '/confirm=yes">Click to confirm</a>');
2015-07-13 20:10:26 +02:00
}
}
2008-03-09 22:49:53 +00:00
2012-05-25 12:24:34 +00:00
// FIXME v mysql query should be replaced by authmodule
2018-09-11 07:51:35 -05:00
$userlist = LegacyAuth::get()->getUserlist();
2014-06-17 22:11:44 +01:00
echo '
<form role="form" class="form-horizontal" method="GET" action="">
2019-07-17 07:20:26 -05:00
' . csrf_field() . '
2014-06-17 22:11:44 +01:00
<input type="hidden" name="action" value="del">
<div class="form-group">
<label for="user_id" class="col-sm-2 control-label">Select User: </label>
<div class="col-sm-6">
<select id="user_id" name="id" class="form-control input-sm">
';
foreach ($userlist as $userentry) {
$i++;
echo '<option value="' . $userentry['user_id'] . '">' . $userentry['username'] . '</option>';
2008-03-09 22:49:53 +00:00
}
2015-07-13 20:10:26 +02:00
echo '
2008-03-09 22:49:53 +00:00
</select>
2015-07-13 20:10:26 +02:00
</div>
</div>
2014-06-17 22:11:44 +01:00
<div class="form-group">
<div class="col-sm-2">
2015-07-13 20:10:26 +02:00
</div>
2014-06-17 22:11:44 +01:00
<div class="col-sm-6">
<button class="btn btn-danger btn-sm">Delete User</button>
2015-07-13 20:10:26 +02:00
</div>
</div>
</form>
';
2016-08-18 20:28:22 -05:00
} else {
print_error('Authentication module does not allow user management!');
2015-07-13 20:10:26 +02:00
}//end if
}//end if
2008-03-09 22:49:53 +00:00
echo '</div>';