forked from poweradmin/poweradmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
users.php
183 lines (164 loc) · 7.22 KB
/
users.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
/* Poweradmin, a friendly web-based admin tool for PowerDNS.
* See <http://www.poweradmin.org> for more details.
*
* Copyright 2007-2010 Rejo Zenger <[email protected]>
* Copyright 2010-2014 Poweradmin Development Team
* <http://www.poweradmin.org/credits.html>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Script that handles requests to update and list users
*
* @package Poweradmin
* @copyright 2007-2010 Rejo Zenger <[email protected]>
* @copyright 2010-2014 Poweradmin Development Team
* @license http://opensource.org/licenses/GPL-3.0 GPL
*/
require_once ("inc/toolkit.inc.php");
include_once ("inc/header.inc.php");
do_hook ( 'verify_permission', 'user_view_others' ) ? $perm_view_others = "1" : $perm_view_others = "0";
do_hook ( 'verify_permission', 'user_edit_own' ) ? $perm_edit_own = "1" : $perm_edit_own = "0";
do_hook ( 'verify_permission', 'user_edit_others' ) ? $perm_edit_others = "1" : $perm_edit_others = "0";
do_hook ( 'verify_permission', 'templ_perm_edit' ) ? $perm_templ_perm_edit = "1" : $perm_templ_perm_edit = "0";
do_hook ( 'verify_permission', 'user_is_ueberuser' ) ? $perm_is_godlike = "1" : $perm_is_godlike = "0";
do_hook ( 'verify_permission', 'user_add_new' ) ? $perm_add_new = "1" : $perm_add_new = "0";
// f (isset($_GET['action']) && $_GET['action'] === "switchuser" && $perm_is_godlike === "1"){
// $_SESSION["userlogin"] = $_GET['username'];
// echo '<meta http-equiv="refresh" content="1"/>';
//
unset ( $commit_button );
if (isset ( $_POST ['commit'] )) {
foreach ( $_POST ['user'] as $user ) {
do_hook('update_user_details' , $user );
}
}
$users = do_hook ( 'get_user_detail_list', "" );
echo " <h2>" . _ ( 'User administration' ) . "</h2>\n";
echo " <form method=\"post\" action=\"\">\n";
echo " <table>\n";
echo " <tr>\n";
echo " <th> </th>\n";
echo " <th>" . _ ( 'Username' ) . "</th>\n";
echo " <th>" . _ ( 'Fullname' ) . "</th>\n";
echo " <th>" . _ ( 'Description' ) . "</th>\n";
echo " <th>" . _ ( 'Email address' ) . "</th>\n";
echo " <th>" . _ ( 'Template' ) . "</th>\n";
if ($ldap_use) {
echo " <th>" . _ ( 'LDAP' ) . "</th>\n";
}
echo " <th>" . _ ( 'Enabled' ) . "</th>\n";
echo " </tr>\n";
if (count ( $users ) > 0 ) {
foreach ( $users as $user ) {
if ($user ['active'] == "1") {
$active = " checked";
} else {
$active = "";
}
if ($user ['use_ldap'] == "1") {
$use_ldap = " checked";
} else {
$use_ldap = "";
}
if (($user ['uid'] == $_SESSION ["userid"] && $perm_edit_own == "1") || ($user ['uid'] != $_SESSION ["userid"] && $perm_edit_others == "1")) {
$commit_button = "1";
echo " <tr>\n";
echo " <td>\n";
echo " <input type=\"hidden\" name=\"user[" . $user ['uid'] . "][uid]\" value=\"" . $user ['uid'] . "\">\n";
echo " <a href=\"edit_user.php?id=" . $user ['uid'] . "\"><img src=\"images/edit.gif\" alt=\"[ " . _ ( 'Edit user' ) . " ]\"></a>\n";
// do not allow to delete him- or herself
if ($user ['uid'] != $_SESSION ["userid"]) {
echo " <a href=\"delete_user.php?id=" . $user ['uid'] . "\"><img src=\"images/delete.gif\" alt=\"[ " . _ ( 'Delete user' ) . " ]\"></a>";
}
// if ($user['uid'] != $_SESSION["userid"] && $perm_is_godlike == "1") {
// echo " <a href=\"users.php?action=switchuser&username=" . $user['username'] . "\"><img src=\"images/switch_user.png\" alt=\"[ " . _('Switch user') . " ]\"></a>\n";
// }
echo " </td>\n";
echo " <td><input type=\"text\" name=\"user[" . $user ['uid'] . "][username]\" value=\"" . $user ['username'] . "\"></td>\n";
echo " <td><input type=\"text\" name=\"user[" . $user ['uid'] . "][fullname]\" value=\"" . $user ['fullname'] . "\"></td>\n";
echo " <td><input type=\"text\" name=\"user[" . $user ['uid'] . "][descr]\" value=\"" . $user ['descr'] . "\"></td>\n";
echo " <td><input type=\"text\" name=\"user[" . $user ['uid'] . "][email]\" value=\"" . $user ['email'] . "\"></td>\n";
echo " <td>\n";
if ($perm_templ_perm_edit == "1") {
echo " <select name=\"user[" . $user ['uid'] . "][templ_id]\">\n";
foreach ( do_hook('list_permission_templates') as $template ) {
($template ['id'] == $user ['tpl_id']) ? $select = " SELECTED" : $select = "";
echo " <option value=\"" . $template ['id'] . "\"" . $select . ">" . $template ['name'] . "</option>\n";
}
echo " </select>\n";
} else {
echo " <input type=\"hidden\" name=\"user[" . $user ['uid'] . "][templ_id]\" value=\"" . $user ['tpl_id'] . "\">\n";
echo " " . $user ['tpl_name'] . "\n";
}
echo " </td>\n";
if ($ldap_use) {
if (($perm_is_godlike == "1")) {
echo " <td><input type=\"checkbox\" name=\"user[" . $user ['uid'] . "][use_ldap]\"" . $use_ldap . "></td>\n";
} else {
if ($use_ldap == " checked") {
echo " <td>Yes</td>\n";
} else {
echo " <td>No</td>\n";
}
}
}
if ($user ['uid'] != $_SESSION ["userid"]) {
echo " <td><input type=\"checkbox\" name=\"user[" . $user ['uid'] . "][active]\"" . $active . "></td>\n";
} else {
echo " <td><input type=\"hidden\" name=\"user[" . $user ['uid'] . "][active]\" value=\"on\"></td>\n";
}
echo " </tr>\n";
} else {
echo " <tr>\n";
echo " <td> </td>\n";
echo " <td>" . $user ['username'] . "</td>\n";
echo " <td>" . $user ['fullname'] . "</td>\n";
echo " <td>" . $user ['descr'] . "</td>\n";
echo " <td>" . $user ['email'] . "</td>\n";
echo " <td>" . $user ['tpl_name'] . "</td>\n";
if ($active == " checked") {
echo " <td>Yes</td>\n";
} else {
echo " <td>No</td>\n";
}
if ($use_ldap == " checked") {
echo " <td>Yes</td>\n";
} else {
echo " <td>No</td>\n";
}
echo " </tr>\n";
}
}
}
echo " </table>\n";
if (isset ( $commit_button ) && $commit_button) {
echo " <input type=\"submit\" class=\"button\" name=\"commit\" value=\"" . _ ( 'Commit changes' ) . "\">\n";
echo " <input type=\"reset\" class=\"button\" name=\"reset\" value=\"" . _ ( 'Reset changes' ) . "\">\n";
}
echo " </form>\n";
if ($perm_templ_perm_edit == "1" || $perm_add_new == "1") {
echo " <ul>\n";
}
if ($perm_templ_perm_edit == "1") {
echo "<li><a href=\"list_perm_templ.php\">" . _ ( 'Edit permission template' ) . "</a>.</li>\n";
}
if ($perm_add_new == "1") {
echo "<li><a href=\"add_user.php\">" . _ ( 'Add user' ) . "</a>.</li>\n";
}
if ($perm_templ_perm_edit == "1" || $perm_add_new == "1") {
echo " </ul>\n";
}
include_once ("inc/footer.inc.php");