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 Message
::Success("Successfully created user \"" . $user['user_name'] . "\"");
59 Message
::Fail("Failed to create user \"" . $user['user_name'] . "\"");
64 Hook
::run(HOOKTYPE_GET_USER_LIST
, $userlist);
67 Click on a username to view more information
.
71 <?php
if (current_user_can(PERMISSION_MANAGE_USERS
)) { ?>
72 <div
class="col-sm-3">
74 <div
class="btn btn-primary" data
-toggle
="modal" data
-target
="#myModal">Add
New User
</div
>
75 <button type
="button" class="btn btn-danger" data
-toggle
="modal" data
-target
="#myModal2">Delete selected
</button
>
81 <div
class="modal fade" id
="myModal" tabindex
="-1" role
="dialog" aria
-labelledby
="confirmModalCenterTitle" aria
-hidden
="true">
82 <div
class="modal-dialog modal-dialog-centered" role
="document">
83 <div
class="modal-content">
84 <div
class="modal-header">
85 <h5
class="modal-title" id
="myModalLabel">Add
new Admin Panel user
</h5
>
86 <button type
="button" class="close" data
-dismiss
="modal" aria
-label
="Close">
87 <span aria
-hidden
="true">×
;</span
></button
>
89 <div
class="modal-body">
90 <div
class="input-group mb-3">
91 <label
for="name_add" name
="user_add" id
="user_add">Username
92 <input style
="width: 170%;" name
="user_add" id
="user_add" class="form-control curvy" type
="text"></label
>
94 <div
class="input-group mb-3">
95 <label
for="password" id
="user_add">Password
96 <input style
="width: 170%;" name
="password" id
="password" class="form-control curvy" type
="password"></label
>
98 <div
class="input-group mb-3">
99 <label
for="user_email" id
="user_add">Email
100 <input style
="width: 170%;" name
="user_email" id
="user_email" class="form-control curvy" type
="text"></label
>
102 <div
class="input-group mb-3">
103 <label
for="add_first_name" id
="user_add">First Name
104 <input style
="width: 170%;" name
="add_first_name" id
="add_first_name" class="form-control curvy" type
="text"></label
>
106 <div
class="input-group mb-3">
107 <label
for="password" id
="user_add">Last Name
108 <input style
="width: 170%;" name
="add_last_name" id
="add_last_name" class="form-control curvy" type
="text"></label
>
110 <div
class="input-group mb-3">
111 <label
for="password" id
="user_add">Info
/Bio
112 <textarea style
="width: 170%;" name
="user_bio" class="form-control curvy" aria
-label
="With textarea"></textarea
></label
>
116 <div
class="modal-footer">
117 <button id
="CloseButton" type
="button" class="btn btn-secondary" data
-dismiss
="modal">Cancel
</button
>
118 <button type
="submit" name
="do_add_user" class="btn btn-danger">Add User
</button
>
127 <table
class="container-xxl table table-sm table-responsive caption-top table-striped">
128 <thead
class="table-primary">
130 <th scope
="col"><input type
="checkbox" label
='selectall' onClick
="toggle_tkl(this)" /></th
>
131 <th scope
="col">Username
</th
>
132 <th scope
="col">First Name
</th
>
133 <th scope
="col">Last Name
</th
>
134 <th scope
="col">Email
</th
>
135 <th scope
="col">Created
</th
>
136 <th scope
="col">Bio
</th
>
137 <th scope
="col">Last login
</th
>
142 foreach($userlist as $user)
145 echo "<td scope=\"col\"><input type=\"checkbox\" value='" .$user->id
. "' name=\"userch[]\"></td>";
146 echo "<td scope=\"col\"><a href=\"".get_config("base_url")."settings/user-edit.php?id=$user->id\">$user->username</a></td>";
147 echo "<td scope=\"col\">".$user->first_name
."</td>";
148 echo "<td scope=\"col\">".$user->last_name
."</td>";
149 echo "<td scope=\"col\"><a href=\"mailto:$user->email\">$user->email</a></td>";
150 echo "<td scope=\"col\"><code>".$user->created
."</code></td>";
151 echo "<td scope=\"col\">".$user->bio
."</td>";
152 $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";
153 echo "<td scope=\"col\">$last</td>";
157 <?php
if (current_user_can(PERMISSION_MANAGE_USERS
)) { ?>
158 <p
><button type
="button" class="btn btn-danger" data
-toggle
="modal" data
-target
="#myModal2">
162 <div
class="modal fade" id
="myModal2" tabindex
="-1" role
="dialog" aria
-labelledby
="confirmModalCenterTitle" aria
-hidden
="true">
163 <div
class="modal-dialog modal-dialog-centered" role
="document">
164 <div
class="modal-content">
165 <div
class="modal-header">
166 <h5
class="modal-title" id
="myModalLabel">Confirm deletion
</h5
>
167 <button type
="button" class="close" data
-dismiss
="modal" aria
-label
="Close">
168 <span aria
-hidden
="true">×
;</span
>
171 <div
class="modal-body">
172 Are you sure you want to
do this
?<br
>
173 This cannot be undone
.
175 <div
class="modal-footer">
176 <button id
="CloseButton" type
="button" class="btn btn-secondary" data
-dismiss
="modal">Cancel
</button
>
177 <button type
="submit" action
="post" name
="delete_user" class="btn btn-danger">Delete
</button
>
182 </div
></form
></div
></div
><br
></div
>
184 require_once '../inc/footer.php'; ?>