Completed
Pull Request — develop (#540)
by Agel_Nash
05:22
created
manager/processors/login.processor.php 1 patch
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -296,7 +296,8 @@  discard block
 block discarded – undo
296 296
  *
297 297
  * @param string $msg
298 298
  */
299
-function jsAlert($msg) {
299
+function jsAlert($msg)
300
+{
300 301
 	global $modx;
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
 block discarded – undo
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
 	global $modx;
316 318
 	return $modx->phpass->CheckPassword($givenPassword, $dbasePassword);
317 319
 }
@@ -323,7 +325,8 @@  discard block
 block discarded – undo
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
 	global $modx;
328 331
 
329 332
 	$user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey);
@@ -353,7 +356,8 @@  discard block
 block discarded – undo
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
 	global $modx;
358 362
 
359 363
 	if($dbasePassword != md5($givenPassword)) {
@@ -367,7 +371,8 @@  discard block
 block discarded – undo
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
 	global $modx;
372 377
 
373 378
 	$field = array();
@@ -381,16 +386,19 @@  discard block
 block discarded – undo
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
 	global $modx;
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
 
Please login to merge, or discard this patch.
manager/processors/undelete_content.processor.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,8 @@
 block discarded – undo
47 47
 /**
48 48
  * @param int $parent
49 49
  */
50
-function getChildren($parent) {
50
+function getChildren($parent)
51
+{
51 52
 
52 53
 	global $modx;
53 54
 	global $children;
Please login to merge, or discard this patch.
manager/processors/remove_installer.processor.php 1 patch
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,10 +17,14 @@  discard block
 block discarded – undo
17 17
 $pth = str_replace("\\","/",$pth);
18 18
 if(isset($_GET["rminstall"])) {
19 19
 	if(is_dir($pth)) {
20
-		if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder";
20
+		if(!rmdirRecursive($pth)) {
21
+		    $msg="An error occured while attempting to remove the install folder";
22
+		}
21 23
 	}
22 24
 }
23
-if($msg) echo "<script>alert('".addslashes($msg)."');</script>";
25
+if($msg) {
26
+    echo "<script>alert('".addslashes($msg)."');</script>";
27
+}
24 28
 echo "<script>window.location='../index.php?a=2';</script>";
25 29
 
26 30
 /**
@@ -30,13 +34,13 @@  discard block
 block discarded – undo
30 34
  * @param bool $followLinks
31 35
  * @return bool
32 36
  */
33
-function rmdirRecursive($path, $followLinks=false) {
37
+function rmdirRecursive($path, $followLinks=false)
38
+{
34 39
    $dir = opendir($path) ;
35 40
    while ($entry = readdir($dir)) {
36 41
 	   if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) {
37 42
 		   @unlink( "$path/$entry" );
38
-	   }
39
-	   elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') {
43
+	   } elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') {
40 44
 		   rmdirRecursive("$path/$entry"); // recursive
41 45
 	   }
42 46
    }
Please login to merge, or discard this patch.
manager/processors/duplicate_content.processor.php 1 patch
Braces   +18 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,7 +42,8 @@  discard block
 block discarded – undo
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
 	global $modx, $_lang;
47 48
 
48 49
 	// invoke OnBeforeDocDuplicate event
@@ -63,8 +64,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	global $modx;
153 160
 
154 161
 	$tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues');
@@ -168,7 +175,8 @@  discard block
 block discarded – undo
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
 	global $modx;
173 181
 
174 182
 	$tbldg = $modx->getFullTableName('document_groups');
Please login to merge, or discard this patch.
manager/processors/execute_module.processor.php 1 patch
Braces   +6 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
70 70
  * @param array $params
71 71
  * @return string
72 72
  */
73
-function evalModule($moduleCode,$params){
73
+function evalModule($moduleCode,$params)
74
+{
74 75
 	global $modx;
75 76
 	$modx->event->params = &$params; // store params inside event object
76 77
 	if(is_array($params)) {
@@ -80,11 +81,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
manager/processors/move_document.processor.php 1 patch
Braces   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,12 +12,20 @@  discard block
 block discarded – undo
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
 block discarded – undo
42 50
  * @param int $currDocID
43 51
  * @return array
44 52
  */
45
-function allChildren($currDocID) {
53
+function allChildren($currDocID)
54
+{
46 55
 	global $modx;
47 56
 	$children= array();
48 57
 	$currDocID = $modx->db->escape($currDocID);
@@ -59,11 +68,11 @@  discard block
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
manager/processors/save_web_user.processor.php 1 patch
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -340,7 +340,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 	global $modx, $_lang, $websignupemail_message;
364 366
 	global $emailsubject, $emailsender;
365 367
 	global $site_name, $site_url;
@@ -387,7 +389,8 @@  discard block
 block discarded – undo
387 389
 }
388 390
 
389 391
 // Save User Settings
390
-function saveUserSettings($id) {
392
+function saveUserSettings($id)
393
+{
391 394
 	global $modx;
392 395
 	$tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
393 396
 
@@ -416,7 +419,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
435 440
 	return $pass;
436 441
 }
437 442
 
438
-function sanitize($str = '', $safecount = 0) {
443
+function sanitize($str = '', $safecount = 0)
444
+{
439 445
 	global $modx;
440 446
 	$safecount++;
441 447
 	if(1000 < $safecount) {
Please login to merge, or discard this patch.
manager/media/script/air-datepicker/datepicker.inc.php 1 patch
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,13 +1,17 @@  discard block
 block discarded – undo
1 1
 <?php
2
-class DATEPICKER {
2
+class DATEPICKER
3
+{
3 4
     /**
4 5
      * @return string
5 6
      */
6
-    public function getDP() {
7
+    public function getDP()
8
+    {
7 9
         global $modx;
8 10
 
9 11
         $load_script = file_get_contents(dirname(__FILE__).'/datepicker.tpl');
10
-        if(!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode();
12
+        if(!isset($modx->config['lang_code'])) {
13
+            $modx->config['lang_code'] = $this->getLangCode();
14
+        }
11 15
 		$modx->config['datetime_format_lc'] = isset($modx->config['datetime_format']) ? strtolower($modx->config['datetime_format']) : 'dd-mm-yyyy';
12 16
         return $modx->mergeSettingsContent($load_script);
13 17
     }
@@ -15,13 +19,18 @@  discard block
 block discarded – undo
15 19
     /**
16 20
      * @return string
17 21
      */
18
-    public function getLangCode() {
22
+    public function getLangCode()
23
+    {
19 24
         global $modx, $modx_lang_attribute;
20 25
 
21
-        if(!$modx_lang_attribute) return 'en';
26
+        if(!$modx_lang_attribute) {
27
+            return 'en';
28
+        }
22 29
 
23 30
         $lc = $modx_lang_attribute;
24
-        if($lc === 'uk') return 'ru';
31
+        if($lc === 'uk') {
32
+            return 'ru';
33
+        }
25 34
         $dp_path = str_replace('\\','/',dirname(__FILE__));
26 35
 
27 36
         return (is_file("{$dp_path}/i18n/datepicker.{$lc}.js")) ? $modx_lang_attribute : 'en';
Please login to merge, or discard this patch.
index.php 1 patch
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -50,17 +50,23 @@  discard block
 block discarded – undo
50 50
 	include_once($autoloader);
51 51
 }
52 52
 
53
-if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);
53
+if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) {
54
+    $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);
55
+}
54 56
 
55 57
 $base_path = str_replace('\\','/',dirname(__FILE__)) . '/';
56
-if(is_file($base_path . 'assets/cache/siteManager.php'))
58
+if(is_file($base_path . 'assets/cache/siteManager.php')) {
57 59
     include_once($base_path . 'assets/cache/siteManager.php');
58
-if(!defined('MGR_DIR') && is_dir("{$base_path}manager"))
60
+}
61
+if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) {
59 62
 	define('MGR_DIR', 'manager');
60
-if(is_file($base_path . 'assets/cache/siteHostnames.php'))
63
+}
64
+if(is_file($base_path . 'assets/cache/siteHostnames.php')) {
61 65
     include_once($base_path . 'assets/cache/siteHostnames.php');
62
-if(!defined('MODX_SITE_HOSTNAMES'))
66
+}
67
+if(!defined('MODX_SITE_HOSTNAMES')) {
63 68
 	define('MODX_SITE_HOSTNAMES', '');
69
+}
64 70
 
65 71
 // get start time
66 72
 $mstart = memory_get_usage();
@@ -129,7 +135,7 @@  discard block
 block discarded – undo
129 135
     @ini_set("display_errors","0");
130 136
 }
131 137
 
132
-if(MODX_CLI){
138
+if(MODX_CLI) {
133 139
     @set_time_limit(0);
134 140
     @ini_set('max_execution_time',0);
135 141
 }
Please login to merge, or discard this patch.