4 require_once "../inc/common.php";
5 require_once "../inc/header.php";
12 <h4
>Panel Accounts
</h4
>
19 if (isset($p['delete_user']) && current_user_can(PERMISSION_MANAGE_USERS
))
22 foreach ($p['userch'] as $id)
24 $user = new PanelUser(NULL, $id);
25 $us = unreal_get_current_user();
26 $deleted = delete_user($id, $info);
27 if ($us->id
== $user->id
) // if it's the current user
30 header("Location: " . get_config("base_url") . "plugins/sql_db/login.php");
33 $msg = ($deleted = 1) ? "Message::Success" : "Message::Fail";
39 if (isset($p['do_add_user']) && current_user_can(PERMISSION_MANAGE_USERS
))
42 $user['user_name'] = $p['user_add'];
43 $user['user_pass'] = $p['password'];
44 $user['fname'] = $p['add_first_name'];
45 $user['lname'] = $p['add_last_name'];
46 $user['user_email'] = $p['user_email'];
47 $user['user_bio'] = $p['user_bio'];
49 if (!create_new_user($user))
51 Message
::Fail("Failed to create user: " . $user['user_name'] . " " . $user['err']);
53 else if (($usr_obj = new PanelUser($user['user_name'])) && isset($usr_obj->id
))
55 $usr_obj->add_meta("role", $p['user_role']);
56 Message
::Success("Successfully created user \"" . $user['user_name'] . "\"");
60 Message
::Fail("Failed to create user \"" . $user['user_name'] . "\"");
65 Hook
::run(HOOKTYPE_GET_USER_LIST
, $userlist);
68 Click on a username to view more information
.
72 <?php
if (current_user_can(PERMISSION_MANAGE_USERS
)) { ?>
73 <div
class="col-sm-3">
75 <div
class="btn btn-primary" data
-toggle
="modal" data
-target
="#myModal">Add
New User
</div
>
76 <button type
="button" class="btn btn-danger" data
-toggle
="modal" data
-target
="#myModal2">Delete selected
</button
>
82 <div
class="modal fade" id
="myModal" tabindex
="-1" role
="dialog" aria
-labelledby
="confirmModalCenterTitle" aria
-hidden
="true">
83 <div
class="modal-dialog modal-dialog-centered" role
="document">
84 <div
class="modal-content">
85 <div
class="modal-header">
86 <h5
class="modal-title" id
="myModalLabel">Add
new Admin Panel user
</h5
>
87 <button type
="button" class="close" data
-dismiss
="modal" aria
-label
="Close">
88 <span aria
-hidden
="true">×
;</span
></button
>
90 <div
class="modal-body">
91 <div
class="input-group mb-3">
92 <label
for="name_add" name
="user_add" id
="user_add">Username
93 <input name
="user_add" id
="user_add" class="form-control curvy" type
="text"></label
>
95 <div
class="input-group mb-3">
96 <label
for="password" id
="user_add">Password
97 <input name
="password" id
="password" class="form-control curvy" type
="password"></label
>
99 <div
class="input-group mb-3">
100 <label
for="user_role" id
="user_add">Role
101 <select name
="user_role" class="custom-select form-control" id
="user_role" style
="width:170%">
103 foreach(get_panel_user_roles_list() as $s => $l)
104 echo "<option value=\"$s\">$s</option>";
108 <div
class="input-group mb-3">
109 <label
for="user_email" id
="user_add">Email
110 <input name
="user_email" id
="user_email" class="form-control curvy" type
="text"></label
>
112 <div
class="input-group mb-3">
113 <label
for="add_first_name" id
="user_add">First Name
114 <input name
="add_first_name" id
="add_first_name" class="form-control curvy" type
="text"></label
>
116 <div
class="input-group mb-3">
117 <label
for="password" id
="user_add">Last Name
118 <input name
="add_last_name" id
="add_last_name" class="form-control curvy" type
="text"></label
>
120 <div
class="input-group mb-3">
121 <label
for="password" id
="user_add">Info
/Bio
122 <textarea name
="user_bio" class="form-control curvy" aria
-label
="With textarea"></textarea
></label
>
126 <div
class="modal-footer">
127 <button id
="CloseButton" type
="button" class="btn btn-secondary" data
-dismiss
="modal">Cancel
</button
>
128 <button type
="submit" name
="do_add_user" class="btn btn-danger">Add User
</button
>
137 <table
class="container-xxl table table-sm table-responsive caption-top table-striped">
138 <thead
class="table-primary">
140 <th scope
="col"><input type
="checkbox" label
='selectall' onClick
="toggle_tkl(this)" /></th
>
141 <th scope
="col">Username
</th
>
142 <th scope
="col">Role
</th
>
143 <th scope
="col">First Name
</th
>
144 <th scope
="col">Last Name
</th
>
145 <th scope
="col">Email
</th
>
146 <th scope
="col">Created
</th
>
147 <th scope
="col">Bio
</th
>
148 <th scope
="col">Last login
</th
>
153 foreach($userlist as $user)
156 echo "<td scope=\"col\"><input type=\"checkbox\" value='" .$user->id
. "' name=\"userch[]\"></td>";
157 echo "<td scope=\"col\"><a href=\"".get_config("base_url")."settings/user-edit.php?id=$user->id\">$user->username</a></td>";
158 echo "<td scope=\"col\"><code>".((isset($user->user_meta
['role'])) ? $user->user_meta
['role'] : "")."</code></td>";
159 echo "<td scope=\"col\">".$user->first_name
."</td>";
160 echo "<td scope=\"col\">".$user->last_name
."</td>";
161 echo "<td scope=\"col\"><a href=\"mailto:$user->email\">$user->email</a></td>";
162 echo "<td scope=\"col\"><code>".$user->created
."</code></td>";
163 echo "<td scope=\"col\">".$user->bio
."</td>";
164 $last = (isset($user->user_meta
['last_login'])) ? "<code>".$user->user_meta
['last_login'] . "</code> <span class=\"badge rounded-pill badge-dark\">".how_long_ago($user->user_meta
['last_login'])."</span>" : "none";
165 echo "<td scope=\"col\">$last</td>";
169 <?php
if (current_user_can(PERMISSION_MANAGE_USERS
)) { ?>
170 <p
><button type
="button" class="btn btn-danger" data
-toggle
="modal" data
-target
="#myModal2">
174 <div
class="modal fade" id
="myModal2" tabindex
="-1" role
="dialog" aria
-labelledby
="confirmModalCenterTitle" aria
-hidden
="true">
175 <div
class="modal-dialog modal-dialog-centered" role
="document">
176 <div
class="modal-content">
177 <div
class="modal-header">
178 <h5
class="modal-title" id
="myModalLabel">Confirm deletion
</h5
>
179 <button type
="button" class="close" data
-dismiss
="modal" aria
-label
="Close">
180 <span aria
-hidden
="true">×
;</span
>
183 <div
class="modal-body">
184 Are you sure you want to
do this
?<br
>
185 This cannot be undone
.
187 <div
class="modal-footer">
188 <button id
="CloseButton" type
="button" class="btn btn-secondary" data
-dismiss
="modal">Cancel
</button
>
189 <button type
="submit" action
="post" name
="delete_user" class="btn btn-danger">Delete
</button
>
194 </div
></form
></div
></div
><br
></div
>
196 require_once '../inc/footer.php'; ?>