@@ -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_user')) { |
|
5 | +if (!$modx->hasPermission('save_user')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | $input = $_POST; |
16 | 16 | |
17 | -$id = (int)$input['id']; |
|
17 | +$id = (int) $input['id']; |
|
18 | 18 | $oldusername = $input['oldusername']; |
19 | 19 | $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User"; |
20 | 20 | $fullname = $input['fullname']; |
@@ -44,56 +44,56 @@ discard block |
||
44 | 44 | $user_groups = $input['user_groups']; |
45 | 45 | |
46 | 46 | // verify password |
47 | -if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
47 | +if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
48 | 48 | webAlertAndQuit("Password typed is mismatched"); |
49 | 49 | } |
50 | 50 | |
51 | 51 | // verify email |
52 | -if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
52 | +if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
53 | 53 | webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
54 | 54 | } |
55 | 55 | |
56 | 56 | // verify admin security |
57 | -if($_SESSION['mgrRole'] != 1) { |
|
57 | +if ($_SESSION['mgrRole'] != 1) { |
|
58 | 58 | // Check to see if user tried to spoof a "1" (admin) role |
59 | - if(!$modx->hasPermission('save_role')) { |
|
59 | + if (!$modx->hasPermission('save_role')) { |
|
60 | 60 | webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!"); |
61 | 61 | } |
62 | 62 | // Verify that the user being edited wasn't an admin and the user ID got spoofed |
63 | 63 | $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1"); |
64 | 64 | $limit = $modx->db->getValue($rs); |
65 | - if($limit > 0) { |
|
65 | + if ($limit > 0) { |
|
66 | 66 | webAlertAndQuit("You cannot alter an administrative user."); |
67 | 67 | } |
68 | 68 | |
69 | 69 | } |
70 | 70 | |
71 | -switch($input['mode']) { |
|
71 | +switch ($input['mode']) { |
|
72 | 72 | case '11' : // new user |
73 | 73 | // check if this user name already exist |
74 | 74 | $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername))); |
75 | 75 | $limit = $modx->db->getValue($rs); |
76 | - if($limit > 0) { |
|
76 | + if ($limit > 0) { |
|
77 | 77 | webAlertAndQuit("User name is already in use!"); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // check if the email address already exist |
81 | 81 | $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id)); |
82 | 82 | $limit = $modx->db->getValue($rs); |
83 | - if($limit > 0) { |
|
83 | + if ($limit > 0) { |
|
84 | 84 | webAlertAndQuit("Email is already in use!"); |
85 | 85 | } |
86 | 86 | |
87 | 87 | // generate a new password for this user |
88 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
89 | - if(strlen($specifiedpassword) < 6) { |
|
88 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
89 | + if (strlen($specifiedpassword) < 6) { |
|
90 | 90 | webAlertAndQuit("Password is too short!"); |
91 | 91 | } else { |
92 | 92 | $newpassword = $specifiedpassword; |
93 | 93 | } |
94 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
94 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
95 | 95 | webAlertAndQuit("You didn't specify a password for this user!"); |
96 | - } elseif($passwordgenmethod == 'g') { |
|
96 | + } elseif ($passwordgenmethod == 'g') { |
|
97 | 97 | $newpassword = generate_password(8); |
98 | 98 | } else { |
99 | 99 | webAlertAndQuit("No password generation method specified!"); |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | /*******************************************************************************/ |
142 | 142 | // put the user in the user_groups he/ she should be in |
143 | 143 | // first, check that up_perms are switched on! |
144 | - if($use_udperms == 1) { |
|
145 | - if(!empty($user_groups)) { |
|
146 | - for($i = 0; $i < count($user_groups); $i++) { |
|
144 | + if ($use_udperms == 1) { |
|
145 | + if (!empty($user_groups)) { |
|
146 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
147 | 147 | $f = array(); |
148 | - $f['user_group'] = (int)$user_groups[$i]; |
|
148 | + $f['user_group'] = (int) $user_groups[$i]; |
|
149 | 149 | $f['member'] = $internalKey; |
150 | 150 | $modx->db->insert($f, $tbl_member_groups); |
151 | 151 | } |
@@ -153,20 +153,20 @@ discard block |
||
153 | 153 | } |
154 | 154 | // end of user_groups stuff! |
155 | 155 | |
156 | - if($passwordnotifymethod == 'e') { |
|
156 | + if ($passwordnotifymethod == 'e') { |
|
157 | 157 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
158 | - if($input['stay'] != '') { |
|
158 | + if ($input['stay'] != '') { |
|
159 | 159 | $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
160 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
160 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
161 | 161 | header($header); |
162 | 162 | } else { |
163 | 163 | $header = "Location: index.php?a=75&r=2"; |
164 | 164 | header($header); |
165 | 165 | } |
166 | 166 | } else { |
167 | - if($input['stay'] != '') { |
|
167 | + if ($input['stay'] != '') { |
|
168 | 168 | $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
169 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
169 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
170 | 170 | } else { |
171 | 171 | $stayUrl = "index.php?a=75&r=2"; |
172 | 172 | } |
@@ -199,36 +199,36 @@ discard block |
||
199 | 199 | break; |
200 | 200 | case '12' : // edit user |
201 | 201 | // generate a new password for this user |
202 | - if($genpassword == 1) { |
|
203 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
204 | - if(strlen($specifiedpassword) < 6) { |
|
202 | + if ($genpassword == 1) { |
|
203 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
204 | + if (strlen($specifiedpassword) < 6) { |
|
205 | 205 | webAlertAndQuit("Password is too short!"); |
206 | 206 | } else { |
207 | 207 | $newpassword = $specifiedpassword; |
208 | 208 | } |
209 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
209 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
210 | 210 | webAlertAndQuit("You didn't specify a password for this user!"); |
211 | - } elseif($passwordgenmethod == 'g') { |
|
211 | + } elseif ($passwordgenmethod == 'g') { |
|
212 | 212 | $newpassword = generate_password(8); |
213 | 213 | } else { |
214 | 214 | webAlertAndQuit("No password generation method specified!"); |
215 | 215 | } |
216 | 216 | } |
217 | - if($passwordnotifymethod == 'e') { |
|
217 | + if ($passwordnotifymethod == 'e') { |
|
218 | 218 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
219 | 219 | } |
220 | 220 | |
221 | 221 | // check if the username already exist |
222 | 222 | $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id)); |
223 | 223 | $limit = $modx->db->getValue($rs); |
224 | - if($limit > 0) { |
|
224 | + if ($limit > 0) { |
|
225 | 225 | webAlertAndQuit("User name is already in use!"); |
226 | 226 | } |
227 | 227 | |
228 | 228 | // check if the email address already exists |
229 | 229 | $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id)); |
230 | 230 | $limit = $modx->db->getValue($rs); |
231 | - if($limit > 0) { |
|
231 | + if ($limit > 0) { |
|
232 | 232 | webAlertAndQuit("Email is already in use!"); |
233 | 233 | } |
234 | 234 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | // update user name and password |
242 | 242 | $field = array(); |
243 | 243 | $field['username'] = $modx->db->escape($newusername); |
244 | - if($genpassword == 1) { |
|
244 | + if ($genpassword == 1) { |
|
245 | 245 | $field['password'] = $modx->phpass->HashPassword($newpassword); |
246 | 246 | } |
247 | 247 | $modx->db->update($field, $tbl_manager_users, "id='{$id}'"); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | )); |
270 | 270 | |
271 | 271 | // invoke OnManagerChangePassword event |
272 | - if($genpassword == 1) { |
|
272 | + if ($genpassword == 1) { |
|
273 | 273 | $modx->invokeEvent("OnManagerChangePassword", array( |
274 | 274 | "userid" => $id, |
275 | 275 | "username" => $newusername, |
@@ -286,13 +286,13 @@ discard block |
||
286 | 286 | /*******************************************************************************/ |
287 | 287 | // put the user in the user_groups he/ she should be in |
288 | 288 | // first, check that up_perms are switched on! |
289 | - if($use_udperms == 1) { |
|
289 | + if ($use_udperms == 1) { |
|
290 | 290 | // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
291 | 291 | $modx->db->delete($tbl_member_groups, "member='{$id}'"); |
292 | - if(!empty($user_groups)) { |
|
293 | - for($i = 0; $i < count($user_groups); $i++) { |
|
292 | + if (!empty($user_groups)) { |
|
293 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
294 | 294 | $field = array(); |
295 | - $field['user_group'] = (int)$user_groups[$i]; |
|
295 | + $field['user_group'] = (int) $user_groups[$i]; |
|
296 | 296 | $field['member'] = $id; |
297 | 297 | $modx->db->insert($field, $tbl_member_groups); |
298 | 298 | } |
@@ -300,13 +300,13 @@ discard block |
||
300 | 300 | } |
301 | 301 | // end of user_groups stuff! |
302 | 302 | /*******************************************************************************/ |
303 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
303 | + if ($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
304 | 304 | $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
305 | 305 | } |
306 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
307 | - if($input['stay'] != '') { |
|
306 | + if ($genpassword == 1 && $passwordnotifymethod == 's') { |
|
307 | + if ($input['stay'] != '') { |
|
308 | 308 | $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
309 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
309 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
310 | 310 | } else { |
311 | 311 | $stayUrl = "index.php?a=75&r=2"; |
312 | 312 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | <div class="sectionHeader"><?php echo $_lang['user_title']; ?></div> |
327 | 327 | <div class="sectionBody"> |
328 | 328 | <div id="disp"> |
329 | - <p><?php echo sprintf($_lang["password_msg"], $modx->htmlspecialchars($newusername), $modx->htmlspecialchars($newpassword)) . (($id == $modx->getLoginUserID()) ? ' ' . $_lang['user_changeddata'] : ''); ?></p> |
|
329 | + <p><?php echo sprintf($_lang["password_msg"], $modx->htmlspecialchars($newusername), $modx->htmlspecialchars($newpassword)).(($id == $modx->getLoginUserID()) ? ' '.$_lang['user_changeddata'] : ''); ?></p> |
|
330 | 330 | </div> |
331 | 331 | </div> |
332 | 332 | </div> |
@@ -334,9 +334,9 @@ discard block |
||
334 | 334 | |
335 | 335 | include_once "footer.inc.php"; |
336 | 336 | } else { |
337 | - if($input['stay'] != '') { |
|
337 | + if ($input['stay'] != '') { |
|
338 | 338 | $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
339 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
339 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
340 | 340 | header($header); |
341 | 341 | } else { |
342 | 342 | $header = "Location: index.php?a=75&r=2"; |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @param string $pwd |
357 | 357 | * @param string $ufn |
358 | 358 | */ |
359 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
359 | +function sendMailMessage($email, $uid, $pwd, $ufn){ |
|
360 | 360 | $modx = evolutionCMS(); global $_lang, $signupemail_message; |
361 | 361 | global $emailsubject, $emailsender; |
362 | 362 | global $site_name; |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | $param['to'] = $email; |
379 | 379 | $param['type'] = 'text'; |
380 | 380 | $rs = $modx->sendmail($param); |
381 | - if(!$rs) { |
|
381 | + if (!$rs) { |
|
382 | 382 | $modx->manager->saveFormValues(); |
383 | 383 | $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
384 | 384 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * |
390 | 390 | * @param int $id |
391 | 391 | */ |
392 | -function saveUserSettings($id) { |
|
392 | +function saveUserSettings($id){ |
|
393 | 393 | $modx = evolutionCMS(); |
394 | 394 | $tbl_user_settings = $modx->getFullTableName('user_settings'); |
395 | 395 | |
@@ -441,27 +441,27 @@ discard block |
||
441 | 441 | |
442 | 442 | // get user setting field names |
443 | 443 | $settings = array(); |
444 | - foreach($_POST as $n => $v) { |
|
445 | - if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
444 | + foreach ($_POST as $n => $v) { |
|
445 | + if (in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
446 | 446 | continue; |
447 | 447 | } // ignore blacklist and empties |
448 | 448 | $settings[$n] = $v; // this value should be saved |
449 | 449 | } |
450 | 450 | |
451 | - foreach($defaults as $k) { |
|
452 | - if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') { |
|
451 | + foreach ($defaults as $k) { |
|
452 | + if (isset($settings['default_'.$k]) && $settings['default_'.$k] == '1') { |
|
453 | 453 | unset($settings[$k]); |
454 | 454 | } |
455 | - unset($settings['default_' . $k]); |
|
455 | + unset($settings['default_'.$k]); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | $modx->db->delete($tbl_user_settings, "user='{$id}'"); |
459 | 459 | |
460 | - foreach($settings as $n => $vl) { |
|
461 | - if(is_array($vl)) { |
|
460 | + foreach ($settings as $n => $vl) { |
|
461 | + if (is_array($vl)) { |
|
462 | 462 | $vl = implode(",", $vl); |
463 | 463 | } |
464 | - if($vl != '') { |
|
464 | + if ($vl != '') { |
|
465 | 465 | $f = array(); |
466 | 466 | $f['user'] = $id; |
467 | 467 | $f['setting_name'] = $n; |
@@ -477,11 +477,11 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @param $msg |
479 | 479 | */ |
480 | -function webAlertAndQuit($msg) { |
|
480 | +function webAlertAndQuit($msg){ |
|
481 | 481 | global $id, $modx; |
482 | 482 | $mode = $_POST['mode']; |
483 | 483 | $modx->manager->saveFormValues($mode); |
484 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : '')); |
|
484 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '12' ? "&id={$id}" : '')); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -490,12 +490,12 @@ discard block |
||
490 | 490 | * @param int $length |
491 | 491 | * @return string |
492 | 492 | */ |
493 | -function generate_password($length = 10) { |
|
493 | +function generate_password($length = 10){ |
|
494 | 494 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
495 | 495 | $ps_len = strlen($allowable_characters); |
496 | 496 | mt_srand((double) microtime() * 1000000); |
497 | 497 | $pass = ""; |
498 | - for($i = 0; $i < $length; $i++) { |
|
498 | + for ($i = 0; $i < $length; $i++) { |
|
499 | 499 | $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
500 | 500 | } |
501 | 501 | return $pass; |
@@ -1,12 +1,12 @@ 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 | 5 | if (!$modx->hasPermission('save_plugin')) { |
6 | 6 | $modx->webAlertAndQuit($_lang['error_no_privileges']); |
7 | 7 | } |
8 | 8 | |
9 | -$id = (int)$_POST['id']; |
|
9 | +$id = (int) $_POST['id']; |
|
10 | 10 | $name = $modx->db->escape(trim($_POST['name'])); |
11 | 11 | $description = $modx->db->escape($_POST['description']); |
12 | 12 | $locked = $_POST['locked'] == 'on' ? '1' : '0'; |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | |
21 | 21 | //Kyle Jaebker - added category support |
22 | 22 | if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { |
23 | - $categoryid = (int)$_POST['categoryid']; |
|
23 | + $categoryid = (int) $_POST['categoryid']; |
|
24 | 24 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
25 | 25 | $categoryid = 0; |
26 | 26 | } else { |
27 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
27 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
28 | 28 | $categoryid = getCategory($_POST['newcategory']); |
29 | 29 | } |
30 | 30 | |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | $moduleguid = isset($parsed['guid']) ? $parsed['guid'] : $moduleguid; |
41 | 41 | |
42 | 42 | $description = isset($parsed['description']) ? $parsed['description'] : $description; |
43 | - $version = isset($parsed['version']) ? '<b>' . $parsed['version'] . '</b> ' : ''; |
|
43 | + $version = isset($parsed['version']) ? '<b>'.$parsed['version'].'</b> ' : ''; |
|
44 | 44 | if ($version) { |
45 | - $description = $version . trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
45 | + $description = $version.trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
46 | 46 | } |
47 | 47 | if (isset($parsed['modx_category'])) { |
48 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
48 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
49 | 49 | $categoryid = getCategory($parsed['modx_category']); |
50 | 50 | } |
51 | 51 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | // finished emptying cache - redirect |
104 | 104 | if ($_POST['stay'] != '') { |
105 | 105 | $a = ($_POST['stay'] == '2') ? "102&id=$newid" : '101'; |
106 | - $header = 'Location: index.php?a=' . $a . '&r=2&stay=' . $_POST['stay']; |
|
106 | + $header = 'Location: index.php?a='.$a.'&r=2&stay='.$_POST['stay']; |
|
107 | 107 | header($header); |
108 | 108 | } else { |
109 | 109 | $header = 'Location: index.php?a=76&r=2'; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | // finished emptying cache - redirect |
159 | 159 | if ($_POST['stay'] != '') { |
160 | 160 | $a = ($_POST['stay'] == '2') ? "102&id=$id" : '101'; |
161 | - $header = 'Location: index.php?a=' . $a . '&r=2&stay=' . $_POST['stay']; |
|
161 | + $header = 'Location: index.php?a='.$a.'&r=2&stay='.$_POST['stay']; |
|
162 | 162 | header($header); |
163 | 163 | } else { |
164 | 164 | $modx->unlockElement(5, $id); |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | // save selected system events |
178 | 178 | $formEventList = array(); |
179 | 179 | foreach ($sysevents as $evtId) { |
180 | - if(!preg_match('@^[1-9][0-9]*$@',$evtId)) $evtId = getEventIdByName($evtId); |
|
180 | + if (!preg_match('@^[1-9][0-9]*$@', $evtId)) $evtId = getEventIdByName($evtId); |
|
181 | 181 | if ($mode == '101') { |
182 | 182 | $rs = $modx->db->select('max(priority) as priority', '[+prefix+]site_plugin_events', "evtid='{$evtId}'"); |
183 | 183 | } else { |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | $rs = $modx->db->select('*', '[+prefix+]site_plugin_events', sprintf("pluginid='%s'", $id)); |
203 | 203 | $dbEventList = array(); |
204 | 204 | $del = array(); |
205 | - while($row = $modx->db->getRow($rs)) { |
|
206 | - if(!in_array($row['evtid'], $evtids)) $del[] = $row['evtid']; |
|
205 | + while ($row = $modx->db->getRow($rs)) { |
|
206 | + if (!in_array($row['evtid'], $evtids)) $del[] = $row['evtid']; |
|
207 | 207 | } |
208 | 208 | |
209 | - if(empty($del)) return; |
|
209 | + if (empty($del)) return; |
|
210 | 210 | |
211 | - foreach($del as $delid) { |
|
211 | + foreach ($del as $delid) { |
|
212 | 212 | $modx->db->delete('[+prefix+]site_plugin_events', sprintf("evtid='%s' AND pluginid='%s'", $delid, $id)); |
213 | 213 | } |
214 | 214 | } |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | function getEventIdByName($name) |
221 | 221 | { |
222 | 222 | $modx = evolutionCMS(); |
223 | - static $eventIds=array(); |
|
223 | + static $eventIds = array(); |
|
224 | 224 | |
225 | - if(isset($eventIds[$name])) return $eventIds[$name]; |
|
225 | + if (isset($eventIds[$name])) return $eventIds[$name]; |
|
226 | 226 | |
227 | 227 | $rs = $modx->db->select('id, name', '[+prefix+]system_eventnames'); |
228 | 228 | while ($row = $modx->db->getRow($rs)) { |
@@ -1,20 +1,20 @@ 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('edit_document')) { |
|
5 | +if (!$modx->hasPermission('edit_document')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$newParentID = isset($_REQUEST['new_parent']) ? (int)$_REQUEST['new_parent'] : 0; |
|
10 | -$documentID = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
|
9 | +$newParentID = isset($_REQUEST['new_parent']) ? (int) $_REQUEST['new_parent'] : 0; |
|
10 | +$documentID = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
11 | 11 | |
12 | 12 | // ok, two things to check. |
13 | 13 | // first, document cannot be moved to itself |
14 | 14 | // second, new parent must be a folder. If not, set it to folder. |
15 | -if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
16 | -if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
17 | -if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
15 | +if ($documentID == $newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
16 | +if ($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
17 | +if ($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
18 | 18 | |
19 | 19 | $parents = $modx->getParentIds($newParentID); |
20 | 20 | if (in_array($documentID, $parents)) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | if ($use_udperms == 1) { |
28 | 28 | if ($oldparent != $newParentID) { |
29 | - include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
29 | + include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php"; |
|
30 | 30 | $udperms = new udperms(); |
31 | 31 | $udperms->user = $modx->getLoginUserID(); |
32 | 32 | $udperms->document = $newParentID; |
@@ -42,28 +42,28 @@ discard block |
||
42 | 42 | * @param int $currDocID |
43 | 43 | * @return array |
44 | 44 | */ |
45 | -function allChildren($currDocID) { |
|
45 | +function allChildren($currDocID){ |
|
46 | 46 | $modx = evolutionCMS(); |
47 | - $children= array(); |
|
47 | + $children = array(); |
|
48 | 48 | $currDocID = $modx->db->escape($currDocID); |
49 | 49 | $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'"); |
50 | - while ($child= $modx->db->getRow($rs)) { |
|
51 | - $children[]= $child['id']; |
|
52 | - $children= array_merge($children, allChildren($child['id'])); |
|
50 | + while ($child = $modx->db->getRow($rs)) { |
|
51 | + $children[] = $child['id']; |
|
52 | + $children = array_merge($children, allChildren($child['id'])); |
|
53 | 53 | } |
54 | 54 | return $children; |
55 | 55 | } |
56 | 56 | |
57 | -$evtOut = $modx->invokeEvent("onBeforeMoveDocument", array ( |
|
57 | +$evtOut = $modx->invokeEvent("onBeforeMoveDocument", array( |
|
58 | 58 | "id_document" => $documentID, |
59 | 59 | "old_parent" => $oldparent, |
60 | 60 | "new_parent" => $newParentID |
61 | 61 | )); |
62 | -if (is_array($evtOut) && count($evtOut) > 0){ |
|
62 | +if (is_array($evtOut) && count($evtOut) > 0) { |
|
63 | 63 | $newParent = array_pop($evtOut); |
64 | - if($newParent == $oldparent) { |
|
64 | + if ($newParent == $oldparent) { |
|
65 | 65 | $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
66 | - }else{ |
|
66 | + } else { |
|
67 | 67 | $newParentID = $newParent; |
68 | 68 | } |
69 | 69 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'"); |
85 | 85 | $limit = $modx->db->getValue($rs); |
86 | 86 | |
87 | - if(!$limit>0) { |
|
87 | + if (!$limit > 0) { |
|
88 | 88 | $modx->db->update(array( |
89 | 89 | 'isfolder' => 0, |
90 | 90 | ), $modx->getFullTableName('site_content'), "id='{$oldparent}'"); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'")); |
94 | 94 | $_SESSION['itemname'] = $pagetitle; |
95 | 95 | |
96 | - $modx->invokeEvent("onAfterMoveDocument", array ( |
|
96 | + $modx->invokeEvent("onAfterMoveDocument", array( |
|
97 | 97 | "id_document" => $documentID, |
98 | 98 | "old_parent" => $oldparent, |
99 | 99 | "new_parent" => $newParentID |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | // empty cache & sync site |
103 | 103 | $modx->clearCache('full'); |
104 | 104 | |
105 | - $header="Location: index.php?a=3&id={$documentID}&r=9"; |
|
105 | + $header = "Location: index.php?a=3&id={$documentID}&r=9"; |
|
106 | 106 | header($header); |
107 | 107 | } else { |
108 | 108 | $modx->webAlertAndQuit("You cannot move a document to a child document!"); |
@@ -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->getFullTableName('web_groups'); |
12 | 12 | |
13 | 13 | $input = $_POST; |
14 | -foreach($input as $k => $v) { |
|
15 | - if($k !== 'comment') { |
|
14 | +foreach ($input as $k => $v) { |
|
15 | + if ($k !== 'comment') { |
|
16 | 16 | $v = sanitize($v); |
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->db->escape($newusername); |
@@ -50,41 +50,41 @@ 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"); |
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!"); |
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->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
66 | 66 | $limit = $modx->db->getValue($rs); |
67 | - if($limit > 0) { |
|
67 | + if ($limit > 0) { |
|
68 | 68 | webAlertAndQuit("User name is already in use!"); |
69 | 69 | } |
70 | 70 | |
71 | 71 | // check if the email address already exist |
72 | 72 | $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
73 | 73 | $limit = $modx->db->getValue($rs); |
74 | - if($limit > 0) { |
|
74 | + if ($limit > 0) { |
|
75 | 75 | webAlertAndQuit("Email is already in use!"); |
76 | 76 | } |
77 | 77 | |
78 | 78 | // generate a new password for this user |
79 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
80 | - if(strlen($specifiedpassword) < 6) { |
|
79 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
80 | + if (strlen($specifiedpassword) < 6) { |
|
81 | 81 | webAlertAndQuit("Password is too short!"); |
82 | 82 | } else { |
83 | 83 | $newpassword = $specifiedpassword; |
84 | 84 | } |
85 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
85 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
86 | 86 | webAlertAndQuit("You didn't specify a password for this user!"); |
87 | - } elseif($passwordgenmethod == 'g') { |
|
87 | + } elseif ($passwordgenmethod == 'g') { |
|
88 | 88 | $newpassword = generate_password(8); |
89 | 89 | } else { |
90 | 90 | webAlertAndQuit("No password generation method specified!"); |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | /*******************************************************************************/ |
115 | 115 | // put the user in the user_groups he/ she should be in |
116 | 116 | // first, check that up_perms are switched on! |
117 | - if($use_udperms == 1) { |
|
118 | - if(!empty($user_groups)) { |
|
119 | - for($i = 0; $i < count($user_groups); $i++) { |
|
117 | + if ($use_udperms == 1) { |
|
118 | + if (!empty($user_groups)) { |
|
119 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
120 | 120 | $f = array(); |
121 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
121 | + $f['webgroup'] = (int) $user_groups[$i]; |
|
122 | 122 | $f['webuser'] = $internalKey; |
123 | 123 | $modx->db->insert($f, $tbl_web_groups); |
124 | 124 | } |
@@ -142,20 +142,20 @@ discard block |
||
142 | 142 | "id" => $internalKey |
143 | 143 | )); |
144 | 144 | |
145 | - if($passwordnotifymethod == 'e') { |
|
145 | + if ($passwordnotifymethod == 'e') { |
|
146 | 146 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
147 | - if($input['stay'] != '') { |
|
147 | + if ($input['stay'] != '') { |
|
148 | 148 | $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
149 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
149 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
150 | 150 | header($header); |
151 | 151 | } else { |
152 | 152 | $header = "Location: index.php?a=99&r=2"; |
153 | 153 | header($header); |
154 | 154 | } |
155 | 155 | } else { |
156 | - if($input['stay'] != '') { |
|
156 | + if ($input['stay'] != '') { |
|
157 | 157 | $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
158 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
158 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
159 | 159 | } else { |
160 | 160 | $stayUrl = "index.php?a=99&r=2"; |
161 | 161 | } |
@@ -188,36 +188,36 @@ discard block |
||
188 | 188 | break; |
189 | 189 | case '88' : // edit user |
190 | 190 | // generate a new password for this user |
191 | - if($genpassword == 1) { |
|
192 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
193 | - if(strlen($specifiedpassword) < 6) { |
|
191 | + if ($genpassword == 1) { |
|
192 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
193 | + if (strlen($specifiedpassword) < 6) { |
|
194 | 194 | webAlertAndQuit("Password is too short!"); |
195 | 195 | } else { |
196 | 196 | $newpassword = $specifiedpassword; |
197 | 197 | } |
198 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
198 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
199 | 199 | webAlertAndQuit("You didn't specify a password for this user!"); |
200 | - } elseif($passwordgenmethod == 'g') { |
|
200 | + } elseif ($passwordgenmethod == 'g') { |
|
201 | 201 | $newpassword = generate_password(8); |
202 | 202 | } else { |
203 | 203 | webAlertAndQuit("No password generation method specified!"); |
204 | 204 | } |
205 | 205 | } |
206 | - if($passwordnotifymethod == 'e') { |
|
206 | + if ($passwordnotifymethod == 'e') { |
|
207 | 207 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
208 | 208 | } |
209 | 209 | |
210 | 210 | // check if the username already exist |
211 | 211 | $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
212 | 212 | $limit = $modx->db->getValue($rs); |
213 | - if($limit > 0) { |
|
213 | + if ($limit > 0) { |
|
214 | 214 | webAlertAndQuit("User name is already in use!"); |
215 | 215 | } |
216 | 216 | |
217 | 217 | // check if the email address already exists |
218 | 218 | $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
219 | 219 | $limit = $modx->db->getValue($rs); |
220 | - if($limit > 0) { |
|
220 | + if ($limit > 0) { |
|
221 | 221 | webAlertAndQuit("Email is already in use!"); |
222 | 222 | } |
223 | 223 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | // update user name and password |
231 | 231 | $field = array(); |
232 | 232 | $field['username'] = $esc_newusername; |
233 | - if($genpassword == 1) { |
|
233 | + if ($genpassword == 1) { |
|
234 | 234 | $field['password'] = md5($newpassword); |
235 | 235 | } |
236 | 236 | $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
@@ -247,13 +247,13 @@ discard block |
||
247 | 247 | /*******************************************************************************/ |
248 | 248 | // put the user in the user_groups he/ she should be in |
249 | 249 | // first, check that up_perms are switched on! |
250 | - if($use_udperms == 1) { |
|
250 | + if ($use_udperms == 1) { |
|
251 | 251 | // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
252 | 252 | $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
253 | - if(!empty($user_groups)) { |
|
254 | - for($i = 0; $i < count($user_groups); $i++) { |
|
253 | + if (!empty($user_groups)) { |
|
254 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
255 | 255 | $field = array(); |
256 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
256 | + $field['webgroup'] = (int) $user_groups[$i]; |
|
257 | 257 | $field['webuser'] = $id; |
258 | 258 | $modx->db->insert($field, $tbl_web_groups); |
259 | 259 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | )); |
276 | 276 | |
277 | 277 | // invoke OnWebChangePassword event |
278 | - if($genpassword == 1) { |
|
278 | + if ($genpassword == 1) { |
|
279 | 279 | $modx->invokeEvent("OnWebChangePassword", array( |
280 | 280 | "userid" => $id, |
281 | 281 | "username" => $newusername, |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | "id" => $id |
290 | 290 | )); |
291 | 291 | |
292 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
293 | - if($input['stay'] != '') { |
|
292 | + if ($genpassword == 1 && $passwordnotifymethod == 's') { |
|
293 | + if ($input['stay'] != '') { |
|
294 | 294 | $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
295 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
295 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
296 | 296 | } else { |
297 | 297 | $stayUrl = "index.php?a=99&r=2"; |
298 | 298 | } |
@@ -320,9 +320,9 @@ discard block |
||
320 | 320 | |
321 | 321 | include_once "footer.inc.php"; |
322 | 322 | } else { |
323 | - if($input['stay'] != '') { |
|
323 | + if ($input['stay'] != '') { |
|
324 | 324 | $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
325 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
325 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
326 | 326 | header($header); |
327 | 327 | } else { |
328 | 328 | $header = "Location: index.php?a=99&r=2"; |
@@ -340,15 +340,15 @@ discard block |
||
340 | 340 | * @param string $string |
341 | 341 | * @return string |
342 | 342 | */ |
343 | -function save_user_quoted_printable($string) { |
|
343 | +function save_user_quoted_printable($string){ |
|
344 | 344 | $crlf = "\n"; |
345 | - $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
345 | + $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string).$crlf; |
|
346 | 346 | $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
347 | 347 | $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
348 | - $f[] = '/([\011\040])' . $crlf . '/e'; |
|
349 | - $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
348 | + $f[] = '/([\011\040])'.$crlf.'/e'; |
|
349 | + $r[] = "'=' . sprintf('%02X', ord('\\1')) . '".$crlf."'"; |
|
350 | 350 | $string = preg_replace($f, $r, $string); |
351 | - return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
351 | + return trim(wordwrap($string, 70, ' ='.$crlf)); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * @param string $pwd |
360 | 360 | * @param string $ufn |
361 | 361 | */ |
362 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
362 | +function sendMailMessage($email, $uid, $pwd, $ufn){ |
|
363 | 363 | $modx = evolutionCMS(); global $_lang, $websignupemail_message; |
364 | 364 | global $emailsubject, $emailsender; |
365 | 365 | global $site_name, $site_url; |
@@ -380,14 +380,14 @@ discard block |
||
380 | 380 | $param['to'] = $email; |
381 | 381 | $param['type'] = 'text'; |
382 | 382 | $rs = $modx->sendmail($param); |
383 | - if(!$rs) { |
|
383 | + if (!$rs) { |
|
384 | 384 | $modx->manager->saveFormValues(); |
385 | 385 | $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
386 | 386 | } |
387 | 387 | } |
388 | 388 | |
389 | 389 | // Save User Settings |
390 | -function saveUserSettings($id) { |
|
390 | +function saveUserSettings($id){ |
|
391 | 391 | $modx = evolutionCMS(); |
392 | 392 | $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
393 | 393 | |
@@ -399,12 +399,12 @@ discard block |
||
399 | 399 | |
400 | 400 | $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
401 | 401 | |
402 | - foreach($settings as $n) { |
|
402 | + foreach ($settings as $n) { |
|
403 | 403 | $vl = $_POST[$n]; |
404 | - if(is_array($vl)) { |
|
404 | + if (is_array($vl)) { |
|
405 | 405 | $vl = implode(",", $vl); |
406 | 406 | } |
407 | - if($vl != '') { |
|
407 | + if ($vl != '') { |
|
408 | 408 | $f = array(); |
409 | 409 | $f['webuser'] = $id; |
410 | 410 | $f['setting_name'] = $n; |
@@ -416,33 +416,33 @@ discard block |
||
416 | 416 | } |
417 | 417 | |
418 | 418 | // Web alert - sends an alert to web browser |
419 | -function webAlertAndQuit($msg) { |
|
419 | +function webAlertAndQuit($msg){ |
|
420 | 420 | global $id, $modx; |
421 | 421 | $mode = $_POST['mode']; |
422 | 422 | $modx->manager->saveFormValues($mode); |
423 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
423 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '88' ? "&id={$id}" : '')); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | // Generate password |
427 | -function generate_password($length = 10) { |
|
427 | +function generate_password($length = 10){ |
|
428 | 428 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
429 | 429 | $ps_len = strlen($allowable_characters); |
430 | 430 | mt_srand((double) microtime() * 1000000); |
431 | 431 | $pass = ""; |
432 | - for($i = 0; $i < $length; $i++) { |
|
432 | + for ($i = 0; $i < $length; $i++) { |
|
433 | 433 | $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
434 | 434 | } |
435 | 435 | return $pass; |
436 | 436 | } |
437 | 437 | |
438 | -function sanitize($str = '', $safecount = 0) { |
|
438 | +function sanitize($str = '', $safecount = 0){ |
|
439 | 439 | $modx = evolutionCMS(); |
440 | 440 | $safecount++; |
441 | - if(1000 < $safecount) { |
|
441 | + if (1000 < $safecount) { |
|
442 | 442 | exit("error too many loops '{$safecount}'"); |
443 | 443 | } |
444 | - if(is_array($str)) { |
|
445 | - foreach($str as $i => $v) { |
|
444 | + if (is_array($str)) { |
|
445 | + foreach ($str as $i => $v) { |
|
446 | 446 | $str[$i] = sanitize($v, $safecount); |
447 | 447 | } |
448 | 448 | } else { |
@@ -1,27 +1,27 @@ 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('new_document') || !$modx->hasPermission('save_document')) { |
|
5 | +if (!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
10 | -if($id==0) { |
|
9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
14 | 14 | $children = array(); |
15 | 15 | |
16 | 16 | // check permissions on the document |
17 | -include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
17 | +include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php"; |
|
18 | 18 | $udperms = new udperms(); |
19 | 19 | $udperms->user = $modx->getLoginUserID(); |
20 | 20 | $udperms->document = $id; |
21 | 21 | $udperms->role = $_SESSION['mgrRole']; |
22 | 22 | $udperms->duplicateDoc = true; |
23 | 23 | |
24 | -if(!$udperms->checkPermissions()) { |
|
24 | +if (!$udperms->checkPermissions()) { |
|
25 | 25 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
26 | 26 | } |
27 | 27 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $_SESSION['itemname'] = $name; |
34 | 34 | |
35 | 35 | // finish cloning - redirect |
36 | -$header="Location: index.php?r=1&a=3&id=$id"; |
|
36 | +$header = "Location: index.php?r=1&a=3&id=$id"; |
|
37 | 37 | header($header); |
38 | 38 | |
39 | 39 | /** |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param int $_toplevel |
43 | 43 | * @return int |
44 | 44 | */ |
45 | -function duplicateDocument($docid, $parent=null, $_toplevel=0) { |
|
45 | +function duplicateDocument($docid, $parent = null, $_toplevel = 0){ |
|
46 | 46 | $modx = evolutionCMS(); global $_lang; |
47 | 47 | |
48 | 48 | // invoke OnBeforeDocDuplicate event |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $content = $modx->db->getRow($rs); |
64 | 64 | |
65 | 65 | // Handle incremental ID |
66 | - switch($modx->config['docid_incrmnt_method']) |
|
66 | + switch ($modx->config['docid_incrmnt_method']) |
|
67 | 67 | { |
68 | 68 | case '1': |
69 | 69 | $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id"; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $content['id'] = $modx->db->getValue($rs); |
72 | 72 | break; |
73 | 73 | case '2': |
74 | - $rs = $modx->db->select('MAX(id)+1',$tblsc); |
|
74 | + $rs = $modx->db->select('MAX(id)+1', $tblsc); |
|
75 | 75 | $content['id'] = $modx->db->getValue($rs); |
76 | 76 | break; |
77 | 77 | |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'")); |
86 | 86 | $pagetitle = $modx->db->escape($pagetitle); |
87 | 87 | $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'")); |
88 | - if($count>=1) $count = ' '.($count+1); |
|
88 | + if ($count >= 1) $count = ' '.($count + 1); |
|
89 | 89 | else $count = ''; |
90 | 90 | |
91 | 91 | $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle']; |
92 | 92 | $content['alias'] = null; |
93 | - } elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) { |
|
93 | + } elseif ($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) { |
|
94 | 94 | $content['alias'] = null; |
95 | 95 | } |
96 | 96 | |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | |
154 | 154 | $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues'); |
155 | 155 | |
156 | - $newid = (int)$newid; |
|
157 | - $oldid = (int)$oldid; |
|
156 | + $newid = (int) $newid; |
|
157 | + $oldid = (int) $oldid; |
|
158 | 158 | |
159 | 159 | $modx->db->insert( |
160 | 160 | array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | |
174 | 174 | $tbldg = $modx->getFullTableName('document_groups'); |
175 | 175 | |
176 | - $newid = (int)$newid; |
|
177 | - $oldid = (int)$oldid; |
|
176 | + $newid = (int) $newid; |
|
177 | + $oldid = (int) $oldid; |
|
178 | 178 | |
179 | 179 | $modx->db->insert( |
180 | 180 | array('document'=>'', 'document_group'=>''), $tbldg, // Insert into |
@@ -1,18 +1,18 @@ 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('exec_module')) { |
|
5 | +if (!$modx->hasPermission('exec_module')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
10 | -if($id==0) { |
|
9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
14 | 14 | // check if user has access permission, except admins |
15 | -if($_SESSION['mgrRole']!=1){ |
|
15 | +if ($_SESSION['mgrRole'] != 1) { |
|
16 | 16 | $rs = $modx->db->select( |
17 | 17 | 'sma.usergroup,mg.member', |
18 | 18 | $modx->getFullTableName("site_module_access")." sma |
@@ -24,18 +24,18 @@ discard block |
||
24 | 24 | $permissionAccessInt = -1; |
25 | 25 | |
26 | 26 | while ($row = $modx->db->getRow($rs)) { |
27 | - if($row["usergroup"] && $row["member"]) { |
|
27 | + if ($row["usergroup"] && $row["member"]) { |
|
28 | 28 | //if there are permissions and this member has permission, ofcourse |
29 | 29 | //this is granted |
30 | 30 | $permissionAccessInt = 1; |
31 | - } elseif ($permissionAccessInt==-1) { |
|
31 | + } elseif ($permissionAccessInt == -1) { |
|
32 | 32 | //if there are permissions but this member has no permission and the |
33 | 33 | //variable was still in init state we set permission to 0; no permissions |
34 | 34 | $permissionAccessInt = 0; |
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | - if($permissionAccessInt==0) { |
|
38 | + if ($permissionAccessInt == 0) { |
|
39 | 39 | $modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106"); |
40 | 40 | } |
41 | 41 | } |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | // get module data |
44 | 44 | $rs = $modx->db->select('*', $modx->getFullTableName("site_modules"), "id='{$id}'"); |
45 | 45 | $content = $modx->db->getRow($rs); |
46 | -if(!$content) { |
|
46 | +if (!$content) { |
|
47 | 47 | $modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106"); |
48 | 48 | } |
49 | -if($content['disabled']) { |
|
49 | +if ($content['disabled']) { |
|
50 | 50 | $modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106"); |
51 | 51 | } |
52 | 52 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // Set the item name for logger |
60 | 60 | $_SESSION['itemname'] = $content['name']; |
61 | 61 | |
62 | -$output = evalModule($content["modulecode"],$parameter); |
|
62 | +$output = evalModule($content["modulecode"], $parameter); |
|
63 | 63 | echo $output; |
64 | 64 | include MODX_MANAGER_PATH."includes/sysalert.display.inc.php"; |
65 | 65 | |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | * @param array $params |
71 | 71 | * @return string |
72 | 72 | */ |
73 | -function evalModule($moduleCode,$params){ |
|
73 | +function evalModule($moduleCode, $params){ |
|
74 | 74 | $modx = evolutionCMS(); |
75 | 75 | $modx->event->params = &$params; // store params inside event object |
76 | - if(is_array($params)) { |
|
76 | + if (is_array($params)) { |
|
77 | 77 | extract($params, EXTR_SKIP); |
78 | 78 | } |
79 | 79 | ob_start(); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | if (isset($php_errormsg)) |
84 | 84 | { |
85 | 85 | $error_info = error_get_last(); |
86 | - switch($error_info['type']) |
|
86 | + switch ($error_info['type']) |
|
87 | 87 | { |
88 | 88 | case E_NOTICE : |
89 | 89 | $error_level = 1; |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | default: |
98 | 98 | $error_level = 99; |
99 | 99 | } |
100 | - if($modx->config['error_reporting']==='99' || 2<$error_level) |
|
100 | + if ($modx->config['error_reporting'] === '99' || 2 < $error_level) |
|
101 | 101 | { |
102 | - $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg); |
|
102 | + $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'].' - Module', $error_info['message'], $error_info['line'], $msg); |
|
103 | 103 | $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>"); |
104 | 104 | } |
105 | 105 | } |