Completed
Pull Request — develop (#716)
by Serg
06:34
created
manager/processors/save_user.processor.php 3 patches
Indentation   +245 added lines, -245 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", 12);
48
+    webAlertAndQuit("Password typed is mismatched", 12);
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!", 12);
53
+    webAlertAndQuit("E-mail address doesn't seem to be valid!", 12);
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!", 12);
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.", 12);
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!", 12);
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.", 12);
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!", 12);
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!", 12);
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!", 12);
91
-			} else {
92
-				$newpassword = $specifiedpassword;
93
-			}
94
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
95
-			webAlertAndQuit("You didn't specify a password for this user!", 12);
96
-		} elseif($passwordgenmethod == 'g') {
97
-			$newpassword = generate_password(8);
98
-		} else {
99
-			webAlertAndQuit("No password generation method specified!", 12);
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
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!", 12);
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!", 12);
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!", 12);
91
+            } else {
92
+                $newpassword = $specifiedpassword;
93
+            }
94
+        } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
95
+            webAlertAndQuit("You didn't specify a password for this user!", 12);
96
+        } elseif($passwordgenmethod == 'g') {
97
+            $newpassword = generate_password(8);
98
+        } else {
99
+            webAlertAndQuit("No password generation method specified!", 12);
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 119
         saveManagerUserSettings($internalKey);
120 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') {
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 157
             sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL);
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
-			?>
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!", 12);
206
-				} else {
207
-					$newpassword = $specifiedpassword;
208
-				}
209
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
210
-				webAlertAndQuit("You didn't specify a password for this user!", 12);
211
-			} elseif($passwordgenmethod == 'g') {
212
-				$newpassword = generate_password(8);
213
-			} else {
214
-				webAlertAndQuit("No password generation method specified!", 12);
215
-			}
216
-		}
217
-		if($passwordnotifymethod == 'e') {
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!", 12);
206
+                } else {
207
+                    $newpassword = $specifiedpassword;
208
+                }
209
+            } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
210
+                webAlertAndQuit("You didn't specify a password for this user!", 12);
211
+            } elseif($passwordgenmethod == 'g') {
212
+                $newpassword = generate_password(8);
213
+            } else {
214
+                webAlertAndQuit("No password generation method specified!", 12);
215
+            }
216
+        }
217
+        if($passwordnotifymethod == 'e') {
218 218
             sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL);
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!", 12);
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!", 12);
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
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!", 12);
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!", 12);
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 253
         saveManagerUserSettings($id);
254 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
-			?>
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,18 +332,18 @@  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.", 12);
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.", 12);
349 349
 }
Please login to merge, or discard this patch.
Switch Indentation   +237 added lines, -237 removed lines patch added patch discarded remove patch
@@ -69,110 +69,110 @@  discard block
 block discarded – undo
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!", 12);
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!", 12);
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!", 12);
91
-			} else {
92
-				$newpassword = $specifiedpassword;
93
-			}
94
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
95
-			webAlertAndQuit("You didn't specify a password for this user!", 12);
96
-		} elseif($passwordgenmethod == 'g') {
97
-			$newpassword = generate_password(8);
98
-		} else {
99
-			webAlertAndQuit("No password generation method specified!", 12);
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
-        saveManagerUserSettings($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
-            sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL);
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!", 12);
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!", 12);
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!", 12);
91
+			    } else {
92
+				    $newpassword = $specifiedpassword;
93
+			    }
94
+		    } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
95
+			    webAlertAndQuit("You didn't specify a password for this user!", 12);
96
+		    } elseif($passwordgenmethod == 'g') {
97
+			    $newpassword = generate_password(8);
98
+		    } else {
99
+			    webAlertAndQuit("No password generation method specified!", 12);
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
+            saveManagerUserSettings($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
+                sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL);
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!", 12);
206
-				} else {
207
-					$newpassword = $specifiedpassword;
208
-				}
209
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
210
-				webAlertAndQuit("You didn't specify a password for this user!", 12);
211
-			} elseif($passwordgenmethod == 'g') {
212
-				$newpassword = generate_password(8);
213
-			} else {
214
-				webAlertAndQuit("No password generation method specified!", 12);
215
-			}
216
-		}
217
-		if($passwordnotifymethod == 'e') {
218
-            sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL);
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!", 12);
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!", 12);
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
-        saveManagerUserSettings($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!", 12);
206
+				    } else {
207
+					    $newpassword = $specifiedpassword;
208
+				    }
209
+			    } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
210
+				    webAlertAndQuit("You didn't specify a password for this user!", 12);
211
+			    } elseif($passwordgenmethod == 'g') {
212
+				    $newpassword = generate_password(8);
213
+			    } else {
214
+				    webAlertAndQuit("No password generation method specified!", 12);
215
+			    }
216
+		    }
217
+		    if($passwordnotifymethod == 'e') {
218
+                sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL);
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!", 12);
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!", 12);
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
+            saveManagerUserSettings($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,18 +332,18 @@  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.", 12);
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.", 12);
349 349
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 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", 12);
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!", 12);
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!", 12);
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.", 12);
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!", 12);
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!", 12);
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!", 12);
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!", 12);
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!", 12);
@@ -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
             sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL);
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!", 12);
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!", 12);
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!", 12);
215 215
 			}
216 216
 		}
217
-		if($passwordnotifymethod == 'e') {
217
+		if ($passwordnotifymethod == 'e') {
218 218
             sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL);
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!", 12);
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!", 12);
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";
Please login to merge, or discard this patch.
manager/processors/save_web_user.processor.php 3 patches
Indentation   +192 added lines, -192 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_web_user')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $tbl_web_users = $modx->getFullTableName('web_users');
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 $input = $_POST;
14 14
 foreach($input as $k => $v) {
15
-	if($k !== 'comment') {
16
-		$v = $modx->htmlspecialchars($v, ENT_NOQUOTES);
17
-	}
18
-	$input[$k] = $v;
15
+    if($k !== 'comment') {
16
+        $v = $modx->htmlspecialchars($v, ENT_NOQUOTES);
17
+    }
18
+    $input[$k] = $v;
19 19
 }
20 20
 
21 21
 $id = (int)$input['id'];
@@ -51,82 +51,82 @@  discard block
 block discarded – undo
51 51
 
52 52
 // verify password
53 53
 if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
54
-	webAlertAndQuit("Password typed is mismatched", 88);
54
+    webAlertAndQuit("Password typed is mismatched", 88);
55 55
 }
56 56
 
57 57
 // verify email
58 58
 if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
59
-	webAlertAndQuit("E-mail address doesn't seem to be valid!", 88);
59
+    webAlertAndQuit("E-mail address doesn't seem to be valid!", 88);
60 60
 }
61 61
 
62 62
 switch($input['mode']) {
63
-	case '87' : // new user
64
-		// check if this user name already exist
65
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
-		$limit = $modx->db->getValue($rs);
67
-		if($limit > 0) {
68
-			webAlertAndQuit("User name is already in use!", 88);
69
-		}
70
-
71
-		// check if the email address already exist
72
-		if ($modx->config['allow_multiple_emails'] != 1) {
73
-			$rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
74
-			$limit = $modx->db->getValue($rs);
75
-			if($limit > 0) {
76
-				webAlertAndQuit("Email is already in use!", 88);
77
-			}
78
-		}
79
-
80
-		// generate a new password for this user
81
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
82
-			if(strlen($specifiedpassword) < 6) {
83
-				webAlertAndQuit("Password is too short!", 88);
84
-			} else {
85
-				$newpassword = $specifiedpassword;
86
-			}
87
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
88
-			webAlertAndQuit("You didn't specify a password for this user!", 88);
89
-		} elseif($passwordgenmethod == 'g') {
90
-			$newpassword = generate_password(8);
91
-		} else {
92
-			webAlertAndQuit("No password generation method specified!", 88);
93
-		}
94
-
95
-		// invoke OnBeforeWUsrFormSave event
96
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
97
-			"mode" => "new",
98
-		));
99
-
100
-		// create the user account
101
-		$field = array();
102
-		$field['username'] = $esc_newusername;
103
-		$field['password'] = md5($newpassword);
104
-		$internalKey = $modx->db->insert($field, $tbl_web_users);
105
-
106
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
107
-		$field = $modx->db->escape($field);
108
-		$modx->db->insert($field, $tbl_web_user_attributes);
109
-
110
-		// Save User Settings
63
+    case '87' : // new user
64
+        // check if this user name already exist
65
+        $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
+        $limit = $modx->db->getValue($rs);
67
+        if($limit > 0) {
68
+            webAlertAndQuit("User name is already in use!", 88);
69
+        }
70
+
71
+        // check if the email address already exist
72
+        if ($modx->config['allow_multiple_emails'] != 1) {
73
+            $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
74
+            $limit = $modx->db->getValue($rs);
75
+            if($limit > 0) {
76
+                webAlertAndQuit("Email is already in use!", 88);
77
+            }
78
+        }
79
+
80
+        // generate a new password for this user
81
+        if($specifiedpassword != "" && $passwordgenmethod == "spec") {
82
+            if(strlen($specifiedpassword) < 6) {
83
+                webAlertAndQuit("Password is too short!", 88);
84
+            } else {
85
+                $newpassword = $specifiedpassword;
86
+            }
87
+        } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
88
+            webAlertAndQuit("You didn't specify a password for this user!", 88);
89
+        } elseif($passwordgenmethod == 'g') {
90
+            $newpassword = generate_password(8);
91
+        } else {
92
+            webAlertAndQuit("No password generation method specified!", 88);
93
+        }
94
+
95
+        // invoke OnBeforeWUsrFormSave event
96
+        $modx->invokeEvent("OnBeforeWUsrFormSave", array(
97
+            "mode" => "new",
98
+        ));
99
+
100
+        // create the user account
101
+        $field = array();
102
+        $field['username'] = $esc_newusername;
103
+        $field['password'] = md5($newpassword);
104
+        $internalKey = $modx->db->insert($field, $tbl_web_users);
105
+
106
+        $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
107
+        $field = $modx->db->escape($field);
108
+        $modx->db->insert($field, $tbl_web_user_attributes);
109
+
110
+        // Save User Settings
111 111
         saveWebUserSettings($internalKey);
112 112
 
113
-		// Set the item name for logger
114
-		$_SESSION['itemname'] = $newusername;
115
-
116
-		/*******************************************************************************/
117
-		// put the user in the user_groups he/ she should be in
118
-		// first, check that up_perms are switched on!
119
-		if($use_udperms == 1) {
120
-			if(!empty($user_groups)) {
121
-				for($i = 0; $i < count($user_groups); $i++) {
122
-					$f = array();
123
-					$f['webgroup'] = (int)$user_groups[$i];
124
-					$f['webuser'] = $internalKey;
125
-					$modx->db->insert($f, $tbl_web_groups);
126
-				}
127
-			}
128
-		}
129
-		// end of user_groups stuff!
113
+        // Set the item name for logger
114
+        $_SESSION['itemname'] = $newusername;
115
+
116
+        /*******************************************************************************/
117
+        // put the user in the user_groups he/ she should be in
118
+        // first, check that up_perms are switched on!
119
+        if($use_udperms == 1) {
120
+            if(!empty($user_groups)) {
121
+                for($i = 0; $i < count($user_groups); $i++) {
122
+                    $f = array();
123
+                    $f['webgroup'] = (int)$user_groups[$i];
124
+                    $f['webuser'] = $internalKey;
125
+                    $modx->db->insert($f, $tbl_web_groups);
126
+                }
127
+            }
128
+        }
129
+        // end of user_groups stuff!
130 130
 
131 131
         // invoke OnWebSaveUser event
132 132
         $modx->invokeEvent("OnWebSaveUser", array(
@@ -144,26 +144,26 @@  discard block
 block discarded – undo
144 144
             "id" => $internalKey
145 145
         ));
146 146
 
147
-		if($passwordnotifymethod == 'e') {
147
+        if($passwordnotifymethod == 'e') {
148 148
             sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url);
149
-			if($input['stay'] != '') {
150
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
151
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
152
-				header($header);
153
-			} else {
154
-				$header = "Location: index.php?a=99&r=2";
155
-				header($header);
156
-			}
157
-		} else {
158
-			if($input['stay'] != '') {
159
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
160
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
161
-			} else {
162
-				$stayUrl = "index.php?a=99&r=2";
163
-			}
164
-
165
-			include_once "header.inc.php";
166
-			?>
149
+            if($input['stay'] != '') {
150
+                $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
151
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
152
+                header($header);
153
+            } else {
154
+                $header = "Location: index.php?a=99&r=2";
155
+                header($header);
156
+            }
157
+        } else {
158
+            if($input['stay'] != '') {
159
+                $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
160
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
161
+            } else {
162
+                $stayUrl = "index.php?a=99&r=2";
163
+            }
164
+
165
+            include_once "header.inc.php";
166
+            ?>
167 167
 
168 168
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
169 169
 
@@ -185,86 +185,86 @@  discard block
 block discarded – undo
185 185
 			</div>
186 186
 			<?php
187 187
 
188
-			include_once "footer.inc.php";
189
-		}
190
-		break;
191
-	case '88' : // edit user
192
-		// generate a new password for this user
193
-		if($genpassword == 1) {
194
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
195
-				if(strlen($specifiedpassword) < 6) {
196
-					webAlertAndQuit("Password is too short!", 88);
197
-				} else {
198
-					$newpassword = $specifiedpassword;
199
-				}
200
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
201
-				webAlertAndQuit("You didn't specify a password for this user!", 88);
202
-			} elseif($passwordgenmethod == 'g') {
203
-				$newpassword = generate_password(8);
204
-			} else {
205
-				webAlertAndQuit("No password generation method specified!", 88);
206
-			}
207
-		}
208
-		if($passwordnotifymethod == 'e') {
188
+            include_once "footer.inc.php";
189
+        }
190
+        break;
191
+    case '88' : // edit user
192
+        // generate a new password for this user
193
+        if($genpassword == 1) {
194
+            if($specifiedpassword != "" && $passwordgenmethod == "spec") {
195
+                if(strlen($specifiedpassword) < 6) {
196
+                    webAlertAndQuit("Password is too short!", 88);
197
+                } else {
198
+                    $newpassword = $specifiedpassword;
199
+                }
200
+            } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
201
+                webAlertAndQuit("You didn't specify a password for this user!", 88);
202
+            } elseif($passwordgenmethod == 'g') {
203
+                $newpassword = generate_password(8);
204
+            } else {
205
+                webAlertAndQuit("No password generation method specified!", 88);
206
+            }
207
+        }
208
+        if($passwordnotifymethod == 'e') {
209 209
             sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url);
210
-		}
211
-
212
-		// check if the username already exist
213
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
214
-		$limit = $modx->db->getValue($rs);
215
-		if($limit > 0) {
216
-			webAlertAndQuit("User name is already in use!", 88);
217
-		}
218
-
219
-		// check if the email address already exists
220
-		if ($modx->config['allow_multiple_emails'] != 1) {
221
-			$rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
222
-			$limit = $modx->db->getValue($rs);
223
-			if($limit > 0) {
224
-				webAlertAndQuit("Email is already in use!", 88);
225
-			}
226
-		}
227
-
228
-		// invoke OnBeforeWUsrFormSave event
229
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
230
-			"mode" => "upd",
231
-			"id" => $id
232
-		));
233
-
234
-		// update user name and password
235
-		$field = array();
236
-		$field['username'] = $esc_newusername;
237
-		if($genpassword == 1) {
238
-			$field['password'] = md5($newpassword);
239
-		}
240
-		$modx->db->update($field, $tbl_web_users, "id='{$id}'");
241
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
242
-		$field = $modx->db->escape($field);
243
-		$modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
244
-
245
-		// Save User Settings
210
+        }
211
+
212
+        // check if the username already exist
213
+        $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
214
+        $limit = $modx->db->getValue($rs);
215
+        if($limit > 0) {
216
+            webAlertAndQuit("User name is already in use!", 88);
217
+        }
218
+
219
+        // check if the email address already exists
220
+        if ($modx->config['allow_multiple_emails'] != 1) {
221
+            $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
222
+            $limit = $modx->db->getValue($rs);
223
+            if($limit > 0) {
224
+                webAlertAndQuit("Email is already in use!", 88);
225
+            }
226
+        }
227
+
228
+        // invoke OnBeforeWUsrFormSave event
229
+        $modx->invokeEvent("OnBeforeWUsrFormSave", array(
230
+            "mode" => "upd",
231
+            "id" => $id
232
+        ));
233
+
234
+        // update user name and password
235
+        $field = array();
236
+        $field['username'] = $esc_newusername;
237
+        if($genpassword == 1) {
238
+            $field['password'] = md5($newpassword);
239
+        }
240
+        $modx->db->update($field, $tbl_web_users, "id='{$id}'");
241
+        $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
242
+        $field = $modx->db->escape($field);
243
+        $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
244
+
245
+        // Save User Settings
246 246
         saveWebUserSettings($id);
247 247
 
248
-		// Set the item name for logger
249
-		$_SESSION['itemname'] = $newusername;
250
-
251
-		/*******************************************************************************/
252
-		// put the user in the user_groups he/ she should be in
253
-		// first, check that up_perms are switched on!
254
-		if($use_udperms == 1) {
255
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
256
-			$modx->db->delete($tbl_web_groups, "webuser='{$id}'");
257
-			if(!empty($user_groups)) {
258
-				for($i = 0; $i < count($user_groups); $i++) {
259
-					$field = array();
260
-					$field['webgroup'] = (int)$user_groups[$i];
261
-					$field['webuser'] = $id;
262
-					$modx->db->insert($field, $tbl_web_groups);
263
-				}
264
-			}
265
-		}
266
-		// end of user_groups stuff!
267
-		/*******************************************************************************/
248
+        // Set the item name for logger
249
+        $_SESSION['itemname'] = $newusername;
250
+
251
+        /*******************************************************************************/
252
+        // put the user in the user_groups he/ she should be in
253
+        // first, check that up_perms are switched on!
254
+        if($use_udperms == 1) {
255
+            // as this is an existing user, delete his/ her entries in the groups before saving the new groups
256
+            $modx->db->delete($tbl_web_groups, "webuser='{$id}'");
257
+            if(!empty($user_groups)) {
258
+                for($i = 0; $i < count($user_groups); $i++) {
259
+                    $field = array();
260
+                    $field['webgroup'] = (int)$user_groups[$i];
261
+                    $field['webuser'] = $id;
262
+                    $modx->db->insert($field, $tbl_web_groups);
263
+                }
264
+            }
265
+        }
266
+        // end of user_groups stuff!
267
+        /*******************************************************************************/
268 268
 
269 269
         // invoke OnWebSaveUser event
270 270
         $modx->invokeEvent("OnWebSaveUser", array(
@@ -293,16 +293,16 @@  discard block
 block discarded – undo
293 293
             "id" => $id
294 294
         ));
295 295
 
296
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
297
-			if($input['stay'] != '') {
298
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
299
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
300
-			} else {
301
-				$stayUrl = "index.php?a=99&r=2";
302
-			}
296
+        if($genpassword == 1 && $passwordnotifymethod == 's') {
297
+            if($input['stay'] != '') {
298
+                $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
299
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
300
+            } else {
301
+                $stayUrl = "index.php?a=99&r=2";
302
+            }
303 303
 
304
-			include_once "header.inc.php";
305
-			?>
304
+            include_once "header.inc.php";
305
+            ?>
306 306
 
307 307
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
308 308
 
@@ -322,18 +322,18 @@  discard block
 block discarded – undo
322 322
 			</div>
323 323
 			<?php
324 324
 
325
-			include_once "footer.inc.php";
326
-		} else {
327
-			if($input['stay'] != '') {
328
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
329
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
330
-				header($header);
331
-			} else {
332
-				$header = "Location: index.php?a=99&r=2";
333
-				header($header);
334
-			}
335
-		}
336
-		break;
337
-	default :
338
-		webAlertAndQuit("No operation set in request.", 88);
325
+            include_once "footer.inc.php";
326
+        } else {
327
+            if($input['stay'] != '') {
328
+                $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
329
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
330
+                header($header);
331
+            } else {
332
+                $header = "Location: index.php?a=99&r=2";
333
+                header($header);
334
+            }
335
+        }
336
+        break;
337
+    default :
338
+        webAlertAndQuit("No operation set in request.", 88);
339 339
 }
Please login to merge, or discard this patch.
Switch Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -60,110 +60,110 @@  discard block
 block discarded – undo
60 60
 }
61 61
 
62 62
 switch($input['mode']) {
63
-	case '87' : // new user
64
-		// check if this user name already exist
65
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
-		$limit = $modx->db->getValue($rs);
67
-		if($limit > 0) {
68
-			webAlertAndQuit("User name is already in use!", 88);
69
-		}
70
-
71
-		// check if the email address already exist
72
-		if ($modx->config['allow_multiple_emails'] != 1) {
73
-			$rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
74
-			$limit = $modx->db->getValue($rs);
75
-			if($limit > 0) {
76
-				webAlertAndQuit("Email is already in use!", 88);
77
-			}
78
-		}
79
-
80
-		// generate a new password for this user
81
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
82
-			if(strlen($specifiedpassword) < 6) {
83
-				webAlertAndQuit("Password is too short!", 88);
84
-			} else {
85
-				$newpassword = $specifiedpassword;
86
-			}
87
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
88
-			webAlertAndQuit("You didn't specify a password for this user!", 88);
89
-		} elseif($passwordgenmethod == 'g') {
90
-			$newpassword = generate_password(8);
91
-		} else {
92
-			webAlertAndQuit("No password generation method specified!", 88);
93
-		}
94
-
95
-		// invoke OnBeforeWUsrFormSave event
96
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
97
-			"mode" => "new",
98
-		));
99
-
100
-		// create the user account
101
-		$field = array();
102
-		$field['username'] = $esc_newusername;
103
-		$field['password'] = md5($newpassword);
104
-		$internalKey = $modx->db->insert($field, $tbl_web_users);
105
-
106
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
107
-		$field = $modx->db->escape($field);
108
-		$modx->db->insert($field, $tbl_web_user_attributes);
109
-
110
-		// Save User Settings
111
-        saveWebUserSettings($internalKey);
112
-
113
-		// Set the item name for logger
114
-		$_SESSION['itemname'] = $newusername;
115
-
116
-		/*******************************************************************************/
117
-		// put the user in the user_groups he/ she should be in
118
-		// first, check that up_perms are switched on!
119
-		if($use_udperms == 1) {
120
-			if(!empty($user_groups)) {
121
-				for($i = 0; $i < count($user_groups); $i++) {
122
-					$f = array();
123
-					$f['webgroup'] = (int)$user_groups[$i];
124
-					$f['webuser'] = $internalKey;
125
-					$modx->db->insert($f, $tbl_web_groups);
126
-				}
127
-			}
128
-		}
129
-		// end of user_groups stuff!
130
-
131
-        // invoke OnWebSaveUser event
132
-        $modx->invokeEvent("OnWebSaveUser", array(
133
-            "mode" => "new",
134
-            "userid" => $internalKey,
135
-            "username" => $newusername,
136
-            "userpassword" => $newpassword,
137
-            "useremail" => $email,
138
-            "userfullname" => $fullname
139
-        ));
140
-
141
-        // invoke OnWUsrFormSave event
142
-        $modx->invokeEvent("OnWUsrFormSave", array(
143
-            "mode" => "new",
144
-            "id" => $internalKey
145
-        ));
146
-
147
-		if($passwordnotifymethod == 'e') {
148
-            sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url);
149
-			if($input['stay'] != '') {
150
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
151
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
152
-				header($header);
153
-			} else {
154
-				$header = "Location: index.php?a=99&r=2";
155
-				header($header);
156
-			}
157
-		} else {
158
-			if($input['stay'] != '') {
159
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
160
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
161
-			} else {
162
-				$stayUrl = "index.php?a=99&r=2";
163
-			}
164
-
165
-			include_once "header.inc.php";
166
-			?>
63
+	    case '87' : // new user
64
+		    // check if this user name already exist
65
+		    $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
+		    $limit = $modx->db->getValue($rs);
67
+		    if($limit > 0) {
68
+			    webAlertAndQuit("User name is already in use!", 88);
69
+		    }
70
+
71
+		    // check if the email address already exist
72
+		    if ($modx->config['allow_multiple_emails'] != 1) {
73
+			    $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
74
+			    $limit = $modx->db->getValue($rs);
75
+			    if($limit > 0) {
76
+				    webAlertAndQuit("Email is already in use!", 88);
77
+			    }
78
+		    }
79
+
80
+		    // generate a new password for this user
81
+		    if($specifiedpassword != "" && $passwordgenmethod == "spec") {
82
+			    if(strlen($specifiedpassword) < 6) {
83
+				    webAlertAndQuit("Password is too short!", 88);
84
+			    } else {
85
+				    $newpassword = $specifiedpassword;
86
+			    }
87
+		    } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
88
+			    webAlertAndQuit("You didn't specify a password for this user!", 88);
89
+		    } elseif($passwordgenmethod == 'g') {
90
+			    $newpassword = generate_password(8);
91
+		    } else {
92
+			    webAlertAndQuit("No password generation method specified!", 88);
93
+		    }
94
+
95
+		    // invoke OnBeforeWUsrFormSave event
96
+		    $modx->invokeEvent("OnBeforeWUsrFormSave", array(
97
+			    "mode" => "new",
98
+		    ));
99
+
100
+		    // create the user account
101
+		    $field = array();
102
+		    $field['username'] = $esc_newusername;
103
+		    $field['password'] = md5($newpassword);
104
+		    $internalKey = $modx->db->insert($field, $tbl_web_users);
105
+
106
+		    $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
107
+		    $field = $modx->db->escape($field);
108
+		    $modx->db->insert($field, $tbl_web_user_attributes);
109
+
110
+		    // Save User Settings
111
+            saveWebUserSettings($internalKey);
112
+
113
+		    // Set the item name for logger
114
+		    $_SESSION['itemname'] = $newusername;
115
+
116
+		    /*******************************************************************************/
117
+		    // put the user in the user_groups he/ she should be in
118
+		    // first, check that up_perms are switched on!
119
+		    if($use_udperms == 1) {
120
+			    if(!empty($user_groups)) {
121
+				    for($i = 0; $i < count($user_groups); $i++) {
122
+					    $f = array();
123
+					    $f['webgroup'] = (int)$user_groups[$i];
124
+					    $f['webuser'] = $internalKey;
125
+					    $modx->db->insert($f, $tbl_web_groups);
126
+				    }
127
+			    }
128
+		    }
129
+		    // end of user_groups stuff!
130
+
131
+            // invoke OnWebSaveUser event
132
+            $modx->invokeEvent("OnWebSaveUser", array(
133
+                "mode" => "new",
134
+                "userid" => $internalKey,
135
+                "username" => $newusername,
136
+                "userpassword" => $newpassword,
137
+                "useremail" => $email,
138
+                "userfullname" => $fullname
139
+            ));
140
+
141
+            // invoke OnWUsrFormSave event
142
+            $modx->invokeEvent("OnWUsrFormSave", array(
143
+                "mode" => "new",
144
+                "id" => $internalKey
145
+            ));
146
+
147
+		    if($passwordnotifymethod == 'e') {
148
+                sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url);
149
+			    if($input['stay'] != '') {
150
+				    $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
151
+				    $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
152
+				    header($header);
153
+			    } else {
154
+				    $header = "Location: index.php?a=99&r=2";
155
+				    header($header);
156
+			    }
157
+		    } else {
158
+			    if($input['stay'] != '') {
159
+				    $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
160
+				    $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
161
+			    } else {
162
+				    $stayUrl = "index.php?a=99&r=2";
163
+			    }
164
+
165
+			    include_once "header.inc.php";
166
+			    ?>
167 167
 
168 168
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
169 169
 
@@ -185,124 +185,124 @@  discard block
 block discarded – undo
185 185
 			</div>
186 186
 			<?php
187 187
 
188
-			include_once "footer.inc.php";
189
-		}
190
-		break;
191
-	case '88' : // edit user
192
-		// generate a new password for this user
193
-		if($genpassword == 1) {
194
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
195
-				if(strlen($specifiedpassword) < 6) {
196
-					webAlertAndQuit("Password is too short!", 88);
197
-				} else {
198
-					$newpassword = $specifiedpassword;
199
-				}
200
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
201
-				webAlertAndQuit("You didn't specify a password for this user!", 88);
202
-			} elseif($passwordgenmethod == 'g') {
203
-				$newpassword = generate_password(8);
204
-			} else {
205
-				webAlertAndQuit("No password generation method specified!", 88);
206
-			}
207
-		}
208
-		if($passwordnotifymethod == 'e') {
209
-            sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url);
210
-		}
211
-
212
-		// check if the username already exist
213
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
214
-		$limit = $modx->db->getValue($rs);
215
-		if($limit > 0) {
216
-			webAlertAndQuit("User name is already in use!", 88);
217
-		}
218
-
219
-		// check if the email address already exists
220
-		if ($modx->config['allow_multiple_emails'] != 1) {
221
-			$rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
222
-			$limit = $modx->db->getValue($rs);
223
-			if($limit > 0) {
224
-				webAlertAndQuit("Email is already in use!", 88);
225
-			}
226
-		}
227
-
228
-		// invoke OnBeforeWUsrFormSave event
229
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
230
-			"mode" => "upd",
231
-			"id" => $id
232
-		));
233
-
234
-		// update user name and password
235
-		$field = array();
236
-		$field['username'] = $esc_newusername;
237
-		if($genpassword == 1) {
238
-			$field['password'] = md5($newpassword);
239
-		}
240
-		$modx->db->update($field, $tbl_web_users, "id='{$id}'");
241
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
242
-		$field = $modx->db->escape($field);
243
-		$modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
244
-
245
-		// Save User Settings
246
-        saveWebUserSettings($id);
247
-
248
-		// Set the item name for logger
249
-		$_SESSION['itemname'] = $newusername;
250
-
251
-		/*******************************************************************************/
252
-		// put the user in the user_groups he/ she should be in
253
-		// first, check that up_perms are switched on!
254
-		if($use_udperms == 1) {
255
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
256
-			$modx->db->delete($tbl_web_groups, "webuser='{$id}'");
257
-			if(!empty($user_groups)) {
258
-				for($i = 0; $i < count($user_groups); $i++) {
259
-					$field = array();
260
-					$field['webgroup'] = (int)$user_groups[$i];
261
-					$field['webuser'] = $id;
262
-					$modx->db->insert($field, $tbl_web_groups);
263
-				}
264
-			}
265
-		}
266
-		// end of user_groups stuff!
267
-		/*******************************************************************************/
268
-
269
-        // invoke OnWebSaveUser event
270
-        $modx->invokeEvent("OnWebSaveUser", array(
271
-            "mode" => "upd",
272
-            "userid" => $id,
273
-            "username" => $newusername,
274
-            "userpassword" => $newpassword,
275
-            "useremail" => $email,
276
-            "userfullname" => $fullname,
277
-            "oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
278
-            "olduseremail" => (($oldemail != $email) ? $oldemail : "")
279
-        ));
280
-
281
-        // invoke OnWebChangePassword event
282
-        if($genpassword == 1) {
283
-            $modx->invokeEvent("OnWebChangePassword", array(
188
+			    include_once "footer.inc.php";
189
+		    }
190
+		    break;
191
+	    case '88' : // edit user
192
+		    // generate a new password for this user
193
+		    if($genpassword == 1) {
194
+			    if($specifiedpassword != "" && $passwordgenmethod == "spec") {
195
+				    if(strlen($specifiedpassword) < 6) {
196
+					    webAlertAndQuit("Password is too short!", 88);
197
+				    } else {
198
+					    $newpassword = $specifiedpassword;
199
+				    }
200
+			    } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
201
+				    webAlertAndQuit("You didn't specify a password for this user!", 88);
202
+			    } elseif($passwordgenmethod == 'g') {
203
+				    $newpassword = generate_password(8);
204
+			    } else {
205
+				    webAlertAndQuit("No password generation method specified!", 88);
206
+			    }
207
+		    }
208
+		    if($passwordnotifymethod == 'e') {
209
+                sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url);
210
+		    }
211
+
212
+		    // check if the username already exist
213
+		    $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
214
+		    $limit = $modx->db->getValue($rs);
215
+		    if($limit > 0) {
216
+			    webAlertAndQuit("User name is already in use!", 88);
217
+		    }
218
+
219
+		    // check if the email address already exists
220
+		    if ($modx->config['allow_multiple_emails'] != 1) {
221
+			    $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
222
+			    $limit = $modx->db->getValue($rs);
223
+			    if($limit > 0) {
224
+				    webAlertAndQuit("Email is already in use!", 88);
225
+			    }
226
+		    }
227
+
228
+		    // invoke OnBeforeWUsrFormSave event
229
+		    $modx->invokeEvent("OnBeforeWUsrFormSave", array(
230
+			    "mode" => "upd",
231
+			    "id" => $id
232
+		    ));
233
+
234
+		    // update user name and password
235
+		    $field = array();
236
+		    $field['username'] = $esc_newusername;
237
+		    if($genpassword == 1) {
238
+			    $field['password'] = md5($newpassword);
239
+		    }
240
+		    $modx->db->update($field, $tbl_web_users, "id='{$id}'");
241
+		    $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
242
+		    $field = $modx->db->escape($field);
243
+		    $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
244
+
245
+		    // Save User Settings
246
+            saveWebUserSettings($id);
247
+
248
+		    // Set the item name for logger
249
+		    $_SESSION['itemname'] = $newusername;
250
+
251
+		    /*******************************************************************************/
252
+		    // put the user in the user_groups he/ she should be in
253
+		    // first, check that up_perms are switched on!
254
+		    if($use_udperms == 1) {
255
+			    // as this is an existing user, delete his/ her entries in the groups before saving the new groups
256
+			    $modx->db->delete($tbl_web_groups, "webuser='{$id}'");
257
+			    if(!empty($user_groups)) {
258
+				    for($i = 0; $i < count($user_groups); $i++) {
259
+					    $field = array();
260
+					    $field['webgroup'] = (int)$user_groups[$i];
261
+					    $field['webuser'] = $id;
262
+					    $modx->db->insert($field, $tbl_web_groups);
263
+				    }
264
+			    }
265
+		    }
266
+		    // end of user_groups stuff!
267
+		    /*******************************************************************************/
268
+
269
+            // invoke OnWebSaveUser event
270
+            $modx->invokeEvent("OnWebSaveUser", array(
271
+                "mode" => "upd",
284 272
                 "userid" => $id,
285 273
                 "username" => $newusername,
286
-                "userpassword" => $newpassword
274
+                "userpassword" => $newpassword,
275
+                "useremail" => $email,
276
+                "userfullname" => $fullname,
277
+                "oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
278
+                "olduseremail" => (($oldemail != $email) ? $oldemail : "")
287 279
             ));
288
-        }
289 280
 
290
-        // invoke OnWUsrFormSave event
291
-        $modx->invokeEvent("OnWUsrFormSave", array(
292
-            "mode" => "upd",
293
-            "id" => $id
294
-        ));
281
+            // invoke OnWebChangePassword event
282
+            if($genpassword == 1) {
283
+                $modx->invokeEvent("OnWebChangePassword", array(
284
+                    "userid" => $id,
285
+                    "username" => $newusername,
286
+                    "userpassword" => $newpassword
287
+                ));
288
+            }
289
+
290
+            // invoke OnWUsrFormSave event
291
+            $modx->invokeEvent("OnWUsrFormSave", array(
292
+                "mode" => "upd",
293
+                "id" => $id
294
+            ));
295 295
 
296
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
297
-			if($input['stay'] != '') {
298
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
299
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
300
-			} else {
301
-				$stayUrl = "index.php?a=99&r=2";
302
-			}
296
+		    if($genpassword == 1 && $passwordnotifymethod == 's') {
297
+			    if($input['stay'] != '') {
298
+				    $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
299
+				    $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
300
+			    } else {
301
+				    $stayUrl = "index.php?a=99&r=2";
302
+			    }
303 303
 
304
-			include_once "header.inc.php";
305
-			?>
304
+			    include_once "header.inc.php";
305
+			    ?>
306 306
 
307 307
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
308 308
 
@@ -322,18 +322,18 @@  discard block
 block discarded – undo
322 322
 			</div>
323 323
 			<?php
324 324
 
325
-			include_once "footer.inc.php";
326
-		} else {
327
-			if($input['stay'] != '') {
328
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
329
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
330
-				header($header);
331
-			} else {
332
-				$header = "Location: index.php?a=99&r=2";
333
-				header($header);
334
-			}
335
-		}
336
-		break;
337
-	default :
338
-		webAlertAndQuit("No operation set in request.", 88);
325
+			    include_once "footer.inc.php";
326
+		    } else {
327
+			    if($input['stay'] != '') {
328
+				    $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
329
+				    $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
330
+				    header($header);
331
+			    } else {
332
+				    $header = "Location: index.php?a=99&r=2";
333
+				    header($header);
334
+			    }
335
+		    }
336
+		    break;
337
+	    default :
338
+		    webAlertAndQuit("No operation set in request.", 88);
339 339
 }
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 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_web_user')) {
5
+if (!$modx->hasPermission('save_web_user')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 $tbl_web_groups = $modx->getFullTableName('web_groups');
12 12
 
13 13
 $input = $_POST;
14
-foreach($input as $k => $v) {
15
-	if($k !== 'comment') {
14
+foreach ($input as $k => $v) {
15
+	if ($k !== 'comment') {
16 16
 		$v = $modx->htmlspecialchars($v, ENT_NOQUOTES);
17 17
 	}
18 18
 	$input[$k] = $v;
19 19
 }
20 20
 
21
-$id = (int)$input['id'];
21
+$id = (int) $input['id'];
22 22
 $oldusername = $input['oldusername'];
23 23
 $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User";
24 24
 $esc_newusername = $modx->db->escape($newusername);
@@ -50,21 +50,21 @@  discard block
 block discarded – undo
50 50
 $user_groups = $input['user_groups'];
51 51
 
52 52
 // verify password
53
-if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
53
+if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
54 54
 	webAlertAndQuit("Password typed is mismatched", 88);
55 55
 }
56 56
 
57 57
 // verify email
58
-if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
58
+if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
59 59
 	webAlertAndQuit("E-mail address doesn't seem to be valid!", 88);
60 60
 }
61 61
 
62
-switch($input['mode']) {
62
+switch ($input['mode']) {
63 63
 	case '87' : // new user
64 64
 		// check if this user name already exist
65 65
 		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66 66
 		$limit = $modx->db->getValue($rs);
67
-		if($limit > 0) {
67
+		if ($limit > 0) {
68 68
 			webAlertAndQuit("User name is already in use!", 88);
69 69
 		}
70 70
 
@@ -72,21 +72,21 @@  discard block
 block discarded – undo
72 72
 		if ($modx->config['allow_multiple_emails'] != 1) {
73 73
 			$rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
74 74
 			$limit = $modx->db->getValue($rs);
75
-			if($limit > 0) {
75
+			if ($limit > 0) {
76 76
 				webAlertAndQuit("Email is already in use!", 88);
77 77
 			}
78 78
 		}
79 79
 
80 80
 		// generate a new password for this user
81
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
82
-			if(strlen($specifiedpassword) < 6) {
81
+		if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
82
+			if (strlen($specifiedpassword) < 6) {
83 83
 				webAlertAndQuit("Password is too short!", 88);
84 84
 			} else {
85 85
 				$newpassword = $specifiedpassword;
86 86
 			}
87
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
87
+		} elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
88 88
 			webAlertAndQuit("You didn't specify a password for this user!", 88);
89
-		} elseif($passwordgenmethod == 'g') {
89
+		} elseif ($passwordgenmethod == 'g') {
90 90
 			$newpassword = generate_password(8);
91 91
 		} else {
92 92
 			webAlertAndQuit("No password generation method specified!", 88);
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 		/*******************************************************************************/
117 117
 		// put the user in the user_groups he/ she should be in
118 118
 		// first, check that up_perms are switched on!
119
-		if($use_udperms == 1) {
120
-			if(!empty($user_groups)) {
121
-				for($i = 0; $i < count($user_groups); $i++) {
119
+		if ($use_udperms == 1) {
120
+			if (!empty($user_groups)) {
121
+				for ($i = 0; $i < count($user_groups); $i++) {
122 122
 					$f = array();
123
-					$f['webgroup'] = (int)$user_groups[$i];
123
+					$f['webgroup'] = (int) $user_groups[$i];
124 124
 					$f['webuser'] = $internalKey;
125 125
 					$modx->db->insert($f, $tbl_web_groups);
126 126
 				}
@@ -144,20 +144,20 @@  discard block
 block discarded – undo
144 144
             "id" => $internalKey
145 145
         ));
146 146
 
147
-		if($passwordnotifymethod == 'e') {
147
+		if ($passwordnotifymethod == 'e') {
148 148
             sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url);
149
-			if($input['stay'] != '') {
149
+			if ($input['stay'] != '') {
150 150
 				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
151
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
151
+				$header = "Location: index.php?a={$a}&r=2&stay=".$input['stay'];
152 152
 				header($header);
153 153
 			} else {
154 154
 				$header = "Location: index.php?a=99&r=2";
155 155
 				header($header);
156 156
 			}
157 157
 		} else {
158
-			if($input['stay'] != '') {
158
+			if ($input['stay'] != '') {
159 159
 				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
160
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
160
+				$stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay'];
161 161
 			} else {
162 162
 				$stayUrl = "index.php?a=99&r=2";
163 163
 			}
@@ -190,29 +190,29 @@  discard block
 block discarded – undo
190 190
 		break;
191 191
 	case '88' : // edit user
192 192
 		// generate a new password for this user
193
-		if($genpassword == 1) {
194
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
195
-				if(strlen($specifiedpassword) < 6) {
193
+		if ($genpassword == 1) {
194
+			if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
195
+				if (strlen($specifiedpassword) < 6) {
196 196
 					webAlertAndQuit("Password is too short!", 88);
197 197
 				} else {
198 198
 					$newpassword = $specifiedpassword;
199 199
 				}
200
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
200
+			} elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
201 201
 				webAlertAndQuit("You didn't specify a password for this user!", 88);
202
-			} elseif($passwordgenmethod == 'g') {
202
+			} elseif ($passwordgenmethod == 'g') {
203 203
 				$newpassword = generate_password(8);
204 204
 			} else {
205 205
 				webAlertAndQuit("No password generation method specified!", 88);
206 206
 			}
207 207
 		}
208
-		if($passwordnotifymethod == 'e') {
208
+		if ($passwordnotifymethod == 'e') {
209 209
             sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $websignupemail_message, $site_url);
210 210
 		}
211 211
 
212 212
 		// check if the username already exist
213 213
 		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
214 214
 		$limit = $modx->db->getValue($rs);
215
-		if($limit > 0) {
215
+		if ($limit > 0) {
216 216
 			webAlertAndQuit("User name is already in use!", 88);
217 217
 		}
218 218
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		if ($modx->config['allow_multiple_emails'] != 1) {
221 221
 			$rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
222 222
 			$limit = $modx->db->getValue($rs);
223
-			if($limit > 0) {
223
+			if ($limit > 0) {
224 224
 				webAlertAndQuit("Email is already in use!", 88);
225 225
 			}
226 226
 		}
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		// update user name and password
235 235
 		$field = array();
236 236
 		$field['username'] = $esc_newusername;
237
-		if($genpassword == 1) {
237
+		if ($genpassword == 1) {
238 238
 			$field['password'] = md5($newpassword);
239 239
 		}
240 240
 		$modx->db->update($field, $tbl_web_users, "id='{$id}'");
@@ -251,13 +251,13 @@  discard block
 block discarded – undo
251 251
 		/*******************************************************************************/
252 252
 		// put the user in the user_groups he/ she should be in
253 253
 		// first, check that up_perms are switched on!
254
-		if($use_udperms == 1) {
254
+		if ($use_udperms == 1) {
255 255
 			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
256 256
 			$modx->db->delete($tbl_web_groups, "webuser='{$id}'");
257
-			if(!empty($user_groups)) {
258
-				for($i = 0; $i < count($user_groups); $i++) {
257
+			if (!empty($user_groups)) {
258
+				for ($i = 0; $i < count($user_groups); $i++) {
259 259
 					$field = array();
260
-					$field['webgroup'] = (int)$user_groups[$i];
260
+					$field['webgroup'] = (int) $user_groups[$i];
261 261
 					$field['webuser'] = $id;
262 262
 					$modx->db->insert($field, $tbl_web_groups);
263 263
 				}
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
         ));
280 280
 
281 281
         // invoke OnWebChangePassword event
282
-        if($genpassword == 1) {
282
+        if ($genpassword == 1) {
283 283
             $modx->invokeEvent("OnWebChangePassword", array(
284 284
                 "userid" => $id,
285 285
                 "username" => $newusername,
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
             "id" => $id
294 294
         ));
295 295
 
296
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
297
-			if($input['stay'] != '') {
296
+		if ($genpassword == 1 && $passwordnotifymethod == 's') {
297
+			if ($input['stay'] != '') {
298 298
 				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
299
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
299
+				$stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay'];
300 300
 			} else {
301 301
 				$stayUrl = "index.php?a=99&r=2";
302 302
 			}
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
 
325 325
 			include_once "footer.inc.php";
326 326
 		} else {
327
-			if($input['stay'] != '') {
327
+			if ($input['stay'] != '') {
328 328
 				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
329
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
329
+				$header = "Location: index.php?a={$a}&r=2&stay=".$input['stay'];
330 330
 				header($header);
331 331
 			} else {
332 332
 				$header = "Location: index.php?a=99&r=2";
Please login to merge, or discard this patch.
manager/processors/delete_content.processor.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if (!$modx->hasPermission('delete_document')) {
6 6
     $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10
-if ($id==0) {
9
+$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
10
+if ($id == 0) {
11 11
     $modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 /*******ищем родителя чтобы к нему вернуться********/
15
-$content=$modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'"));
16
-$pid=($content['parent']==0?$id:$content['parent']);
15
+$content = $modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'"));
16
+$pid = ($content['parent'] == 0 ? $id : $content['parent']);
17 17
 
18 18
 /************ а заодно и путь возврата (сам путь внизу файла) **********/
19
-$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC';
20
-$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon';
21
-$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:'';
22
-$add_path=$sd.$sb.$pg;
19
+$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC';
20
+$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon';
21
+$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : '';
22
+$add_path = $sd.$sb.$pg;
23 23
 
24 24
 /*****************************/
25 25
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
                             "children"=>$children
46 46
                         ));
47 47
 
48
-if (count($children)>0) {
48
+if (count($children) > 0) {
49 49
     $modx->db->update(
50 50
         array(
51 51
             'deleted'   => 1,
@@ -54,19 +54,19 @@  discard block
 block discarded – undo
54 54
         ), $modx->getFullTableName('site_content'), "id IN (".implode(", ", $children).")");
55 55
 }
56 56
 
57
-if ($site_start==$id) {
57
+if ($site_start == $id) {
58 58
     $modx->webAlertAndQuit("Document is 'Site start' and cannot be deleted!");
59 59
 }
60 60
 
61
-if ($site_unavailable_page==$id) {
61
+if ($site_unavailable_page == $id) {
62 62
     $modx->webAlertAndQuit("Document is used as the 'Site unavailable page' and cannot be deleted!");
63 63
 }
64 64
 
65
-if ($error_page==$id) {
65
+if ($error_page == $id) {
66 66
     $modx->webAlertAndQuit("Document is used as the 'Site error page' and cannot be deleted!");
67 67
 }
68 68
 
69
-if ($unauthorized_page==$id) {
69
+if ($unauthorized_page == $id) {
70 70
     $modx->webAlertAndQuit("Document is used as the 'Site unauthorized page' and cannot be deleted!");
71 71
 }
72 72
 
@@ -92,5 +92,5 @@  discard block
 block discarded – undo
92 92
 $modx->clearCache('full');
93 93
 
94 94
 // finished emptying cache - redirect
95
-$header="Location: index.php?a=3&id=$pid&r=1".$add_path;
95
+$header = "Location: index.php?a=3&id=$pid&r=1".$add_path;
96 96
 header($header);
Please login to merge, or discard this patch.
manager/processors/save_module.processor.php 1 patch
Switch Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -59,123 +59,123 @@
 block discarded – undo
59 59
 }
60 60
 
61 61
 switch ($_POST['mode']) {
62
-    case '107':
63
-        // invoke OnBeforeModFormSave event
64
-        $modx->invokeEvent("OnBeforeModFormSave", array(
65
-                "mode" => "new",
66
-                "id" => $id
67
-            ));
68
-
69
-        // disallow duplicate names for new modules
70
-        $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'");
71
-        $count = $modx->db->getValue($rs);
72
-        if ($count > 0) {
73
-            $modx->manager->saveFormValues(107);
74
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107");
75
-        }
76
-
77
-        // save the new module
78
-        $newid = $modx->db->insert(array(
79
-            'name' => $name,
80
-            'description' => $description,
81
-            'disabled' => $disabled,
82
-            'wrap' => $wrap,
83
-            'locked' => $locked,
84
-            'icon' => $icon,
85
-            'resourcefile' => $resourcefile,
86
-            'enable_resource' => $enable_resource,
87
-            'category' => $categoryid,
88
-            'enable_sharedparams' => $enable_sharedparams,
89
-            'guid' => $guid,
90
-            'modulecode' => $modulecode,
91
-            'properties' => $properties,
92
-            'createdon' => $currentdate,
93
-            'editedon' => $currentdate
94
-        ), $modx->getFullTableName('site_modules'));
95
-
96
-        // save user group access permissions
97
-        saveUserGroupAccessPermissons();
98
-
99
-        // invoke OnModFormSave event
100
-        $modx->invokeEvent("OnModFormSave", array(
101
-                "mode" => "new",
102
-                "id" => $newid
103
-            ));
104
-
105
-        // Set the item name for logger
106
-        $_SESSION['itemname'] = $name;
107
-
108
-        // empty cache
109
-        $modx->clearCache('full');
110
-
111
-        // finished emptying cache - redirect
112
-        if ($_POST['stay'] != '') {
113
-            $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107";
114
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
115
-            header($header);
116
-        } else {
117
-            $header = "Location: index.php?a=106&r=2";
118
-            header($header);
119
-        }
120
-        break;
121
-    case '108':
122
-        // invoke OnBeforeModFormSave event
123
-        $modx->invokeEvent("OnBeforeModFormSave", array(
124
-                "mode" => "upd",
125
-                "id" => $id
126
-            ));
127
-
128
-        // disallow duplicate names for new modules
129
-        $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'");
130
-        if ($modx->db->getValue($rs) > 0) {
131
-            $modx->manager->saveFormValues(108);
132
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}");
133
-        }
134
-
135
-        // save the edited module
136
-        $modx->db->update(array(
137
-            'name' => $name,
138
-            'description' => $description,
139
-            'icon' => $icon,
140
-            'enable_resource' => $enable_resource,
141
-            'resourcefile' => $resourcefile,
142
-            'disabled' => $disabled,
143
-            'wrap' => $wrap,
144
-            'locked' => $locked,
145
-            'category' => $categoryid,
146
-            'enable_sharedparams' => $enable_sharedparams,
147
-            'guid' => $guid,
148
-            'modulecode' => $modulecode,
149
-            'properties' => $properties,
150
-            'editedon' => $currentdate
151
-        ), $modx->getFullTableName('site_modules'), "id='{$id}'");
152
-
153
-        // save user group access permissions
154
-        saveUserGroupAccessPermissons();
155
-
156
-        // invoke OnModFormSave event
157
-        $modx->invokeEvent("OnModFormSave", array(
158
-                "mode" => "upd",
159
-                "id" => $id
160
-            ));
161
-
162
-        // Set the item name for logger
163
-        $_SESSION['itemname'] = $name;
164
-
165
-        // empty cache
166
-        $modx->clearCache('full');
167
-
168
-        // finished emptying cache - redirect
169
-        if ($_POST['stay'] != '') {
170
-            $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107";
171
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
172
-            header($header);
173
-        } else {
174
-            $modx->unlockElement(6, $id);
175
-            $header = "Location: index.php?a=106&r=2";
176
-            header($header);
177
-        }
178
-        break;
179
-    default:
180
-        $modx->webAlertAndQuit("No operation set in request.");
62
+        case '107':
63
+            // invoke OnBeforeModFormSave event
64
+            $modx->invokeEvent("OnBeforeModFormSave", array(
65
+                    "mode" => "new",
66
+                    "id" => $id
67
+                ));
68
+
69
+            // disallow duplicate names for new modules
70
+            $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'");
71
+            $count = $modx->db->getValue($rs);
72
+            if ($count > 0) {
73
+                $modx->manager->saveFormValues(107);
74
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107");
75
+            }
76
+
77
+            // save the new module
78
+            $newid = $modx->db->insert(array(
79
+                'name' => $name,
80
+                'description' => $description,
81
+                'disabled' => $disabled,
82
+                'wrap' => $wrap,
83
+                'locked' => $locked,
84
+                'icon' => $icon,
85
+                'resourcefile' => $resourcefile,
86
+                'enable_resource' => $enable_resource,
87
+                'category' => $categoryid,
88
+                'enable_sharedparams' => $enable_sharedparams,
89
+                'guid' => $guid,
90
+                'modulecode' => $modulecode,
91
+                'properties' => $properties,
92
+                'createdon' => $currentdate,
93
+                'editedon' => $currentdate
94
+            ), $modx->getFullTableName('site_modules'));
95
+
96
+            // save user group access permissions
97
+            saveUserGroupAccessPermissons();
98
+
99
+            // invoke OnModFormSave event
100
+            $modx->invokeEvent("OnModFormSave", array(
101
+                    "mode" => "new",
102
+                    "id" => $newid
103
+                ));
104
+
105
+            // Set the item name for logger
106
+            $_SESSION['itemname'] = $name;
107
+
108
+            // empty cache
109
+            $modx->clearCache('full');
110
+
111
+            // finished emptying cache - redirect
112
+            if ($_POST['stay'] != '') {
113
+                $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107";
114
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
115
+                header($header);
116
+            } else {
117
+                $header = "Location: index.php?a=106&r=2";
118
+                header($header);
119
+            }
120
+            break;
121
+        case '108':
122
+            // invoke OnBeforeModFormSave event
123
+            $modx->invokeEvent("OnBeforeModFormSave", array(
124
+                    "mode" => "upd",
125
+                    "id" => $id
126
+                ));
127
+
128
+            // disallow duplicate names for new modules
129
+            $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'");
130
+            if ($modx->db->getValue($rs) > 0) {
131
+                $modx->manager->saveFormValues(108);
132
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}");
133
+            }
134
+
135
+            // save the edited module
136
+            $modx->db->update(array(
137
+                'name' => $name,
138
+                'description' => $description,
139
+                'icon' => $icon,
140
+                'enable_resource' => $enable_resource,
141
+                'resourcefile' => $resourcefile,
142
+                'disabled' => $disabled,
143
+                'wrap' => $wrap,
144
+                'locked' => $locked,
145
+                'category' => $categoryid,
146
+                'enable_sharedparams' => $enable_sharedparams,
147
+                'guid' => $guid,
148
+                'modulecode' => $modulecode,
149
+                'properties' => $properties,
150
+                'editedon' => $currentdate
151
+            ), $modx->getFullTableName('site_modules'), "id='{$id}'");
152
+
153
+            // save user group access permissions
154
+            saveUserGroupAccessPermissons();
155
+
156
+            // invoke OnModFormSave event
157
+            $modx->invokeEvent("OnModFormSave", array(
158
+                    "mode" => "upd",
159
+                    "id" => $id
160
+                ));
161
+
162
+            // Set the item name for logger
163
+            $_SESSION['itemname'] = $name;
164
+
165
+            // empty cache
166
+            $modx->clearCache('full');
167
+
168
+            // finished emptying cache - redirect
169
+            if ($_POST['stay'] != '') {
170
+                $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107";
171
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
172
+                header($header);
173
+            } else {
174
+                $modx->unlockElement(6, $id);
175
+                $header = "Location: index.php?a=106&r=2";
176
+                header($header);
177
+            }
178
+            break;
179
+        default:
180
+            $modx->webAlertAndQuit("No operation set in request.");
181 181
 }
Please login to merge, or discard this patch.
manager/actions/search.static.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  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
     exit();
4 4
 }
5 5
 unset($_SESSION['itemname']); // clear this, because it's only set for logging purposes
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
                         <?php
42 42
                         $rs = $modx->db->select('*', $modx->getFullTableName('site_templates'));
43 43
                         $option[] = '<option value="">No selected</option>';
44
-                        $templateid = (isset($_REQUEST['templateid']) && $_REQUEST['templateid'] !== '') ? (int)$_REQUEST['templateid'] : '';
44
+                        $templateid = (isset($_REQUEST['templateid']) && $_REQUEST['templateid'] !== '') ? (int) $_REQUEST['templateid'] : '';
45 45
                         $selected = $templateid === 0 ? ' selected="selected"' : '';
46
-                        $option[] = '<option value="0"' . $selected . '>(blank)</option>';
46
+                        $option[] = '<option value="0"'.$selected.'>(blank)</option>';
47 47
                         while ($row = $modx->db->getRow($rs)) {
48 48
                             $templatename = htmlspecialchars($row['templatename'], ENT_QUOTES, $modx->config['modx_charset']);
49 49
                             $selected = $row['id'] == $templateid ? ' selected="selected"' : '';
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     $searchfields = htmlentities(trim($_POST['searchfields']), ENT_QUOTES, $modx_manager_charset);
87 87
     $searchlongtitle = $modx->db->escape(trim($_REQUEST['searchfields']));
88 88
     $search_alias = $modx->db->escape(trim($_REQUEST['searchfields']));
89
-    $templateid = isset($_REQUEST['templateid']) && $_REQUEST['templateid'] !== '' ? (int)$_REQUEST['templateid'] : '';
89
+    $templateid = isset($_REQUEST['templateid']) && $_REQUEST['templateid'] !== '' ? (int) $_REQUEST['templateid'] : '';
90 90
     $searchcontent = $modx->db->escape($_REQUEST['content']);
91 91
 
92 92
     $fields = 'DISTINCT sc.id, contenttype, pagetitle, longtitle, description, introtext, menutitle, deleted, published, isfolder, type';
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
         $friendly_url_suffix = $modx->config['friendly_url_suffix'];
101 101
         $base_url = $modx->config['base_url'];
102 102
         $site_url = $modx->config['site_url'];
103
-        $url = preg_replace('@' . $friendly_url_suffix . '$@', '', $url);
103
+        $url = preg_replace('@'.$friendly_url_suffix.'$@', '', $url);
104 104
         if ($url[0] === '/') {
105
-            $url = preg_replace('@^' . $base_url . '@', '', $url);
105
+            $url = preg_replace('@^'.$base_url.'@', '', $url);
106 106
         }
107 107
         if (substr($url, 0, 4) === 'http') {
108
-            $url = preg_replace('@^' . $site_url . '@', '', $url);
108
+            $url = preg_replace('@^'.$site_url.'@', '', $url);
109 109
         }
110 110
         $idFromAlias = $modx->getIdFromAlias($url);
111 111
     }
@@ -118,18 +118,18 @@  discard block
 block discarded – undo
118 118
 		$articul_query = "SELECT `contentid` FROM {$tbl_site_tmplvar_contentvalues} WHERE `value` LIKE '%{$searchfields}%'";
119 119
 		$articul_result = $modx->db->query($articul_query);
120 120
 		$articul_id_array = $modx->db->makeArray($articul_result);
121
-		if(count($articul_id_array)>0){
121
+		if (count($articul_id_array) > 0) {
122 122
 			$articul_id = '';
123 123
 			$i = 1;
124
-			foreach( $articul_id_array as $articul ) {
125
-				$articul_id.=$articul['contentid'];
126
-				if($i !== count($articul_id_array)){
127
-					$articul_id.=',';
124
+			foreach ($articul_id_array as $articul) {
125
+				$articul_id .= $articul['contentid'];
126
+				if ($i !== count($articul_id_array)) {
127
+					$articul_id .= ',';
128 128
 				}
129 129
 				$i++;
130 130
 			}
131 131
 		$articul_id_query = " OR sc.id IN ({$articul_id})";
132
-		}else{
132
+		} else {
133 133
 			$articul_id_query = '';
134 134
 		}
135 135
 		/*end search by TV*/
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         if (ctype_digit($searchfields)) {
138 138
             $sqladd .= "sc.id='{$searchfields}'";
139 139
             if (strlen($searchfields) > 3) {
140
-				$sqladd .= $articul_id_query;//search by TV
140
+				$sqladd .= $articul_id_query; //search by TV
141 141
                 $sqladd .= " OR sc.pagetitle LIKE '%{$searchfields}%'";
142 142
             }
143 143
         }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             $sqladd .= " OR sc.introtext LIKE '%{$searchlongtitle}%'";
158 158
             $sqladd .= " OR sc.menutitle LIKE '%{$searchlongtitle}%'";
159 159
             $sqladd .= " OR sc.alias LIKE '%{$search_alias}%'";
160
-            $sqladd .= $articul_id_query;//search by TV
160
+            $sqladd .= $articul_id_query; //search by TV
161 161
             $sqladd .= ")";
162 162
         }
163 163
     } else if ($idFromAlias) {
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
         $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : '';
182 182
         $mgrRole = (isset ($_SESSION['mgrRole']) && $_SESSION['mgrRole'] == 1) ? 1 : 0;
183 183
         $docgrp_cond = $docgrp ? " OR dg.document_group IN ({$docgrp})" : '';
184
-        $fields .= ', MAX(IF(1=' . $mgrRole . ' OR sc.privatemgr=0' . $docgrp_cond . ',1,0)) AS hasAccess';
185
-        $sqladd = '(' . $sqladd . ") AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))");
184
+        $fields .= ', MAX(IF(1='.$mgrRole.' OR sc.privatemgr=0'.$docgrp_cond.',1,0)) AS hasAccess';
185
+        $sqladd = '('.$sqladd.") AND (1={$mgrRole} OR sc.privatemgr=0".(!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))");
186 186
     }
187 187
 
188 188
     if ($sqladd) {
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     $where = $sqladd;
193 193
 
194 194
     if ($where) {
195
-        $rs = $modx->db->select($fields, $tbl_site_content . ' AS sc LEFT JOIN ' . $tbldg . ' AS dg ON dg.document=sc.id', $where, 'sc.id');
195
+        $rs = $modx->db->select($fields, $tbl_site_content.' AS sc LEFT JOIN '.$tbldg.' AS dg ON dg.document=sc.id', $where, 'sc.id');
196 196
         $limit = $modx->db->getRecordCount($rs);
197 197
     } else {
198 198
         $limit = 0;
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                 if ($limit < 1) {
212 212
                     echo $_lang['search_empty'];
213 213
                 } else {
214
-                    printf('<p>' . $_lang['search_results_returned_msg'] . '</p>', $limit);
214
+                    printf('<p>'.$_lang['search_results_returned_msg'].'</p>', $limit);
215 215
                     ?>
216 216
                     <script type="text/javascript" src="media/script/tablesort.js"></script>
217 217
                     <table class="grid sortabletable sortable-onload-2 rowstyle-even" id="table-1">
@@ -271,14 +271,14 @@  discard block
 block discarded – undo
271 271
                                 if (function_exists('mb_strlen') && function_exists('mb_substr')) {
272 272
                                     ?>
273 273
                                     <td<?= $tdClass ?>>
274
-                                        <a href="index.php?a=27&id=<?= $row['id'] ?>"><?= mb_strlen($row['pagetitle'], $modx_manager_charset) > 70 ? mb_substr($row['pagetitle'], 0, 70, $modx_manager_charset) . "..." : $row['pagetitle'] ?></a>
274
+                                        <a href="index.php?a=27&id=<?= $row['id'] ?>"><?= mb_strlen($row['pagetitle'], $modx_manager_charset) > 70 ? mb_substr($row['pagetitle'], 0, 70, $modx_manager_charset)."..." : $row['pagetitle'] ?></a>
275 275
                                     </td>
276
-                                    <td<?= $tdClass ?>><?= mb_strlen($row['description'], $modx_manager_charset) > 70 ? mb_substr($row['description'], 0, 70, $modx_manager_charset) . "..." : $row['description'] ?></td>
276
+                                    <td<?= $tdClass ?>><?= mb_strlen($row['description'], $modx_manager_charset) > 70 ? mb_substr($row['description'], 0, 70, $modx_manager_charset)."..." : $row['description'] ?></td>
277 277
                                     <?php
278 278
                                 } else {
279 279
                                     ?>
280
-                                    <td<?= $tdClass ?>><?= strlen($row['pagetitle']) > 20 ? substr($row['pagetitle'], 0, 20) . '...' : $row['pagetitle'] ?></td>
281
-                                    <td<?= $tdClass ?>><?= strlen($row['description']) > 35 ? substr($row['description'], 0, 35) . '...' : $row['description'] ?></td>
280
+                                    <td<?= $tdClass ?>><?= strlen($row['pagetitle']) > 20 ? substr($row['pagetitle'], 0, 20).'...' : $row['pagetitle'] ?></td>
281
+                                    <td<?= $tdClass ?>><?= strlen($row['description']) > 35 ? substr($row['description'], 0, 35).'...' : $row['description'] ?></td>
282 282
                                     <?php
283 283
                                 }
284 284
                                 ?>
@@ -298,115 +298,115 @@  discard block
 block discarded – undo
298 298
                 if ($modx->hasPermission('new_document') && $modx->hasPermission('edit_document') && $modx->hasPermission('save_document')) {
299 299
                     $docscounts = $modx->db->getRecordCount($rs);
300 300
                     if ($docscounts > 0) {
301
-                        $output .= '<li><b><i class="fa fa-sitemap"></i> ' . $_lang["manage_documents"] . ' (' . $docscounts . ')</b></li>';
301
+                        $output .= '<li><b><i class="fa fa-sitemap"></i> '.$_lang["manage_documents"].' ('.$docscounts.')</b></li>';
302 302
                         while ($row = $modx->db->getRow($rs)) {
303
-                            $output .= '<li' . addClassForItemList('', !$row['published'], $row['deleted']) . '><a href="index.php?a=27&id=' . $row['id'] . '" id="content_' . $row['id'] . '" target="main">' . highlightingCoincidence($row['pagetitle'] . ' <small>(' . $row['id'] . ')</small>', $_REQUEST['searchfields']) . $_style['icons_external_link'] . '</a></li>';
303
+                            $output .= '<li'.addClassForItemList('', !$row['published'], $row['deleted']).'><a href="index.php?a=27&id='.$row['id'].'" id="content_'.$row['id'].'" target="main">'.highlightingCoincidence($row['pagetitle'].' <small>('.$row['id'].')</small>', $_REQUEST['searchfields']).$_style['icons_external_link'].'</a></li>';
304 304
                         }
305 305
                     }
306 306
                 }
307 307
 
308 308
                 //templates
309 309
                 if ($modx->hasPermission('edit_template')) {
310
-                    $rs = $modx->db->select("id,templatename,locked", $modx->getFullTableName('site_templates'), "`id` like '%" . $searchfields . "%' 
311
-					OR `templatename` like '%" . $searchfields . "%' 
312
-					OR `description` like '%" . $searchfields . "%' 
313
-					OR `content` like '%" . $searchfields . "%'");
310
+                    $rs = $modx->db->select("id,templatename,locked", $modx->getFullTableName('site_templates'), "`id` like '%".$searchfields."%' 
311
+					OR `templatename` like '%" . $searchfields."%' 
312
+					OR `description` like '%" . $searchfields."%' 
313
+					OR `content` like '%" . $searchfields."%'");
314 314
                     $templatecounts = $modx->db->getRecordCount($rs);
315 315
                     if ($templatecounts > 0) {
316
-                        $output .= '<li><b><i class="fa fa-newspaper-o"></i> ' . $_lang["manage_templates"] . ' (' . $templatecounts . ')</b></li>';
316
+                        $output .= '<li><b><i class="fa fa-newspaper-o"></i> '.$_lang["manage_templates"].' ('.$templatecounts.')</b></li>';
317 317
                         while ($row = $modx->db->getRow($rs)) {
318
-                            $output .= '<li' . addClassForItemList($row['locked']) . '><a href="index.php?a=16&id=' . $row['id'] . '" id="templates_' . $row['id'] . '" target="main">' . highlightingCoincidence($row['templatename'], $_REQUEST['searchfields']) . $_style['icons_external_link'] . '</a></li>';
318
+                            $output .= '<li'.addClassForItemList($row['locked']).'><a href="index.php?a=16&id='.$row['id'].'" id="templates_'.$row['id'].'" target="main">'.highlightingCoincidence($row['templatename'], $_REQUEST['searchfields']).$_style['icons_external_link'].'</a></li>';
319 319
                         }
320 320
                     }
321 321
                 }
322 322
 
323 323
                 //tvs
324 324
                 if ($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
325
-                    $rs = $modx->db->select("id,name,locked", $modx->getFullTableName('site_tmplvars'), "`id` like '%" . $searchfields . "%' 
326
-					OR `name` like '%" . $searchfields . "%' 
327
-					OR `description` like '%" . $searchfields . "%' 
328
-					OR `type` like '%" . $searchfields . "%' 
329
-					OR `elements` like '%" . $searchfields . "%' 
330
-					OR `display` like '%" . $searchfields . "%' 
331
-					OR `display_params` like '%" . $searchfields . "%' 
332
-					OR `default_text` like '%" . $searchfields . "%'");
325
+                    $rs = $modx->db->select("id,name,locked", $modx->getFullTableName('site_tmplvars'), "`id` like '%".$searchfields."%' 
326
+					OR `name` like '%" . $searchfields."%' 
327
+					OR `description` like '%" . $searchfields."%' 
328
+					OR `type` like '%" . $searchfields."%' 
329
+					OR `elements` like '%" . $searchfields."%' 
330
+					OR `display` like '%" . $searchfields."%' 
331
+					OR `display_params` like '%" . $searchfields."%' 
332
+					OR `default_text` like '%" . $searchfields."%'");
333 333
                     $tvscounts = $modx->db->getRecordCount($rs);
334 334
                     if ($tvscounts > 0) {
335
-                        $output .= '<li><b><i class="fa fa-list-alt"></i> ' . $_lang["settings_templvars"] . ' (' . $tvscounts . ')</b></li>';
335
+                        $output .= '<li><b><i class="fa fa-list-alt"></i> '.$_lang["settings_templvars"].' ('.$tvscounts.')</b></li>';
336 336
                         while ($row = $modx->db->getRow($rs)) {
337
-                            $output .= '<li' . addClassForItemList($row['locked']) . '><a href="index.php?a=301&id=' . $row['id'] . '" id="tmplvars_' . $row['id'] . '" target="main">' . highlightingCoincidence($row['name'], $_REQUEST['searchfields']) . $_style['icons_external_link'] . '</a></li>';
337
+                            $output .= '<li'.addClassForItemList($row['locked']).'><a href="index.php?a=301&id='.$row['id'].'" id="tmplvars_'.$row['id'].'" target="main">'.highlightingCoincidence($row['name'], $_REQUEST['searchfields']).$_style['icons_external_link'].'</a></li>';
338 338
                         }
339 339
                     }
340 340
                 }
341 341
 
342 342
                 //Chunks
343 343
                 if ($modx->hasPermission('edit_chunk')) {
344
-                    $rs = $modx->db->select("id,name,locked,disabled", $modx->getFullTableName('site_htmlsnippets'), "`id` like '%" . $searchfields . "%' 
345
-					OR `name` like '%" . $searchfields . "%' 
346
-					OR `description` like '%" . $searchfields . "%'     
347
-					OR `snippet` like '%" . $searchfields . "%'");
344
+                    $rs = $modx->db->select("id,name,locked,disabled", $modx->getFullTableName('site_htmlsnippets'), "`id` like '%".$searchfields."%' 
345
+					OR `name` like '%" . $searchfields."%' 
346
+					OR `description` like '%" . $searchfields."%'     
347
+					OR `snippet` like '%" . $searchfields."%'");
348 348
                     $chunkscounts = $modx->db->getRecordCount($rs);
349 349
                     if ($chunkscounts > 0) {
350
-                        $output .= '<li><b><i class="fa fa-th-large"></i> ' . $_lang["manage_htmlsnippets"] . ' (' . $chunkscounts . ')</b></li>';
350
+                        $output .= '<li><b><i class="fa fa-th-large"></i> '.$_lang["manage_htmlsnippets"].' ('.$chunkscounts.')</b></li>';
351 351
                         while ($row = $modx->db->getRow($rs)) {
352
-                            $output .= '<li' . addClassForItemList($row['locked'], $row['disabled']) . '><a href="index.php?a=78&id=' . $row['id'] . '" id="htmlsnippets_' . $row['id'] . '" target="main">' . highlightingCoincidence($row['name'], $_REQUEST['searchfields']) . $_style['icons_external_link'] . '</a></li>';
352
+                            $output .= '<li'.addClassForItemList($row['locked'], $row['disabled']).'><a href="index.php?a=78&id='.$row['id'].'" id="htmlsnippets_'.$row['id'].'" target="main">'.highlightingCoincidence($row['name'], $_REQUEST['searchfields']).$_style['icons_external_link'].'</a></li>';
353 353
                         }
354 354
                     }
355 355
                 }
356 356
 
357 357
                 //Snippets
358 358
                 if ($modx->hasPermission('edit_snippet')) {
359
-                    $rs = $modx->db->select("id,name,locked,disabled", $modx->getFullTableName('site_snippets'), "`id` like '%" . $searchfields . "%' 
360
-					OR `name` like '%" . $searchfields . "%' 
361
-					OR `description` like '%" . $searchfields . "%' 
362
-					OR `snippet` like '%" . $searchfields . "%'  
363
-					OR `properties` like '%" . $searchfields . "%'      
364
-					OR `moduleguid` like '%" . $searchfields . "%'");
359
+                    $rs = $modx->db->select("id,name,locked,disabled", $modx->getFullTableName('site_snippets'), "`id` like '%".$searchfields."%' 
360
+					OR `name` like '%" . $searchfields."%' 
361
+					OR `description` like '%" . $searchfields."%' 
362
+					OR `snippet` like '%" . $searchfields."%'  
363
+					OR `properties` like '%" . $searchfields."%'      
364
+					OR `moduleguid` like '%" . $searchfields."%'");
365 365
                     $snippetscounts = $modx->db->getRecordCount($rs);
366 366
                     if ($snippetscounts > 0) {
367
-                        $output .= '<li><b><i class="fa fa-code"></i> ' . $_lang["manage_snippets"] . ' (' . $snippetscounts . ')</b></li>';
367
+                        $output .= '<li><b><i class="fa fa-code"></i> '.$_lang["manage_snippets"].' ('.$snippetscounts.')</b></li>';
368 368
                         while ($row = $modx->db->getRow($rs)) {
369
-                            $output .= '<li' . addClassForItemList($row['locked'], $row['disabled']) . '><a href="index.php?a=22&id=' . $row['id'] . '" id="snippets_' . $row['id'] . '" target="main">' . highlightingCoincidence($row['name'], $_REQUEST['searchfields']) . $_style['icons_external_link'] . '</a></li>';
369
+                            $output .= '<li'.addClassForItemList($row['locked'], $row['disabled']).'><a href="index.php?a=22&id='.$row['id'].'" id="snippets_'.$row['id'].'" target="main">'.highlightingCoincidence($row['name'], $_REQUEST['searchfields']).$_style['icons_external_link'].'</a></li>';
370 370
                         }
371 371
                     }
372 372
                 }
373 373
 
374 374
                 //plugins
375 375
                 if ($modx->hasPermission('edit_plugin')) {
376
-                    $rs = $modx->db->select("id,name,locked,disabled", $modx->getFullTableName('site_plugins'), "`id` like '%" . $searchfields . "%' 
377
-					OR `name` like '%" . $searchfields . "%' 
378
-					OR `description` like '%" . $searchfields . "%' 
379
-					OR `plugincode` like '%" . $searchfields . "%'  
380
-					OR `properties` like '%" . $searchfields . "%'      
381
-					OR `moduleguid` like '%" . $searchfields . "%'");
376
+                    $rs = $modx->db->select("id,name,locked,disabled", $modx->getFullTableName('site_plugins'), "`id` like '%".$searchfields."%' 
377
+					OR `name` like '%" . $searchfields."%' 
378
+					OR `description` like '%" . $searchfields."%' 
379
+					OR `plugincode` like '%" . $searchfields."%'  
380
+					OR `properties` like '%" . $searchfields."%'      
381
+					OR `moduleguid` like '%" . $searchfields."%'");
382 382
                     $pluginscounts = $modx->db->getRecordCount($rs);
383 383
                     if ($pluginscounts > 0) {
384
-                        $output .= '<li><b><i class="fa fa-plug"></i> ' . $_lang["manage_plugins"] . ' (' . $pluginscounts . ')</b></li>';
384
+                        $output .= '<li><b><i class="fa fa-plug"></i> '.$_lang["manage_plugins"].' ('.$pluginscounts.')</b></li>';
385 385
                         while ($row = $modx->db->getRow($rs)) {
386
-                            $output .= '<li' . addClassForItemList($row['locked'], $row['disabled']) . '><a href="index.php?a=102&id=' . $row['id'] . '" id="plugins_' . $row['id'] . '" target="main">' . highlightingCoincidence($row['name'], $_REQUEST['searchfields']) . $_style['icons_external_link'] . '</a></li>';
386
+                            $output .= '<li'.addClassForItemList($row['locked'], $row['disabled']).'><a href="index.php?a=102&id='.$row['id'].'" id="plugins_'.$row['id'].'" target="main">'.highlightingCoincidence($row['name'], $_REQUEST['searchfields']).$_style['icons_external_link'].'</a></li>';
387 387
                         }
388 388
                     }
389 389
                 }
390 390
 
391 391
                 //modules
392 392
                 if ($modx->hasPermission('edit_module')) {
393
-                    $rs = $modx->db->select("id,name,locked,disabled", $modx->getFullTableName('site_modules'), "`id` like '%" . $searchfields . "%' 
394
-                    OR `name` like '%" . $searchfields . "%' 
395
-                    OR `description` like '%" . $searchfields . "%' 
396
-                    OR `modulecode` like '%" . $searchfields . "%'  
397
-                    OR `properties` like '%" . $searchfields . "%'  
398
-                    OR `guid` like '%" . $searchfields . "%'      
399
-                    OR `resourcefile` like '%" . $searchfields . "%'");
393
+                    $rs = $modx->db->select("id,name,locked,disabled", $modx->getFullTableName('site_modules'), "`id` like '%".$searchfields."%' 
394
+                    OR `name` like '%" . $searchfields."%' 
395
+                    OR `description` like '%" . $searchfields."%' 
396
+                    OR `modulecode` like '%" . $searchfields."%'  
397
+                    OR `properties` like '%" . $searchfields."%'  
398
+                    OR `guid` like '%" . $searchfields."%'      
399
+                    OR `resourcefile` like '%" . $searchfields."%'");
400 400
                     $modulescounts = $modx->db->getRecordCount($rs);
401 401
                     if ($modulescounts > 0) {
402
-                        $output .= '<li><b><i class="fa fa-cogs"></i> ' . $_lang["modules"] . ' (' . $modulescounts . ')</b></li>';
402
+                        $output .= '<li><b><i class="fa fa-cogs"></i> '.$_lang["modules"].' ('.$modulescounts.')</b></li>';
403 403
                         while ($row = $modx->db->getRow($rs)) {
404
-                            $output .= '<li' . addClassForItemList($row['locked'], $row['disabled']) . '><a href="index.php?a=108&id=' . $row['id'] . '" id="modules_' . $row['id'] . '" target="main">' . highlightingCoincidence($row['name'], $_REQUEST['searchfields']) . $_style['icons_external_link'] . '</a></li>';
404
+                            $output .= '<li'.addClassForItemList($row['locked'], $row['disabled']).'><a href="index.php?a=108&id='.$row['id'].'" id="modules_'.$row['id'].'" target="main">'.highlightingCoincidence($row['name'], $_REQUEST['searchfields']).$_style['icons_external_link'].'</a></li>';
405 405
                         }
406 406
                     }
407 407
                 }
408 408
 
409
-                echo $output ? '<div class="ajaxSearchResults"><ul>' . $output . '</ul></div>' : '1';
409
+                echo $output ? '<div class="ajaxSearchResults"><ul>'.$output.'</ul></div>' : '1';
410 410
             }
411 411
 
412 412
             ?>
Please login to merge, or discard this patch.
manager/actions/mutate_module.dynamic.php 3 patches
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@  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
 switch($modx->manager->action) {
6
-	case 107:
7
-		if(!$modx->hasPermission('new_module')) {
8
-			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
9
-		}
10
-		break;
11
-	case 108:
12
-		if(!$modx->hasPermission('edit_module')) {
13
-			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
14
-		}
15
-		break;
16
-	default:
17
-		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    case 107:
7
+        if(!$modx->hasPermission('new_module')) {
8
+            $modx->webAlertAndQuit($_lang["error_no_privileges"]);
9
+        }
10
+        break;
11
+    case 108:
12
+        if(!$modx->hasPermission('edit_module')) {
13
+            $modx->webAlertAndQuit($_lang["error_no_privileges"]);
14
+        }
15
+        break;
16
+    default:
17
+        $modx->webAlertAndQuit($_lang["error_no_privileges"]);
18 18
 }
19 19
 $id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
20 20
 // Get table names (alphabetical)
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
 // check to see the module editor isn't locked
34 34
 if($lockedEl = $modx->elementIsLocked(6, $id)) {
35
-	$modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['module']));
35
+    $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['module']));
36 36
 }
37 37
 // end check for lock
38 38
 
@@ -40,22 +40,22 @@  discard block
 block discarded – undo
40 40
 $modx->lockElement(6, $id);
41 41
 
42 42
 if(isset($_GET['id'])) {
43
-	$rs = $modx->db->select('*', $tbl_site_modules, "id='{$id}'");
44
-	$content = $modx->db->getRow($rs);
45
-	if(!$content) {
46
-		$modx->webAlertAndQuit("Module not found for id '{$id}'.");
47
-	}
48
-	$content['properties'] = str_replace("&", "&amp;", $content['properties']);
49
-	$_SESSION['itemname'] = $content['name'];
50
-	if($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) {
51
-		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
52
-	}
43
+    $rs = $modx->db->select('*', $tbl_site_modules, "id='{$id}'");
44
+    $content = $modx->db->getRow($rs);
45
+    if(!$content) {
46
+        $modx->webAlertAndQuit("Module not found for id '{$id}'.");
47
+    }
48
+    $content['properties'] = str_replace("&", "&amp;", $content['properties']);
49
+    $_SESSION['itemname'] = $content['name'];
50
+    if($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) {
51
+        $modx->webAlertAndQuit($_lang["error_no_privileges"]);
52
+    }
53 53
 } else {
54
-	$_SESSION['itemname'] = $_lang["new_module"];
55
-	$content['wrap'] = '1';
54
+    $_SESSION['itemname'] = $_lang["new_module"];
55
+    $content['wrap'] = '1';
56 56
 }
57 57
 if($modx->manager->hasFormValues()) {
58
-	$modx->manager->loadFormValues();
58
+    $modx->manager->loadFormValues();
59 59
 }
60 60
 
61 61
 // Add lock-element JS-Script
@@ -426,18 +426,18 @@  discard block
 block discarded – undo
426 426
 
427 427
 <form name="mutate" id="mutate" class="module" method="post" action="index.php?a=109">
428 428
 	<?php
429
-	// invoke OnModFormPrerender event
430
-	$evtOut = $modx->invokeEvent('OnModFormPrerender', array('id' => $id));
431
-	if(is_array($evtOut)) {
432
-		echo implode('', $evtOut);
433
-	}
434
-
435
-	// Prepare internal params & info-tab via parseDocBlock
436
-	$modulecode = isset($content['modulecode']) ? $modx->db->escape($content['modulecode']) : '';
437
-	$docBlock = $modx->parseDocBlockFromString($modulecode);
438
-	$docBlockList = $modx->convertDocBlockIntoList($docBlock);
439
-	$internal = array();
440
-	?>
429
+    // invoke OnModFormPrerender event
430
+    $evtOut = $modx->invokeEvent('OnModFormPrerender', array('id' => $id));
431
+    if(is_array($evtOut)) {
432
+        echo implode('', $evtOut);
433
+    }
434
+
435
+    // Prepare internal params & info-tab via parseDocBlock
436
+    $modulecode = isset($content['modulecode']) ? $modx->db->escape($content['modulecode']) : '';
437
+    $docBlock = $modx->parseDocBlockFromString($modulecode);
438
+    $docBlockList = $modx->convertDocBlockIntoList($docBlock);
439
+    $internal = array();
440
+    ?>
441 441
 	<input type="hidden" name="id" value="<?= $content['id'] ?>">
442 442
 	<input type="hidden" name="mode" value="<?= $modx->manager->action ?>">
443 443
 
@@ -490,11 +490,11 @@  discard block
 block discarded – undo
490 490
 							<select name="categoryid" class="form-control" onchange="documentDirty=true;">
491 491
 								<option>&nbsp;</option>
492 492
 								<?php
493
-								include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
494
-								foreach(getCategories() as $n => $v) {
495
-									echo "\t\t\t" . '<option value="' . $v['id'] . '"' . ($content['category'] == $v['id'] ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($v['category']) . "</option>\n";
496
-								}
497
-								?>
493
+                                include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
494
+                                foreach(getCategories() as $n => $v) {
495
+                                    echo "\t\t\t" . '<option value="' . $v['id'] . '"' . ($content['category'] == $v['id'] ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($v['category']) . "</option>\n";
496
+                                }
497
+                                ?>
498 498
 							</select>
499 499
 						</div>
500 500
 					</div>
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 							<i class="<?= $_style["actions_save"] ?>"></i> <?= $_lang['manage_depends'] ?></a>
602 602
 					</div>
603 603
 					<?php
604
-					$ds = $modx->db->select("smd.id, COALESCE(ss.name,st.templatename,sv.name,sc.name,sp.name,sd.pagetitle) AS name, 
604
+                    $ds = $modx->db->select("smd.id, COALESCE(ss.name,st.templatename,sv.name,sc.name,sp.name,sd.pagetitle) AS name, 
605 605
 					CASE smd.type
606 606
 						WHEN 10 THEN 'Chunk'
607 607
 						WHEN 20 THEN 'Document'
@@ -617,17 +617,17 @@  discard block
 block discarded – undo
617 617
 						LEFT JOIN {$tbl_site_templates} AS st ON st.id = smd.resource AND smd.type = 50
618 618
 						LEFT JOIN {$tbl_site_tmplvars} AS sv ON sv.id = smd.resource AND smd.type = 60", "smd.module='{$id}'", 'smd.type,name');
619 619
 
620
-					include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php";
621
-					$grd = new DataGrid('', $ds, 0); // set page size to 0 t show all items
622
-					$grd->noRecordMsg = $_lang['no_records_found'];
623
-					$grd->cssClass = 'grid';
624
-					$grd->columnHeaderClass = 'gridHeader';
625
-					$grd->itemClass = 'gridItem';
626
-					$grd->altItemClass = 'gridAltItem';
627
-					$grd->columns = $_lang['element_name'] . " ," . $_lang['type'];
628
-					$grd->fields = "name,type";
629
-					echo $grd->render();
630
-					?>
620
+                    include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php";
621
+                    $grd = new DataGrid('', $ds, 0); // set page size to 0 t show all items
622
+                    $grd->noRecordMsg = $_lang['no_records_found'];
623
+                    $grd->cssClass = 'grid';
624
+                    $grd->columnHeaderClass = 'gridHeader';
625
+                    $grd->itemClass = 'gridItem';
626
+                    $grd->altItemClass = 'gridAltItem';
627
+                    $grd->columns = $_lang['element_name'] . " ," . $_lang['type'];
628
+                    $grd->fields = "name,type";
629
+                    echo $grd->render();
630
+                    ?>
631 631
 				</div>
632 632
 			</div>
633 633
 		<?php endif; ?>
@@ -639,12 +639,12 @@  discard block
 block discarded – undo
639 639
 			<div class="container container-body">
640 640
 				<?php if($use_udperms == 1) : ?>
641 641
 					<?php
642
-					// fetch user access permissions for the module
643
-					$rs = $modx->db->select('usergroup', $tbl_site_module_access, "module='{$id}'");
644
-					$groupsarray = $modx->db->getColumn('usergroup', $rs);
642
+                    // fetch user access permissions for the module
643
+                    $rs = $modx->db->select('usergroup', $tbl_site_module_access, "module='{$id}'");
644
+                    $groupsarray = $modx->db->getColumn('usergroup', $rs);
645 645
 
646
-					if($modx->hasPermission('access_permissions')) {
647
-						?>
646
+                    if($modx->hasPermission('access_permissions')) {
647
+                        ?>
648 648
 						<!-- User Group Access Permissions -->
649 649
 						<script type="text/javascript">
650 650
 							function makePublic(b) {
@@ -668,28 +668,28 @@  discard block
 block discarded – undo
668 668
 						</script>
669 669
 						<p><?= $_lang['module_group_access_msg'] ?></p>
670 670
 						<?php
671
-					}
672
-					$chk = '';
673
-					$rs = $modx->db->select('name, id', $tbl_membergroup_names, '', 'name');
674
-					while($row = $modx->db->getRow($rs)) {
675
-						$groupsarray = is_numeric($id) && $id > 0 ? $groupsarray : array();
676
-						$checked = in_array($row['id'], $groupsarray);
677
-						if($modx->hasPermission('access_permissions')) {
678
-							if($checked) {
679
-								$notPublic = true;
680
-							}
681
-							$chks .= '<label><input type="checkbox" name="usrgroups[]" value="' . $row['id'] . '"' . ($checked ? ' checked="checked"' : '') . ' onclick="makePublic(false)" /> ' . $row['name'] . "</label><br />\n";
682
-						} else {
683
-							if($checked) {
684
-								$chks = '<input type="hidden" name="usrgroups[]"  value="' . $row['id'] . '" />' . "\n" . $chks;
685
-							}
686
-						}
687
-					}
688
-					if($modx->hasPermission('access_permissions')) {
689
-						$chks = '<label><input type="checkbox" name="chkallgroups"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true)" /><span class="warning"> ' . $_lang['all_usr_groups'] . '</span></label><br />' . "\n" . $chks;
690
-					}
691
-					echo $chks;
692
-					?>
671
+                    }
672
+                    $chk = '';
673
+                    $rs = $modx->db->select('name, id', $tbl_membergroup_names, '', 'name');
674
+                    while($row = $modx->db->getRow($rs)) {
675
+                        $groupsarray = is_numeric($id) && $id > 0 ? $groupsarray : array();
676
+                        $checked = in_array($row['id'], $groupsarray);
677
+                        if($modx->hasPermission('access_permissions')) {
678
+                            if($checked) {
679
+                                $notPublic = true;
680
+                            }
681
+                            $chks .= '<label><input type="checkbox" name="usrgroups[]" value="' . $row['id'] . '"' . ($checked ? ' checked="checked"' : '') . ' onclick="makePublic(false)" /> ' . $row['name'] . "</label><br />\n";
682
+                        } else {
683
+                            if($checked) {
684
+                                $chks = '<input type="hidden" name="usrgroups[]"  value="' . $row['id'] . '" />' . "\n" . $chks;
685
+                            }
686
+                        }
687
+                    }
688
+                    if($modx->hasPermission('access_permissions')) {
689
+                        $chks = '<label><input type="checkbox" name="chkallgroups"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true)" /><span class="warning"> ' . $_lang['all_usr_groups'] . '</span></label><br />' . "\n" . $chks;
690
+                    }
691
+                    echo $chks;
692
+                    ?>
693 693
 				<?php endif; ?>
694 694
 			</div>
695 695
 		</div>
@@ -705,11 +705,11 @@  discard block
 block discarded – undo
705 705
 
706 706
 		<input type="submit" name="save" style="display:none;">
707 707
 		<?php
708
-		// invoke OnModFormRender event
709
-		$evtOut = $modx->invokeEvent('OnModFormRender', array('id' => $id));
710
-		if(is_array($evtOut)) {
711
-			echo implode('', $evtOut);
712
-		}
713
-		?>
708
+        // invoke OnModFormRender event
709
+        $evtOut = $modx->invokeEvent('OnModFormRender', array('id' => $id));
710
+        if(is_array($evtOut)) {
711
+            echo implode('', $evtOut);
712
+        }
713
+        ?>
714 714
 </form>
715 715
 <script type="text/javascript">setTimeout('showParameters();', 10);</script>
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  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
-switch($modx->manager->action) {
5
+switch ($modx->manager->action) {
6 6
 	case 107:
7
-		if(!$modx->hasPermission('new_module')) {
7
+		if (!$modx->hasPermission('new_module')) {
8 8
 			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
9 9
 		}
10 10
 		break;
11 11
 	case 108:
12
-		if(!$modx->hasPermission('edit_module')) {
12
+		if (!$modx->hasPermission('edit_module')) {
13 13
 			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
14 14
 		}
15 15
 		break;
16 16
 	default:
17 17
 		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
18 18
 }
19
-$id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
19
+$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
20 20
 // Get table names (alphabetical)
21 21
 $tbl_membergroup_names = $modx->getFullTableName('membergroup_names');
22 22
 $tbl_site_content = $modx->getFullTableName('site_content');
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
 
33 33
 // check to see the module editor isn't locked
34
-if($lockedEl = $modx->elementIsLocked(6, $id)) {
34
+if ($lockedEl = $modx->elementIsLocked(6, $id)) {
35 35
 	$modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['module']));
36 36
 }
37 37
 // end check for lock
@@ -39,29 +39,29 @@  discard block
 block discarded – undo
39 39
 // Lock snippet for other users to edit
40 40
 $modx->lockElement(6, $id);
41 41
 
42
-if(isset($_GET['id'])) {
42
+if (isset($_GET['id'])) {
43 43
 	$rs = $modx->db->select('*', $tbl_site_modules, "id='{$id}'");
44 44
 	$content = $modx->db->getRow($rs);
45
-	if(!$content) {
45
+	if (!$content) {
46 46
 		$modx->webAlertAndQuit("Module not found for id '{$id}'.");
47 47
 	}
48 48
 	$content['properties'] = str_replace("&", "&amp;", $content['properties']);
49 49
 	$_SESSION['itemname'] = $content['name'];
50
-	if($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) {
50
+	if ($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) {
51 51
 		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
52 52
 	}
53 53
 } else {
54 54
 	$_SESSION['itemname'] = $_lang["new_module"];
55 55
 	$content['wrap'] = '1';
56 56
 }
57
-if($modx->manager->hasFormValues()) {
57
+if ($modx->manager->hasFormValues()) {
58 58
 	$modx->manager->loadFormValues();
59 59
 }
60 60
 
61 61
 // Add lock-element JS-Script
62 62
 $lockElementId = $id;
63 63
 $lockElementType = 6;
64
-require_once(MODX_MANAGER_PATH . 'includes/active_user_locks.inc.php');
64
+require_once(MODX_MANAGER_PATH.'includes/active_user_locks.inc.php');
65 65
 ?>
66 66
 <script type="text/javascript">
67 67
 	function loadDependencies() {
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 	function BrowseServer() {
409 409
 		var w = screen.width * 0.7;
410 410
 		var h = screen.height * 0.7;
411
-		OpenServerBrowser("<?= MODX_MANAGER_URL;?>media/browser/<?= $which_browser;?>/browser.php?Type=images", w, h);
411
+		OpenServerBrowser("<?= MODX_MANAGER_URL; ?>media/browser/<?= $which_browser; ?>/browser.php?Type=images", w, h);
412 412
 	}
413 413
 
414 414
 	function SetUrl(url, width, height, alt) {
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	<?php
429 429
 	// invoke OnModFormPrerender event
430 430
 	$evtOut = $modx->invokeEvent('OnModFormPrerender', array('id' => $id));
431
-	if(is_array($evtOut)) {
431
+	if (is_array($evtOut)) {
432 432
 		echo implode('', $evtOut);
433 433
 	}
434 434
 
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 	<input type="hidden" name="mode" value="<?= $modx->manager->action ?>">
443 443
 
444 444
 	<h1>
445
-		<i class="<?= ($content['icon'] != '' ? $content['icon'] : $_style['icons_module']) ?>"></i><?= ($content['name'] ? $content['name'] . '<small>(' . $content['id'] . ')</small>' : $_lang['new_module']) ?><i class="fa fa-question-circle help"></i>
445
+		<i class="<?= ($content['icon'] != '' ? $content['icon'] : $_style['icons_module']) ?>"></i><?= ($content['name'] ? $content['name'].'<small>('.$content['id'].')</small>' : $_lang['new_module']) ?><i class="fa fa-question-circle help"></i>
446 446
 	</h1>
447 447
 
448 448
 	<?= $_style['actionbuttons']['dynamic']['element'] ?>
@@ -467,8 +467,8 @@  discard block
 block discarded – undo
467 467
 						<div class="col-md-9 col-lg-10">
468 468
 							<div class="form-control-name clearfix">
469 469
 								<input name="name" type="text" maxlength="100" value="<?= $modx->htmlspecialchars($content['name']) ?>" class="form-control form-control-lg" onchange="documentDirty=true;" />
470
-								<?php if($modx->hasPermission('save_role')): ?>
471
-									<label class="custom-control" title="<?= $_lang['lock_module'] . "\n" . $_lang['lock_module_msg'] ?>" tooltip>
470
+								<?php if ($modx->hasPermission('save_role')): ?>
471
+									<label class="custom-control" title="<?= $_lang['lock_module']."\n".$_lang['lock_module_msg'] ?>" tooltip>
472 472
 										<input name="locked" type="checkbox"<?= ($content['locked'] == 1 ? ' checked="checked"' : '') ?> />
473 473
 										<i class="fa fa-lock"></i>
474 474
 									</label>
@@ -490,9 +490,9 @@  discard block
 block discarded – undo
490 490
 							<select name="categoryid" class="form-control" onchange="documentDirty=true;">
491 491
 								<option>&nbsp;</option>
492 492
 								<?php
493
-								include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
494
-								foreach(getCategories() as $n => $v) {
495
-									echo "\t\t\t" . '<option value="' . $v['id'] . '"' . ($content['category'] == $v['id'] ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($v['category']) . "</option>\n";
493
+								include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
494
+								foreach (getCategories() as $n => $v) {
495
+									echo "\t\t\t".'<option value="'.$v['id'].'"'.($content['category'] == $v['id'] ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($v['category'])."</option>\n";
496 496
 								}
497 497
 								?>
498 498
 							</select>
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 				<div class="form-group">
525 525
 					<div class="form-row">
526 526
 						<label for="disabled"><input name="disabled" id="disabled" type="checkbox" value="on"<?= ($content['disabled'] == 1 ? ' checked="checked"' : '') ?> />
527
-							<?= ($content['disabled'] == 1 ? '<span class="text-danger">' . $_lang['module_disabled'] . '</span>' : $_lang['module_disabled']) ?></label>
527
+							<?= ($content['disabled'] == 1 ? '<span class="text-danger">'.$_lang['module_disabled'].'</span>' : $_lang['module_disabled']) ?></label>
528 528
 					</div>
529 529
 					<div class="form-row">
530 530
 						<label for="parse_docblock">
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 			</div>
590 590
 			<!-- HTML text editor end -->
591 591
 		</div>
592
-		<?php if($modx->manager->action == '108'): ?>
592
+		<?php if ($modx->manager->action == '108'): ?>
593 593
 			<!-- Dependencies -->
594 594
 			<div class="tab-page" id="tabDepend">
595 595
 				<h2 class="tab"><?= $_lang['settings_dependencies'] ?></h2>
@@ -617,14 +617,14 @@  discard block
 block discarded – undo
617 617
 						LEFT JOIN {$tbl_site_templates} AS st ON st.id = smd.resource AND smd.type = 50
618 618
 						LEFT JOIN {$tbl_site_tmplvars} AS sv ON sv.id = smd.resource AND smd.type = 60", "smd.module='{$id}'", 'smd.type,name');
619 619
 
620
-					include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php";
620
+					include_once MODX_MANAGER_PATH."includes/controls/datagrid.class.php";
621 621
 					$grd = new DataGrid('', $ds, 0); // set page size to 0 t show all items
622 622
 					$grd->noRecordMsg = $_lang['no_records_found'];
623 623
 					$grd->cssClass = 'grid';
624 624
 					$grd->columnHeaderClass = 'gridHeader';
625 625
 					$grd->itemClass = 'gridItem';
626 626
 					$grd->altItemClass = 'gridAltItem';
627
-					$grd->columns = $_lang['element_name'] . " ," . $_lang['type'];
627
+					$grd->columns = $_lang['element_name']." ,".$_lang['type'];
628 628
 					$grd->fields = "name,type";
629 629
 					echo $grd->render();
630 630
 					?>
@@ -637,13 +637,13 @@  discard block
 block discarded – undo
637 637
 			<h2 class="tab"><?= $_lang['access_permissions'] ?></h2>
638 638
 			<script type="text/javascript">tp.addTabPage(document.getElementById("tabPermissions"));</script>
639 639
 			<div class="container container-body">
640
-				<?php if($use_udperms == 1) : ?>
640
+				<?php if ($use_udperms == 1) : ?>
641 641
 					<?php
642 642
 					// fetch user access permissions for the module
643 643
 					$rs = $modx->db->select('usergroup', $tbl_site_module_access, "module='{$id}'");
644 644
 					$groupsarray = $modx->db->getColumn('usergroup', $rs);
645 645
 
646
-					if($modx->hasPermission('access_permissions')) {
646
+					if ($modx->hasPermission('access_permissions')) {
647 647
 						?>
648 648
 						<!-- User Group Access Permissions -->
649 649
 						<script type="text/javascript">
@@ -671,22 +671,22 @@  discard block
 block discarded – undo
671 671
 					}
672 672
 					$chk = '';
673 673
 					$rs = $modx->db->select('name, id', $tbl_membergroup_names, '', 'name');
674
-					while($row = $modx->db->getRow($rs)) {
674
+					while ($row = $modx->db->getRow($rs)) {
675 675
 						$groupsarray = is_numeric($id) && $id > 0 ? $groupsarray : array();
676 676
 						$checked = in_array($row['id'], $groupsarray);
677
-						if($modx->hasPermission('access_permissions')) {
678
-							if($checked) {
677
+						if ($modx->hasPermission('access_permissions')) {
678
+							if ($checked) {
679 679
 								$notPublic = true;
680 680
 							}
681
-							$chks .= '<label><input type="checkbox" name="usrgroups[]" value="' . $row['id'] . '"' . ($checked ? ' checked="checked"' : '') . ' onclick="makePublic(false)" /> ' . $row['name'] . "</label><br />\n";
681
+							$chks .= '<label><input type="checkbox" name="usrgroups[]" value="'.$row['id'].'"'.($checked ? ' checked="checked"' : '').' onclick="makePublic(false)" /> '.$row['name']."</label><br />\n";
682 682
 						} else {
683
-							if($checked) {
684
-								$chks = '<input type="hidden" name="usrgroups[]"  value="' . $row['id'] . '" />' . "\n" . $chks;
683
+							if ($checked) {
684
+								$chks = '<input type="hidden" name="usrgroups[]"  value="'.$row['id'].'" />'."\n".$chks;
685 685
 							}
686 686
 						}
687 687
 					}
688
-					if($modx->hasPermission('access_permissions')) {
689
-						$chks = '<label><input type="checkbox" name="chkallgroups"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true)" /><span class="warning"> ' . $_lang['all_usr_groups'] . '</span></label><br />' . "\n" . $chks;
688
+					if ($modx->hasPermission('access_permissions')) {
689
+						$chks = '<label><input type="checkbox" name="chkallgroups"'.(!$notPublic ? ' checked="checked"' : '').' onclick="makePublic(true)" /><span class="warning"> '.$_lang['all_usr_groups'].'</span></label><br />'."\n".$chks;
690 690
 					}
691 691
 					echo $chks;
692 692
 					?>
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 		<?php
708 708
 		// invoke OnModFormRender event
709 709
 		$evtOut = $modx->invokeEvent('OnModFormRender', array('id' => $id));
710
-		if(is_array($evtOut)) {
710
+		if (is_array($evtOut)) {
711 711
 			echo implode('', $evtOut);
712 712
 		}
713 713
 		?>
Please login to merge, or discard this patch.
Braces   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  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
-switch($modx->manager->action) {
5
+switch($modx->manager->action) {
6 6
 	case 107:
7
-		if(!$modx->hasPermission('new_module')) {
7
+		if(!$modx->hasPermission('new_module')) {
8 8
 			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
9 9
 		}
10 10
 		break;
11 11
 	case 108:
12
-		if(!$modx->hasPermission('edit_module')) {
12
+		if(!$modx->hasPermission('edit_module')) {
13 13
 			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
14 14
 		}
15 15
 		break;
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
 
33 33
 // check to see the module editor isn't locked
34
-if($lockedEl = $modx->elementIsLocked(6, $id)) {
34
+if($lockedEl = $modx->elementIsLocked(6, $id)) {
35 35
 	$modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['module']));
36 36
 }
37 37
 // end check for lock
@@ -39,22 +39,22 @@  discard block
 block discarded – undo
39 39
 // Lock snippet for other users to edit
40 40
 $modx->lockElement(6, $id);
41 41
 
42
-if(isset($_GET['id'])) {
42
+if(isset($_GET['id'])) {
43 43
 	$rs = $modx->db->select('*', $tbl_site_modules, "id='{$id}'");
44 44
 	$content = $modx->db->getRow($rs);
45
-	if(!$content) {
45
+	if(!$content) {
46 46
 		$modx->webAlertAndQuit("Module not found for id '{$id}'.");
47 47
 	}
48 48
 	$content['properties'] = str_replace("&", "&amp;", $content['properties']);
49 49
 	$_SESSION['itemname'] = $content['name'];
50
-	if($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) {
50
+	if($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) {
51 51
 		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
52 52
 	}
53
-} else {
53
+} else {
54 54
 	$_SESSION['itemname'] = $_lang["new_module"];
55 55
 	$content['wrap'] = '1';
56 56
 }
57
-if($modx->manager->hasFormValues()) {
57
+if($modx->manager->hasFormValues()) {
58 58
 	$modx->manager->loadFormValues();
59 59
 }
60 60
 
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	<?php
429 429
 	// invoke OnModFormPrerender event
430 430
 	$evtOut = $modx->invokeEvent('OnModFormPrerender', array('id' => $id));
431
-	if(is_array($evtOut)) {
431
+	if(is_array($evtOut)) {
432 432
 		echo implode('', $evtOut);
433 433
 	}
434 434
 
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 								<option>&nbsp;</option>
492 492
 								<?php
493 493
 								include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
494
-								foreach(getCategories() as $n => $v) {
494
+								foreach(getCategories() as $n => $v) {
495 495
 									echo "\t\t\t" . '<option value="' . $v['id'] . '"' . ($content['category'] == $v['id'] ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($v['category']) . "</option>\n";
496 496
 								}
497 497
 								?>
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 					$rs = $modx->db->select('usergroup', $tbl_site_module_access, "module='{$id}'");
644 644
 					$groupsarray = $modx->db->getColumn('usergroup', $rs);
645 645
 
646
-					if($modx->hasPermission('access_permissions')) {
646
+					if($modx->hasPermission('access_permissions')) {
647 647
 						?>
648 648
 						<!-- User Group Access Permissions -->
649 649
 						<script type="text/javascript">
@@ -671,21 +671,21 @@  discard block
 block discarded – undo
671 671
 					}
672 672
 					$chk = '';
673 673
 					$rs = $modx->db->select('name, id', $tbl_membergroup_names, '', 'name');
674
-					while($row = $modx->db->getRow($rs)) {
674
+					while($row = $modx->db->getRow($rs)) {
675 675
 						$groupsarray = is_numeric($id) && $id > 0 ? $groupsarray : array();
676 676
 						$checked = in_array($row['id'], $groupsarray);
677
-						if($modx->hasPermission('access_permissions')) {
678
-							if($checked) {
677
+						if($modx->hasPermission('access_permissions')) {
678
+							if($checked) {
679 679
 								$notPublic = true;
680 680
 							}
681 681
 							$chks .= '<label><input type="checkbox" name="usrgroups[]" value="' . $row['id'] . '"' . ($checked ? ' checked="checked"' : '') . ' onclick="makePublic(false)" /> ' . $row['name'] . "</label><br />\n";
682
-						} else {
683
-							if($checked) {
682
+						} else {
683
+							if($checked) {
684 684
 								$chks = '<input type="hidden" name="usrgroups[]"  value="' . $row['id'] . '" />' . "\n" . $chks;
685 685
 							}
686 686
 						}
687 687
 					}
688
-					if($modx->hasPermission('access_permissions')) {
688
+					if($modx->hasPermission('access_permissions')) {
689 689
 						$chks = '<label><input type="checkbox" name="chkallgroups"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true)" /><span class="warning"> ' . $_lang['all_usr_groups'] . '</span></label><br />' . "\n" . $chks;
690 690
 					}
691 691
 					echo $chks;
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 		<?php
708 708
 		// invoke OnModFormRender event
709 709
 		$evtOut = $modx->invokeEvent('OnModFormRender', array('id' => $id));
710
-		if(is_array($evtOut)) {
710
+		if(is_array($evtOut)) {
711 711
 			echo implode('', $evtOut);
712 712
 		}
713 713
 		?>
Please login to merge, or discard this patch.
manager/actions/logging.static.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if (!$modx->hasPermission('logs')) {
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
                             $logs_user = record_sort(array_unique_multi($logs, 'internalKey'), 'username');
29 29
                             foreach ($logs_user as $row) {
30 30
                                 $selectedtext = $row['internalKey'] == $_REQUEST['searchuser'] ? ' selected="selected"' : '';
31
-                                echo "\t\t" . '<option value="' . $row['internalKey'] . '"' . $selectedtext . '>' . $row['username'] . "</option>\n";
31
+                                echo "\t\t".'<option value="'.$row['internalKey'].'"'.$selectedtext.'>'.$row['username']."</option>\n";
32 32
                             }
33 33
                             ?>
34 34
                         </select>
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
                                     continue;
50 50
                                 }
51 51
                                 $selectedtext = $row['action'] == $_REQUEST['action'] ? ' selected="selected"' : '';
52
-                                echo "\t\t" . '<option value="' . $row['action'] . '"' . $selectedtext . '>' . $row['action'] . ' - ' . $action . "</option>\n";
52
+                                echo "\t\t".'<option value="'.$row['action'].'"'.$selectedtext.'>'.$row['action'].' - '.$action."</option>\n";
53 53
                             }
54 54
                             ?>
55 55
                         </select>
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
                             $logs_items = record_sort(array_unique_multi($logs, 'itemid'), 'itemid');
66 66
                             foreach ($logs_items as $row) {
67 67
                                 $selectedtext = $row['itemid'] == $_REQUEST['itemid'] ? ' selected="selected"' : '';
68
-                                echo "\t\t" . '<option value="' . $row['itemid'] . '"' . $selectedtext . '>' . $row['itemid'] . "</option>\n";
68
+                                echo "\t\t".'<option value="'.$row['itemid'].'"'.$selectedtext.'>'.$row['itemid']."</option>\n";
69 69
                             }
70 70
                             ?>
71 71
                         </select>
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
                             $logs_names = record_sort(array_unique_multi($logs, 'itemname'), 'itemname');
82 82
                             foreach ($logs_names as $row) {
83 83
                                 $selectedtext = $row['itemname'] == $_REQUEST['itemname'] ? ' selected="selected"' : '';
84
-                                echo "\t\t" . '<option value="' . $row['itemname'] . '"' . $selectedtext . '>' . $row['itemname'] . "</option>\n";
84
+                                echo "\t\t".'<option value="'.$row['itemname'].'"'.$selectedtext.'>'.$row['itemname']."</option>\n";
85 85
                             }
86 86
                             ?>
87 87
                         </select>
@@ -139,26 +139,26 @@  discard block
 block discarded – undo
139 139
     // get the selections the user made.
140 140
     $sqladd = array();
141 141
     if ($_REQUEST['searchuser'] != 0) {
142
-        $sqladd[] = "internalKey='" . (int)$_REQUEST['searchuser'] . "'";
142
+        $sqladd[] = "internalKey='".(int) $_REQUEST['searchuser']."'";
143 143
     }
144 144
     if ($_REQUEST['action'] != 0) {
145
-        $sqladd[] = "action=" . (int)$_REQUEST['action'];
145
+        $sqladd[] = "action=".(int) $_REQUEST['action'];
146 146
     }
147 147
     if ($_REQUEST['itemid'] != 0 || $_REQUEST['itemid'] == "-") {
148
-        $sqladd[] = "itemid='" . $_REQUEST['itemid'] . "'";
148
+        $sqladd[] = "itemid='".$_REQUEST['itemid']."'";
149 149
     }
150 150
     if ($_REQUEST['itemname'] != '0') {
151
-        $sqladd[] = "itemname='" . $modx->db->escape($_REQUEST['itemname']) . "'";
151
+        $sqladd[] = "itemname='".$modx->db->escape($_REQUEST['itemname'])."'";
152 152
     }
153 153
     if ($_REQUEST['message'] != "") {
154
-        $sqladd[] = "message LIKE '%" . $modx->db->escape($_REQUEST['message']) . "%'";
154
+        $sqladd[] = "message LIKE '%".$modx->db->escape($_REQUEST['message'])."%'";
155 155
     }
156 156
     // date stuff
157 157
     if ($_REQUEST['datefrom'] != "") {
158
-        $sqladd[] = "timestamp>" . $modx->toTimeStamp($_REQUEST['datefrom']);
158
+        $sqladd[] = "timestamp>".$modx->toTimeStamp($_REQUEST['datefrom']);
159 159
     }
160 160
     if ($_REQUEST['dateto'] != "") {
161
-        $sqladd[] = "timestamp<" . $modx->toTimeStamp($_REQUEST['dateto']);
161
+        $sqladd[] = "timestamp<".$modx->toTimeStamp($_REQUEST['dateto']);
162 162
     }
163 163
 
164 164
     // If current position is not set, set it to zero
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     // Number of result to display on the page, will be in the LIMIT of the sql query also
172 172
     $int_num_result = is_numeric($_REQUEST['nrresults']) ? $_REQUEST['nrresults'] : $number_of_logs;
173 173
 
174
-    $extargv = "&a=13&searchuser=" . $_REQUEST['searchuser'] . "&action=" . $_REQUEST['action'] . "&itemid=" . $_REQUEST['itemid'] . "&itemname=" . $_REQUEST['itemname'] . "&message=" . $_REQUEST['message'] . "&dateto=" . $_REQUEST['dateto'] . "&datefrom=" . $_REQUEST['datefrom'] . "&nrresults=" . $int_num_result . "&log_submit=" . $_REQUEST['log_submit']; // extra argv here (could be anything depending on your page)
174
+    $extargv = "&a=13&searchuser=".$_REQUEST['searchuser']."&action=".$_REQUEST['action']."&itemid=".$_REQUEST['itemid']."&itemname=".$_REQUEST['itemname']."&message=".$_REQUEST['message']."&dateto=".$_REQUEST['dateto']."&datefrom=".$_REQUEST['datefrom']."&nrresults=".$int_num_result."&log_submit=".$_REQUEST['log_submit']; // extra argv here (could be anything depending on your page)
175 175
 
176 176
     // build the sql
177 177
     $limit = $num_rows = $modx->db->getValue($modx->db->select('COUNT(*)', $modx->getFullTableName('manager_log'), (!empty($sqladd) ? implode(' AND ', $sqladd) : '')));
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
     $rs = $modx->db->select('*', $modx->getFullTableName('manager_log'), (!empty($sqladd) ? implode(' AND ', $sqladd) : ''), 'timestamp DESC, id DESC', "{$int_cur_position}, {$int_num_result}");
180 180
 
181 181
 if ($limit < 1) {
182
-    echo '<p>' . $_lang["mgrlog_emptysrch"] . '</p>';
182
+    echo '<p>'.$_lang["mgrlog_emptysrch"].'</p>';
183 183
 } else {
184
-    echo '<p>' . $_lang["mgrlog_sortinst"] . '</p>';
184
+    echo '<p>'.$_lang["mgrlog_sortinst"].'</p>';
185 185
 
186 186
     // New instance of the Paging class, you can modify the color and the width of the html table
187 187
     $p = new EvolutionCMS\Support\Paginate($num_rows, $int_cur_position, $int_num_result, $extargv);
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
     $current_row = $int_cur_position / $int_num_result;
193 193
 
194 194
     // Display the result as you like...
195
-    print "<p>" . $_lang["paging_showing"] . " " . $array_paging['lower'];
196
-    print " " . $_lang["paging_to"] . " " . $array_paging['upper'];
197
-    print " (" . $array_paging['total'] . " " . $_lang["paging_total"] . ")<br />";
198
-    $paging = $array_paging['first_link'] . $_lang["paging_first"] . (isset($array_paging['first_link']) ? "</a> " : " ");
199
-    $paging .= $array_paging['previous_link'] . $_lang["paging_prev"] . (isset($array_paging['previous_link']) ? "</a> " : " ");
195
+    print "<p>".$_lang["paging_showing"]." ".$array_paging['lower'];
196
+    print " ".$_lang["paging_to"]." ".$array_paging['upper'];
197
+    print " (".$array_paging['total']." ".$_lang["paging_total"].")<br />";
198
+    $paging = $array_paging['first_link'].$_lang["paging_first"].(isset($array_paging['first_link']) ? "</a> " : " ");
199
+    $paging .= $array_paging['previous_link'].$_lang["paging_prev"].(isset($array_paging['previous_link']) ? "</a> " : " ");
200 200
     $pagesfound = sizeof($array_row_paging);
201 201
     if ($pagesfound > 6) {
202 202
         $paging .= $array_row_paging[$current_row - 2]; // ."&nbsp;";
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
         $paging .= $array_row_paging[$current_row + 2]; // ."&nbsp;";
207 207
     } else {
208 208
         for ($i = 0; $i < $pagesfound; $i++) {
209
-            $paging .= $array_row_paging[$i] . "&nbsp;";
209
+            $paging .= $array_row_paging[$i]."&nbsp;";
210 210
         }
211 211
     }
212
-    $paging .= $array_paging['next_link'] . $_lang["paging_next"] . (isset($array_paging['next_link']) ? "</a> " : " ") . " ";
213
-    $paging .= $array_paging['last_link'] . $_lang["paging_last"] . (isset($array_paging['last_link']) ? "</a> " : " ") . " ";
212
+    $paging .= $array_paging['next_link'].$_lang["paging_next"].(isset($array_paging['next_link']) ? "</a> " : " ")." ";
213
+    $paging .= $array_paging['last_link'].$_lang["paging_last"].(isset($array_paging['last_link']) ? "</a> " : " ")." ";
214 214
     // The above exemple print somethings like:
215 215
     // Results 1 to 20 of 597  <<< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 >>>
216 216
     // Of course you can now play with array_row_paging in order to print
@@ -246,16 +246,16 @@  discard block
 block discarded – undo
246 246
                     if (!preg_match("/^[0-9]+$/", $logentry['itemid'])) {
247 247
                         $item = '<div style="text-align:center;">-</div>';
248 248
                     } elseif ($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) {
249
-                        $item = '<a href="index.php?a=3&amp;id=' . $logentry['itemid'] . '">' . $logentry['itemname'] . '</a>';
249
+                        $item = '<a href="index.php?a=3&amp;id='.$logentry['itemid'].'">'.$logentry['itemname'].'</a>';
250 250
                     } else {
251 251
                         $item = $logentry['itemname'];
252 252
                     }
253 253
                     //index.php?a=13&searchuser=' . $logentry['internalKey'] . '&action=' . $logentry['action'] . '&itemname=' . $logentry['itemname'] . '&log_submit=true'
254
-                    $user_drill = 'index.php?a=13&searchuser=' . $logentry['internalKey'] . '&itemname=0&log_submit=true';
254
+                    $user_drill = 'index.php?a=13&searchuser='.$logentry['internalKey'].'&itemname=0&log_submit=true';
255 255
                     ?>
256 256
                     <tr>
257
-                        <td><?= '<a href="' . $user_drill . '">' . $logentry['username'] . '</a>' ?></td>
258
-                        <td class="text-nowrap"><?= '[' . $logentry['action'] . '] ' . $logentry['message'] ?></td>
257
+                        <td><?= '<a href="'.$user_drill.'">'.$logentry['username'].'</a>' ?></td>
258
+                        <td class="text-nowrap"><?= '['.$logentry['action'].'] '.$logentry['message'] ?></td>
259 259
                         <td class="text-xs-right"><?= $logentry['itemid'] ?></td>
260 260
                         <td><?= $item ?></td>
261 261
                         <td class="text-nowrap"><?= $modx->toDateFormat($logentry['timestamp'] + $server_offset_time) ?></td>
Please login to merge, or discard this patch.
Braces   +27 added lines, -27 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('logs')) {
5
+if (!$modx->hasPermission('logs')) {
6 6
     $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
                             <?php
27 27
                             // get all users currently in the log
28 28
                             $logs_user = record_sort(array_unique_multi($logs, 'internalKey'), 'username');
29
-                            foreach ($logs_user as $row) {
29
+                            foreach ($logs_user as $row) {
30 30
                                 $selectedtext = $row['internalKey'] == $_REQUEST['searchuser'] ? ' selected="selected"' : '';
31 31
                                 echo "\t\t" . '<option value="' . $row['internalKey'] . '"' . $selectedtext . '>' . $row['username'] . "</option>\n";
32 32
                             }
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
                             // get all available actions in the log
44 44
                             include_once "actionlist.inc.php";
45 45
                             $logs_actions = record_sort(array_unique_multi($logs, 'action'), 'action');
46
-                            foreach ($logs_actions as $row) {
46
+                            foreach ($logs_actions as $row) {
47 47
                                 $action = getAction($row['action']);
48
-                                if ($action == 'Idle') {
48
+                                if ($action == 'Idle') {
49 49
                                     continue;
50 50
                                 }
51 51
                                 $selectedtext = $row['action'] == $_REQUEST['action'] ? ' selected="selected"' : '';
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                             <?php
64 64
                             // get all itemid currently in logging
65 65
                             $logs_items = record_sort(array_unique_multi($logs, 'itemid'), 'itemid');
66
-                            foreach ($logs_items as $row) {
66
+                            foreach ($logs_items as $row) {
67 67
                                 $selectedtext = $row['itemid'] == $_REQUEST['itemid'] ? ' selected="selected"' : '';
68 68
                                 echo "\t\t" . '<option value="' . $row['itemid'] . '"' . $selectedtext . '>' . $row['itemid'] . "</option>\n";
69 69
                             }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                             <?php
80 80
                             // get all itemname currently in logging
81 81
                             $logs_names = record_sort(array_unique_multi($logs, 'itemname'), 'itemname');
82
-                            foreach ($logs_names as $row) {
82
+                            foreach ($logs_names as $row) {
83 83
                                 $selectedtext = $row['itemname'] == $_REQUEST['itemname'] ? ' selected="selected"' : '';
84 84
                                 echo "\t\t" . '<option value="' . $row['itemname'] . '"' . $selectedtext . '>' . $row['itemname'] . "</option>\n";
85 85
                             }
@@ -135,36 +135,36 @@  discard block
 block discarded – undo
135 135
     <div class="container container-body">
136 136
 
137 137
 <?php
138
-if (isset($_REQUEST['log_submit'])) {
138
+if (isset($_REQUEST['log_submit'])) {
139 139
     // get the selections the user made.
140 140
     $sqladd = array();
141
-    if ($_REQUEST['searchuser'] != 0) {
141
+    if ($_REQUEST['searchuser'] != 0) {
142 142
         $sqladd[] = "internalKey='" . (int)$_REQUEST['searchuser'] . "'";
143 143
     }
144
-    if ($_REQUEST['action'] != 0) {
144
+    if ($_REQUEST['action'] != 0) {
145 145
         $sqladd[] = "action=" . (int)$_REQUEST['action'];
146 146
     }
147
-    if ($_REQUEST['itemid'] != 0 || $_REQUEST['itemid'] == "-") {
147
+    if ($_REQUEST['itemid'] != 0 || $_REQUEST['itemid'] == "-") {
148 148
         $sqladd[] = "itemid='" . $_REQUEST['itemid'] . "'";
149 149
     }
150
-    if ($_REQUEST['itemname'] != '0') {
150
+    if ($_REQUEST['itemname'] != '0') {
151 151
         $sqladd[] = "itemname='" . $modx->db->escape($_REQUEST['itemname']) . "'";
152 152
     }
153
-    if ($_REQUEST['message'] != "") {
153
+    if ($_REQUEST['message'] != "") {
154 154
         $sqladd[] = "message LIKE '%" . $modx->db->escape($_REQUEST['message']) . "%'";
155 155
     }
156 156
     // date stuff
157
-    if ($_REQUEST['datefrom'] != "") {
157
+    if ($_REQUEST['datefrom'] != "") {
158 158
         $sqladd[] = "timestamp>" . $modx->toTimeStamp($_REQUEST['datefrom']);
159 159
     }
160
-    if ($_REQUEST['dateto'] != "") {
160
+    if ($_REQUEST['dateto'] != "") {
161 161
         $sqladd[] = "timestamp<" . $modx->toTimeStamp($_REQUEST['dateto']);
162 162
     }
163 163
 
164 164
     // If current position is not set, set it to zero
165
-    if (!isset($_REQUEST['int_cur_position']) || $_REQUEST['int_cur_position'] == 0) {
165
+    if (!isset($_REQUEST['int_cur_position']) || $_REQUEST['int_cur_position'] == 0) {
166 166
         $int_cur_position = 0;
167
-    } else {
167
+    } else {
168 168
         $int_cur_position = $_REQUEST['int_cur_position'];
169 169
     }
170 170
 
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
 
179 179
     $rs = $modx->db->select('*', $modx->getFullTableName('manager_log'), (!empty($sqladd) ? implode(' AND ', $sqladd) : ''), 'timestamp DESC, id DESC', "{$int_cur_position}, {$int_num_result}");
180 180
 
181
-if ($limit < 1) {
181
+if ($limit < 1) {
182 182
     echo '<p>' . $_lang["mgrlog_emptysrch"] . '</p>';
183
-} else {
183
+} else {
184 184
     echo '<p>' . $_lang["mgrlog_sortinst"] . '</p>';
185 185
 
186 186
     // New instance of the Paging class, you can modify the color and the width of the html table
@@ -198,14 +198,14 @@  discard block
 block discarded – undo
198 198
     $paging = $array_paging['first_link'] . $_lang["paging_first"] . (isset($array_paging['first_link']) ? "</a> " : " ");
199 199
     $paging .= $array_paging['previous_link'] . $_lang["paging_prev"] . (isset($array_paging['previous_link']) ? "</a> " : " ");
200 200
     $pagesfound = sizeof($array_row_paging);
201
-    if ($pagesfound > 6) {
201
+    if ($pagesfound > 6) {
202 202
         $paging .= $array_row_paging[$current_row - 2]; // ."&nbsp;";
203 203
         $paging .= $array_row_paging[$current_row - 1]; // ."&nbsp;";
204 204
         $paging .= $array_row_paging[$current_row]; // ."&nbsp;";
205 205
         $paging .= $array_row_paging[$current_row + 1]; // ."&nbsp;";
206 206
         $paging .= $array_row_paging[$current_row + 2]; // ."&nbsp;";
207
-    } else {
208
-        for ($i = 0; $i < $pagesfound; $i++) {
207
+    } else {
208
+        for ($i = 0; $i < $pagesfound; $i++) {
209 209
             $paging .= $array_row_paging[$i] . "&nbsp;";
210 210
         }
211 211
     }
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
                 // grab the entire log file...
243 243
                 $logentries = array();
244 244
                 $i = 0;
245
-                while ($logentry = $modx->db->getRow($rs)) {
246
-                    if (!preg_match("/^[0-9]+$/", $logentry['itemid'])) {
245
+                while ($logentry = $modx->db->getRow($rs)) {
246
+                    if (!preg_match("/^[0-9]+$/", $logentry['itemid'])) {
247 247
                         $item = '<div style="text-align:center;">-</div>';
248
-                    } elseif ($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) {
248
+                    } elseif ($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) {
249 249
                         $item = '<a href="index.php?a=3&amp;id=' . $logentry['itemid'] . '">' . $logentry['itemname'] . '</a>';
250
-                    } else {
250
+                    } else {
251 251
                         $item = $logentry['itemname'];
252 252
                     }
253 253
                     //index.php?a=13&searchuser=' . $logentry['internalKey'] . '&action=' . $logentry['action'] . '&itemname=' . $logentry['itemname'] . '&log_submit=true'
@@ -284,6 +284,6 @@  discard block
 block discarded – undo
284 284
     // @see index.php @ 915
285 285
     global $action;
286 286
     $action = 1;
287
-} else {
287
+} else {
288 288
     echo $_lang["mgrlog_noquery"];
289 289
 }
Please login to merge, or discard this patch.
manager/actions/help/01About_EVO.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,18 +4,18 @@
 block discarded – undo
4 4
 }
5 5
 $logo= '<img src="media/style/default/images/misc/login-logo.png" height="54" width="358" border="0">';
6 6
 $downloadLinks = array(
7
-	0=>array('title'=>$_lang["information"],'link'=>'https://evo.im/'),
8
-	1=>array('title'=>$_lang["download"],'link'=>'https://github.com/evolution-cms/evolution/releases'),
9
-	2=>array('title'=>$_lang["previous_releases"],'link'=>'https://modx.com/download/evolution/previous-releases.html'),
10
-	3=>array('title'=>$_lang["extras"],'link'=>array(
11
-		'http://extras.evolution-cms.com/',
12
-		'https://github.com/extras-evolution'
13
-	)),
7
+    0=>array('title'=>$_lang["information"],'link'=>'https://evo.im/'),
8
+    1=>array('title'=>$_lang["download"],'link'=>'https://github.com/evolution-cms/evolution/releases'),
9
+    2=>array('title'=>$_lang["previous_releases"],'link'=>'https://modx.com/download/evolution/previous-releases.html'),
10
+    3=>array('title'=>$_lang["extras"],'link'=>array(
11
+        'http://extras.evolution-cms.com/',
12
+        'https://github.com/extras-evolution'
13
+    )),
14 14
 );
15 15
 
16 16
 $translationLinks = array(
17
-	0=>array('title'=>'Evolution CMS','link'=>'https://www.transifex.com/evolutioncms/evolution/'),
18
-	1=>array('title'=>$_lang["extras"],'link'=>'https://www.transifex.com/evolutioncms/extras/'),
17
+    0=>array('title'=>'Evolution CMS','link'=>'https://www.transifex.com/evolutioncms/evolution/'),
18
+    1=>array('title'=>$_lang["extras"],'link'=>'https://www.transifex.com/evolutioncms/extras/'),
19 19
 );
20 20
 
21 21
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 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
-$logo= '<img src="media/style/default/images/misc/login-logo.png" height="54" width="358" border="0">';
5
+$logo = '<img src="media/style/default/images/misc/login-logo.png" height="54" width="358" border="0">';
6 6
 $downloadLinks = array(
7
-	0=>array('title'=>$_lang["information"],'link'=>'https://evo.im/'),
8
-	1=>array('title'=>$_lang["download"],'link'=>'https://github.com/evolution-cms/evolution/releases'),
9
-	2=>array('title'=>$_lang["previous_releases"],'link'=>'https://modx.com/download/evolution/previous-releases.html'),
10
-	3=>array('title'=>$_lang["extras"],'link'=>array(
7
+	0=>array('title'=>$_lang["information"], 'link'=>'https://evo.im/'),
8
+	1=>array('title'=>$_lang["download"], 'link'=>'https://github.com/evolution-cms/evolution/releases'),
9
+	2=>array('title'=>$_lang["previous_releases"], 'link'=>'https://modx.com/download/evolution/previous-releases.html'),
10
+	3=>array('title'=>$_lang["extras"], 'link'=>array(
11 11
 		'http://extras.evolution-cms.com/',
12 12
 		'https://github.com/extras-evolution'
13 13
 	)),
14 14
 );
15 15
 
16 16
 $translationLinks = array(
17
-	0=>array('title'=>'Evolution CMS','link'=>'https://www.transifex.com/evolutioncms/evolution/'),
18
-	1=>array('title'=>$_lang["extras"],'link'=>'https://www.transifex.com/evolutioncms/extras/'),
17
+	0=>array('title'=>'Evolution CMS', 'link'=>'https://www.transifex.com/evolutioncms/evolution/'),
18
+	1=>array('title'=>$_lang["extras"], 'link'=>'https://www.transifex.com/evolutioncms/extras/'),
19 19
 );
20 20
 
21 21
 
Please login to merge, or discard this patch.
manager/actions/import_site.static.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
     <div class="container container-body">
45 45
         <?php
46 46
         if (!isset($_POST['import'])) {
47
-            echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>";
47
+            echo "<div class=\"element-edit-message\">".$_lang['import_site_message']."</div>";
48 48
             ?>
49 49
             <form action="index.php" method="post" name="importFrm">
50 50
                 <input type="hidden" name="import" value="import"/>
Please login to merge, or discard this patch.