Completed
Pull Request — develop (#689)
by Alexander
05:50
created
manager/processors/save_user.processor.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	global $modx, $_lang, $signupemail_message;
361 361
 	global $emailsubject, $emailsender;
362 362
 	global $site_name;
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
389 389
  *
390 390
  * @param int $id
391 391
  */
392
-function saveUserSettings($id) {
392
+function saveUserSettings($id){
393 393
 	global $modx;
394 394
 	$tbl_user_settings = $modx->getFullTableName('user_settings');
395 395
 
@@ -441,27 +441,27 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
manager/processors/cache_sync.class.processor.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
         if (isset($this->aliases[$id])) {
95 95
             if ($this->aliasVisible[$id] == 1) {
96 96
                 if ($path != '') {
97
-                    $path = $this->aliases[$id] . '/' . $path;
97
+                    $path = $this->aliases[$id].'/'.$path;
98 98
                 } else {
99 99
                     $path = $this->aliases[$id];
100 100
                 }
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
             $modx->messageQuit("Cache path not set.");
119 119
         }
120 120
 
121
-        $files = glob(realpath($this->cachePath) . '/*.pageCache.php');
121
+        $files = glob(realpath($this->cachePath).'/*.pageCache.php');
122 122
         $filesincache = count($files);
123 123
         $deletedfiles = array();
124 124
         while ($file = array_shift($files)) {
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
                 if (isset($opcache)) {
152 152
                     echo '<p>Opcache empty.</p>';
153 153
                 }
154
-                echo '<p>' . $_lang['cache_files_deleted'] . '</p><ul>';
154
+                echo '<p>'.$_lang['cache_files_deleted'].'</p><ul>';
155 155
                 foreach ($deletedfiles as $deletedfile) {
156
-                    echo '<li>' . $deletedfile . '</li>';
156
+                    echo '<li>'.$deletedfile.'</li>';
157 157
                 }
158 158
                 echo '</ul>';
159 159
             }
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 
173 173
 
174 174
         // write the file
175
-        $content = '<?php' . "\n";
176
-        $content .= '$recent_update=\'' . $this->request_time . '\';' . "\n";
177
-        $content .= '$cacheRefreshTime=\'' . $cacheRefreshTime . '\';' . "\n";
175
+        $content = '<?php'."\n";
176
+        $content .= '$recent_update=\''.$this->request_time.'\';'."\n";
177
+        $content .= '$cacheRefreshTime=\''.$cacheRefreshTime.'\';'."\n";
178 178
 
179
-        $filename = $this->cachePath . '/sitePublishing.idx.php';
179
+        $filename = $this->cachePath.'/sitePublishing.idx.php';
180 180
         if (!$handle = fopen($filename, 'w')) {
181 181
             exit("Cannot open file ({$filename}");
182 182
         }
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
         $timesArr = array();
201 201
 
202 202
         $result = $modx->db->select('MIN(pub_date) AS minpub', '[+prefix+]site_content',
203
-            'pub_date>' . $this->request_time);
203
+            'pub_date>'.$this->request_time);
204 204
         if (!$result) {
205 205
             echo "Couldn't determine next publish event!";
206 206
         }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
         }
212 212
 
213 213
         $result = $modx->db->select('MIN(unpub_date) AS minunpub', '[+prefix+]site_content',
214
-            'unpub_date>' . $this->request_time);
214
+            'unpub_date>'.$this->request_time);
215 215
         if (!$result) {
216 216
             echo "Couldn't determine next unpublish event!";
217 217
         }
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         $config = array();
251 251
         $content .= '$c=&$this->config;';
252 252
         while (list($key, $value) = $modx->db->getRow($rs, 'num')) {
253
-            $content .= '$c[\'' . $key . '\']="' . $this->escapeDoubleQuotes($value) . '";';
253
+            $content .= '$c[\''.$key.'\']="'.$this->escapeDoubleQuotes($value).'";';
254 254
             $config[$key] = $value;
255 255
         }
256 256
 
@@ -288,23 +288,23 @@  discard block
 block discarded – undo
288 288
             $docid = $doc['id'];
289 289
             if ($use_alias_path) {
290 290
                 $tmpPath = $this->getParents($doc['parent']);
291
-                $alias = (strlen($tmpPath) > 0 ? "$tmpPath/" : '') . $doc['alias'];
291
+                $alias = (strlen($tmpPath) > 0 ? "$tmpPath/" : '').$doc['alias'];
292 292
                 $key = $alias;
293 293
             } else {
294 294
                 $key = $doc['alias'];
295 295
             }
296 296
 
297 297
             $doc['path'] = $tmpPath;
298
-            $content .= '$a[' . $docid . ']=array(\'id\'=>' . $docid . ',\'alias\'=>\'' . $doc['alias'] . '\',\'path\'=>\'' . $doc['path'] . '\',\'parent\'=>' . $doc['parent'] . ',\'isfolder\'=>' . $doc['isfolder'] . ',\'alias_visible\'=>' . $doc['alias_visible'] . ');';
299
-            $content .= '$d[\'' . $key . '\']=' . $docid . ';';
300
-            $content .= '$m[]=array(' . $doc['parent'] . '=>' . $docid . ');';
298
+            $content .= '$a['.$docid.']=array(\'id\'=>'.$docid.',\'alias\'=>\''.$doc['alias'].'\',\'path\'=>\''.$doc['path'].'\',\'parent\'=>'.$doc['parent'].',\'isfolder\'=>'.$doc['isfolder'].',\'alias_visible\'=>'.$doc['alias_visible'].');';
299
+            $content .= '$d[\''.$key.'\']='.$docid.';';
300
+            $content .= '$m[]=array('.$doc['parent'].'=>'.$docid.');';
301 301
         }
302 302
 
303 303
         // get content types
304 304
         $rs = $modx->db->select('id, contentType', '[+prefix+]site_content', "contentType!='text/html'");
305 305
         $content .= '$c=&$this->contentTypes;';
306 306
         while ($doc = $modx->db->getRow($rs)) {
307
-            $content .= '$c[\'' . $doc['id'] . '\']=\'' . $doc['contentType'] . '\';';
307
+            $content .= '$c[\''.$doc['id'].'\']=\''.$doc['contentType'].'\';';
308 308
         }
309 309
 
310 310
         // WRITE Chunks to cache file
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             if ($modx->config['minifyphp_incache']) {
315 315
                 $doc['snippet'] = $this->php_strip_whitespace($doc['snippet']);
316 316
             }
317
-            $content .= '$c[\'' . $doc['name'] . '\']=\'' . ($doc['disabled'] ? '' : $this->escapeSingleQuotes($doc['snippet'])) . '\';';
317
+            $content .= '$c[\''.$doc['name'].'\']=\''.($doc['disabled'] ? '' : $this->escapeSingleQuotes($doc['snippet'])).'\';';
318 318
         }
319 319
 
320 320
         // WRITE snippets to cache file
@@ -325,18 +325,18 @@  discard block
 block discarded – undo
325 325
         while ($row = $modx->db->getRow($rs)) {
326 326
             $key = $row['name'];
327 327
             if ($row['disabled']) {
328
-                $content .= '$s[\'' . $key . '\']=\'return false;\';';
328
+                $content .= '$s[\''.$key.'\']=\'return false;\';';
329 329
             } else {
330 330
                 $value = trim($row['snippet']);
331 331
                 if ($modx->config['minifyphp_incache']) {
332 332
                     $value = $this->php_strip_whitespace($value);
333 333
                 }
334
-                $content .= '$s[\'' . $key . '\']=\'' . $this->escapeSingleQuotes($value) . '\';';
334
+                $content .= '$s[\''.$key.'\']=\''.$this->escapeSingleQuotes($value).'\';';
335 335
                 $properties = $modx->parseProperties($row['properties']);
336 336
                 $sharedproperties = $modx->parseProperties($row['sharedproperties']);
337 337
                 $properties = array_merge($sharedproperties, $properties);
338 338
                 if (0 < count($properties)) {
339
-                    $content .= '$s[\'' . $key . 'Props\']=\'' . $this->escapeSingleQuotes(json_encode($properties)) . '\';';
339
+                    $content .= '$s[\''.$key.'Props\']=\''.$this->escapeSingleQuotes(json_encode($properties)).'\';';
340 340
                 }
341 341
             }
342 342
         }
@@ -354,13 +354,13 @@  discard block
 block discarded – undo
354 354
             if ($modx->config['minifyphp_incache']) {
355 355
                 $value = $this->php_strip_whitespace($value);
356 356
             }
357
-            $content .= '$p[\'' . $key . '\']=\'' . $this->escapeSingleQuotes($value) . '\';';
357
+            $content .= '$p[\''.$key.'\']=\''.$this->escapeSingleQuotes($value).'\';';
358 358
             if ($row['properties'] != '' || $row['sharedproperties'] != '') {
359 359
                 $properties = $modx->parseProperties($row['properties']);
360 360
                 $sharedproperties = $modx->parseProperties($row['sharedproperties']);
361 361
                 $properties = array_merge($sharedproperties, $properties);
362 362
                 if (0 < count($properties)) {
363
-                    $content .= '$p[\'' . $key . 'Props\']=\'' . $this->escapeSingleQuotes(json_encode($properties)) . '\';';
363
+                    $content .= '$p[\''.$key.'Props\']=\''.$this->escapeSingleQuotes(json_encode($properties)).'\';';
364 364
                 }
365 365
             }
366 366
         }
@@ -383,14 +383,14 @@  discard block
 block discarded – undo
383 383
         }
384 384
         foreach ($events as $evtname => $pluginnames) {
385 385
             $events[$evtname] = $pluginnames;
386
-            $content .= '$e[\'' . $evtname . '\']=array(\'' . implode('\',\'',
387
-                    $this->escapeSingleQuotes($pluginnames)) . '\');';
386
+            $content .= '$e[\''.$evtname.'\']=array(\''.implode('\',\'',
387
+                    $this->escapeSingleQuotes($pluginnames)).'\');';
388 388
         }
389 389
 
390 390
         $content .= "\n";
391 391
 
392 392
         // close and write the file
393
-        $filename = $this->cachePath . 'siteCache.idx.php';
393
+        $filename = $this->cachePath.'siteCache.idx.php';
394 394
 
395 395
         // invoke OnBeforeCacheUpdate event
396 396
         if ($modx) {
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
             exit("Cannot write main MODX cache file! Make sure the assets/cache directory is writable!");
402 402
         }
403 403
 
404
-        if (!is_file($this->cachePath . '/.htaccess')) {
405
-            file_put_contents($this->cachePath . '/.htaccess', "order deny,allow\ndeny from all\n");
404
+        if (!is_file($this->cachePath.'/.htaccess')) {
405
+            file_put_contents($this->cachePath.'/.htaccess', "order deny,allow\ndeny from all\n");
406 406
         }
407 407
 
408 408
         // invoke OnCacheUpdate event
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 
425 425
         $source = trim($source);
426 426
         if (substr($source, 0, 5) !== '<?php') {
427
-            $source = '<?php ' . $source;
427
+            $source = '<?php '.$source;
428 428
         }
429 429
 
430 430
         $tokens = token_get_all($source);
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
             }
483 483
         }
484 484
         $source = preg_replace(array('@^<\?php@i', '|\s+|', '|<!--|', '|-->|', '|-->\s+<!--|'),
485
-            array('', ' ', "\n" . '<!--', '-->' . "\n", '-->' . "\n" . '<!--'), $_);
485
+            array('', ' ', "\n".'<!--', '-->'."\n", '-->'."\n".'<!--'), $_);
486 486
         $source = trim($source);
487 487
 
488 488
         return $source;
Please login to merge, or discard this patch.
manager/processors/user_documents_permissions.class.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         $role = $this->role;
37 37
 
38 38
         if ($role == 1) {
39
-            return true;  // administrator - grant all document permissions
39
+            return true; // administrator - grant all document permissions
40 40
         }
41 41
 
42 42
         if ($modx->config['use_udperms'] == 0 || $modx->config['use_udperms'] == "" || !isset($modx->config['use_udperms'])) {
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
             are private to the manager users will not be private to web users if the
64 64
             document group is not assigned to a web user group and visa versa.
65 65
          */
66
-        $permissionsok = false;  // set permissions to false
66
+        $permissionsok = false; // set permissions to false
67 67
 
68 68
         $rs = $modx->db->select(
69 69
             'count(DISTINCT sc.id)',
70 70
             "{$tblsc} AS sc 
71 71
 				LEFT JOIN {$tbldg} AS dg on dg.document = sc.id 
72 72
 				LEFT JOIN {$tbldgn} dgn ON dgn.id = dg.document_group",
73
-            "sc.id='{$this->document}' AND (" . (empty($docgrp) ? '' : "dg.document_group = " . $docgrp . " ||") . " sc.privatemgr = 0)"
73
+            "sc.id='{$this->document}' AND (".(empty($docgrp) ? '' : "dg.document_group = ".$docgrp." ||")." sc.privatemgr = 0)"
74 74
         );
75 75
         $limit = $modx->db->getValue($rs);
76 76
         if ($limit == 1) {
Please login to merge, or discard this patch.
manager/processors/duplicate_module.processor.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
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_module')) {
5
+if (!$modx->hasPermission('new_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
 
@@ -17,17 +17,17 @@  discard block
 block discarded – undo
17 17
  * @return string
18 18
  */
19 19
 function createGUID(){
20
-	srand((double)microtime()*1000000);
21
-	$r = rand() ;
22
-	$u = uniqid(getmypid() . $r . (double)microtime()*1000000,1);
23
-	$m = md5 ($u);
20
+	srand((double) microtime() * 1000000);
21
+	$r = rand();
22
+	$u = uniqid(getmypid().$r.(double) microtime() * 1000000, 1);
23
+	$m = md5($u);
24 24
 	return $m;
25 25
 }
26 26
 
27 27
 // count duplicates
28 28
 $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_modules'), "id='{$id}'"));
29 29
 $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_modules'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'"));
30
-if($count>=1) $count = ' '.($count+1);
30
+if ($count >= 1) $count = ' '.($count + 1);
31 31
 else $count = '';
32 32
 
33 33
 // duplicate module
@@ -72,5 +72,5 @@  discard block
 block discarded – undo
72 72
 $_SESSION['itemname'] = $name;
73 73
 
74 74
 // finish duplicating - redirect to new module
75
-$header="Location: index.php?r=2&a=108&id=$newid";
75
+$header = "Location: index.php?r=2&a=108&id=$newid";
76 76
 header($header);
Please login to merge, or discard this patch.
manager/processors/delete_content.processor.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@  discard block
 block discarded – undo
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('delete_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
 /*******ищем родителя чтобы к нему вернуться********/
15
-$content=$modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'"));
16
-$pid=($content['parent']==0?$id:$content['parent']);
15
+$content = $modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'"));
16
+$pid = ($content['parent'] == 0 ? $id : $content['parent']);
17 17
 
18 18
 /************ а заодно и путь возврата (сам путь внизу файла) **********/
19
-$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC';
20
-$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon';
21
-$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:'';
22
-$add_path=$sd.$sb.$pg;
19
+$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC';
20
+$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon';
21
+$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : '';
22
+$add_path = $sd.$sb.$pg;
23 23
 
24 24
 /*****************************/
25 25
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 $children = array();
28 28
 
29 29
 // check permissions on the document
30
-include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
30
+include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php";
31 31
 $udperms = new udperms();
32 32
 $udperms->user = $modx->getLoginUserID();
33 33
 $udperms->document = $id;
@@ -52,17 +52,17 @@  discard block
 block discarded – undo
52 52
     $parent = $modx->db->escape($parent);
53 53
     $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent={$parent} AND deleted=0");
54 54
         // the document has children documents, we'll need to delete those too
55
-        while ($childid=$modx->db->getValue($rs)) {
56
-            if ($childid==$site_start) {
55
+        while ($childid = $modx->db->getValue($rs)) {
56
+            if ($childid == $site_start) {
57 57
                 $modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site start' document, and cannot be deleted. Please assign another document as your 'Site start' document and try again.");
58 58
             }
59
-            if ($childid==$site_unavailable_page) {
59
+            if ($childid == $site_unavailable_page) {
60 60
                 $modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site unavailable page' document, and cannot be deleted. Please assign another document as your 'Site unavailable page' document and try again.");
61 61
             }
62
-            if ($childid==$error_page) {
62
+            if ($childid == $error_page) {
63 63
                 $modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site error page' document, and cannot be deleted. Please assign another document as your 'Site error page' document and try again.");
64 64
             }
65
-            if ($childid==$unauthorized_page) {
65
+            if ($childid == $unauthorized_page) {
66 66
                 $modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site unauthorized page' document, and cannot be deleted. Please assign another document as your 'Site unauthorized page' document and try again.");
67 67
             }
68 68
             $children[] = $childid;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
                             "children"=>$children
81 81
                         ));
82 82
 
83
-if (count($children)>0) {
83
+if (count($children) > 0) {
84 84
     $modx->db->update(
85 85
         array(
86 86
             'deleted'   => 1,
@@ -89,19 +89,19 @@  discard block
 block discarded – undo
89 89
         ), $modx->getFullTableName('site_content'), "id IN (".implode(", ", $children).")");
90 90
 }
91 91
 
92
-if ($site_start==$id) {
92
+if ($site_start == $id) {
93 93
     $modx->webAlertAndQuit("Document is 'Site start' and cannot be deleted!");
94 94
 }
95 95
 
96
-if ($site_unavailable_page==$id) {
96
+if ($site_unavailable_page == $id) {
97 97
     $modx->webAlertAndQuit("Document is used as the 'Site unavailable page' and cannot be deleted!");
98 98
 }
99 99
 
100
-if ($error_page==$id) {
100
+if ($error_page == $id) {
101 101
     $modx->webAlertAndQuit("Document is used as the 'Site error page' and cannot be deleted!");
102 102
 }
103 103
 
104
-if ($unauthorized_page==$id) {
104
+if ($unauthorized_page == $id) {
105 105
     $modx->webAlertAndQuit("Document is used as the 'Site unauthorized page' and cannot be deleted!");
106 106
 }
107 107
 
@@ -127,5 +127,5 @@  discard block
 block discarded – undo
127 127
 $modx->clearCache('full');
128 128
 
129 129
 // finished emptying cache - redirect
130
-$header="Location: index.php?a=3&id=$pid&r=1".$add_path;
130
+$header = "Location: index.php?a=3&id=$pid&r=1".$add_path;
131 131
 header($header);
Please login to merge, or discard this patch.
manager/processors/undelete_content.processor.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,44 +1,44 @@  discard block
 block discarded – undo
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('delete_document')) {
5
+if (!$modx->hasPermission('delete_document')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = isset($_REQUEST['id'])? (int)$_REQUEST['id'] : 0;
10
-if($id==0) {
9
+$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
10
+if ($id == 0) {
11 11
 	$modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 /************ webber ********/
15
-$content=$modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'"));
16
-$pid=($content['parent']==0?$id:$content['parent']);
15
+$content = $modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'"));
16
+$pid = ($content['parent'] == 0 ? $id : $content['parent']);
17 17
 
18 18
 /************** webber *************/
19
-$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC';
20
-$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon';
21
-$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:'';
22
-$add_path=$sd.$sb.$pg;
19
+$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC';
20
+$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon';
21
+$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : '';
22
+$add_path = $sd.$sb.$pg;
23 23
 
24 24
 /***********************************/
25 25
 
26 26
 
27 27
 // check permissions on the document
28
-include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
28
+include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php";
29 29
 $udperms = new udperms();
30 30
 $udperms->user = $modx->getLoginUserID();
31 31
 $udperms->document = $id;
32 32
 $udperms->role = $_SESSION['mgrRole'];
33 33
 
34
-if(!$udperms->checkPermissions()) {
34
+if (!$udperms->checkPermissions()) {
35 35
 	$modx->webAlertAndQuit($_lang["access_permission_denied"]);
36 36
 }
37 37
 
38 38
 // get the timestamp on which the document was deleted.
39 39
 $rs = $modx->db->select('deletedon', $modx->getFullTableName('site_content'), "id='{$id}' AND deleted=1");
40 40
 $deltime = $modx->db->getValue($rs);
41
-if(!$deltime) {
41
+if (!$deltime) {
42 42
 	$modx->webAlertAndQuit("Couldn't find document to determine it's date of deletion!");
43 43
 }
44 44
 
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 /**
48 48
  * @param int $parent
49 49
  */
50
-function getChildren($parent) {
50
+function getChildren($parent){
51 51
 
52 52
 	global $modx;
53 53
 	global $children;
54 54
 	global $deltime;
55 55
 
56
-	$rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int)$parent."' AND deleted=1 AND deletedon='".(int)$deltime."'");
56
+	$rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int) $parent."' AND deleted=1 AND deletedon='".(int) $deltime."'");
57 57
 		// the document has children documents, we'll need to delete those too
58
-		while ($row=$modx->db->getRow($rs)) {
58
+		while ($row = $modx->db->getRow($rs)) {
59 59
 			$children[] = $row['id'];
60 60
 			getChildren($row['id']);
61 61
 			//echo "Found childNode of parentNode $parent: ".$row['id']."<br />";
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
 getChildren($id);
66 66
 
67
-if(count($children)>0) {
67
+if (count($children) > 0) {
68 68
 	$modx->db->update(
69 69
 		array(
70 70
 			'deleted'   => 0,
@@ -93,5 +93,5 @@  discard block
 block discarded – undo
93 93
 $modx->clearCache('full');
94 94
 
95 95
 // finished emptying cache - redirect
96
-$header="Location: index.php?a=3&id=$pid&r=1".$add_path;
96
+$header = "Location: index.php?a=3&id=$pid&r=1".$add_path;
97 97
 header($header);
Please login to merge, or discard this patch.
manager/processors/remove_installer.processor.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,15 +12,15 @@  discard block
 block discarded – undo
12 12
  *
13 13
  */
14 14
 
15
-$msg ='';
15
+$msg = '';
16 16
 $pth = dirname(dirname(dirname(__FILE__)))."/install/";
17
-$pth = str_replace("\\","/",$pth);
18
-if(isset($_GET["rminstall"])) {
19
-	if(is_dir($pth)) {
20
-		if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder";
17
+$pth = str_replace("\\", "/", $pth);
18
+if (isset($_GET["rminstall"])) {
19
+	if (is_dir($pth)) {
20
+		if (!rmdirRecursive($pth)) $msg = "An error occured while attempting to remove the install folder";
21 21
 	}
22 22
 }
23
-if($msg) echo "<script>alert('".addslashes($msg)."');</script>";
23
+if ($msg) echo "<script>alert('".addslashes($msg)."');</script>";
24 24
 echo "<script>window.location='../index.php?a=2';</script>";
25 25
 
26 26
 /**
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
  * @param bool $followLinks
31 31
  * @return bool
32 32
  */
33
-function rmdirRecursive($path, $followLinks=false) {
34
-   $dir = opendir($path) ;
33
+function rmdirRecursive($path, $followLinks = false){
34
+   $dir = opendir($path);
35 35
    while ($entry = readdir($dir)) {
36 36
 	   if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) {
37
-		   @unlink( "$path/$entry" );
37
+		   @unlink("$path/$entry");
38 38
 	   }
39
-	   elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') {
39
+	   elseif (is_dir("$path/$entry") && $entry != '.' && $entry != '..') {
40 40
 		   rmdirRecursive("$path/$entry"); // recursive
41 41
 	   }
42 42
    }
Please login to merge, or discard this patch.
manager/processors/duplicate_content.processor.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 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
 	global $modx, $_lang;
47 47
 
48 48
 	// invoke OnBeforeDocDuplicate event
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 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);
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
manager/processors/move_document.processor.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
42 42
  * @param int $currDocID
43 43
  * @return array
44 44
  */
45
-function allChildren($currDocID) {
45
+function allChildren($currDocID){
46 46
 	global $modx;
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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!");
Please login to merge, or discard this patch.