@@ -12,12 +12,20 @@ discard block |
||
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) { |
|
16 | + $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
17 | +} |
|
18 | +if($documentID <= 0) { |
|
19 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
20 | +} |
|
21 | +if($newParentID < 0) { |
|
22 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
23 | +} |
|
18 | 24 | |
19 | 25 | $parents = $modx->getParentIds($newParentID); |
20 | -if (in_array($documentID, $parents)) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
26 | +if (in_array($documentID, $parents)) { |
|
27 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
28 | +} |
|
21 | 29 | |
22 | 30 | $rs = $modx->db->select('parent', $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
23 | 31 | $oldparent = $modx->db->getValue($rs); |
@@ -42,7 +50,8 @@ discard block |
||
42 | 50 | * @param int $currDocID |
43 | 51 | * @return array |
44 | 52 | */ |
45 | -function allChildren($currDocID) { |
|
53 | +function allChildren($currDocID) |
|
54 | +{ |
|
46 | 55 | $modx = DocumentParser::getInstance(); |
47 | 56 | $children= array(); |
48 | 57 | $currDocID = $modx->db->escape($currDocID); |
@@ -59,11 +68,11 @@ discard block |
||
59 | 68 | "old_parent" => $oldparent, |
60 | 69 | "new_parent" => $newParentID |
61 | 70 | )); |
62 | -if (is_array($evtOut) && count($evtOut) > 0){ |
|
71 | +if (is_array($evtOut) && count($evtOut) > 0) { |
|
63 | 72 | $newParent = array_pop($evtOut); |
64 | 73 | if($newParent == $oldparent) { |
65 | 74 | $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
66 | - }else{ |
|
75 | + } else { |
|
67 | 76 | $newParentID = $newParent; |
68 | 77 | } |
69 | 78 | } |
@@ -177,7 +177,9 @@ 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)) { |
|
181 | + $evtId = getEventIdByName($evtId); |
|
182 | + } |
|
181 | 183 | if ($mode == '101') { |
182 | 184 | $rs = $modx->db->select('max(priority) as priority', '[+prefix+]site_plugin_events', "evtid='{$evtId}'"); |
183 | 185 | } else { |
@@ -203,10 +205,14 @@ discard block |
||
203 | 205 | $dbEventList = array(); |
204 | 206 | $del = array(); |
205 | 207 | while($row = $modx->db->getRow($rs)) { |
206 | - if(!in_array($row['evtid'], $evtids)) $del[] = $row['evtid']; |
|
208 | + if(!in_array($row['evtid'], $evtids)) { |
|
209 | + $del[] = $row['evtid']; |
|
210 | + } |
|
207 | 211 | } |
208 | 212 | |
209 | - if(empty($del)) return; |
|
213 | + if(empty($del)) { |
|
214 | + return; |
|
215 | + } |
|
210 | 216 | |
211 | 217 | foreach($del as $delid) { |
212 | 218 | $modx->db->delete('[+prefix+]site_plugin_events', sprintf("evtid='%s' AND pluginid='%s'", $delid, $id)); |
@@ -222,7 +228,9 @@ discard block |
||
222 | 228 | $modx = DocumentParser::getInstance(); |
223 | 229 | static $eventIds=array(); |
224 | 230 | |
225 | - if(isset($eventIds[$name])) return $eventIds[$name]; |
|
231 | + if(isset($eventIds[$name])) { |
|
232 | + return $eventIds[$name]; |
|
233 | + } |
|
226 | 234 | |
227 | 235 | $rs = $modx->db->select('id, name', '[+prefix+]system_eventnames'); |
228 | 236 | while ($row = $modx->db->getRow($rs)) { |
@@ -340,7 +340,8 @@ 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 | 345 | $crlf = "\n"; |
345 | 346 | $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
346 | 347 | $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
@@ -359,7 +360,8 @@ discard block |
||
359 | 360 | * @param string $pwd |
360 | 361 | * @param string $ufn |
361 | 362 | */ |
362 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
363 | +function sendMailMessage($email, $uid, $pwd, $ufn) |
|
364 | +{ |
|
363 | 365 | $modx = DocumentParser::getInstance(); global $_lang, $websignupemail_message; |
364 | 366 | global $emailsubject, $emailsender; |
365 | 367 | global $site_name, $site_url; |
@@ -387,7 +389,8 @@ discard block |
||
387 | 389 | } |
388 | 390 | |
389 | 391 | // Save User Settings |
390 | -function saveUserSettings($id) { |
|
392 | +function saveUserSettings($id) |
|
393 | +{ |
|
391 | 394 | $modx = DocumentParser::getInstance(); |
392 | 395 | $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
393 | 396 | |
@@ -416,7 +419,8 @@ discard block |
||
416 | 419 | } |
417 | 420 | |
418 | 421 | // Web alert - sends an alert to web browser |
419 | -function webAlertAndQuit($msg) { |
|
422 | +function webAlertAndQuit($msg) |
|
423 | +{ |
|
420 | 424 | global $id, $modx; |
421 | 425 | $mode = $_POST['mode']; |
422 | 426 | $modx->manager->saveFormValues($mode); |
@@ -424,7 +428,8 @@ discard block |
||
424 | 428 | } |
425 | 429 | |
426 | 430 | // Generate password |
427 | -function generate_password($length = 10) { |
|
431 | +function generate_password($length = 10) |
|
432 | +{ |
|
428 | 433 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
429 | 434 | $ps_len = strlen($allowable_characters); |
430 | 435 | mt_srand((double) microtime() * 1000000); |
@@ -435,7 +440,8 @@ discard block |
||
435 | 440 | return $pass; |
436 | 441 | } |
437 | 442 | |
438 | -function sanitize($str = '', $safecount = 0) { |
|
443 | +function sanitize($str = '', $safecount = 0) |
|
444 | +{ |
|
439 | 445 | $modx = DocumentParser::getInstance(); |
440 | 446 | $safecount++; |
441 | 447 | if(1000 < $safecount) { |
@@ -42,7 +42,8 @@ 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 | 47 | $modx = DocumentParser::getInstance(); global $_lang; |
47 | 48 | |
48 | 49 | // invoke OnBeforeDocDuplicate event |
@@ -63,8 +64,7 @@ discard block |
||
63 | 64 | $content = $modx->db->getRow($rs); |
64 | 65 | |
65 | 66 | // Handle incremental ID |
66 | - switch($modx->config['docid_incrmnt_method']) |
|
67 | - { |
|
67 | + switch($modx->config['docid_incrmnt_method']) { |
|
68 | 68 | case '1': |
69 | 69 | $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id"; |
70 | 70 | $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL"); |
@@ -85,8 +85,11 @@ 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); |
|
89 | - else $count = ''; |
|
88 | + if($count>=1) { |
|
89 | + $count = ' '.($count+1); |
|
90 | + } else { |
|
91 | + $count = ''; |
|
92 | + } |
|
90 | 93 | |
91 | 94 | $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle']; |
92 | 95 | $content['alias'] = null; |
@@ -95,7 +98,9 @@ discard block |
||
95 | 98 | } |
96 | 99 | |
97 | 100 | // change the parent accordingly |
98 | - if ($parent !== null) $content['parent'] = $parent; |
|
101 | + if ($parent !== null) { |
|
102 | + $content['parent'] = $parent; |
|
103 | + } |
|
99 | 104 | |
100 | 105 | // Change the author |
101 | 106 | $content['createdby'] = $userID; |
@@ -135,8 +140,9 @@ discard block |
||
135 | 140 | // Start duplicating all the child documents that aren't deleted. |
136 | 141 | $_toplevel++; |
137 | 142 | $rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC'); |
138 | - while ($row = $modx->db->getRow($rs)) |
|
139 | - duplicateDocument($row['id'], $newparent, $_toplevel); |
|
143 | + while ($row = $modx->db->getRow($rs)) { |
|
144 | + duplicateDocument($row['id'], $newparent, $_toplevel); |
|
145 | + } |
|
140 | 146 | |
141 | 147 | // return the new doc id |
142 | 148 | return $newparent; |
@@ -148,7 +154,8 @@ discard block |
||
148 | 154 | * @param int $oldid |
149 | 155 | * @param int $newid |
150 | 156 | */ |
151 | -function duplicateTVs($oldid, $newid){ |
|
157 | +function duplicateTVs($oldid, $newid) |
|
158 | +{ |
|
152 | 159 | $modx = DocumentParser::getInstance(); |
153 | 160 | |
154 | 161 | $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues'); |
@@ -168,7 +175,8 @@ discard block |
||
168 | 175 | * @param int $oldid |
169 | 176 | * @param int $newid |
170 | 177 | */ |
171 | -function duplicateAccess($oldid, $newid){ |
|
178 | +function duplicateAccess($oldid, $newid) |
|
179 | +{ |
|
172 | 180 | $modx = DocumentParser::getInstance(); |
173 | 181 | |
174 | 182 | $tbldg = $modx->getFullTableName('document_groups'); |
@@ -296,7 +296,8 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @param string $msg |
298 | 298 | */ |
299 | -function jsAlert($msg) { |
|
299 | +function jsAlert($msg) |
|
300 | +{ |
|
300 | 301 | $modx = DocumentParser::getInstance(); |
301 | 302 | if($_POST['ajax'] != 1) { |
302 | 303 | echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>"; |
@@ -311,7 +312,8 @@ discard block |
||
311 | 312 | * @param string $dbasePassword |
312 | 313 | * @return bool |
313 | 314 | */ |
314 | -function login($username, $givenPassword, $dbasePassword) { |
|
315 | +function login($username, $givenPassword, $dbasePassword) |
|
316 | +{ |
|
315 | 317 | $modx = DocumentParser::getInstance(); |
316 | 318 | return $modx->phpass->CheckPassword($givenPassword, $dbasePassword); |
317 | 319 | } |
@@ -323,7 +325,8 @@ discard block |
||
323 | 325 | * @param string $username |
324 | 326 | * @return bool |
325 | 327 | */ |
326 | -function loginV1($internalKey, $givenPassword, $dbasePassword, $username) { |
|
328 | +function loginV1($internalKey, $givenPassword, $dbasePassword, $username) |
|
329 | +{ |
|
327 | 330 | $modx = DocumentParser::getInstance(); |
328 | 331 | |
329 | 332 | $user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey); |
@@ -353,7 +356,8 @@ discard block |
||
353 | 356 | * @param string $username |
354 | 357 | * @return bool |
355 | 358 | */ |
356 | -function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) { |
|
359 | +function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) |
|
360 | +{ |
|
357 | 361 | $modx = DocumentParser::getInstance(); |
358 | 362 | |
359 | 363 | if($dbasePassword != md5($givenPassword)) { |
@@ -367,7 +371,8 @@ discard block |
||
367 | 371 | * @param string $username |
368 | 372 | * @param string $password |
369 | 373 | */ |
370 | -function updateNewHash($username, $password) { |
|
374 | +function updateNewHash($username, $password) |
|
375 | +{ |
|
371 | 376 | $modx = DocumentParser::getInstance(); |
372 | 377 | |
373 | 378 | $field = array(); |
@@ -381,16 +386,19 @@ discard block |
||
381 | 386 | * @param int $failed_allowed |
382 | 387 | * @param int $blocked_minutes |
383 | 388 | */ |
384 | -function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) { |
|
389 | +function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) |
|
390 | +{ |
|
385 | 391 | $modx = DocumentParser::getInstance(); |
386 | 392 | |
387 | 393 | $failedlogins += 1; |
388 | 394 | |
389 | 395 | $fields = array('failedlogincount' => $failedlogins); |
390 | - if($failedlogins >= $failed_allowed) //block user for too many fail attempts |
|
396 | + if($failedlogins >= $failed_allowed) { |
|
397 | + //block user for too many fail attempts |
|
391 | 398 | { |
392 | 399 | $fields['blockeduntil'] = time() + ($blocked_minutes * 60); |
393 | 400 | } |
401 | + } |
|
394 | 402 | |
395 | 403 | $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); |
396 | 404 |
@@ -356,7 +356,8 @@ 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 | 361 | $modx = DocumentParser::getInstance(); global $_lang, $signupemail_message; |
361 | 362 | global $emailsubject, $emailsender; |
362 | 363 | global $site_name; |
@@ -389,7 +390,8 @@ discard block |
||
389 | 390 | * |
390 | 391 | * @param int $id |
391 | 392 | */ |
392 | -function saveUserSettings($id) { |
|
393 | +function saveUserSettings($id) |
|
394 | +{ |
|
393 | 395 | $modx = DocumentParser::getInstance(); |
394 | 396 | $tbl_user_settings = $modx->getFullTableName('user_settings'); |
395 | 397 | |
@@ -477,7 +479,8 @@ discard block |
||
477 | 479 | * |
478 | 480 | * @param $msg |
479 | 481 | */ |
480 | -function webAlertAndQuit($msg) { |
|
482 | +function webAlertAndQuit($msg) |
|
483 | +{ |
|
481 | 484 | global $id, $modx; |
482 | 485 | $mode = $_POST['mode']; |
483 | 486 | $modx->manager->saveFormValues($mode); |
@@ -490,7 +493,8 @@ discard block |
||
490 | 493 | * @param int $length |
491 | 494 | * @return string |
492 | 495 | */ |
493 | -function generate_password($length = 10) { |
|
496 | +function generate_password($length = 10) |
|
497 | +{ |
|
494 | 498 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
495 | 499 | $ps_len = strlen($allowable_characters); |
496 | 500 | mt_srand((double) microtime() * 1000000); |
@@ -12,7 +12,7 @@ discard block |
||
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 |
@@ -70,7 +70,8 @@ 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 | 75 | $modx = DocumentParser::getInstance(); |
75 | 76 | $modx->event->params = &$params; // store params inside event object |
76 | 77 | if(is_array($params)) { |
@@ -80,11 +81,9 @@ discard block |
||
80 | 81 | $mod = eval($moduleCode); |
81 | 82 | $msg = ob_get_contents(); |
82 | 83 | ob_end_clean(); |
83 | - if (isset($php_errormsg)) |
|
84 | - { |
|
84 | + if (isset($php_errormsg)) { |
|
85 | 85 | $error_info = error_get_last(); |
86 | - switch($error_info['type']) |
|
87 | - { |
|
86 | + switch($error_info['type']) { |
|
88 | 87 | case E_NOTICE : |
89 | 88 | $error_level = 1; |
90 | 89 | case E_USER_NOTICE : |
@@ -97,8 +96,7 @@ discard block |
||
97 | 96 | default: |
98 | 97 | $error_level = 99; |
99 | 98 | } |
100 | - if($modx->config['error_reporting']==='99' || 2<$error_level) |
|
101 | - { |
|
99 | + if($modx->config['error_reporting']==='99' || 2<$error_level) { |
|
102 | 100 | $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg); |
103 | 101 | $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>"); |
104 | 102 | } |
@@ -79,7 +79,8 @@ discard block |
||
79 | 79 | * @return string |
80 | 80 | */ |
81 | 81 | public function getParents($id, $path = '') |
82 | - { // modx:returns child's parent |
|
82 | + { |
|
83 | +// modx:returns child's parent |
|
83 | 84 | $modx = DocumentParser::getInstance(); |
84 | 85 | if (empty($this->aliases)) { |
85 | 86 | $f = "id, IF(alias='', id, alias) AS alias, parent, alias_visible"; |
@@ -456,7 +457,8 @@ discard block |
||
456 | 457 | $_ = trim($_); |
457 | 458 | } |
458 | 459 | $lastChar = substr($_, -1); |
459 | - if (!in_array($lastChar, $chars)) {// ,320,327,288,284,289 |
|
460 | + if (!in_array($lastChar, $chars)) { |
|
461 | +// ,320,327,288,284,289 |
|
460 | 462 | if (!in_array($prev_token, |
461 | 463 | array(T_FOREACH, T_WHILE, T_FOR, T_BOOLEAN_AND, T_BOOLEAN_OR, T_DOUBLE_ARROW))) { |
462 | 464 | $_ .= ' '; |
@@ -47,7 +47,8 @@ |
||
47 | 47 | /** |
48 | 48 | * @param int $parent |
49 | 49 | */ |
50 | -function getChildren($parent) { |
|
50 | +function getChildren($parent) |
|
51 | +{ |
|
51 | 52 | |
52 | 53 | $modx = DocumentParser::getInstance(); |
53 | 54 | global $children; |