@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | -if(!$modx->hasPermission('save_web_user')) { |
|
5 | +if (!$modx->hasPermission('save_web_user')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
@@ -11,14 +11,14 @@ discard block |
||
11 | 11 | $tbl_web_groups = $modx->getDatabase()->getFullTableName('web_groups'); |
12 | 12 | |
13 | 13 | $input = $_POST; |
14 | -foreach($input as $k => $v) { |
|
15 | - if($k !== 'comment' && $k !=='user_groups') { |
|
14 | +foreach ($input as $k => $v) { |
|
15 | + if ($k !== 'comment' && $k !== 'user_groups') { |
|
16 | 16 | $v = $modx->getPhpCompat()->htmlspecialchars($v, ENT_NOQUOTES); |
17 | 17 | } |
18 | 18 | $input[$k] = $v; |
19 | 19 | } |
20 | 20 | |
21 | -$id = (int)$input['id']; |
|
21 | +$id = (int) $input['id']; |
|
22 | 22 | $oldusername = $input['oldusername']; |
23 | 23 | $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User"; |
24 | 24 | $esc_newusername = $modx->getDatabase()->escape($newusername); |
@@ -50,21 +50,21 @@ discard block |
||
50 | 50 | $user_groups = $input['user_groups']; |
51 | 51 | |
52 | 52 | // verify password |
53 | -if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
53 | +if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
54 | 54 | webAlertAndQuit("Password typed is mismatched", 88); |
55 | 55 | } |
56 | 56 | |
57 | 57 | // verify email |
58 | -if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
58 | +if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
59 | 59 | webAlertAndQuit("E-mail address doesn't seem to be valid!", 88); |
60 | 60 | } |
61 | 61 | |
62 | -switch($input['mode']) { |
|
62 | +switch ($input['mode']) { |
|
63 | 63 | case '87' : // new user |
64 | 64 | // check if this user name already exist |
65 | 65 | $rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
66 | 66 | $limit = $modx->getDatabase()->getValue($rs); |
67 | - if($limit > 0) { |
|
67 | + if ($limit > 0) { |
|
68 | 68 | webAlertAndQuit("User name is already in use!", 88); |
69 | 69 | } |
70 | 70 | |
@@ -72,21 +72,21 @@ discard block |
||
72 | 72 | if ($modx->config['allow_multiple_emails'] != 1) { |
73 | 73 | $rs = $modx->getDatabase()->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
74 | 74 | $limit = $modx->getDatabase()->getValue($rs); |
75 | - if($limit > 0) { |
|
75 | + if ($limit > 0) { |
|
76 | 76 | webAlertAndQuit("Email is already in use!", 88); |
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | 80 | // generate a new password for this user |
81 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
82 | - if(strlen($specifiedpassword) < 6) { |
|
81 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
82 | + if (strlen($specifiedpassword) < 6) { |
|
83 | 83 | webAlertAndQuit("Password is too short!", 88); |
84 | 84 | } else { |
85 | 85 | $newpassword = $specifiedpassword; |
86 | 86 | } |
87 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
87 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
88 | 88 | webAlertAndQuit("You didn't specify a password for this user!", 88); |
89 | - } elseif($passwordgenmethod == 'g') { |
|
89 | + } elseif ($passwordgenmethod == 'g') { |
|
90 | 90 | $newpassword = generate_password(8); |
91 | 91 | } else { |
92 | 92 | webAlertAndQuit("No password generation method specified!", 88); |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | /*******************************************************************************/ |
117 | 117 | // put the user in the user_groups he/ she should be in |
118 | 118 | // first, check that up_perms are switched on! |
119 | - if($use_udperms == 1) { |
|
120 | - if(!empty($user_groups)) { |
|
121 | - for($i = 0; $i < count($user_groups); $i++) { |
|
119 | + if ($use_udperms == 1) { |
|
120 | + if (!empty($user_groups)) { |
|
121 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
122 | 122 | $f = array(); |
123 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
123 | + $f['webgroup'] = (int) $user_groups[$i]; |
|
124 | 124 | $f['webuser'] = $internalKey; |
125 | 125 | $modx->getDatabase()->insert($f, $tbl_web_groups); |
126 | 126 | } |
@@ -144,20 +144,20 @@ discard block |
||
144 | 144 | "id" => $internalKey |
145 | 145 | )); |
146 | 146 | |
147 | - if($passwordnotifymethod == 'e') { |
|
147 | + if ($passwordnotifymethod == 'e') { |
|
148 | 148 | sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url); |
149 | - if($input['stay'] != '') { |
|
149 | + if ($input['stay'] != '') { |
|
150 | 150 | $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
151 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
151 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
152 | 152 | header($header); |
153 | 153 | } else { |
154 | 154 | $header = "Location: index.php?a=99&r=2"; |
155 | 155 | header($header); |
156 | 156 | } |
157 | 157 | } else { |
158 | - if($input['stay'] != '') { |
|
158 | + if ($input['stay'] != '') { |
|
159 | 159 | $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
160 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
160 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
161 | 161 | } else { |
162 | 162 | $stayUrl = "index.php?a=99&r=2"; |
163 | 163 | } |
@@ -190,29 +190,29 @@ discard block |
||
190 | 190 | break; |
191 | 191 | case '88' : // edit user |
192 | 192 | // generate a new password for this user |
193 | - if($genpassword == 1) { |
|
194 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
195 | - if(strlen($specifiedpassword) < 6) { |
|
193 | + if ($genpassword == 1) { |
|
194 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
195 | + if (strlen($specifiedpassword) < 6) { |
|
196 | 196 | webAlertAndQuit("Password is too short!", 88); |
197 | 197 | } else { |
198 | 198 | $newpassword = $specifiedpassword; |
199 | 199 | } |
200 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
200 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
201 | 201 | webAlertAndQuit("You didn't specify a password for this user!", 88); |
202 | - } elseif($passwordgenmethod == 'g') { |
|
202 | + } elseif ($passwordgenmethod == 'g') { |
|
203 | 203 | $newpassword = generate_password(8); |
204 | 204 | } else { |
205 | 205 | webAlertAndQuit("No password generation method specified!", 88); |
206 | 206 | } |
207 | 207 | } |
208 | - if($passwordnotifymethod == 'e') { |
|
208 | + if ($passwordnotifymethod == 'e') { |
|
209 | 209 | sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url); |
210 | 210 | } |
211 | 211 | |
212 | 212 | // check if the username already exist |
213 | 213 | $rs = $modx->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
214 | 214 | $limit = $modx->getDatabase()->getValue($rs); |
215 | - if($limit > 0) { |
|
215 | + if ($limit > 0) { |
|
216 | 216 | webAlertAndQuit("User name is already in use!", 88); |
217 | 217 | } |
218 | 218 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | if ($modx->config['allow_multiple_emails'] != 1) { |
221 | 221 | $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
222 | 222 | $limit = $modx->getDatabase()->getValue($rs); |
223 | - if($limit > 0) { |
|
223 | + if ($limit > 0) { |
|
224 | 224 | webAlertAndQuit("Email is already in use!", 88); |
225 | 225 | } |
226 | 226 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | // update user name and password |
235 | 235 | $field = array(); |
236 | 236 | $field['username'] = $esc_newusername; |
237 | - if($genpassword == 1) { |
|
237 | + if ($genpassword == 1) { |
|
238 | 238 | $field['password'] = md5($newpassword); |
239 | 239 | } |
240 | 240 | $modx->getDatabase()->update($field, $tbl_web_users, "id='{$id}'"); |
@@ -251,13 +251,13 @@ discard block |
||
251 | 251 | /*******************************************************************************/ |
252 | 252 | // put the user in the user_groups he/ she should be in |
253 | 253 | // first, check that up_perms are switched on! |
254 | - if($use_udperms == 1) { |
|
254 | + if ($use_udperms == 1) { |
|
255 | 255 | // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
256 | 256 | $modx->getDatabase()->delete($tbl_web_groups, "webuser='{$id}'"); |
257 | - if(!empty($user_groups)) { |
|
258 | - for($i = 0; $i < count($user_groups); $i++) { |
|
257 | + if (!empty($user_groups)) { |
|
258 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
259 | 259 | $field = array(); |
260 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
260 | + $field['webgroup'] = (int) $user_groups[$i]; |
|
261 | 261 | $field['webuser'] = $id; |
262 | 262 | $modx->getDatabase()->insert($field, $tbl_web_groups); |
263 | 263 | } |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | )); |
280 | 280 | |
281 | 281 | // invoke OnWebChangePassword event |
282 | - if($genpassword == 1) { |
|
282 | + if ($genpassword == 1) { |
|
283 | 283 | $modx->invokeEvent("OnWebChangePassword", array( |
284 | 284 | "userid" => $id, |
285 | 285 | "username" => $newusername, |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | "id" => $id |
294 | 294 | )); |
295 | 295 | |
296 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
297 | - if($input['stay'] != '') { |
|
296 | + if ($genpassword == 1 && $passwordnotifymethod == 's') { |
|
297 | + if ($input['stay'] != '') { |
|
298 | 298 | $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
299 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
299 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
300 | 300 | } else { |
301 | 301 | $stayUrl = "index.php?a=99&r=2"; |
302 | 302 | } |
@@ -324,9 +324,9 @@ discard block |
||
324 | 324 | |
325 | 325 | include_once "footer.inc.php"; |
326 | 326 | } else { |
327 | - if($input['stay'] != '') { |
|
327 | + if ($input['stay'] != '') { |
|
328 | 328 | $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
329 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
329 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
330 | 330 | header($header); |
331 | 331 | } else { |
332 | 332 | $header = "Location: index.php?a=99&r=2"; |