2008-03-09 22:49:53 +00:00
< ? php
2018-09-11 07:51:35 -05:00
use LibreNMS\Authentication\LegacyAuth ;
2017-11-18 11:33:03 +01:00
2015-07-13 20:10:26 +02:00
echo '<div style="margin: 10px;">' ;
2008-03-09 22:49:53 +00:00
2019-08-05 14:16:05 -05: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 {
2015-07-13 20:10:26 +02:00
echo '<h3>Delete User</h3>' ;
2008-03-09 22:49:53 +00:00
2015-07-13 20:10:26 +02:00
$pagetitle [] = 'Delete user' ;
2011-10-18 14:41:19 +00:00
2018-09-11 07:51:35 -05:00
if ( LegacyAuth :: get () -> canManageUsers ()) {
2015-07-13 20:10:26 +02:00
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
2015-07-13 20:10:26 +02: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
}
2011-09-21 14:54:21 +00:00
}
2008-03-09 22:49:53 +00:00
2015-07-13 20:10:26 +02: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
2015-07-13 20:10:26 +02:00
echo '
< form role = " form " class = " form-horizontal " method = " GET " action = " " >
2019-07-17 07:20:26 -05:00
' . csrf_field() . '
2015-07-13 20:10:26 +02: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 " >
' ;
2014-06-17 22:11:44 +01:00
2015-07-13 20:10:26 +02:00
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 '
</ select >
</ div >
</ div >
< div class = " form-group " >
< div class = " col-sm-2 " >
</ div >
< div class = " col-sm-6 " >
< button class = " btn btn-danger btn-sm " > Delete User </ button >
</ div >
</ div >
</ form >
' ;
2016-08-18 20:28:22 -05:00
} else {
2015-07-13 20:10:26 +02:00
print_error ( 'Authentication module does not allow user management!' );
} //end if
} //end if
2008-03-09 22:49:53 +00:00
2015-07-13 20:10:26 +02:00
echo '</div>' ;