18 * You should have received a copy of the GNU General Public License |
18 * You should have received a copy of the GNU General Public License |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 */ |
20 */ |
21 |
21 |
22 require_once("inc/toolkit.inc.php"); |
22 require_once("inc/toolkit.inc.php"); |
|
23 include_once("inc/header.inc.php"); |
23 |
24 |
24 if($_POST["commit"]) |
25 $edit_id = "-1"; |
25 { |
26 if (isset($_GET['id']) && v_num($_GET['id'])) { |
26 if($_POST["username"] && $_POST["level"] && $_POST["fullname"]) |
27 $edit_id = $_GET['id']; |
27 { |
28 } |
28 if(!isset($_POST["active"])) |
29 |
29 { |
30 verify_permission(user_edit_own) ? $perm_edit_own = "1" : $perm_edit_own = "0" ; |
30 $active = 0; |
31 verify_permission(user_edit_others) ? $perm_edit_others = "1" : $perm_edit_others = "0" ; |
|
32 |
|
33 if ($edit_id == "-1") { |
|
34 error(ERR_INV_INPUT); |
|
35 } elseif (($edit_id == $_SESSION["userid"] && $perm_edit_own == "1") || ($edit_id != $_SESSION["userid"] && $perm_edit_others == "1" )) { |
|
36 |
|
37 if($_POST["commit"]) { |
|
38 |
|
39 $i_username = "-1"; |
|
40 $i_fullname = "-1"; |
|
41 $i_email = "-1"; |
|
42 $i_description = "-1"; |
|
43 $i_password = "-1"; |
|
44 $i_perm_templ = "0"; |
|
45 $i_active = "0"; |
|
46 |
|
47 if (isset($_POST['username'])) { |
|
48 $i_username = $_POST['username']; |
31 } |
49 } |
32 else |
50 |
33 { |
51 if (isset($_POST['fullname'])) { |
34 $active = 1; |
52 $i_fullname = $_POST['fullname']; |
35 } |
53 } |
36 if(edit_user($_POST["number"], $_POST["username"], $_POST["fullname"], $_POST["email"], $_POST["level"], $_POST["description"], $active, $_POST["password"])) |
54 |
37 { |
55 if (isset($_POST['email'])) { |
38 clean_page("users.php"); |
56 $i_email = $_POST['email']; |
39 } |
57 } |
40 else |
58 |
41 { |
59 if (isset($_POST['description'])) { |
42 error("Error editting user!"); |
60 $i_description = $_POST['description']; |
|
61 } |
|
62 |
|
63 if (isset($_POST['password'])) { |
|
64 $i_password = $_POST['password']; |
|
65 } |
|
66 |
|
67 if (isset($_POST['perm_templ']) && v_num($_POST['perm_templ'])) { |
|
68 $i_perm_templ = $_POST['perm_templ']; |
|
69 } |
|
70 |
|
71 if (isset($_POST['active']) && v_num($_POST['active'])) { |
|
72 $i_active = $_POST['active']; |
|
73 } |
|
74 |
|
75 if ( $i_username == "-1" || $i_fullname == "-1" || $i_email < "1" || $i_description == "-1" || $i_password == "-1" ) { |
|
76 error(ERR_INV_INPUT); |
|
77 } else { |
|
78 if($i_username != "" && $i_perm_templ > "0" && $i_fullname) { |
|
79 if(!isset($i_active)) { |
|
80 $active = 0; |
|
81 } else { |
|
82 $active = 1; |
|
83 } |
|
84 if(edit_user($edit_id, $i_username, $i_fullname, $i_email, $i_perm_templ, $i_description, $active, $i_password)) { |
|
85 success(SUC_USER_UPD); |
|
86 } |
|
87 } |
43 } |
88 } |
44 } |
89 } |
|
90 |
|
91 $users = get_user_detail_list($edit_id) ; |
|
92 |
|
93 foreach ($users as $user) { |
|
94 |
|
95 (($user['active']) == "1") ? $check = " CHECKED" : $check = "" ; |
|
96 |
|
97 echo " <h2>" . _('Edit user') . " \"" . $user['fullname'] . "\"</h2>\n"; |
|
98 echo " <form method=\"post\">\n"; |
|
99 echo " <input type=\"hidden\" name=\"number\" value=\"" . $edit_id . "\">\n"; |
|
100 echo " <table>\n"; |
|
101 echo " <tr>\n"; |
|
102 echo " <td class=\"n\">" . _('Username') . "</td>\n"; |
|
103 echo " <td class=\"n\"><input type=\"text\" class=\"input\" name=\"username\" value=\"" . $user['username'] . "\"></td>\n"; |
|
104 echo " </tr>\n"; |
|
105 echo " <tr>\n"; |
|
106 echo " <td class=\"n\">" . _('Fullname') . "</td>\n"; |
|
107 echo " <td class=\"n\"><input type=\"text\" class=\"input\" name=\"fullname\" value=\"" . $user['fullname'] . "\"></td>\n"; |
|
108 echo " </tr>\n"; |
|
109 echo " <tr>\n"; |
|
110 echo " <td class=\"n\">" . _('Password') . "</td>\n"; |
|
111 echo " <td class=\"n\"><input type=\"text\" class=\"input\" name=\"password\"></td>\n"; |
|
112 echo " </tr>\n"; |
|
113 echo " <tr>\n"; |
|
114 echo " <td class=\"n\">" . _('Email') . "</td>\n"; |
|
115 echo " <td class=\"n\"><input type=\"text\" class=\"input\" name=\"email\" value=\"" . $user['email'] . "\"></td>\n"; |
|
116 echo " </tr>\n"; |
|
117 echo " <tr>\n"; |
|
118 echo " <td class=\"n\">" . _('Permission template') . "</td>\n"; |
|
119 echo " <td class=\"n\">\n"; |
|
120 echo " <select name=\"perm_templ\">\n"; |
|
121 foreach (list_permission_templates() as $template) { |
|
122 ($template['id'] == $user['tpl_id']) ? $select = " SELECTED" : $select = "" ; |
|
123 echo " <option value=\"" . $template['id'] . "\"" . $select . ">" . $template['name'] . "</option>\n"; |
|
124 } |
|
125 echo " </select>\n"; |
|
126 echo " </td>\n"; |
|
127 echo " </tr>\n"; |
|
128 echo " <tr>\n"; |
|
129 echo " <td class=\"n\">" . _('Description') . "</td>\n"; |
|
130 echo " <td class=\"n\"><textarea rows=\"4\" cols=\"30\" class=\"inputarea\" name=\"description\">" . $user['descr'] . "</textarea></td>\n"; |
|
131 echo " </tr>\n"; |
|
132 echo " <tr>\n"; |
|
133 echo " <td class=\"n\">" . _('Enabled') . "</td>\n"; |
|
134 echo " <td class=\"n\"><input type=\"checkbox\" class=\"input\" name=\"active\" value=\"1\"" . $check . "></td>\n"; |
|
135 echo " </tr>\n"; |
|
136 echo " <tr>\n"; |
|
137 echo " <td class=\"n\"> </td>\n"; |
|
138 echo " <td class=\"n\"><input type=\"submit\" class=\"button\" name=\"commit\" value=\"" . _('Commit changes') . "\"></td>\n"; |
|
139 echo " </table>\n"; |
|
140 echo " </form>\n"; |
|
141 |
|
142 echo " <p>\n"; |
|
143 printf(" This user has been assigned the \"%s\" permission template.", $user['tpl_name']); |
|
144 if ($user['tpl_descr'] != "") { |
|
145 echo " The description for this template is: \"" . $user['tpl_descr'] . "\"."; |
|
146 } |
|
147 echo " Based on this template, this user has the following permissions:"; |
|
148 echo " </p>\n"; |
|
149 echo " <ul>\n"; |
|
150 foreach (get_permissions_by_template_id($user['tpl_id']) as $item) { |
|
151 echo " <li>" . $item['descr'] . " (" . $item['name'] . ")</li>\n"; |
|
152 } |
|
153 echo " </ul>\n"; |
|
154 } |
|
155 } else { |
|
156 error(ERR_PERM_EDIT_USER); |
45 } |
157 } |
46 |
|
47 include_once("inc/header.inc.php"); |
|
48 |
|
49 if (!level(10)) |
|
50 { |
|
51 error("You do not have the required access level."); |
|
52 } |
|
53 ?> |
|
54 <h2><?php echo _('Edit user'); ?> "<?php echo get_fullname_from_userid($_GET["id"]) ?>"</h2> |
|
55 <?php |
|
56 $r = array(); |
|
57 $r = get_user_info($_GET["id"]); |
|
58 ?> |
|
59 <form method="post"> |
|
60 <input type="HIDDEN" name="number" value="<?php echo $_GET["id"] ?>"> |
|
61 <table> |
|
62 <tr> |
|
63 <td class="n"><?php echo _('User name'); ?>:</td> |
|
64 <td class="n"><input type="text" class="input" name="username" value="<?php echo $r["username"]?>"></td> |
|
65 </tr> |
|
66 <tr> |
|
67 <td class="n"><?php echo _('Full name'); ?>:</td> |
|
68 <td class="n"><input type="text" class="input" name="fullname" value="<?php echo $r["fullname"]?>"></td> |
|
69 </tr> |
|
70 <tr> |
|
71 <td class="n"><?php echo _('Password'); ?>:</td> |
|
72 <td class="n"><input type="password" class="input" name="password" value=""></td> |
|
73 </tr> |
|
74 <tr> |
|
75 <td class="n"><?php echo _('E-mail'); ?>:</td> |
|
76 <td class="n"><input type="text" class="input" name="email" value="<?php echo $r["email"]?>"></td> |
|
77 </tr> |
|
78 <tr> |
|
79 <td class="n"><?php echo _('User level'); ?>:</td> |
|
80 <td class="n"> |
|
81 <select name="level"> |
|
82 <option value="1" <?php if($r["level"] == 1) { echo "selectED"; } ?>>1 (<?php echo _('Normal user'); ?>)</option> |
|
83 <option value="5" <?php if($r["level"] == 5) { echo "selectED"; } ?>>5 (<?php echo _('Administrator'); ?>)</option> |
|
84 <option value="10" <?php if($r["level"] == 10) { echo "selectED"; } ?>>10 (<?php echo _('Administrator w/ user admin rights'); ?>)</option> |
|
85 </select> |
|
86 </td> |
|
87 </tr> |
|
88 <tr> |
|
89 <td class="n"><?php echo _('Description'); ?>:</td> |
|
90 <td class="n"> |
|
91 <textarea rows="6" cols="30" class="inputarea" name="description"><?php echo $r["description"]?></textarea> |
|
92 </td> |
|
93 </tr> |
|
94 <tr> |
|
95 <td class="n"><?php echo _('Active'); ?>:</td> |
|
96 <td class="n"><input type="checkbox" name="active" value="1" <?php if($r["active"]) { ?>CHECKED<?php } ?>></td> |
|
97 </tr> |
|
98 <tr> |
|
99 <td class="n"> </td> |
|
100 <td class="n"><input type="submit" class="button" name="commit" value="<?php echo _('Commit changes'); ?>"></td> |
|
101 </tr> |
|
102 </table> |
|
103 </form> |
|
104 <?php |
|
105 |
158 |
106 include_once("inc/footer.inc.php"); |
159 include_once("inc/footer.inc.php"); |
107 |
160 |
108 ?> |
161 ?> |