Completed
Pull Request — develop (#545)
by Agel_Nash
05:36
created
manager/processors/save_user.processor.php 3 patches
Indentation   +368 added lines, -368 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3
-	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
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_user')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $modx->loadExtension('phpass');
@@ -45,134 +45,134 @@  discard block
 block discarded – undo
45 45
 
46 46
 // verify password
47 47
 if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
48
-	webAlertAndQuit("Password typed is mismatched");
48
+    webAlertAndQuit("Password typed is mismatched");
49 49
 }
50 50
 
51 51
 // verify email
52 52
 if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
53
-	webAlertAndQuit("E-mail address doesn't seem to be valid!");
53
+    webAlertAndQuit("E-mail address doesn't seem to be valid!");
54 54
 }
55 55
 
56 56
 // verify admin security
57 57
 if($_SESSION['mgrRole'] != 1) {
58
-	// Check to see if user tried to spoof a "1" (admin) role
59
-	if(!$modx->hasPermission('save_role')) {
60
-		webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!");
61
-	}
62
-	// Verify that the user being edited wasn't an admin and the user ID got spoofed
63
-	$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1");
64
-	$limit = $modx->db->getValue($rs);
65
-	if($limit > 0) {
66
-		webAlertAndQuit("You cannot alter an administrative user.");
67
-	}
58
+    // Check to see if user tried to spoof a "1" (admin) role
59
+    if(!$modx->hasPermission('save_role')) {
60
+        webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!");
61
+    }
62
+    // Verify that the user being edited wasn't an admin and the user ID got spoofed
63
+    $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1");
64
+    $limit = $modx->db->getValue($rs);
65
+    if($limit > 0) {
66
+        webAlertAndQuit("You cannot alter an administrative user.");
67
+    }
68 68
 
69 69
 }
70 70
 
71 71
 switch($input['mode']) {
72
-	case '11' : // new user
73
-		// check if this user name already exist
74
-		$rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername)));
75
-		$limit = $modx->db->getValue($rs);
76
-		if($limit > 0) {
77
-			webAlertAndQuit("User name is already in use!");
78
-		}
79
-
80
-		// check if the email address already exist
81
-		$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id));
82
-		$limit = $modx->db->getValue($rs);
83
-		if($limit > 0) {
84
-			webAlertAndQuit("Email is already in use!");
85
-		}
86
-
87
-		// generate a new password for this user
88
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
89
-			if(strlen($specifiedpassword) < 6) {
90
-				webAlertAndQuit("Password is too short!");
91
-			} else {
92
-				$newpassword = $specifiedpassword;
93
-			}
94
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
95
-			webAlertAndQuit("You didn't specify a password for this user!");
96
-		} elseif($passwordgenmethod == 'g') {
97
-			$newpassword = generate_password(8);
98
-		} else {
99
-			webAlertAndQuit("No password generation method specified!");
100
-		}
101
-
102
-		// invoke OnBeforeUserFormSave event
103
-		$modx->invokeEvent("OnBeforeUserFormSave", array(
104
-			"mode" => "new",
105
-		));
106
-
107
-		// create the user account
108
-		$internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users);
109
-
110
-		$field = array();
111
-		$field['password'] = $modx->phpass->HashPassword($newpassword);
112
-		$modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'");
113
-
114
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
115
-		$field = $modx->db->escape($field);
116
-		$modx->db->insert($field, $tbl_user_attributes);
117
-
118
-		// Save user settings
119
-		saveUserSettings($internalKey);
120
-
121
-		// invoke OnManagerSaveUser event
122
-		$modx->invokeEvent("OnManagerSaveUser", array(
123
-			"mode" => "new",
124
-			"userid" => $internalKey,
125
-			"username" => $newusername,
126
-			"userpassword" => $newpassword,
127
-			"useremail" => $email,
128
-			"userfullname" => $fullname,
129
-			"userroleid" => $role
130
-		));
131
-
132
-		// invoke OnUserFormSave event
133
-		$modx->invokeEvent("OnUserFormSave", array(
134
-			"mode" => "new",
135
-			"id" => $internalKey
136
-		));
137
-
138
-		// Set the item name for logger
139
-		$_SESSION['itemname'] = $newusername;
140
-
141
-		/*******************************************************************************/
142
-		// put the user in the user_groups he/ she should be in
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++) {
147
-					$f = array();
148
-					$f['user_group'] = (int)$user_groups[$i];
149
-					$f['member'] = $internalKey;
150
-					$modx->db->insert($f, $tbl_member_groups);
151
-				}
152
-			}
153
-		}
154
-		// end of user_groups stuff!
155
-
156
-		if($passwordnotifymethod == 'e') {
157
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
158
-			if($input['stay'] != '') {
159
-				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
160
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
161
-				header($header);
162
-			} else {
163
-				$header = "Location: index.php?a=75&r=2";
164
-				header($header);
165
-			}
166
-		} else {
167
-			if($input['stay'] != '') {
168
-				$a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
169
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
170
-			} else {
171
-				$stayUrl = "index.php?a=75&r=2";
172
-			}
173
-
174
-			include_once "header.inc.php";
175
-			?>
72
+    case '11' : // new user
73
+        // check if this user name already exist
74
+        $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername)));
75
+        $limit = $modx->db->getValue($rs);
76
+        if($limit > 0) {
77
+            webAlertAndQuit("User name is already in use!");
78
+        }
79
+
80
+        // check if the email address already exist
81
+        $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id));
82
+        $limit = $modx->db->getValue($rs);
83
+        if($limit > 0) {
84
+            webAlertAndQuit("Email is already in use!");
85
+        }
86
+
87
+        // generate a new password for this user
88
+        if($specifiedpassword != "" && $passwordgenmethod == "spec") {
89
+            if(strlen($specifiedpassword) < 6) {
90
+                webAlertAndQuit("Password is too short!");
91
+            } else {
92
+                $newpassword = $specifiedpassword;
93
+            }
94
+        } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
95
+            webAlertAndQuit("You didn't specify a password for this user!");
96
+        } elseif($passwordgenmethod == 'g') {
97
+            $newpassword = generate_password(8);
98
+        } else {
99
+            webAlertAndQuit("No password generation method specified!");
100
+        }
101
+
102
+        // invoke OnBeforeUserFormSave event
103
+        $modx->invokeEvent("OnBeforeUserFormSave", array(
104
+            "mode" => "new",
105
+        ));
106
+
107
+        // create the user account
108
+        $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users);
109
+
110
+        $field = array();
111
+        $field['password'] = $modx->phpass->HashPassword($newpassword);
112
+        $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'");
113
+
114
+        $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
115
+        $field = $modx->db->escape($field);
116
+        $modx->db->insert($field, $tbl_user_attributes);
117
+
118
+        // Save user settings
119
+        saveUserSettings($internalKey);
120
+
121
+        // invoke OnManagerSaveUser event
122
+        $modx->invokeEvent("OnManagerSaveUser", array(
123
+            "mode" => "new",
124
+            "userid" => $internalKey,
125
+            "username" => $newusername,
126
+            "userpassword" => $newpassword,
127
+            "useremail" => $email,
128
+            "userfullname" => $fullname,
129
+            "userroleid" => $role
130
+        ));
131
+
132
+        // invoke OnUserFormSave event
133
+        $modx->invokeEvent("OnUserFormSave", array(
134
+            "mode" => "new",
135
+            "id" => $internalKey
136
+        ));
137
+
138
+        // Set the item name for logger
139
+        $_SESSION['itemname'] = $newusername;
140
+
141
+        /*******************************************************************************/
142
+        // put the user in the user_groups he/ she should be in
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++) {
147
+                    $f = array();
148
+                    $f['user_group'] = (int)$user_groups[$i];
149
+                    $f['member'] = $internalKey;
150
+                    $modx->db->insert($f, $tbl_member_groups);
151
+                }
152
+            }
153
+        }
154
+        // end of user_groups stuff!
155
+
156
+        if($passwordnotifymethod == 'e') {
157
+            sendMailMessage($email, $newusername, $newpassword, $fullname);
158
+            if($input['stay'] != '') {
159
+                $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
160
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
161
+                header($header);
162
+            } else {
163
+                $header = "Location: index.php?a=75&r=2";
164
+                header($header);
165
+            }
166
+        } else {
167
+            if($input['stay'] != '') {
168
+                $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11";
169
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
170
+            } else {
171
+                $stayUrl = "index.php?a=75&r=2";
172
+            }
173
+
174
+            include_once "header.inc.php";
175
+            ?>
176 176
 
177 177
 			<h1><?php echo $_lang['user_title']; ?></h1>
178 178
 
@@ -194,125 +194,125 @@  discard block
 block discarded – undo
194 194
 			</div>
195 195
 			<?php
196 196
 
197
-			include_once "footer.inc.php";
198
-		}
199
-		break;
200
-	case '12' : // edit user
201
-		// generate a new password for this user
202
-		if($genpassword == 1) {
203
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
204
-				if(strlen($specifiedpassword) < 6) {
205
-					webAlertAndQuit("Password is too short!");
206
-				} else {
207
-					$newpassword = $specifiedpassword;
208
-				}
209
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
210
-				webAlertAndQuit("You didn't specify a password for this user!");
211
-			} elseif($passwordgenmethod == 'g') {
212
-				$newpassword = generate_password(8);
213
-			} else {
214
-				webAlertAndQuit("No password generation method specified!");
215
-			}
216
-		}
217
-		if($passwordnotifymethod == 'e') {
218
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
219
-		}
220
-
221
-		// check if the username already exist
222
-		$rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id));
223
-		$limit = $modx->db->getValue($rs);
224
-		if($limit > 0) {
225
-			webAlertAndQuit("User name is already in use!");
226
-		}
227
-
228
-		// check if the email address already exists
229
-		$rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id));
230
-		$limit = $modx->db->getValue($rs);
231
-		if($limit > 0) {
232
-			webAlertAndQuit("Email is already in use!");
233
-		}
234
-
235
-		// invoke OnBeforeUserFormSave event
236
-		$modx->invokeEvent("OnBeforeUserFormSave", array(
237
-			"mode" => "upd",
238
-			"id" => $id
239
-		));
240
-
241
-		// update user name and password
242
-		$field = array();
243
-		$field['username'] = $modx->db->escape($newusername);
244
-		if($genpassword == 1) {
245
-			$field['password'] = $modx->phpass->HashPassword($newpassword);
246
-		}
247
-		$modx->db->update($field, $tbl_manager_users, "id='{$id}'");
248
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
249
-		$field = $modx->db->escape($field);
250
-		$modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'");
251
-
252
-		// Save user settings
253
-		saveUserSettings($id);
254
-
255
-		// Set the item name for logger
256
-		$_SESSION['itemname'] = $newusername;
257
-
258
-		// invoke OnManagerSaveUser event
259
-		$modx->invokeEvent("OnManagerSaveUser", array(
260
-			"mode" => "upd",
261
-			"userid" => $id,
262
-			"username" => $newusername,
263
-			"userpassword" => $newpassword,
264
-			"useremail" => $email,
265
-			"userfullname" => $fullname,
266
-			"userroleid" => $role,
267
-			"oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
268
-			"olduseremail" => (($oldemail != $email) ? $oldemail : "")
269
-		));
270
-
271
-		// invoke OnManagerChangePassword event
272
-		if($genpassword == 1) {
273
-			$modx->invokeEvent("OnManagerChangePassword", array(
274
-				"userid" => $id,
275
-				"username" => $newusername,
276
-				"userpassword" => $newpassword
277
-			));
278
-		}
279
-
280
-		// invoke OnUserFormSave event
281
-		$modx->invokeEvent("OnUserFormSave", array(
282
-			"mode" => "upd",
283
-			"id" => $id
284
-		));
285
-
286
-		/*******************************************************************************/
287
-		// put the user in the user_groups he/ she should be in
288
-		// first, check that up_perms are switched on!
289
-		if($use_udperms == 1) {
290
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
291
-			$modx->db->delete($tbl_member_groups, "member='{$id}'");
292
-			if(!empty($user_groups)) {
293
-				for($i = 0; $i < count($user_groups); $i++) {
294
-					$field = array();
295
-					$field['user_group'] = (int)$user_groups[$i];
296
-					$field['member'] = $id;
297
-					$modx->db->insert($field, $tbl_member_groups);
298
-				}
299
-			}
300
-		}
301
-		// end of user_groups stuff!
302
-		/*******************************************************************************/
303
-		if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
304
-			$modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
305
-		}
306
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
307
-			if($input['stay'] != '') {
308
-				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
309
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
310
-			} else {
311
-				$stayUrl = "index.php?a=75&r=2";
312
-			}
313
-
314
-			include_once "header.inc.php";
315
-			?>
197
+            include_once "footer.inc.php";
198
+        }
199
+        break;
200
+    case '12' : // edit user
201
+        // generate a new password for this user
202
+        if($genpassword == 1) {
203
+            if($specifiedpassword != "" && $passwordgenmethod == "spec") {
204
+                if(strlen($specifiedpassword) < 6) {
205
+                    webAlertAndQuit("Password is too short!");
206
+                } else {
207
+                    $newpassword = $specifiedpassword;
208
+                }
209
+            } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
210
+                webAlertAndQuit("You didn't specify a password for this user!");
211
+            } elseif($passwordgenmethod == 'g') {
212
+                $newpassword = generate_password(8);
213
+            } else {
214
+                webAlertAndQuit("No password generation method specified!");
215
+            }
216
+        }
217
+        if($passwordnotifymethod == 'e') {
218
+            sendMailMessage($email, $newusername, $newpassword, $fullname);
219
+        }
220
+
221
+        // check if the username already exist
222
+        $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id));
223
+        $limit = $modx->db->getValue($rs);
224
+        if($limit > 0) {
225
+            webAlertAndQuit("User name is already in use!");
226
+        }
227
+
228
+        // check if the email address already exists
229
+        $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id));
230
+        $limit = $modx->db->getValue($rs);
231
+        if($limit > 0) {
232
+            webAlertAndQuit("Email is already in use!");
233
+        }
234
+
235
+        // invoke OnBeforeUserFormSave event
236
+        $modx->invokeEvent("OnBeforeUserFormSave", array(
237
+            "mode" => "upd",
238
+            "id" => $id
239
+        ));
240
+
241
+        // update user name and password
242
+        $field = array();
243
+        $field['username'] = $modx->db->escape($newusername);
244
+        if($genpassword == 1) {
245
+            $field['password'] = $modx->phpass->HashPassword($newpassword);
246
+        }
247
+        $modx->db->update($field, $tbl_manager_users, "id='{$id}'");
248
+        $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
249
+        $field = $modx->db->escape($field);
250
+        $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'");
251
+
252
+        // Save user settings
253
+        saveUserSettings($id);
254
+
255
+        // Set the item name for logger
256
+        $_SESSION['itemname'] = $newusername;
257
+
258
+        // invoke OnManagerSaveUser event
259
+        $modx->invokeEvent("OnManagerSaveUser", array(
260
+            "mode" => "upd",
261
+            "userid" => $id,
262
+            "username" => $newusername,
263
+            "userpassword" => $newpassword,
264
+            "useremail" => $email,
265
+            "userfullname" => $fullname,
266
+            "userroleid" => $role,
267
+            "oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
268
+            "olduseremail" => (($oldemail != $email) ? $oldemail : "")
269
+        ));
270
+
271
+        // invoke OnManagerChangePassword event
272
+        if($genpassword == 1) {
273
+            $modx->invokeEvent("OnManagerChangePassword", array(
274
+                "userid" => $id,
275
+                "username" => $newusername,
276
+                "userpassword" => $newpassword
277
+            ));
278
+        }
279
+
280
+        // invoke OnUserFormSave event
281
+        $modx->invokeEvent("OnUserFormSave", array(
282
+            "mode" => "upd",
283
+            "id" => $id
284
+        ));
285
+
286
+        /*******************************************************************************/
287
+        // put the user in the user_groups he/ she should be in
288
+        // first, check that up_perms are switched on!
289
+        if($use_udperms == 1) {
290
+            // as this is an existing user, delete his/ her entries in the groups before saving the new groups
291
+            $modx->db->delete($tbl_member_groups, "member='{$id}'");
292
+            if(!empty($user_groups)) {
293
+                for($i = 0; $i < count($user_groups); $i++) {
294
+                    $field = array();
295
+                    $field['user_group'] = (int)$user_groups[$i];
296
+                    $field['member'] = $id;
297
+                    $modx->db->insert($field, $tbl_member_groups);
298
+                }
299
+            }
300
+        }
301
+        // end of user_groups stuff!
302
+        /*******************************************************************************/
303
+        if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) {
304
+            $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";');
305
+        }
306
+        if($genpassword == 1 && $passwordnotifymethod == 's') {
307
+            if($input['stay'] != '') {
308
+                $a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
309
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
310
+            } else {
311
+                $stayUrl = "index.php?a=75&r=2";
312
+            }
313
+
314
+            include_once "header.inc.php";
315
+            ?>
316 316
 
317 317
 			<h1><?php echo $_lang['user_title']; ?></h1>
318 318
 
@@ -332,20 +332,20 @@  discard block
 block discarded – undo
332 332
 			</div>
333 333
 			<?php
334 334
 
335
-			include_once "footer.inc.php";
336
-		} else {
337
-			if($input['stay'] != '') {
338
-				$a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
339
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
340
-				header($header);
341
-			} else {
342
-				$header = "Location: index.php?a=75&r=2";
343
-				header($header);
344
-			}
345
-		}
346
-		break;
347
-	default:
348
-		webAlertAndQuit("No operation set in request.");
335
+            include_once "footer.inc.php";
336
+        } else {
337
+            if($input['stay'] != '') {
338
+                $a = ($input['stay'] == '2') ? "12&id={$id}" : "11";
339
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
340
+                header($header);
341
+            } else {
342
+                $header = "Location: index.php?a=75&r=2";
343
+                header($header);
344
+            }
345
+        }
346
+        break;
347
+    default:
348
+        webAlertAndQuit("No operation set in request.");
349 349
 }
350 350
 
351 351
 /**
@@ -357,31 +357,31 @@  discard block
 block discarded – undo
357 357
  * @param string $ufn
358 358
  */
359 359
 function sendMailMessage($email, $uid, $pwd, $ufn) {
360
-	$modx = DocumentParser::getInstance(); global $_lang, $signupemail_message;
361
-	global $emailsubject, $emailsender;
362
-	global $site_name;
363
-	$manager_url = MODX_MANAGER_URL;
364
-	$message = sprintf($signupemail_message, $uid, $pwd); // use old method
365
-	// replace placeholders
366
-	$message = str_replace("[+uid+]", $uid, $message);
367
-	$message = str_replace("[+pwd+]", $pwd, $message);
368
-	$message = str_replace("[+ufn+]", $ufn, $message);
369
-	$message = str_replace("[+sname+]", $site_name, $message);
370
-	$message = str_replace("[+saddr+]", $emailsender, $message);
371
-	$message = str_replace("[+semail+]", $emailsender, $message);
372
-	$message = str_replace("[+surl+]", $manager_url, $message);
373
-
374
-	$param = array();
375
-	$param['from'] = "{$site_name}<{$emailsender}>";
376
-	$param['subject'] = $emailsubject;
377
-	$param['body'] = $message;
378
-	$param['to'] = $email;
379
-	$param['type'] = 'text';
380
-	$rs = $modx->sendmail($param);
381
-	if(!$rs) {
382
-		$modx->manager->saveFormValues();
383
-		$modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
384
-	}
360
+    $modx = DocumentParser::getInstance(); global $_lang, $signupemail_message;
361
+    global $emailsubject, $emailsender;
362
+    global $site_name;
363
+    $manager_url = MODX_MANAGER_URL;
364
+    $message = sprintf($signupemail_message, $uid, $pwd); // use old method
365
+    // replace placeholders
366
+    $message = str_replace("[+uid+]", $uid, $message);
367
+    $message = str_replace("[+pwd+]", $pwd, $message);
368
+    $message = str_replace("[+ufn+]", $ufn, $message);
369
+    $message = str_replace("[+sname+]", $site_name, $message);
370
+    $message = str_replace("[+saddr+]", $emailsender, $message);
371
+    $message = str_replace("[+semail+]", $emailsender, $message);
372
+    $message = str_replace("[+surl+]", $manager_url, $message);
373
+
374
+    $param = array();
375
+    $param['from'] = "{$site_name}<{$emailsender}>";
376
+    $param['subject'] = $emailsubject;
377
+    $param['body'] = $message;
378
+    $param['to'] = $email;
379
+    $param['type'] = 'text';
380
+    $rs = $modx->sendmail($param);
381
+    if(!$rs) {
382
+        $modx->manager->saveFormValues();
383
+        $modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
384
+    }
385 385
 }
386 386
 
387 387
 /**
@@ -390,86 +390,86 @@  discard block
 block discarded – undo
390 390
  * @param int $id
391 391
  */
392 392
 function saveUserSettings($id) {
393
-	$modx = DocumentParser::getInstance();
394
-	$tbl_user_settings = $modx->getFullTableName('user_settings');
395
-
396
-	$ignore = array(
397
-		'id',
398
-		'oldusername',
399
-		'oldemail',
400
-		'newusername',
401
-		'fullname',
402
-		'newpassword',
403
-		'newpasswordcheck',
404
-		'passwordgenmethod',
405
-		'passwordnotifymethod',
406
-		'specifiedpassword',
407
-		'confirmpassword',
408
-		'email',
409
-		'phone',
410
-		'mobilephone',
411
-		'fax',
412
-		'dob',
413
-		'country',
414
-		'street',
415
-		'city',
416
-		'state',
417
-		'zip',
418
-		'gender',
419
-		'photo',
420
-		'comment',
421
-		'role',
422
-		'failedlogincount',
423
-		'blocked',
424
-		'blockeduntil',
425
-		'blockedafter',
426
-		'user_groups',
427
-		'mode',
428
-		'blockedmode',
429
-		'stay',
430
-		'save',
431
-		'theme_refresher'
432
-	);
433
-
434
-	// determine which settings can be saved blank (based on 'default_{settingname}' POST checkbox values)
435
-	$defaults = array(
436
-		'upload_images',
437
-		'upload_media',
438
-		'upload_flash',
439
-		'upload_files'
440
-	);
441
-
442
-	// get user setting field names
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))) {
446
-			continue;
447
-		} // ignore blacklist and empties
448
-		$settings[$n] = $v; // this value should be saved
449
-	}
450
-
451
-	foreach($defaults as $k) {
452
-		if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') {
453
-			unset($settings[$k]);
454
-		}
455
-		unset($settings['default_' . $k]);
456
-	}
457
-
458
-	$modx->db->delete($tbl_user_settings, "user='{$id}'");
459
-
460
-	foreach($settings as $n => $vl) {
461
-		if(is_array($vl)) {
462
-			$vl = implode(",", $vl);
463
-		}
464
-		if($vl != '') {
465
-			$f = array();
466
-			$f['user'] = $id;
467
-			$f['setting_name'] = $n;
468
-			$f['setting_value'] = $vl;
469
-			$f = $modx->db->escape($f);
470
-			$modx->db->insert($f, $tbl_user_settings);
471
-		}
472
-	}
393
+    $modx = DocumentParser::getInstance();
394
+    $tbl_user_settings = $modx->getFullTableName('user_settings');
395
+
396
+    $ignore = array(
397
+        'id',
398
+        'oldusername',
399
+        'oldemail',
400
+        'newusername',
401
+        'fullname',
402
+        'newpassword',
403
+        'newpasswordcheck',
404
+        'passwordgenmethod',
405
+        'passwordnotifymethod',
406
+        'specifiedpassword',
407
+        'confirmpassword',
408
+        'email',
409
+        'phone',
410
+        'mobilephone',
411
+        'fax',
412
+        'dob',
413
+        'country',
414
+        'street',
415
+        'city',
416
+        'state',
417
+        'zip',
418
+        'gender',
419
+        'photo',
420
+        'comment',
421
+        'role',
422
+        'failedlogincount',
423
+        'blocked',
424
+        'blockeduntil',
425
+        'blockedafter',
426
+        'user_groups',
427
+        'mode',
428
+        'blockedmode',
429
+        'stay',
430
+        'save',
431
+        'theme_refresher'
432
+    );
433
+
434
+    // determine which settings can be saved blank (based on 'default_{settingname}' POST checkbox values)
435
+    $defaults = array(
436
+        'upload_images',
437
+        'upload_media',
438
+        'upload_flash',
439
+        'upload_files'
440
+    );
441
+
442
+    // get user setting field names
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))) {
446
+            continue;
447
+        } // ignore blacklist and empties
448
+        $settings[$n] = $v; // this value should be saved
449
+    }
450
+
451
+    foreach($defaults as $k) {
452
+        if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') {
453
+            unset($settings[$k]);
454
+        }
455
+        unset($settings['default_' . $k]);
456
+    }
457
+
458
+    $modx->db->delete($tbl_user_settings, "user='{$id}'");
459
+
460
+    foreach($settings as $n => $vl) {
461
+        if(is_array($vl)) {
462
+            $vl = implode(",", $vl);
463
+        }
464
+        if($vl != '') {
465
+            $f = array();
466
+            $f['user'] = $id;
467
+            $f['setting_name'] = $n;
468
+            $f['setting_value'] = $vl;
469
+            $f = $modx->db->escape($f);
470
+            $modx->db->insert($f, $tbl_user_settings);
471
+        }
472
+    }
473 473
 }
474 474
 
475 475
 /**
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
  * @param $msg
479 479
  */
480 480
 function webAlertAndQuit($msg) {
481
-	global $id, $modx;
482
-	$mode = $_POST['mode'];
483
-	$modx->manager->saveFormValues($mode);
484
-	$modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : ''));
481
+    global $id, $modx;
482
+    $mode = $_POST['mode'];
483
+    $modx->manager->saveFormValues($mode);
484
+    $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : ''));
485 485
 }
486 486
 
487 487
 /**
@@ -491,12 +491,12 @@  discard block
 block discarded – undo
491 491
  * @return string
492 492
  */
493 493
 function generate_password($length = 10) {
494
-	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
495
-	$ps_len = strlen($allowable_characters);
496
-	mt_srand((double) microtime() * 1000000);
497
-	$pass = "";
498
-	for($i = 0; $i < $length; $i++) {
499
-		$pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
500
-	}
501
-	return $pass;
494
+    $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
495
+    $ps_len = strlen($allowable_characters);
496
+    mt_srand((double) microtime() * 1000000);
497
+    $pass = "";
498
+    for($i = 0; $i < $length; $i++) {
499
+        $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
500
+    }
501
+    return $pass;
502 502
 }
Please login to merge, or discard this 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
 	$modx = DocumentParser::getInstance(); global $_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
 	$modx = DocumentParser::getInstance();
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.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -356,7 +356,8 @@  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 361
 	$modx = DocumentParser::getInstance(); global $_lang, $signupemail_message;
361 362
 	global $emailsubject, $emailsender;
362 363
 	global $site_name;
@@ -389,7 +390,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
manager/processors/execute_module.processor.php 3 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -3,51 +3,51 @@  discard block
 block discarded – undo
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('exec_module')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10 10
 if($id==0) {
11
-	$modx->webAlertAndQuit($_lang["error_no_id"]);
11
+    $modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 // check if user has access permission, except admins
15 15
 if($_SESSION['mgrRole']!=1){
16
-	$rs = $modx->db->select(
17
-		'sma.usergroup,mg.member',
18
-		$modx->getFullTableName("site_module_access")." sma
16
+    $rs = $modx->db->select(
17
+        'sma.usergroup,mg.member',
18
+        $modx->getFullTableName("site_module_access")." sma
19 19
 			LEFT JOIN ".$modx->getFullTableName("member_groups")." mg ON mg.user_group = sma.usergroup AND member='".$modx->getLoginUserID()."'",
20
-		"sma.module = '{$id}'"
21
-		);
22
-	//initialize permission to -1, if it stays -1 no permissions
23
-	//attached so permission granted
24
-	$permissionAccessInt = -1;
20
+        "sma.module = '{$id}'"
21
+        );
22
+    //initialize permission to -1, if it stays -1 no permissions
23
+    //attached so permission granted
24
+    $permissionAccessInt = -1;
25 25
 
26
-	while ($row = $modx->db->getRow($rs)) {
27
-		if($row["usergroup"] && $row["member"]) {
28
-			//if there are permissions and this member has permission, ofcourse
29
-			//this is granted
30
-			$permissionAccessInt = 1;
31
-		} elseif ($permissionAccessInt==-1) {
32
-			//if there are permissions but this member has no permission and the
33
-			//variable was still in init state we set permission to 0; no permissions
34
-			$permissionAccessInt = 0;
35
-		}
36
-	}
26
+    while ($row = $modx->db->getRow($rs)) {
27
+        if($row["usergroup"] && $row["member"]) {
28
+            //if there are permissions and this member has permission, ofcourse
29
+            //this is granted
30
+            $permissionAccessInt = 1;
31
+        } elseif ($permissionAccessInt==-1) {
32
+            //if there are permissions but this member has no permission and the
33
+            //variable was still in init state we set permission to 0; no permissions
34
+            $permissionAccessInt = 0;
35
+        }
36
+    }
37 37
 
38
-	if($permissionAccessInt==0) {
39
-		$modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106");
40
-	}
38
+    if($permissionAccessInt==0) {
39
+        $modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106");
40
+    }
41 41
 }
42 42
 
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 46
 if(!$content) {
47
-	$modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106");
47
+    $modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106");
48 48
 }
49 49
 if($content['disabled']) {
50
-	$modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106");
50
+    $modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106");
51 51
 }
52 52
 
53 53
 // Set the item name for logger
@@ -71,38 +71,38 @@  discard block
 block discarded – undo
71 71
  * @return string
72 72
  */
73 73
 function evalModule($moduleCode,$params){
74
-	$modx = DocumentParser::getInstance();
75
-	$modx->event->params = &$params; // store params inside event object
76
-	if(is_array($params)) {
77
-		extract($params, EXTR_SKIP);
78
-	}
79
-	ob_start();
80
-	$mod = eval($moduleCode);
81
-	$msg = ob_get_contents();
82
-	ob_end_clean();
83
-	if (isset($php_errormsg))
84
-	{
85
-		$error_info = error_get_last();
74
+    $modx = DocumentParser::getInstance();
75
+    $modx->event->params = &$params; // store params inside event object
76
+    if(is_array($params)) {
77
+        extract($params, EXTR_SKIP);
78
+    }
79
+    ob_start();
80
+    $mod = eval($moduleCode);
81
+    $msg = ob_get_contents();
82
+    ob_end_clean();
83
+    if (isset($php_errormsg))
84
+    {
85
+        $error_info = error_get_last();
86 86
         switch($error_info['type'])
87 87
         {
88
-        	case E_NOTICE :
89
-        		$error_level = 1;
90
-        	case E_USER_NOTICE :
91
-        		break;
92
-        	case E_DEPRECATED :
93
-        	case E_USER_DEPRECATED :
94
-        	case E_STRICT :
95
-        		$error_level = 2;
96
-        		break;
97
-        	default:
98
-        		$error_level = 99;
88
+            case E_NOTICE :
89
+                $error_level = 1;
90
+            case E_USER_NOTICE :
91
+                break;
92
+            case E_DEPRECATED :
93
+            case E_USER_DEPRECATED :
94
+            case E_STRICT :
95
+                $error_level = 2;
96
+                break;
97
+            default:
98
+                $error_level = 99;
99
+        }
100
+        if($modx->config['error_reporting']==='99' || 2<$error_level)
101
+        {
102
+            $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg);
103
+            $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>");
99 104
         }
100
-		if($modx->config['error_reporting']==='99' || 2<$error_level)
101
-		{
102
-			$modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg);
103
-			$modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>");
104
-		}
105
-	}
106
-	unset($modx->event->params);
107
-	return $mod.$msg;
105
+    }
106
+    unset($modx->event->params);
107
+    return $mod.$msg;
108 108
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  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('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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 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
 	$modx = DocumentParser::getInstance();
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this 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
 	$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
 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/cache_sync.class.processor.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,7 +79,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
                             $_ .= ' ';
Please login to merge, or discard this patch.
manager/processors/undelete_content.processor.php 3 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -3,12 +3,12 @@  discard block
 block discarded – undo
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
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $id = isset($_REQUEST['id'])? (int)$_REQUEST['id'] : 0;
10 10
 if($id==0) {
11
-	$modx->webAlertAndQuit($_lang["error_no_id"]);
11
+    $modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 /************ webber ********/
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 $udperms->role = $_SESSION['mgrRole'];
33 33
 
34 34
 if(!$udperms->checkPermissions()) {
35
-	$modx->webAlertAndQuit($_lang["access_permission_denied"]);
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 41
 if(!$deltime) {
42
-	$modx->webAlertAndQuit("Couldn't find document to determine it's date of deletion!");
42
+    $modx->webAlertAndQuit("Couldn't find document to determine it's date of deletion!");
43 43
 }
44 44
 
45 45
 $children = array();
@@ -49,36 +49,36 @@  discard block
 block discarded – undo
49 49
  */
50 50
 function getChildren($parent) {
51 51
 
52
-	$modx = DocumentParser::getInstance();
53
-	global $children;
54
-	global $deltime;
55
-
56
-	$rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int)$parent."' AND deleted=1 AND deletedon='".(int)$deltime."'");
57
-		// the document has children documents, we'll need to delete those too
58
-		while ($row=$modx->db->getRow($rs)) {
59
-			$children[] = $row['id'];
60
-			getChildren($row['id']);
61
-			//echo "Found childNode of parentNode $parent: ".$row['id']."<br />";
62
-		}
52
+    $modx = DocumentParser::getInstance();
53
+    global $children;
54
+    global $deltime;
55
+
56
+    $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int)$parent."' AND deleted=1 AND deletedon='".(int)$deltime."'");
57
+        // the document has children documents, we'll need to delete those too
58
+        while ($row=$modx->db->getRow($rs)) {
59
+            $children[] = $row['id'];
60
+            getChildren($row['id']);
61
+            //echo "Found childNode of parentNode $parent: ".$row['id']."<br />";
62
+        }
63 63
 }
64 64
 
65 65
 getChildren($id);
66 66
 
67 67
 if(count($children)>0) {
68
-	$modx->db->update(
69
-		array(
70
-			'deleted'   => 0,
71
-			'deletedby' => 0,
72
-			'deletedon' => 0,
73
-		), $modx->getFullTableName('site_content'), "id IN(".implode(", ", $children).")");
68
+    $modx->db->update(
69
+        array(
70
+            'deleted'   => 0,
71
+            'deletedby' => 0,
72
+            'deletedon' => 0,
73
+        ), $modx->getFullTableName('site_content'), "id IN(".implode(", ", $children).")");
74 74
 }
75 75
 //'undelete' the document.
76 76
 $modx->db->update(
77
-	array(
78
-		'deleted'   => 0,
79
-		'deletedby' => 0,
80
-		'deletedon' => 0,
81
-	), $modx->getFullTableName('site_content'), "id='{$id}'");
77
+    array(
78
+        'deleted'   => 0,
79
+        'deletedby' => 0,
80
+        'deletedon' => 0,
81
+    ), $modx->getFullTableName('site_content'), "id='{$id}'");
82 82
 
83 83
 $modx->invokeEvent("OnDocFormUnDelete",
84 84
     array(
Please login to merge, or discard this 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
 	$modx = DocumentParser::getInstance();
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.
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
 	$modx = DocumentParser::getInstance();
53 54
 	global $children;
Please login to merge, or discard this patch.
manager/includes/template.parser.class.inc.php 3 patches
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -10,178 +10,178 @@
 block discarded – undo
10 10
 Class TemplateParser {
11 11
 
12 12
     /**
13
-	 * @param array $config [action, tabs, toArray]
14
-	 * @param array $data
15
-	 * @return string
16
-	 */
17
-	public function output($config = array(), $data = array()) {
13
+     * @param array $config [action, tabs, toArray]
14
+     * @param array $data
15
+     * @return string
16
+     */
17
+    public function output($config = array(), $data = array()) {
18 18
         $modx = DocumentParser::getInstance();
19 19
 
20
-		$output = '';
21
-		$action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : '');
22
-		$tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : '';
20
+        $output = '';
21
+        $action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : '');
22
+        $tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : '';
23 23
 
24
-		if($action) {
25
-			$sql = $modx->db->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name
24
+        if($action) {
25
+            $sql = $modx->db->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name
26 26
 			FROM ' . $modx->getFullTableName('system_templates') . ' AS t1
27 27
 			INNER JOIN ' . $modx->getFullTableName('categories') . ' AS t2 ON t2.id=t1.category
28 28
 			WHERE t1.action IN(' . $action . ') ' . $tab . '
29 29
 			ORDER BY t1.tab ASC, t1.rank ASC');
30 30
 
31
-			if($modx->db->getRecordCount($sql)) {
32
-				$tabs = array();
33
-				while($row = $modx->db->getRow($sql)) {
34
-					if(!$row['value'] && !empty($data[$row['name']])) {
35
-						$row['value'] = $data[$row['name']];
36
-					}
37
-					$tabs[$row['tab']]['category_name'] = $row['category_name'];
38
-					$tabs[$row['tab']][$row['name']] = TemplateParser::render($row);
39
-				}
40
-
41
-				if(!empty($config['toArray'])) {
42
-					$output = $tabs;
43
-				} else {
44
-					$output .= '<div class="tab-pane" id="pane_' . $action . '">';
45
-					$output .= '
31
+            if($modx->db->getRecordCount($sql)) {
32
+                $tabs = array();
33
+                while($row = $modx->db->getRow($sql)) {
34
+                    if(!$row['value'] && !empty($data[$row['name']])) {
35
+                        $row['value'] = $data[$row['name']];
36
+                    }
37
+                    $tabs[$row['tab']]['category_name'] = $row['category_name'];
38
+                    $tabs[$row['tab']][$row['name']] = TemplateParser::render($row);
39
+                }
40
+
41
+                if(!empty($config['toArray'])) {
42
+                    $output = $tabs;
43
+                } else {
44
+                    $output .= '<div class="tab-pane" id="pane_' . $action . '">';
45
+                    $output .= '
46 46
 					<script type="text/javascript">
47 47
 						var pane_' . $action . ' = new WebFXTabPane(document.getElementById("pane_' . $action . '"), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . ');
48 48
 					</script>';
49 49
 
50
-					foreach($tabs as $idTab => $tab) {
51
-						$output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">';
52
-						$output .= '
50
+                    foreach($tabs as $idTab => $tab) {
51
+                        $output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">';
52
+                        $output .= '
53 53
 						<h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']) . '</h2>
54 54
 						<script type="text/javascript">pane_' . $action . '.addTabPage(document.getElementById("tab_' . $action . '_' . $idTab . '"));</script>';
55
-						unset($tab['category_name']);
56
-						foreach($tab as $item) {
57
-							$output .= $item;
58
-						}
59
-						$output .= '</div>';
60
-					}
61
-					$output .= '</div>';
62
-				}
63
-			}
64
-		}
65
-
66
-		return $output;
67
-	}
55
+                        unset($tab['category_name']);
56
+                        foreach($tab as $item) {
57
+                            $output .= $item;
58
+                        }
59
+                        $output .= '</div>';
60
+                    }
61
+                    $output .= '</div>';
62
+                }
63
+            }
64
+        }
65
+
66
+        return $output;
67
+    }
68 68
 
69 69
     /**
70 70
      * @param array $data
71 71
      * @return string
72 72
      */
73
-	private function render($data) {
74
-		$modx = DocumentParser::getInstance(); global $_lang, $_country_lang;
73
+    private function render($data) {
74
+        $modx = DocumentParser::getInstance(); global $_lang, $_country_lang;
75 75
 
76
-		$data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']);
77
-		$data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $_POST[$data['name']][$data['value']] : (isset($data['value']) ? $modx->htmlspecialchars($data['value']) : ''));
78
-		$data['readonly'] = ($data['readonly'] ? ' readonly' : '');
76
+        $data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']);
77
+        $data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $_POST[$data['name']][$data['value']] : (isset($data['value']) ? $modx->htmlspecialchars($data['value']) : ''));
78
+        $data['readonly'] = ($data['readonly'] ? ' readonly' : '');
79 79
 
80
-		$output = '';
81
-		$output .= '<div class="form-group row">';
80
+        $output = '';
81
+        $output .= '<div class="form-group row">';
82 82
 
83
-		switch($data['type']) {
83
+        switch($data['type']) {
84 84
 
85
-			case 'text':
86
-				$output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>
85
+            case 'text':
86
+                $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>
87 87
 					<div class="col-sm-7">
88 88
 					<input type="text" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />';
89
-				$output .= $data['content'];
90
-				$output .= '</div>';
89
+                $output .= $data['content'];
90
+                $output .= '</div>';
91 91
 
92
-				break;
92
+                break;
93 93
 
94
-			case 'textarea':
95
-				$output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>
94
+            case 'textarea':
95
+                $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>
96 96
 					<div class="col-sm-7">
97 97
 					<textarea name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;"[+readonly+]>[+value+]</textarea>';
98
-				$output .= $data['content'];
99
-				$output .= '</div>';
98
+                $output .= $data['content'];
99
+                $output .= '</div>';
100 100
 
101
-				break;
101
+                break;
102 102
 
103
-			case 'date':
104
-				$data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $modx->toDateFormat($_POST[$data['name']][$data['value']]) : (isset($data['value']) ? $modx->toDateFormat($data['value']) : ''));
105
-				$output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>
103
+            case 'date':
104
+                $data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $modx->toDateFormat($_POST[$data['name']][$data['value']]) : (isset($data['value']) ? $modx->toDateFormat($data['value']) : ''));
105
+                $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>
106 106
 					<div class="col-sm-7">
107 107
 					<input type="text" name="[+name+]" class="form-control DatePicker" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />';
108
-				$output .= $data['content'];
109
-				$output .= '</div>';
110
-
111
-				break;
112
-
113
-			case 'select':
114
-				$output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
115
-				$output .= '<div class="col-sm-7">';
116
-				$output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">';
117
-				if($data['name'] == 'country' && isset($_country_lang)) {
118
-					$chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country'];
119
-					$output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '>&nbsp;</option>';
120
-					foreach($_country_lang as $key => $value) {
121
-						$output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>';
122
-					}
123
-				} else {
124
-					if($data['elements']) {
125
-						$elements = explode('||', $data['elements']);
126
-						foreach($elements as $key => $value) {
127
-							$value = explode('==', $value);
128
-							$output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>';
129
-						}
130
-					}
131
-				}
132
-				$output .= '</select>';
133
-				$output .= $data['content'];
134
-				$output .= '</div>';
135
-
136
-				break;
137
-
138
-			case 'checkbox':
139
-				$output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
140
-				$output .= '<div class="col-sm-7">';
141
-				$output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />';
142
-				if($data['elements']) {
143
-					$elements = explode('||', $data['elements']);
144
-					foreach($elements as $key => $value) {
145
-						$value = explode('==', $value);
146
-						$output .= '<br /><input type="checkbox" name="' . $value[0] . '" class="form-control" id="' . $value[0] . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]);
147
-					}
148
-				}
149
-				$output .= $data['content'];
150
-				$output .= '</div>';
151
-
152
-				break;
153
-
154
-			case 'radio':
155
-				$output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
156
-				$output .= '<div class="col-sm-7">';
157
-				$output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />';
158
-				if($data['elements']) {
159
-					$elements = explode('||', $data['elements']);
160
-					foreach($elements as $key => $value) {
161
-						$value = explode('==', $value);
162
-						$output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_' . $key . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]);
163
-					}
164
-				}
165
-				$output .= $data['content'];
166
-				$output .= '</div>';
167
-
168
-				break;
169
-
170
-			case 'custom':
171
-				$output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
172
-				$output .= '<div class="col-sm-7">';
173
-				$output .= $data['content'];
174
-				$output .= '</div>';
175
-
176
-				break;
177
-		}
178
-
179
-		$output .= '</div>';
180
-
181
-		$output = $modx->parseText($output, $data);
182
-
183
-		return $output;
184
-	}
108
+                $output .= $data['content'];
109
+                $output .= '</div>';
110
+
111
+                break;
112
+
113
+            case 'select':
114
+                $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
115
+                $output .= '<div class="col-sm-7">';
116
+                $output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">';
117
+                if($data['name'] == 'country' && isset($_country_lang)) {
118
+                    $chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country'];
119
+                    $output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '>&nbsp;</option>';
120
+                    foreach($_country_lang as $key => $value) {
121
+                        $output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>';
122
+                    }
123
+                } else {
124
+                    if($data['elements']) {
125
+                        $elements = explode('||', $data['elements']);
126
+                        foreach($elements as $key => $value) {
127
+                            $value = explode('==', $value);
128
+                            $output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>';
129
+                        }
130
+                    }
131
+                }
132
+                $output .= '</select>';
133
+                $output .= $data['content'];
134
+                $output .= '</div>';
135
+
136
+                break;
137
+
138
+            case 'checkbox':
139
+                $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
140
+                $output .= '<div class="col-sm-7">';
141
+                $output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />';
142
+                if($data['elements']) {
143
+                    $elements = explode('||', $data['elements']);
144
+                    foreach($elements as $key => $value) {
145
+                        $value = explode('==', $value);
146
+                        $output .= '<br /><input type="checkbox" name="' . $value[0] . '" class="form-control" id="' . $value[0] . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]);
147
+                    }
148
+                }
149
+                $output .= $data['content'];
150
+                $output .= '</div>';
151
+
152
+                break;
153
+
154
+            case 'radio':
155
+                $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
156
+                $output .= '<div class="col-sm-7">';
157
+                $output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />';
158
+                if($data['elements']) {
159
+                    $elements = explode('||', $data['elements']);
160
+                    foreach($elements as $key => $value) {
161
+                        $value = explode('==', $value);
162
+                        $output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_' . $key . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]);
163
+                    }
164
+                }
165
+                $output .= $data['content'];
166
+                $output .= '</div>';
167
+
168
+                break;
169
+
170
+            case 'custom':
171
+                $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
172
+                $output .= '<div class="col-sm-7">';
173
+                $output .= $data['content'];
174
+                $output .= '</div>';
175
+
176
+                break;
177
+        }
178
+
179
+        $output .= '</div>';
180
+
181
+        $output = $modx->parseText($output, $data);
182
+
183
+        return $output;
184
+    }
185 185
 
186 186
 }
187 187
 
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -7,53 +7,53 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-Class TemplateParser {
10
+Class TemplateParser{
11 11
 
12 12
     /**
13 13
 	 * @param array $config [action, tabs, toArray]
14 14
 	 * @param array $data
15 15
 	 * @return string
16 16
 	 */
17
-	public function output($config = array(), $data = array()) {
17
+	public function output($config = array(), $data = array()){
18 18
         $modx = DocumentParser::getInstance();
19 19
 
20 20
 		$output = '';
21 21
 		$action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : '');
22
-		$tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : '';
22
+		$tab = isset($config['tab']) ? ' AND tab IN('.$config['tab'].')' : '';
23 23
 
24
-		if($action) {
24
+		if ($action) {
25 25
 			$sql = $modx->db->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name
26
-			FROM ' . $modx->getFullTableName('system_templates') . ' AS t1
27
-			INNER JOIN ' . $modx->getFullTableName('categories') . ' AS t2 ON t2.id=t1.category
28
-			WHERE t1.action IN(' . $action . ') ' . $tab . '
26
+			FROM ' . $modx->getFullTableName('system_templates').' AS t1
27
+			INNER JOIN ' . $modx->getFullTableName('categories').' AS t2 ON t2.id=t1.category
28
+			WHERE t1.action IN(' . $action.') '.$tab.'
29 29
 			ORDER BY t1.tab ASC, t1.rank ASC');
30 30
 
31
-			if($modx->db->getRecordCount($sql)) {
31
+			if ($modx->db->getRecordCount($sql)) {
32 32
 				$tabs = array();
33
-				while($row = $modx->db->getRow($sql)) {
34
-					if(!$row['value'] && !empty($data[$row['name']])) {
33
+				while ($row = $modx->db->getRow($sql)) {
34
+					if (!$row['value'] && !empty($data[$row['name']])) {
35 35
 						$row['value'] = $data[$row['name']];
36 36
 					}
37 37
 					$tabs[$row['tab']]['category_name'] = $row['category_name'];
38 38
 					$tabs[$row['tab']][$row['name']] = TemplateParser::render($row);
39 39
 				}
40 40
 
41
-				if(!empty($config['toArray'])) {
41
+				if (!empty($config['toArray'])) {
42 42
 					$output = $tabs;
43 43
 				} else {
44
-					$output .= '<div class="tab-pane" id="pane_' . $action . '">';
44
+					$output .= '<div class="tab-pane" id="pane_'.$action.'">';
45 45
 					$output .= '
46 46
 					<script type="text/javascript">
47
-						var pane_' . $action . ' = new WebFXTabPane(document.getElementById("pane_' . $action . '"), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . ');
47
+						var pane_' . $action.' = new WebFXTabPane(document.getElementById("pane_'.$action.'"), '.($modx->config['remember_last_tab'] == 1 ? 'true' : 'false').');
48 48
 					</script>';
49 49
 
50
-					foreach($tabs as $idTab => $tab) {
51
-						$output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">';
50
+					foreach ($tabs as $idTab => $tab) {
51
+						$output .= '<div class="tab-page" id="tab_'.$action.'_'.$idTab.'">';
52 52
 						$output .= '
53
-						<h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']) . '</h2>
54
-						<script type="text/javascript">pane_' . $action . '.addTabPage(document.getElementById("tab_' . $action . '_' . $idTab . '"));</script>';
53
+						<h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']).'</h2>
54
+						<script type="text/javascript">pane_' . $action.'.addTabPage(document.getElementById("tab_'.$action.'_'.$idTab.'"));</script>';
55 55
 						unset($tab['category_name']);
56
-						foreach($tab as $item) {
56
+						foreach ($tab as $item) {
57 57
 							$output .= $item;
58 58
 						}
59 59
 						$output .= '</div>';
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      * @param array $data
71 71
      * @return string
72 72
      */
73
-	private function render($data) {
73
+	private function render($data){
74 74
 		$modx = DocumentParser::getInstance(); global $_lang, $_country_lang;
75 75
 
76 76
 		$data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']);
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		$output = '';
81 81
 		$output .= '<div class="form-group row">';
82 82
 
83
-		switch($data['type']) {
83
+		switch ($data['type']) {
84 84
 
85 85
 			case 'text':
86 86
 				$output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>
@@ -114,18 +114,18 @@  discard block
 block discarded – undo
114 114
 				$output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
115 115
 				$output .= '<div class="col-sm-7">';
116 116
 				$output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">';
117
-				if($data['name'] == 'country' && isset($_country_lang)) {
117
+				if ($data['name'] == 'country' && isset($_country_lang)) {
118 118
 					$chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country'];
119
-					$output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '>&nbsp;</option>';
120
-					foreach($_country_lang as $key => $value) {
121
-						$output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>';
119
+					$output .= '<option value=""'.(!isset($chosenCountry) ? ' selected' : '').'>&nbsp;</option>';
120
+					foreach ($_country_lang as $key => $value) {
121
+						$output .= '<option value="'.$key.'"'.(isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '').'>'.$value.'</option>';
122 122
 					}
123 123
 				} else {
124
-					if($data['elements']) {
124
+					if ($data['elements']) {
125 125
 						$elements = explode('||', $data['elements']);
126
-						foreach($elements as $key => $value) {
126
+						foreach ($elements as $key => $value) {
127 127
 							$value = explode('==', $value);
128
-							$output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>';
128
+							$output .= '<option value="'.$value[1].'">'.(isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]).'</option>';
129 129
 						}
130 130
 					}
131 131
 				}
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 				$output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
140 140
 				$output .= '<div class="col-sm-7">';
141 141
 				$output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />';
142
-				if($data['elements']) {
142
+				if ($data['elements']) {
143 143
 					$elements = explode('||', $data['elements']);
144
-					foreach($elements as $key => $value) {
144
+					foreach ($elements as $key => $value) {
145 145
 						$value = explode('==', $value);
146
-						$output .= '<br /><input type="checkbox" name="' . $value[0] . '" class="form-control" id="' . $value[0] . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]);
146
+						$output .= '<br /><input type="checkbox" name="'.$value[0].'" class="form-control" id="'.$value[0].'" value="'.$value[1].'" onChange="documentDirty=true;"[+readonly+] /> '.(isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]);
147 147
 					}
148 148
 				}
149 149
 				$output .= $data['content'];
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
 				$output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
156 156
 				$output .= '<div class="col-sm-7">';
157 157
 				$output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />';
158
-				if($data['elements']) {
158
+				if ($data['elements']) {
159 159
 					$elements = explode('||', $data['elements']);
160
-					foreach($elements as $key => $value) {
160
+					foreach ($elements as $key => $value) {
161 161
 						$value = explode('==', $value);
162
-						$output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_' . $key . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]);
162
+						$output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_'.$key.'" value="'.$value[1].'" onChange="documentDirty=true;"[+readonly+] /> '.(isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]);
163 163
 					}
164 164
 				}
165 165
 				$output .= $data['content'];
Please login to merge, or discard this patch.
Braces   +24 added lines, -21 removed lines patch added patch discarded remove patch
@@ -7,53 +7,55 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-Class TemplateParser {
10
+Class TemplateParser
11
+{
11 12
 
12 13
     /**
13 14
 	 * @param array $config [action, tabs, toArray]
14 15
 	 * @param array $data
15 16
 	 * @return string
16 17
 	 */
17
-	public function output($config = array(), $data = array()) {
18
+	public function output($config = array(), $data = array())
19
+	{
18 20
         $modx = DocumentParser::getInstance();
19 21
 
20 22
 		$output = '';
21 23
 		$action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : '');
22 24
 		$tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : '';
23 25
 
24
-		if($action) {
26
+		if($action) {
25 27
 			$sql = $modx->db->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name
26 28
 			FROM ' . $modx->getFullTableName('system_templates') . ' AS t1
27 29
 			INNER JOIN ' . $modx->getFullTableName('categories') . ' AS t2 ON t2.id=t1.category
28 30
 			WHERE t1.action IN(' . $action . ') ' . $tab . '
29 31
 			ORDER BY t1.tab ASC, t1.rank ASC');
30 32
 
31
-			if($modx->db->getRecordCount($sql)) {
33
+			if($modx->db->getRecordCount($sql)) {
32 34
 				$tabs = array();
33
-				while($row = $modx->db->getRow($sql)) {
34
-					if(!$row['value'] && !empty($data[$row['name']])) {
35
+				while($row = $modx->db->getRow($sql)) {
36
+					if(!$row['value'] && !empty($data[$row['name']])) {
35 37
 						$row['value'] = $data[$row['name']];
36 38
 					}
37 39
 					$tabs[$row['tab']]['category_name'] = $row['category_name'];
38 40
 					$tabs[$row['tab']][$row['name']] = TemplateParser::render($row);
39 41
 				}
40 42
 
41
-				if(!empty($config['toArray'])) {
43
+				if(!empty($config['toArray'])) {
42 44
 					$output = $tabs;
43
-				} else {
45
+				} else {
44 46
 					$output .= '<div class="tab-pane" id="pane_' . $action . '">';
45 47
 					$output .= '
46 48
 					<script type="text/javascript">
47 49
 						var pane_' . $action . ' = new WebFXTabPane(document.getElementById("pane_' . $action . '"), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . ');
48 50
 					</script>';
49 51
 
50
-					foreach($tabs as $idTab => $tab) {
52
+					foreach($tabs as $idTab => $tab) {
51 53
 						$output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">';
52 54
 						$output .= '
53 55
 						<h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']) . '</h2>
54 56
 						<script type="text/javascript">pane_' . $action . '.addTabPage(document.getElementById("tab_' . $action . '_' . $idTab . '"));</script>';
55 57
 						unset($tab['category_name']);
56
-						foreach($tab as $item) {
58
+						foreach($tab as $item) {
57 59
 							$output .= $item;
58 60
 						}
59 61
 						$output .= '</div>';
@@ -70,7 +72,8 @@  discard block
 block discarded – undo
70 72
      * @param array $data
71 73
      * @return string
72 74
      */
73
-	private function render($data) {
75
+	private function render($data)
76
+	{
74 77
 		$modx = DocumentParser::getInstance(); global $_lang, $_country_lang;
75 78
 
76 79
 		$data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']);
@@ -80,7 +83,7 @@  discard block
 block discarded – undo
80 83
 		$output = '';
81 84
 		$output .= '<div class="form-group row">';
82 85
 
83
-		switch($data['type']) {
86
+		switch($data['type']) {
84 87
 
85 88
 			case 'text':
86 89
 				$output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>
@@ -114,16 +117,16 @@  discard block
 block discarded – undo
114 117
 				$output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
115 118
 				$output .= '<div class="col-sm-7">';
116 119
 				$output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">';
117
-				if($data['name'] == 'country' && isset($_country_lang)) {
120
+				if($data['name'] == 'country' && isset($_country_lang)) {
118 121
 					$chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country'];
119 122
 					$output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '>&nbsp;</option>';
120
-					foreach($_country_lang as $key => $value) {
123
+					foreach($_country_lang as $key => $value) {
121 124
 						$output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>';
122 125
 					}
123
-				} else {
124
-					if($data['elements']) {
126
+				} else {
127
+					if($data['elements']) {
125 128
 						$elements = explode('||', $data['elements']);
126
-						foreach($elements as $key => $value) {
129
+						foreach($elements as $key => $value) {
127 130
 							$value = explode('==', $value);
128 131
 							$output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>';
129 132
 						}
@@ -139,9 +142,9 @@  discard block
 block discarded – undo
139 142
 				$output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
140 143
 				$output .= '<div class="col-sm-7">';
141 144
 				$output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />';
142
-				if($data['elements']) {
145
+				if($data['elements']) {
143 146
 					$elements = explode('||', $data['elements']);
144
-					foreach($elements as $key => $value) {
147
+					foreach($elements as $key => $value) {
145 148
 						$value = explode('==', $value);
146 149
 						$output .= '<br /><input type="checkbox" name="' . $value[0] . '" class="form-control" id="' . $value[0] . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]);
147 150
 					}
@@ -155,9 +158,9 @@  discard block
 block discarded – undo
155 158
 				$output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
156 159
 				$output .= '<div class="col-sm-7">';
157 160
 				$output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />';
158
-				if($data['elements']) {
161
+				if($data['elements']) {
159 162
 					$elements = explode('||', $data['elements']);
160
-					foreach($elements as $key => $value) {
163
+					foreach($elements as $key => $value) {
161 164
 						$value = explode('==', $value);
162 165
 						$output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_' . $key . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]);
163 166
 					}
Please login to merge, or discard this patch.
manager/includes/extenders/export.class.inc.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         $this->count = 0;
58 58
         $this->setUrlMode();
59 59
         $this->generate_mode = 'crawl';
60
-        $this->targetDir = $modx->config['base_path'] . 'temp/export';
60
+        $this->targetDir = $modx->config['base_path'].'temp/export';
61 61
         if (!isset($this->total)) {
62 62
             $this->getTotal();
63 63
         }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
         $ignore_ids = array_filter(array_map('intval', explode(',', $ignore_ids)));
114 114
         if (count($ignore_ids) > 0) {
115
-            $ignore_ids = "AND NOT id IN ('" . implode("','", $ignore_ids) . "')";
115
+            $ignore_ids = "AND NOT id IN ('".implode("','", $ignore_ids)."')";
116 116
         } else {
117 117
             $ignore_ids = '';
118 118
         }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         $noncache = ($noncache == 1) ? '' : 'AND cacheable=1';
123 123
         $where = "deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}";
124 124
         $rs = $modx->db->select('count(id)', $tbl_site_content, $where);
125
-        $this->total = (int)$modx->db->getValue($rs);
125
+        $this->total = (int) $modx->db->getValue($rs);
126 126
 
127 127
         return $this->total;
128 128
     }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         } elseif (!is_readable($directory)) {
152 152
             return $rs;
153 153
         } else {
154
-            $files = glob($directory . '/*');
154
+            $files = glob($directory.'/*');
155 155
             if (!empty($files)) {
156 156
                 foreach ($files as $path) {
157 157
                     $rs = is_dir($path) ? $this->removeDirectoryAll($path) : unlink($path);
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
             $_lang = $back_lang;
182 182
         } else {
183
-            $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}");
183
+            $src = $this->curl_get_contents(MODX_SITE_URL."index.php?id={$docid}");
184 184
         }
185 185
 
186 186
 
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
         $modx = DocumentParser::getInstance();
216 216
 
217 217
         if ($alias === '') {
218
-            $filename = $prefix . $docid . $suffix;
218
+            $filename = $prefix.$docid.$suffix;
219 219
         } else {
220 220
             if ($modx->config['suffix_mode'] === '1' && strpos($alias, '.') !== false) {
221 221
                 $suffix = '';
222 222
             }
223
-            $filename = $prefix . $alias . $suffix;
223
+            $filename = $prefix.$alias.$suffix;
224 224
         }
225 225
 
226 226
         return $filename;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
         $tbl_site_content = $modx->getFullTableName('site_content');
239 239
 
240 240
         $ignore_ids = $this->ignore_ids;
241
-        $dirpath = $this->targetDir . '/';
241
+        $dirpath = $this->targetDir.'/';
242 242
 
243 243
         $prefix = $modx->config['friendly_url_prefix'];
244 244
         $suffix = $modx->config['friendly_url_suffix'];
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 
249 249
         $ph['status'] = 'fail';
250 250
         $ph['msg1'] = $_lang['export_site_failed'];
251
-        $ph['msg2'] = $_lang["export_site_failed_no_write"] . ' - ' . $dirpath;
251
+        $ph['msg2'] = $_lang["export_site_failed_no_write"].' - '.$dirpath;
252 252
         $msg_failed_no_write = $this->parsePlaceholder($tpl, $ph);
253 253
 
254 254
         $ph['msg2'] = $_lang["export_site_failed_no_retrieve"];
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 
282 282
             if (!$row['wasNull']) { // needs writing a document
283 283
                 $docname = $this->getFileName($row['id'], $row['alias'], $prefix, $suffix);
284
-                $filename = $dirpath . $docname;
284
+                $filename = $dirpath.$docname;
285 285
                 if (!is_file($filename)) {
286 286
                     if ($row['published'] === '1') {
287 287
                         $status = $this->makeFile($row['id'], $filename);
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
             if ($row['isfolder'] === '1' && ($modx->config['suffix_mode'] !== '1' || strpos($row['alias'],
310 310
                         '.') === false)) { // needs making a folder
311 311
                 $end_dir = ($row['alias'] !== '') ? $row['alias'] : $row['id'];
312
-                $dir_path = $dirpath . $end_dir;
312
+                $dir_path = $dirpath.$end_dir;
313 313
                 if (strpos($dir_path, MODX_BASE_PATH) === false) {
314 314
                     return false;
315 315
                 }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 
326 326
                 if ($modx->config['make_folders'] === '1' && $row['published'] === '1') {
327 327
                     if (!empty($filename) && is_file($filename)) {
328
-                        rename($filename, $dir_path . '/index.html');
328
+                        rename($filename, $dir_path.'/index.html');
329 329
                     }
330 330
                 }
331 331
                 $this->targetDir = $dir_path;
@@ -349,8 +349,8 @@  discard block
 block discarded – undo
349 349
 
350 350
         $ch = curl_init();
351 351
         curl_setopt($ch, CURLOPT_URL, $url);
352
-        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);    // 0 = DO NOT VERIFY AUTHENTICITY OF SSL-CERT
353
-        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);    // 2 = CERT MUST INDICATE BEING CONNECTED TO RIGHT SERVER
352
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 0 = DO NOT VERIFY AUTHENTICITY OF SSL-CERT
353
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 2 = CERT MUST INDICATE BEING CONNECTED TO RIGHT SERVER
354 354
         curl_setopt($ch, CURLOPT_HEADER, false);
355 355
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
356 356
         curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
Please login to merge, or discard this patch.
manager/includes/extenders/manager.api.class.inc.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -144,33 +144,33 @@  discard block
 block discarded – undo
144 144
             $algorithm = 'UNCRYPT';
145 145
         }
146 146
 
147
-        $salt = md5($password . $seed);
147
+        $salt = md5($password.$seed);
148 148
 
149 149
         switch ($algorithm) {
150 150
             case 'BLOWFISH_Y':
151
-                $salt = '$2y$07$' . substr($salt, 0, 22);
151
+                $salt = '$2y$07$'.substr($salt, 0, 22);
152 152
                 break;
153 153
             case 'BLOWFISH_A':
154
-                $salt = '$2a$07$' . substr($salt, 0, 22);
154
+                $salt = '$2a$07$'.substr($salt, 0, 22);
155 155
                 break;
156 156
             case 'SHA512':
157
-                $salt = '$6$' . substr($salt, 0, 16);
157
+                $salt = '$6$'.substr($salt, 0, 16);
158 158
                 break;
159 159
             case 'SHA256':
160
-                $salt = '$5$' . substr($salt, 0, 16);
160
+                $salt = '$5$'.substr($salt, 0, 16);
161 161
                 break;
162 162
             case 'MD5':
163
-                $salt = '$1$' . substr($salt, 0, 8);
163
+                $salt = '$1$'.substr($salt, 0, 8);
164 164
                 break;
165 165
         }
166 166
 
167 167
         if ($algorithm !== 'UNCRYPT') {
168
-            $password = sha1($password) . crypt($password, $salt);
168
+            $password = sha1($password).crypt($password, $salt);
169 169
         } else {
170
-            $password = sha1($salt . $password);
170
+            $password = sha1($salt.$password);
171 171
         }
172 172
 
173
-        $result = strtolower($algorithm) . '>' . md5($salt . $password) . substr(md5($salt), 0, 8);
173
+        $result = strtolower($algorithm).'>'.md5($salt.$password).substr(md5($salt), 0, 8);
174 174
 
175 175
         return $result;
176 176
     }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         $check_files = explode("\n", $check_files);
253 253
         foreach ($check_files as $file) {
254 254
             $file = trim($file);
255
-            $file = MODX_BASE_PATH . $file;
255
+            $file = MODX_BASE_PATH.$file;
256 256
             if (!is_file($file)) {
257 257
                 continue;
258 258
             }
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         $checksum = unserialize($checksum);
276 276
         foreach ($check_files as $file) {
277 277
             $file = trim($file);
278
-            $filePath = MODX_BASE_PATH . $file;
278
+            $filePath = MODX_BASE_PATH.$file;
279 279
             if (!is_file($filePath)) {
280 280
                 continue;
281 281
             }
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
     {
295 295
         $modx = DocumentParser::getInstance();
296 296
         $tbl_system_settings = $modx->getFullTableName('system_settings');
297
-        $sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','" . $modx->db->escape($checksum) . "')";
297
+        $sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','".$modx->db->escape($checksum)."')";
298 298
         $modx->db->query($sql);
299 299
     }
300 300
 
@@ -371,10 +371,10 @@  discard block
 block discarded – undo
371 371
             foreach ($settings as $key => $val) {
372 372
                 $f = array();
373 373
                 $f['user'] = $_SESSION['mgrInternalKey'];
374
-                $f['setting_name'] = '_LAST_' . $key;
374
+                $f['setting_name'] = '_LAST_'.$key;
375 375
                 $f['setting_value'] = $val;
376 376
                 $f = $modx->db->escape($f);
377
-                $f = "(`" . implode("`, `", array_keys($f)) . "`) VALUES('" . implode("', '", array_values($f)) . "')";
377
+                $f = "(`".implode("`, `", array_keys($f))."`) VALUES('".implode("', '", array_values($f))."')";
378 378
                 $f .= " ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value)";
379 379
                 $modx->db->insert($f, $modx->getFullTableName('user_settings'));
380 380
             }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -116,7 +116,8 @@  discard block
 block discarded – undo
116 116
      * @return string
117 117
      */
118 118
     public function getHashType($db_value = '')
119
-    { // md5 | v1 | phpass
119
+    {
120
+// md5 | v1 | phpass
120 121
         $c = substr($db_value, 0, 1);
121 122
         if ($c === '$') {
122 123
             return 'phpass';
@@ -135,7 +136,8 @@  discard block
 block discarded – undo
135 136
      * @return string
136 137
      */
137 138
     public function genV1Hash($password, $seed = '1')
138
-    { // $seed is user_id basically
139
+    {
140
+// $seed is user_id basically
139 141
         $modx = DocumentParser::getInstance();
140 142
 
141 143
         if (isset($modx->config['pwd_hash_algo']) && !empty($modx->config['pwd_hash_algo'])) {
Please login to merge, or discard this patch.
manager/includes/extenders/maketable.class.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function setTableWidth($value)
132 132
     {
133
-        $this->tableWidth = (int)$value;
133
+        $this->tableWidth = (int) $value;
134 134
     }
135 135
 
136 136
     /**
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
     {
318 318
         $currentWidth = '';
319 319
         if (is_array($this->columnWidths)) {
320
-            $currentWidth = $this->columnWidths[$columnPosition] ? ' width="' . $this->columnWidths[$columnPosition] . '" ' : '';
320
+            $currentWidth = $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : '';
321 321
         }
322 322
 
323 323
         return $currentWidth;
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
             $currentClass = $this->rowAlternateClass;
347 347
         }
348 348
 
349
-        return ' class="' . $currentClass . '"';
349
+        return ' class="'.$currentClass.'"';
350 350
     }
351 351
 
352 352
     /**
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
     {
361 361
         $cellAction = '';
362 362
         if ($this->cellAction) {
363
-            $cellAction = ' onClick="javascript:window.location=\'' . $this->cellAction . $this->actionField . '=' . urlencode($currentActionFieldValue) . '\'" ';
363
+            $cellAction = ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" ';
364 364
         }
365 365
 
366 366
         return $cellAction;
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
     {
378 378
         $cell = $value;
379 379
         if ($this->linkAction) {
380
-            $cell = '<a href="' . $this->linkAction . $this->actionField . '=' . urlencode($currentActionFieldValue) . '">' . $cell . '</a>';
380
+            $cell = '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>';
381 381
         }
382 382
 
383 383
         return $cell;
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
             $end = '?';
407 407
         }
408 408
 
409
-        return $link . $end;
409
+        return $link.$end;
410 410
     }
411 411
 
412 412
     /**
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
         if (is_array($fieldsArray)) {
427 427
             $i = 0;
428 428
             foreach ($fieldsArray as $fieldName => $fieldValue) {
429
-                $table .= "\t<tr" . $this->determineRowClass($i) . ">\n";
429
+                $table .= "\t<tr".$this->determineRowClass($i).">\n";
430 430
                 $currentActionFieldValue = $fieldValue[$this->actionField];
431 431
                 if (is_array($this->selectedValues)) {
432 432
                     $isChecked = array_search($currentActionFieldValue, $this->selectedValues) === false ? 0 : 1;
@@ -437,15 +437,15 @@  discard block
 block discarded – undo
437 437
                 $colPosition = 0;
438 438
                 foreach ($fieldValue as $key => $value) {
439 439
                     if (!in_array($key, $this->excludeFields)) {
440
-                        $table .= "\t\t<td" . $this->getCellAction($currentActionFieldValue) . ">";
440
+                        $table .= "\t\t<td".$this->getCellAction($currentActionFieldValue).">";
441 441
                         $table .= $this->createCellText($currentActionFieldValue, $value);
442 442
                         $table .= "</td>\n";
443 443
                         if ($i == 0) {
444 444
                             if (empty ($header) && $this->formElementType) {
445
-                                $header .= "\t\t<th style=\"width:32px\" " . ($this->thClass ? 'class="' . $this->thClass . '"' : '') . ">" . ($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '') . "</th>\n";
445
+                                $header .= "\t\t<th style=\"width:32px\" ".($this->thClass ? 'class="'.$this->thClass.'"' : '').">".($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '')."</th>\n";
446 446
                             }
447 447
                             $headerText = array_key_exists($key, $fieldHeadersArray) ? $fieldHeadersArray[$key] : $key;
448
-                            $header .= "\t\t<th" . $this->getColumnWidth($colPosition) . ($this->thClass ? ' class="' . $this->thClass . '" ' : '') . ">" . $headerText . "</th>\n";
448
+                            $header .= "\t\t<th".$this->getColumnWidth($colPosition).($this->thClass ? ' class="'.$this->thClass.'" ' : '').">".$headerText."</th>\n";
449 449
                         }
450 450
                         $colPosition++;
451 451
                     }
@@ -453,9 +453,9 @@  discard block
 block discarded – undo
453 453
                 $i++;
454 454
                 $table .= "\t</tr>\n";
455 455
             }
456
-            $table = "\n" . '<table' . ($this->tableWidth > 0 ? ' width="' . $this->tableWidth . '"' : '') . ($this->tableClass ? ' class="' . $this->tableClass . '"' : '') . ($this->tableID ? ' id="' . $this->tableID . '"' : '') . ">\n" . ($header ? "\t<thead>\n\t<tr class=\"" . $this->rowHeaderClass . "\">\n" . $header . "\t</tr>\n\t</thead>\n" : '') . $table . "</table>\n";
456
+            $table = "\n".'<table'.($this->tableWidth > 0 ? ' width="'.$this->tableWidth.'"' : '').($this->tableClass ? ' class="'.$this->tableClass.'"' : '').($this->tableID ? ' id="'.$this->tableID.'"' : '').">\n".($header ? "\t<thead>\n\t<tr class=\"".$this->rowHeaderClass."\">\n".$header."\t</tr>\n\t</thead>\n" : '').$table."</table>\n";
457 457
             if ($this->formElementType) {
458
-                $table = "\n" . '<form id="' . $this->formName . '" name="' . $this->formName . '" action="' . $this->formAction . '" method="POST">' . $table;
458
+                $table = "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table;
459 459
             }
460 460
             if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists.
461 461
                 /* commented this part because of cookie
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 
470 470
                 $table .= '</select>'.$_lang["pagination_table_perpage"].'</div>';
471 471
                 */
472
-                $table .= '<div id="pagination" class="paginate">' . $_lang["pagination_table_gotopage"] . '<ul>' . $this->pageNav . '</ul></div>';
472
+                $table .= '<div id="pagination" class="paginate">'.$_lang["pagination_table_gotopage"].'<ul>'.$this->pageNav.'</ul></div>';
473 473
                 //$table .= '<script language="javascript">function updatePageSize(size){window.location = \''.$this->prepareLink($linkpage).'pageSize=\'+size;}</script>';
474 474
 
475 475
             }
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 <script language="javascript">
479 479
 	toggled = 0;
480 480
 	function clickAll() {
481
-		myform = document.getElementById("' . $this->formName . '");
481
+		myform = document.getElementById("' . $this->formName.'");
482 482
 		for(i=0;i<myform.length;i++) {
483 483
 			if(myform.elements[i].type==\'checkbox\') {
484 484
 				myform.elements[i].checked=(toggled?false:true);
@@ -490,9 +490,9 @@  discard block
 block discarded – undo
490 490
             }
491 491
             if ($this->formElementType) {
492 492
                 if ($this->extra) {
493
-                    $table .= "\n" . $this->extra . "\n";
493
+                    $table .= "\n".$this->extra."\n";
494 494
                 }
495
-                $table .= "\n" . '</form>' . "\n";
495
+                $table .= "\n".'</form>'."\n";
496 496
             }
497 497
 
498 498
             return $table;
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
         $numPages = ceil($numRecords / MAX_DISPLAY_RECORDS_NUM);
516 516
         $nav = '';
517 517
         if ($numPages > 1) {
518
-            $currentURL = empty($qs) ? '' : '?' . $qs;
518
+            $currentURL = empty($qs) ? '' : '?'.$qs;
519 519
             if ($currentPage > 6) {
520 520
                 $nav .= $this->createPageLink($currentURL, 1, $_lang["pagination_table_first"]);
521 521
             }
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
                 $nav .= $this->createPageLink($currentURL, $numPages, $_lang["pagination_table_last"]);
541 541
             }
542 542
         }
543
-        $this->pageNav = ' ' . $nav;
543
+        $this->pageNav = ' '.$nav;
544 544
     }
545 545
 
546 546
     /**
@@ -556,14 +556,14 @@  discard block
 block discarded – undo
556 556
     public function createPageLink($link = '', $pageNum, $displayText, $currentPage = false, $qs = '')
557 557
     {
558 558
         $modx = DocumentParser::getInstance();
559
-        $orderBy = !empty($_GET['orderby']) ? '&orderby=' . $_GET['orderby'] : '';
560
-        $orderDir = !empty($_GET['orderdir']) ? '&orderdir=' . $_GET['orderdir'] : '';
559
+        $orderBy = !empty($_GET['orderby']) ? '&orderby='.$_GET['orderby'] : '';
560
+        $orderDir = !empty($_GET['orderdir']) ? '&orderdir='.$_GET['orderdir'] : '';
561 561
         if (!empty($qs)) {
562 562
             $qs = "?$qs";
563 563
         }
564 564
         $link = empty($link) ? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'],
565
-            $qs . "page=$pageNum$orderBy$orderDir") : $this->prepareLink($link) . "page=$pageNum";
566
-        $nav = '<li' . ($currentPage ? ' class="currentPage"' : '') . '><a' . ($currentPage ? ' class="currentPage"' : '') . ' href="' . $link . '">' . $displayText . '</a></li>' . "\n";
565
+            $qs."page=$pageNum$orderBy$orderDir") : $this->prepareLink($link)."page=$pageNum";
566
+        $nav = '<li'.($currentPage ? ' class="currentPage"' : '').'><a'.($currentPage ? ' class="currentPage"' : '').' href="'.$link.'">'.$displayText.'</a></li>'."\n";
567 567
 
568 568
         return $nav;
569 569
     }
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
         $field = '';
582 582
         if ($this->formElementType) {
583 583
             $checked = $isChecked ? "checked " : "";
584
-            $field = "\t\t" . '<td><input type="' . $this->formElementType . '" name="' . ($this->formElementName ? $this->formElementName : $value) . '"  value="' . $value . '" ' . $checked . '/></td>' . "\n";
584
+            $field = "\t\t".'<td><input type="'.$this->formElementType.'" name="'.($this->formElementName ? $this->formElementName : $value).'"  value="'.$value.'" '.$checked.'/></td>'."\n";
585 585
         }
586 586
 
587 587
         return $field;
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
     public function handlePaging()
596 596
     {
597 597
         $offset = (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0;
598
-        $limitClause = ' LIMIT ' . ($offset * MAX_DISPLAY_RECORDS_NUM) . ', ' . MAX_DISPLAY_RECORDS_NUM;
598
+        $limitClause = ' LIMIT '.($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM;
599 599
 
600 600
         return $limitClause;
601 601
     }
@@ -610,10 +610,10 @@  discard block
 block discarded – undo
610 610
     public function handleSorting($natural_order = false)
611 611
     {
612 612
         $orderByClause = '';
613
-        if ((bool)$natural_order === false) {
613
+        if ((bool) $natural_order === false) {
614 614
             $orderby = !empty($_GET['orderby']) ? $_GET['orderby'] : "id";
615 615
             $orderdir = !empty($_GET['orderdir']) ? $_GET['orderdir'] : "DESC";
616
-            $orderByClause = !empty($orderby) ? ' ORDER BY ' . $orderby . ' ' . $orderdir . ' ' : "";
616
+            $orderByClause = !empty($orderby) ? ' ORDER BY '.$orderby.' '.$orderdir.' ' : "";
617 617
         }
618 618
 
619 619
         return $orderByClause;
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
             }
643 643
         }
644 644
 
645
-        return '<a href="[~' . $modx->documentIdentifier . '~]?' . $qs . 'orderby=' . $key . $orderDir . '">' . $text . '</a>';
645
+        return '<a href="[~'.$modx->documentIdentifier.'~]?'.$qs.'orderby='.$key.$orderDir.'">'.$text.'</a>';
646 646
     }
647 647
 
648 648
 }
Please login to merge, or discard this patch.
manager/includes/tmplvars.commands.inc.php 3 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
  */
132 132
 function ProcessFile($file) {
133 133
     // get the file
134
-	$buffer = @file_get_contents($file);
135
-	if ($buffer === false) $buffer = " Could not retrieve document '$file'.";
134
+    $buffer = @file_get_contents($file);
135
+    if ($buffer === false) $buffer = " Could not retrieve document '$file'.";
136 136
     return $buffer;
137 137
 }
138 138
 
@@ -168,20 +168,20 @@  discard block
 block discarded – undo
168 168
 function parseTvValues($param, $tvsArray)
169 169
 {
170 170
     $modx = DocumentParser::getInstance();
171
-	$tvsArray = is_array($modx->documentObject) ? array_merge($tvsArray, $modx->documentObject) : $tvsArray;
172
-	if (strpos($param, '[*') !== false) {
173
-		$matches = $modx->getTagsFromContent($param, '[*', '*]');
174
-		foreach ($matches[0] as $i=>$match) {
175
-			if(isset($tvsArray[ $matches[1][$i] ])) {
176
-				if(is_array($tvsArray[ $matches[1][$i] ])) {
177
-					$value = $tvsArray[$matches[1][$i]]['value'];
178
-					$value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value;
179
-				} else {
180
-					$value = $tvsArray[ $matches[1][$i] ];
181
-				}
182
-				$param = str_replace($match, $value, $param);
183
-			}
184
-		}
185
-	}
186
-	return $param;
171
+    $tvsArray = is_array($modx->documentObject) ? array_merge($tvsArray, $modx->documentObject) : $tvsArray;
172
+    if (strpos($param, '[*') !== false) {
173
+        $matches = $modx->getTagsFromContent($param, '[*', '*]');
174
+        foreach ($matches[0] as $i=>$match) {
175
+            if(isset($tvsArray[ $matches[1][$i] ])) {
176
+                if(is_array($tvsArray[ $matches[1][$i] ])) {
177
+                    $value = $tvsArray[$matches[1][$i]]['value'];
178
+                    $value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value;
179
+                } else {
180
+                    $value = $tvsArray[ $matches[1][$i] ];
181
+                }
182
+                $param = str_replace($match, $value, $param);
183
+            }
184
+        }
185
+    }
186
+    return $param;
187 187
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  * Created by Raymond Irving Feb, 2005
5 5
  */
6 6
 global $BINDINGS; // Array of supported bindings. must be upper case
7
-$BINDINGS = array (
7
+$BINDINGS = array(
8 8
     'FILE',
9 9
     'CHUNK',
10 10
     'DOCUMENT',
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
  * @param array $tvsArray
23 23
  * @return string
24 24
  */
25
-function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) {
25
+function ProcessTVCommand($value, $name = '', $docid = '', $src = 'docform', $tvsArray = array()){
26 26
     $modx = DocumentParser::getInstance();
27
-    $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier;
27
+    $docid = (int) $docid > 0 ? (int) $docid : $modx->documentIdentifier;
28 28
     $nvalue = trim($value);
29 29
     if (substr($nvalue, 0, 1) != '@')
30 30
         return $value;
31
-    elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') {
31
+    elseif (isset($modx->config['enable_bindings']) && $modx->config['enable_bindings'] != 1 && $src === 'docform') {
32 32
         return '@Bindings is disabled.';
33 33
     }
34 34
     else {
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
                 break;
55 55
 
56 56
             case "SELECT" : // selects a record from the cms database
57
-                $rt = array ();
58
-                $replacementVars = array (
57
+                $rt = array();
58
+                $replacementVars = array(
59 59
                     'DBASE' => $modx->db->config['dbase'],
60 60
                     'PREFIX' => $modx->db->config['table_prefix']
61 61
                 );
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
                 break;
97 97
 
98 98
             case 'DIRECTORY' :
99
-                $files = array ();
100
-                $path = $modx->config['base_path'] . $param;
99
+                $files = array();
100
+                $path = $modx->config['base_path'].$param;
101 101
                 if (substr($path, -1, 1) != '/') {
102 102
                     $path .= '/';
103 103
                 }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
  * @param $file
130 130
  * @return string
131 131
  */
132
-function ProcessFile($file) {
132
+function ProcessFile($file){
133 133
     // get the file
134 134
 	$buffer = @file_get_contents($file);
135 135
 	if ($buffer === false) $buffer = " Could not retrieve document '$file'.";
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
 {
147 147
     global $BINDINGS;
148 148
     $binding_array = array();
149
-    foreach($BINDINGS as $cmd)
149
+    foreach ($BINDINGS as $cmd)
150 150
     {
151
-        if(strpos($binding_string,'@'.$cmd)===0)
151
+        if (strpos($binding_string, '@'.$cmd) === 0)
152 152
         {
153
-            $code = substr($binding_string,strlen($cmd)+1);
154
-            $binding_array = array($cmd,trim($code));
153
+            $code = substr($binding_string, strlen($cmd) + 1);
154
+            $binding_array = array($cmd, trim($code));
155 155
             break;
156 156
         }
157 157
     }
@@ -172,12 +172,12 @@  discard block
 block discarded – undo
172 172
 	if (strpos($param, '[*') !== false) {
173 173
 		$matches = $modx->getTagsFromContent($param, '[*', '*]');
174 174
 		foreach ($matches[0] as $i=>$match) {
175
-			if(isset($tvsArray[ $matches[1][$i] ])) {
176
-				if(is_array($tvsArray[ $matches[1][$i] ])) {
175
+			if (isset($tvsArray[$matches[1][$i]])) {
176
+				if (is_array($tvsArray[$matches[1][$i]])) {
177 177
 					$value = $tvsArray[$matches[1][$i]]['value'];
178 178
 					$value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value;
179 179
 				} else {
180
-					$value = $tvsArray[ $matches[1][$i] ];
180
+					$value = $tvsArray[$matches[1][$i]];
181 181
 				}
182 182
 				$param = str_replace($match, $value, $param);
183 183
 			}
Please login to merge, or discard this patch.
Braces   +22 added lines, -18 removed lines patch added patch discarded remove patch
@@ -22,16 +22,16 @@  discard block
 block discarded – undo
22 22
  * @param array $tvsArray
23 23
  * @return string
24 24
  */
25
-function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) {
25
+function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array())
26
+{
26 27
     $modx = DocumentParser::getInstance();
27 28
     $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier;
28 29
     $nvalue = trim($value);
29
-    if (substr($nvalue, 0, 1) != '@')
30
-        return $value;
31
-    elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') {
30
+    if (substr($nvalue, 0, 1) != '@') {
31
+            return $value;
32
+    } elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') {
32 33
         return '@Bindings is disabled.';
33
-    }
34
-    else {
34
+    } else {
35 35
         list ($cmd, $param) = ParseCommand($nvalue);
36 36
         $cmd = trim($cmd);
37 37
         $param = parseTvValues($param, $tvsArray);
@@ -47,10 +47,11 @@  discard block
 block discarded – undo
47 47
 
48 48
             case "DOCUMENT" : // retrieve a document and process it's content
49 49
                 $rs = $modx->getDocument($param);
50
-                if (is_array($rs))
51
-                    $output = $rs['content'];
52
-                else
53
-                    $output = "Unable to locate document $param";
50
+                if (is_array($rs)) {
51
+                                    $output = $rs['content'];
52
+                } else {
53
+                                    $output = "Unable to locate document $param";
54
+                }
54 55
                 break;
55 56
 
56 57
             case "SELECT" : // selects a record from the cms database
@@ -80,8 +81,10 @@  discard block
 block discarded – undo
80 81
 
81 82
                     // Grab document regardless of publish status
82 83
                     $doc = $modx->getPageInfo($parent_id, 0, 'id,parent,published');
83
-                    if ($doc['parent'] != 0 && !$doc['published'])
84
-                        continue; // hide unpublished docs if we're not at the top
84
+                    if ($doc['parent'] != 0 && !$doc['published']) {
85
+                                            continue;
86
+                    }
87
+                    // hide unpublished docs if we're not at the top
85 88
 
86 89
                     $tv = $modx->getTemplateVar($name, '*', $doc['id'], $doc['published']);
87 90
 
@@ -129,10 +132,13 @@  discard block
 block discarded – undo
129 132
  * @param $file
130 133
  * @return string
131 134
  */
132
-function ProcessFile($file) {
135
+function ProcessFile($file)
136
+{
133 137
     // get the file
134 138
 	$buffer = @file_get_contents($file);
135
-	if ($buffer === false) $buffer = " Could not retrieve document '$file'.";
139
+	if ($buffer === false) {
140
+	    $buffer = " Could not retrieve document '$file'.";
141
+	}
136 142
     return $buffer;
137 143
 }
138 144
 
@@ -146,10 +152,8 @@  discard block
 block discarded – undo
146 152
 {
147 153
     global $BINDINGS;
148 154
     $binding_array = array();
149
-    foreach($BINDINGS as $cmd)
150
-    {
151
-        if(strpos($binding_string,'@'.$cmd)===0)
152
-        {
155
+    foreach($BINDINGS as $cmd) {
156
+        if(strpos($binding_string,'@'.$cmd)===0) {
153 157
             $code = substr($binding_string,strlen($cmd)+1);
154 158
             $binding_array = array($cmd,trim($code));
155 159
             break;
Please login to merge, or discard this patch.