@@ -67,110 +67,110 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | switch($input['mode']) { |
70 | - case '11' : // new user |
|
71 | - // check if this user name already exist |
|
72 | - $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->getDatabase()->escape($newusername))); |
|
73 | - $limit = $modx->getDatabase()->getValue($rs); |
|
74 | - if($limit > 0) { |
|
75 | - webAlertAndQuit("User name is already in use!", 12); |
|
76 | - } |
|
77 | - |
|
78 | - // check if the email address already exist |
|
79 | - $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->getDatabase()->escape($email), $id)); |
|
80 | - $limit = $modx->getDatabase()->getValue($rs); |
|
81 | - if($limit > 0) { |
|
82 | - webAlertAndQuit("Email is already in use!", 12); |
|
83 | - } |
|
84 | - |
|
85 | - // generate a new password for this user |
|
86 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
87 | - if(strlen($specifiedpassword) < 6) { |
|
88 | - webAlertAndQuit("Password is too short!", 12); |
|
89 | - } else { |
|
90 | - $newpassword = $specifiedpassword; |
|
91 | - } |
|
92 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
93 | - webAlertAndQuit("You didn't specify a password for this user!", 12); |
|
94 | - } elseif($passwordgenmethod == 'g') { |
|
95 | - $newpassword = generate_password(8); |
|
96 | - } else { |
|
97 | - webAlertAndQuit("No password generation method specified!", 12); |
|
98 | - } |
|
99 | - |
|
100 | - // invoke OnBeforeUserFormSave event |
|
101 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
102 | - "mode" => "new", |
|
103 | - )); |
|
104 | - |
|
105 | - // create the user account |
|
106 | - $internalKey = $modx->getDatabase()->insert(array('username' => $modx->getDatabase()->escape($newusername)), $tbl_manager_users); |
|
107 | - |
|
108 | - $field = array(); |
|
109 | - $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
|
110 | - $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
111 | - |
|
112 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
113 | - $field = $modx->getDatabase()->escape($field); |
|
114 | - $modx->getDatabase()->insert($field, $tbl_user_attributes); |
|
115 | - |
|
116 | - // Save user settings |
|
117 | - saveManagerUserSettings($internalKey); |
|
118 | - |
|
119 | - // invoke OnManagerSaveUser event |
|
120 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
121 | - "mode" => "new", |
|
122 | - "userid" => $internalKey, |
|
123 | - "username" => $newusername, |
|
124 | - "userpassword" => $newpassword, |
|
125 | - "useremail" => $email, |
|
126 | - "userfullname" => $fullname, |
|
127 | - "userroleid" => $role |
|
128 | - )); |
|
129 | - |
|
130 | - // invoke OnUserFormSave event |
|
131 | - $modx->invokeEvent("OnUserFormSave", array( |
|
132 | - "mode" => "new", |
|
133 | - "id" => $internalKey |
|
134 | - )); |
|
135 | - |
|
136 | - // Set the item name for logger |
|
137 | - $_SESSION['itemname'] = $newusername; |
|
138 | - |
|
139 | - /*******************************************************************************/ |
|
140 | - // put the user in the user_groups he/ she should be in |
|
141 | - // first, check that up_perms are switched on! |
|
142 | - if($use_udperms == 1) { |
|
143 | - if(!empty($user_groups)) { |
|
144 | - for($i = 0; $i < count($user_groups); $i++) { |
|
145 | - $f = array(); |
|
146 | - $f['user_group'] = (int)$user_groups[$i]; |
|
147 | - $f['member'] = $internalKey; |
|
148 | - $modx->getDatabase()->insert($f, $tbl_member_groups); |
|
149 | - } |
|
150 | - } |
|
151 | - } |
|
152 | - // end of user_groups stuff! |
|
153 | - |
|
154 | - if($passwordnotifymethod == 'e') { |
|
155 | - sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL); |
|
156 | - if($input['stay'] != '') { |
|
157 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
158 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
159 | - header($header); |
|
160 | - } else { |
|
161 | - $header = "Location: index.php?a=75&r=2"; |
|
162 | - header($header); |
|
163 | - } |
|
164 | - } else { |
|
165 | - if($input['stay'] != '') { |
|
166 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
167 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
168 | - } else { |
|
169 | - $stayUrl = "index.php?a=75&r=2"; |
|
170 | - } |
|
171 | - |
|
172 | - include_once "header.inc.php"; |
|
173 | - ?> |
|
70 | + case '11' : // new user |
|
71 | + // check if this user name already exist |
|
72 | + $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->getDatabase()->escape($newusername))); |
|
73 | + $limit = $modx->getDatabase()->getValue($rs); |
|
74 | + if($limit > 0) { |
|
75 | + webAlertAndQuit("User name is already in use!", 12); |
|
76 | + } |
|
77 | + |
|
78 | + // check if the email address already exist |
|
79 | + $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->getDatabase()->escape($email), $id)); |
|
80 | + $limit = $modx->getDatabase()->getValue($rs); |
|
81 | + if($limit > 0) { |
|
82 | + webAlertAndQuit("Email is already in use!", 12); |
|
83 | + } |
|
84 | + |
|
85 | + // generate a new password for this user |
|
86 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
87 | + if(strlen($specifiedpassword) < 6) { |
|
88 | + webAlertAndQuit("Password is too short!", 12); |
|
89 | + } else { |
|
90 | + $newpassword = $specifiedpassword; |
|
91 | + } |
|
92 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
93 | + webAlertAndQuit("You didn't specify a password for this user!", 12); |
|
94 | + } elseif($passwordgenmethod == 'g') { |
|
95 | + $newpassword = generate_password(8); |
|
96 | + } else { |
|
97 | + webAlertAndQuit("No password generation method specified!", 12); |
|
98 | + } |
|
99 | + |
|
100 | + // invoke OnBeforeUserFormSave event |
|
101 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
102 | + "mode" => "new", |
|
103 | + )); |
|
104 | + |
|
105 | + // create the user account |
|
106 | + $internalKey = $modx->getDatabase()->insert(array('username' => $modx->getDatabase()->escape($newusername)), $tbl_manager_users); |
|
107 | + |
|
108 | + $field = array(); |
|
109 | + $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
|
110 | + $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
111 | + |
|
112 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
113 | + $field = $modx->getDatabase()->escape($field); |
|
114 | + $modx->getDatabase()->insert($field, $tbl_user_attributes); |
|
115 | + |
|
116 | + // Save user settings |
|
117 | + saveManagerUserSettings($internalKey); |
|
118 | + |
|
119 | + // invoke OnManagerSaveUser event |
|
120 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
121 | + "mode" => "new", |
|
122 | + "userid" => $internalKey, |
|
123 | + "username" => $newusername, |
|
124 | + "userpassword" => $newpassword, |
|
125 | + "useremail" => $email, |
|
126 | + "userfullname" => $fullname, |
|
127 | + "userroleid" => $role |
|
128 | + )); |
|
129 | + |
|
130 | + // invoke OnUserFormSave event |
|
131 | + $modx->invokeEvent("OnUserFormSave", array( |
|
132 | + "mode" => "new", |
|
133 | + "id" => $internalKey |
|
134 | + )); |
|
135 | + |
|
136 | + // Set the item name for logger |
|
137 | + $_SESSION['itemname'] = $newusername; |
|
138 | + |
|
139 | + /*******************************************************************************/ |
|
140 | + // put the user in the user_groups he/ she should be in |
|
141 | + // first, check that up_perms are switched on! |
|
142 | + if($use_udperms == 1) { |
|
143 | + if(!empty($user_groups)) { |
|
144 | + for($i = 0; $i < count($user_groups); $i++) { |
|
145 | + $f = array(); |
|
146 | + $f['user_group'] = (int)$user_groups[$i]; |
|
147 | + $f['member'] = $internalKey; |
|
148 | + $modx->getDatabase()->insert($f, $tbl_member_groups); |
|
149 | + } |
|
150 | + } |
|
151 | + } |
|
152 | + // end of user_groups stuff! |
|
153 | + |
|
154 | + if($passwordnotifymethod == 'e') { |
|
155 | + sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL); |
|
156 | + if($input['stay'] != '') { |
|
157 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
158 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
159 | + header($header); |
|
160 | + } else { |
|
161 | + $header = "Location: index.php?a=75&r=2"; |
|
162 | + header($header); |
|
163 | + } |
|
164 | + } else { |
|
165 | + if($input['stay'] != '') { |
|
166 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
167 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
168 | + } else { |
|
169 | + $stayUrl = "index.php?a=75&r=2"; |
|
170 | + } |
|
171 | + |
|
172 | + include_once "header.inc.php"; |
|
173 | + ?> |
|
174 | 174 | |
175 | 175 | <h1><?php echo $_lang['user_title']; ?></h1> |
176 | 176 | |
@@ -192,125 +192,125 @@ discard block |
||
192 | 192 | </div> |
193 | 193 | <?php |
194 | 194 | |
195 | - include_once "footer.inc.php"; |
|
196 | - } |
|
197 | - break; |
|
198 | - case '12' : // edit user |
|
199 | - // generate a new password for this user |
|
200 | - if($genpassword == 1) { |
|
201 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
202 | - if(strlen($specifiedpassword) < 6) { |
|
203 | - webAlertAndQuit("Password is too short!", 12); |
|
204 | - } else { |
|
205 | - $newpassword = $specifiedpassword; |
|
206 | - } |
|
207 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
208 | - webAlertAndQuit("You didn't specify a password for this user!", 12); |
|
209 | - } elseif($passwordgenmethod == 'g') { |
|
210 | - $newpassword = generate_password(8); |
|
211 | - } else { |
|
212 | - webAlertAndQuit("No password generation method specified!", 12); |
|
213 | - } |
|
214 | - } |
|
215 | - if($passwordnotifymethod == 'e') { |
|
216 | - sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL); |
|
217 | - } |
|
218 | - |
|
219 | - // check if the username already exist |
|
220 | - $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->getDatabase()->escape($newusername), $id)); |
|
221 | - $limit = $modx->getDatabase()->getValue($rs); |
|
222 | - if($limit > 0) { |
|
223 | - webAlertAndQuit("User name is already in use!", 12); |
|
224 | - } |
|
225 | - |
|
226 | - // check if the email address already exists |
|
227 | - $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->getDatabase()->escape($email), $id)); |
|
228 | - $limit = $modx->getDatabase()->getValue($rs); |
|
229 | - if($limit > 0) { |
|
230 | - webAlertAndQuit("Email is already in use!", 12); |
|
231 | - } |
|
232 | - |
|
233 | - // invoke OnBeforeUserFormSave event |
|
234 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
235 | - "mode" => "upd", |
|
236 | - "id" => $id |
|
237 | - )); |
|
238 | - |
|
239 | - // update user name and password |
|
240 | - $field = array(); |
|
241 | - $field['username'] = $modx->getDatabase()->escape($newusername); |
|
242 | - if($genpassword == 1) { |
|
243 | - $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
|
244 | - } |
|
245 | - $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$id}'"); |
|
246 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
247 | - $field = $modx->getDatabase()->escape($field); |
|
248 | - $modx->getDatabase()->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
249 | - |
|
250 | - // Save user settings |
|
251 | - saveManagerUserSettings($id); |
|
252 | - |
|
253 | - // Set the item name for logger |
|
254 | - $_SESSION['itemname'] = $newusername; |
|
255 | - |
|
256 | - // invoke OnManagerSaveUser event |
|
257 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
258 | - "mode" => "upd", |
|
259 | - "userid" => $id, |
|
260 | - "username" => $newusername, |
|
261 | - "userpassword" => $newpassword, |
|
262 | - "useremail" => $email, |
|
263 | - "userfullname" => $fullname, |
|
264 | - "userroleid" => $role, |
|
265 | - "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
266 | - "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
267 | - )); |
|
268 | - |
|
269 | - // invoke OnManagerChangePassword event |
|
270 | - if($genpassword == 1) { |
|
271 | - $modx->invokeEvent("OnManagerChangePassword", array( |
|
272 | - "userid" => $id, |
|
273 | - "username" => $newusername, |
|
274 | - "userpassword" => $newpassword |
|
275 | - )); |
|
276 | - } |
|
277 | - |
|
278 | - // invoke OnUserFormSave event |
|
279 | - $modx->invokeEvent("OnUserFormSave", array( |
|
280 | - "mode" => "upd", |
|
281 | - "id" => $id |
|
282 | - )); |
|
283 | - |
|
284 | - /*******************************************************************************/ |
|
285 | - // put the user in the user_groups he/ she should be in |
|
286 | - // first, check that up_perms are switched on! |
|
287 | - if($use_udperms == 1) { |
|
288 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
289 | - $modx->getDatabase()->delete($tbl_member_groups, "member='{$id}'"); |
|
290 | - if(!empty($user_groups)) { |
|
291 | - for($i = 0; $i < count($user_groups); $i++) { |
|
292 | - $field = array(); |
|
293 | - $field['user_group'] = (int)$user_groups[$i]; |
|
294 | - $field['member'] = $id; |
|
295 | - $modx->getDatabase()->insert($field, $tbl_member_groups); |
|
296 | - } |
|
297 | - } |
|
298 | - } |
|
299 | - // end of user_groups stuff! |
|
300 | - /*******************************************************************************/ |
|
301 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
302 | - $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
303 | - } |
|
304 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
305 | - if($input['stay'] != '') { |
|
306 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
307 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
308 | - } else { |
|
309 | - $stayUrl = "index.php?a=75&r=2"; |
|
310 | - } |
|
311 | - |
|
312 | - include_once "header.inc.php"; |
|
313 | - ?> |
|
195 | + include_once "footer.inc.php"; |
|
196 | + } |
|
197 | + break; |
|
198 | + case '12' : // edit user |
|
199 | + // generate a new password for this user |
|
200 | + if($genpassword == 1) { |
|
201 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
202 | + if(strlen($specifiedpassword) < 6) { |
|
203 | + webAlertAndQuit("Password is too short!", 12); |
|
204 | + } else { |
|
205 | + $newpassword = $specifiedpassword; |
|
206 | + } |
|
207 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
208 | + webAlertAndQuit("You didn't specify a password for this user!", 12); |
|
209 | + } elseif($passwordgenmethod == 'g') { |
|
210 | + $newpassword = generate_password(8); |
|
211 | + } else { |
|
212 | + webAlertAndQuit("No password generation method specified!", 12); |
|
213 | + } |
|
214 | + } |
|
215 | + if($passwordnotifymethod == 'e') { |
|
216 | + sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL); |
|
217 | + } |
|
218 | + |
|
219 | + // check if the username already exist |
|
220 | + $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->getDatabase()->escape($newusername), $id)); |
|
221 | + $limit = $modx->getDatabase()->getValue($rs); |
|
222 | + if($limit > 0) { |
|
223 | + webAlertAndQuit("User name is already in use!", 12); |
|
224 | + } |
|
225 | + |
|
226 | + // check if the email address already exists |
|
227 | + $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->getDatabase()->escape($email), $id)); |
|
228 | + $limit = $modx->getDatabase()->getValue($rs); |
|
229 | + if($limit > 0) { |
|
230 | + webAlertAndQuit("Email is already in use!", 12); |
|
231 | + } |
|
232 | + |
|
233 | + // invoke OnBeforeUserFormSave event |
|
234 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
235 | + "mode" => "upd", |
|
236 | + "id" => $id |
|
237 | + )); |
|
238 | + |
|
239 | + // update user name and password |
|
240 | + $field = array(); |
|
241 | + $field['username'] = $modx->getDatabase()->escape($newusername); |
|
242 | + if($genpassword == 1) { |
|
243 | + $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
|
244 | + } |
|
245 | + $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$id}'"); |
|
246 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
247 | + $field = $modx->getDatabase()->escape($field); |
|
248 | + $modx->getDatabase()->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
249 | + |
|
250 | + // Save user settings |
|
251 | + saveManagerUserSettings($id); |
|
252 | + |
|
253 | + // Set the item name for logger |
|
254 | + $_SESSION['itemname'] = $newusername; |
|
255 | + |
|
256 | + // invoke OnManagerSaveUser event |
|
257 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
258 | + "mode" => "upd", |
|
259 | + "userid" => $id, |
|
260 | + "username" => $newusername, |
|
261 | + "userpassword" => $newpassword, |
|
262 | + "useremail" => $email, |
|
263 | + "userfullname" => $fullname, |
|
264 | + "userroleid" => $role, |
|
265 | + "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
266 | + "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
267 | + )); |
|
268 | + |
|
269 | + // invoke OnManagerChangePassword event |
|
270 | + if($genpassword == 1) { |
|
271 | + $modx->invokeEvent("OnManagerChangePassword", array( |
|
272 | + "userid" => $id, |
|
273 | + "username" => $newusername, |
|
274 | + "userpassword" => $newpassword |
|
275 | + )); |
|
276 | + } |
|
277 | + |
|
278 | + // invoke OnUserFormSave event |
|
279 | + $modx->invokeEvent("OnUserFormSave", array( |
|
280 | + "mode" => "upd", |
|
281 | + "id" => $id |
|
282 | + )); |
|
283 | + |
|
284 | + /*******************************************************************************/ |
|
285 | + // put the user in the user_groups he/ she should be in |
|
286 | + // first, check that up_perms are switched on! |
|
287 | + if($use_udperms == 1) { |
|
288 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
289 | + $modx->getDatabase()->delete($tbl_member_groups, "member='{$id}'"); |
|
290 | + if(!empty($user_groups)) { |
|
291 | + for($i = 0; $i < count($user_groups); $i++) { |
|
292 | + $field = array(); |
|
293 | + $field['user_group'] = (int)$user_groups[$i]; |
|
294 | + $field['member'] = $id; |
|
295 | + $modx->getDatabase()->insert($field, $tbl_member_groups); |
|
296 | + } |
|
297 | + } |
|
298 | + } |
|
299 | + // end of user_groups stuff! |
|
300 | + /*******************************************************************************/ |
|
301 | + if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
302 | + $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
303 | + } |
|
304 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
305 | + if($input['stay'] != '') { |
|
306 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
307 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
308 | + } else { |
|
309 | + $stayUrl = "index.php?a=75&r=2"; |
|
310 | + } |
|
311 | + |
|
312 | + include_once "header.inc.php"; |
|
313 | + ?> |
|
314 | 314 | |
315 | 315 | <h1><?php echo $_lang['user_title']; ?></h1> |
316 | 316 | |
@@ -330,18 +330,18 @@ discard block |
||
330 | 330 | </div> |
331 | 331 | <?php |
332 | 332 | |
333 | - include_once "footer.inc.php"; |
|
334 | - } else { |
|
335 | - if($input['stay'] != '') { |
|
336 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
337 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
338 | - header($header); |
|
339 | - } else { |
|
340 | - $header = "Location: index.php?a=75&r=2"; |
|
341 | - header($header); |
|
342 | - } |
|
343 | - } |
|
344 | - break; |
|
345 | - default: |
|
346 | - webAlertAndQuit("No operation set in request.", 12); |
|
333 | + include_once "footer.inc.php"; |
|
334 | + } else { |
|
335 | + if($input['stay'] != '') { |
|
336 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
337 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
338 | + header($header); |
|
339 | + } else { |
|
340 | + $header = "Location: index.php?a=75&r=2"; |
|
341 | + header($header); |
|
342 | + } |
|
343 | + } |
|
344 | + break; |
|
345 | + default: |
|
346 | + webAlertAndQuit("No operation set in request.", 12); |
|
347 | 347 | } |
@@ -1,8 +1,8 @@ discard block |
||
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 | |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | $input = $_POST; |
14 | 14 | |
15 | -$id = (int)$input['id']; |
|
15 | +$id = (int) $input['id']; |
|
16 | 16 | $oldusername = $input['oldusername']; |
17 | 17 | $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User"; |
18 | 18 | $fullname = $input['fullname']; |
@@ -42,56 +42,56 @@ discard block |
||
42 | 42 | $user_groups = $input['user_groups']; |
43 | 43 | |
44 | 44 | // verify password |
45 | -if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
45 | +if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
46 | 46 | webAlertAndQuit("Password typed is mismatched", 12); |
47 | 47 | } |
48 | 48 | |
49 | 49 | // verify email |
50 | -if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
50 | +if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
51 | 51 | webAlertAndQuit("E-mail address doesn't seem to be valid!", 12); |
52 | 52 | } |
53 | 53 | |
54 | 54 | // verify admin security |
55 | -if($_SESSION['mgrRole'] != 1) { |
|
55 | +if ($_SESSION['mgrRole'] != 1) { |
|
56 | 56 | // Check to see if user tried to spoof a "1" (admin) role |
57 | - if(!$modx->hasPermission('save_user')) { |
|
57 | + if (!$modx->hasPermission('save_user')) { |
|
58 | 58 | webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!", 12); |
59 | 59 | } |
60 | 60 | // Verify that the user being edited wasn't an admin and the user ID got spoofed |
61 | 61 | $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1"); |
62 | 62 | $limit = $modx->getDatabase()->getValue($rs); |
63 | - if($limit > 0) { |
|
63 | + if ($limit > 0) { |
|
64 | 64 | webAlertAndQuit("You cannot alter an administrative user.", 12); |
65 | 65 | } |
66 | 66 | |
67 | 67 | } |
68 | 68 | |
69 | -switch($input['mode']) { |
|
69 | +switch ($input['mode']) { |
|
70 | 70 | case '11' : // new user |
71 | 71 | // check if this user name already exist |
72 | 72 | $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->getDatabase()->escape($newusername))); |
73 | 73 | $limit = $modx->getDatabase()->getValue($rs); |
74 | - if($limit > 0) { |
|
74 | + if ($limit > 0) { |
|
75 | 75 | webAlertAndQuit("User name is already in use!", 12); |
76 | 76 | } |
77 | 77 | |
78 | 78 | // check if the email address already exist |
79 | 79 | $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->getDatabase()->escape($email), $id)); |
80 | 80 | $limit = $modx->getDatabase()->getValue($rs); |
81 | - if($limit > 0) { |
|
81 | + if ($limit > 0) { |
|
82 | 82 | webAlertAndQuit("Email is already in use!", 12); |
83 | 83 | } |
84 | 84 | |
85 | 85 | // generate a new password for this user |
86 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
87 | - if(strlen($specifiedpassword) < 6) { |
|
86 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
87 | + if (strlen($specifiedpassword) < 6) { |
|
88 | 88 | webAlertAndQuit("Password is too short!", 12); |
89 | 89 | } else { |
90 | 90 | $newpassword = $specifiedpassword; |
91 | 91 | } |
92 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
92 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
93 | 93 | webAlertAndQuit("You didn't specify a password for this user!", 12); |
94 | - } elseif($passwordgenmethod == 'g') { |
|
94 | + } elseif ($passwordgenmethod == 'g') { |
|
95 | 95 | $newpassword = generate_password(8); |
96 | 96 | } else { |
97 | 97 | webAlertAndQuit("No password generation method specified!", 12); |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | /*******************************************************************************/ |
140 | 140 | // put the user in the user_groups he/ she should be in |
141 | 141 | // first, check that up_perms are switched on! |
142 | - if($use_udperms == 1) { |
|
143 | - if(!empty($user_groups)) { |
|
144 | - for($i = 0; $i < count($user_groups); $i++) { |
|
142 | + if ($use_udperms == 1) { |
|
143 | + if (!empty($user_groups)) { |
|
144 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
145 | 145 | $f = array(); |
146 | - $f['user_group'] = (int)$user_groups[$i]; |
|
146 | + $f['user_group'] = (int) $user_groups[$i]; |
|
147 | 147 | $f['member'] = $internalKey; |
148 | 148 | $modx->getDatabase()->insert($f, $tbl_member_groups); |
149 | 149 | } |
@@ -151,20 +151,20 @@ discard block |
||
151 | 151 | } |
152 | 152 | // end of user_groups stuff! |
153 | 153 | |
154 | - if($passwordnotifymethod == 'e') { |
|
154 | + if ($passwordnotifymethod == 'e') { |
|
155 | 155 | sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL); |
156 | - if($input['stay'] != '') { |
|
156 | + if ($input['stay'] != '') { |
|
157 | 157 | $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
158 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
158 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
159 | 159 | header($header); |
160 | 160 | } else { |
161 | 161 | $header = "Location: index.php?a=75&r=2"; |
162 | 162 | header($header); |
163 | 163 | } |
164 | 164 | } else { |
165 | - if($input['stay'] != '') { |
|
165 | + if ($input['stay'] != '') { |
|
166 | 166 | $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
167 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
167 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
168 | 168 | } else { |
169 | 169 | $stayUrl = "index.php?a=75&r=2"; |
170 | 170 | } |
@@ -197,36 +197,36 @@ discard block |
||
197 | 197 | break; |
198 | 198 | case '12' : // edit user |
199 | 199 | // generate a new password for this user |
200 | - if($genpassword == 1) { |
|
201 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
202 | - if(strlen($specifiedpassword) < 6) { |
|
200 | + if ($genpassword == 1) { |
|
201 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
202 | + if (strlen($specifiedpassword) < 6) { |
|
203 | 203 | webAlertAndQuit("Password is too short!", 12); |
204 | 204 | } else { |
205 | 205 | $newpassword = $specifiedpassword; |
206 | 206 | } |
207 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
207 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
208 | 208 | webAlertAndQuit("You didn't specify a password for this user!", 12); |
209 | - } elseif($passwordgenmethod == 'g') { |
|
209 | + } elseif ($passwordgenmethod == 'g') { |
|
210 | 210 | $newpassword = generate_password(8); |
211 | 211 | } else { |
212 | 212 | webAlertAndQuit("No password generation method specified!", 12); |
213 | 213 | } |
214 | 214 | } |
215 | - if($passwordnotifymethod == 'e') { |
|
215 | + if ($passwordnotifymethod == 'e') { |
|
216 | 216 | sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL); |
217 | 217 | } |
218 | 218 | |
219 | 219 | // check if the username already exist |
220 | 220 | $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->getDatabase()->escape($newusername), $id)); |
221 | 221 | $limit = $modx->getDatabase()->getValue($rs); |
222 | - if($limit > 0) { |
|
222 | + if ($limit > 0) { |
|
223 | 223 | webAlertAndQuit("User name is already in use!", 12); |
224 | 224 | } |
225 | 225 | |
226 | 226 | // check if the email address already exists |
227 | 227 | $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->getDatabase()->escape($email), $id)); |
228 | 228 | $limit = $modx->getDatabase()->getValue($rs); |
229 | - if($limit > 0) { |
|
229 | + if ($limit > 0) { |
|
230 | 230 | webAlertAndQuit("Email is already in use!", 12); |
231 | 231 | } |
232 | 232 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | // update user name and password |
240 | 240 | $field = array(); |
241 | 241 | $field['username'] = $modx->getDatabase()->escape($newusername); |
242 | - if($genpassword == 1) { |
|
242 | + if ($genpassword == 1) { |
|
243 | 243 | $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
244 | 244 | } |
245 | 245 | $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$id}'"); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | )); |
268 | 268 | |
269 | 269 | // invoke OnManagerChangePassword event |
270 | - if($genpassword == 1) { |
|
270 | + if ($genpassword == 1) { |
|
271 | 271 | $modx->invokeEvent("OnManagerChangePassword", array( |
272 | 272 | "userid" => $id, |
273 | 273 | "username" => $newusername, |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | /*******************************************************************************/ |
285 | 285 | // put the user in the user_groups he/ she should be in |
286 | 286 | // first, check that up_perms are switched on! |
287 | - if($use_udperms == 1) { |
|
287 | + if ($use_udperms == 1) { |
|
288 | 288 | // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
289 | 289 | $modx->getDatabase()->delete($tbl_member_groups, "member='{$id}'"); |
290 | - if(!empty($user_groups)) { |
|
291 | - for($i = 0; $i < count($user_groups); $i++) { |
|
290 | + if (!empty($user_groups)) { |
|
291 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
292 | 292 | $field = array(); |
293 | - $field['user_group'] = (int)$user_groups[$i]; |
|
293 | + $field['user_group'] = (int) $user_groups[$i]; |
|
294 | 294 | $field['member'] = $id; |
295 | 295 | $modx->getDatabase()->insert($field, $tbl_member_groups); |
296 | 296 | } |
@@ -298,13 +298,13 @@ discard block |
||
298 | 298 | } |
299 | 299 | // end of user_groups stuff! |
300 | 300 | /*******************************************************************************/ |
301 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
301 | + if ($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
302 | 302 | $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
303 | 303 | } |
304 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
305 | - if($input['stay'] != '') { |
|
304 | + if ($genpassword == 1 && $passwordnotifymethod == 's') { |
|
305 | + if ($input['stay'] != '') { |
|
306 | 306 | $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
307 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
307 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
308 | 308 | } else { |
309 | 309 | $stayUrl = "index.php?a=75&r=2"; |
310 | 310 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | <div class="sectionHeader"><?php echo $_lang['user_title']; ?></div> |
325 | 325 | <div class="sectionBody"> |
326 | 326 | <div id="disp"> |
327 | - <p><?php echo sprintf($_lang["password_msg"], $modx->getPhpCompat()->htmlspecialchars($newusername), $modx->getPhpCompat()->htmlspecialchars($newpassword)) . (($id == $modx->getLoginUserID()) ? ' ' . $_lang['user_changeddata'] : ''); ?></p> |
|
327 | + <p><?php echo sprintf($_lang["password_msg"], $modx->getPhpCompat()->htmlspecialchars($newusername), $modx->getPhpCompat()->htmlspecialchars($newpassword)).(($id == $modx->getLoginUserID()) ? ' '.$_lang['user_changeddata'] : ''); ?></p> |
|
328 | 328 | </div> |
329 | 329 | </div> |
330 | 330 | </div> |
@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | |
333 | 333 | include_once "footer.inc.php"; |
334 | 334 | } else { |
335 | - if($input['stay'] != '') { |
|
335 | + if ($input['stay'] != '') { |
|
336 | 336 | $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
337 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
337 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
338 | 338 | header($header); |
339 | 339 | } else { |
340 | 340 | $header = "Location: index.php?a=75&r=2"; |
@@ -1,9 +1,9 @@ discard block |
||
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 | $tbl_manager_users = $modx->getDatabase()->getFullTableName('manager_users'); |
@@ -43,134 +43,134 @@ discard block |
||
43 | 43 | |
44 | 44 | // verify password |
45 | 45 | if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
46 | - webAlertAndQuit("Password typed is mismatched", 12); |
|
46 | + webAlertAndQuit("Password typed is mismatched", 12); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | // verify email |
50 | 50 | if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
51 | - webAlertAndQuit("E-mail address doesn't seem to be valid!", 12); |
|
51 | + webAlertAndQuit("E-mail address doesn't seem to be valid!", 12); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | // verify admin security |
55 | 55 | if($_SESSION['mgrRole'] != 1) { |
56 | - // Check to see if user tried to spoof a "1" (admin) role |
|
57 | - if(!$modx->hasPermission('save_user')) { |
|
58 | - webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!", 12); |
|
59 | - } |
|
60 | - // Verify that the user being edited wasn't an admin and the user ID got spoofed |
|
61 | - $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1"); |
|
62 | - $limit = $modx->getDatabase()->getValue($rs); |
|
63 | - if($limit > 0) { |
|
64 | - webAlertAndQuit("You cannot alter an administrative user.", 12); |
|
65 | - } |
|
56 | + // Check to see if user tried to spoof a "1" (admin) role |
|
57 | + if(!$modx->hasPermission('save_user')) { |
|
58 | + webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!", 12); |
|
59 | + } |
|
60 | + // Verify that the user being edited wasn't an admin and the user ID got spoofed |
|
61 | + $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1"); |
|
62 | + $limit = $modx->getDatabase()->getValue($rs); |
|
63 | + if($limit > 0) { |
|
64 | + webAlertAndQuit("You cannot alter an administrative user.", 12); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | } |
68 | 68 | |
69 | 69 | switch($input['mode']) { |
70 | - case '11' : // new user |
|
71 | - // check if this user name already exist |
|
72 | - $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->getDatabase()->escape($newusername))); |
|
73 | - $limit = $modx->getDatabase()->getValue($rs); |
|
74 | - if($limit > 0) { |
|
75 | - webAlertAndQuit("User name is already in use!", 12); |
|
76 | - } |
|
77 | - |
|
78 | - // check if the email address already exist |
|
79 | - $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->getDatabase()->escape($email), $id)); |
|
80 | - $limit = $modx->getDatabase()->getValue($rs); |
|
81 | - if($limit > 0) { |
|
82 | - webAlertAndQuit("Email is already in use!", 12); |
|
83 | - } |
|
84 | - |
|
85 | - // generate a new password for this user |
|
86 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
87 | - if(strlen($specifiedpassword) < 6) { |
|
88 | - webAlertAndQuit("Password is too short!", 12); |
|
89 | - } else { |
|
90 | - $newpassword = $specifiedpassword; |
|
91 | - } |
|
92 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
93 | - webAlertAndQuit("You didn't specify a password for this user!", 12); |
|
94 | - } elseif($passwordgenmethod == 'g') { |
|
95 | - $newpassword = generate_password(8); |
|
96 | - } else { |
|
97 | - webAlertAndQuit("No password generation method specified!", 12); |
|
98 | - } |
|
99 | - |
|
100 | - // invoke OnBeforeUserFormSave event |
|
101 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
102 | - "mode" => "new", |
|
103 | - )); |
|
104 | - |
|
105 | - // create the user account |
|
106 | - $internalKey = $modx->getDatabase()->insert(array('username' => $modx->getDatabase()->escape($newusername)), $tbl_manager_users); |
|
107 | - |
|
108 | - $field = array(); |
|
109 | - $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
|
110 | - $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
111 | - |
|
112 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
113 | - $field = $modx->getDatabase()->escape($field); |
|
114 | - $modx->getDatabase()->insert($field, $tbl_user_attributes); |
|
115 | - |
|
116 | - // Save user settings |
|
70 | + case '11' : // new user |
|
71 | + // check if this user name already exist |
|
72 | + $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->getDatabase()->escape($newusername))); |
|
73 | + $limit = $modx->getDatabase()->getValue($rs); |
|
74 | + if($limit > 0) { |
|
75 | + webAlertAndQuit("User name is already in use!", 12); |
|
76 | + } |
|
77 | + |
|
78 | + // check if the email address already exist |
|
79 | + $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->getDatabase()->escape($email), $id)); |
|
80 | + $limit = $modx->getDatabase()->getValue($rs); |
|
81 | + if($limit > 0) { |
|
82 | + webAlertAndQuit("Email is already in use!", 12); |
|
83 | + } |
|
84 | + |
|
85 | + // generate a new password for this user |
|
86 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
87 | + if(strlen($specifiedpassword) < 6) { |
|
88 | + webAlertAndQuit("Password is too short!", 12); |
|
89 | + } else { |
|
90 | + $newpassword = $specifiedpassword; |
|
91 | + } |
|
92 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
93 | + webAlertAndQuit("You didn't specify a password for this user!", 12); |
|
94 | + } elseif($passwordgenmethod == 'g') { |
|
95 | + $newpassword = generate_password(8); |
|
96 | + } else { |
|
97 | + webAlertAndQuit("No password generation method specified!", 12); |
|
98 | + } |
|
99 | + |
|
100 | + // invoke OnBeforeUserFormSave event |
|
101 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
102 | + "mode" => "new", |
|
103 | + )); |
|
104 | + |
|
105 | + // create the user account |
|
106 | + $internalKey = $modx->getDatabase()->insert(array('username' => $modx->getDatabase()->escape($newusername)), $tbl_manager_users); |
|
107 | + |
|
108 | + $field = array(); |
|
109 | + $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
|
110 | + $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
111 | + |
|
112 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
113 | + $field = $modx->getDatabase()->escape($field); |
|
114 | + $modx->getDatabase()->insert($field, $tbl_user_attributes); |
|
115 | + |
|
116 | + // Save user settings |
|
117 | 117 | saveManagerUserSettings($internalKey); |
118 | 118 | |
119 | - // invoke OnManagerSaveUser event |
|
120 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
121 | - "mode" => "new", |
|
122 | - "userid" => $internalKey, |
|
123 | - "username" => $newusername, |
|
124 | - "userpassword" => $newpassword, |
|
125 | - "useremail" => $email, |
|
126 | - "userfullname" => $fullname, |
|
127 | - "userroleid" => $role |
|
128 | - )); |
|
129 | - |
|
130 | - // invoke OnUserFormSave event |
|
131 | - $modx->invokeEvent("OnUserFormSave", array( |
|
132 | - "mode" => "new", |
|
133 | - "id" => $internalKey |
|
134 | - )); |
|
135 | - |
|
136 | - // Set the item name for logger |
|
137 | - $_SESSION['itemname'] = $newusername; |
|
138 | - |
|
139 | - /*******************************************************************************/ |
|
140 | - // put the user in the user_groups he/ she should be in |
|
141 | - // first, check that up_perms are switched on! |
|
142 | - if($use_udperms == 1) { |
|
143 | - if(!empty($user_groups)) { |
|
144 | - for($i = 0; $i < count($user_groups); $i++) { |
|
145 | - $f = array(); |
|
146 | - $f['user_group'] = (int)$user_groups[$i]; |
|
147 | - $f['member'] = $internalKey; |
|
148 | - $modx->getDatabase()->insert($f, $tbl_member_groups); |
|
149 | - } |
|
150 | - } |
|
151 | - } |
|
152 | - // end of user_groups stuff! |
|
153 | - |
|
154 | - if($passwordnotifymethod == 'e') { |
|
119 | + // invoke OnManagerSaveUser event |
|
120 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
121 | + "mode" => "new", |
|
122 | + "userid" => $internalKey, |
|
123 | + "username" => $newusername, |
|
124 | + "userpassword" => $newpassword, |
|
125 | + "useremail" => $email, |
|
126 | + "userfullname" => $fullname, |
|
127 | + "userroleid" => $role |
|
128 | + )); |
|
129 | + |
|
130 | + // invoke OnUserFormSave event |
|
131 | + $modx->invokeEvent("OnUserFormSave", array( |
|
132 | + "mode" => "new", |
|
133 | + "id" => $internalKey |
|
134 | + )); |
|
135 | + |
|
136 | + // Set the item name for logger |
|
137 | + $_SESSION['itemname'] = $newusername; |
|
138 | + |
|
139 | + /*******************************************************************************/ |
|
140 | + // put the user in the user_groups he/ she should be in |
|
141 | + // first, check that up_perms are switched on! |
|
142 | + if($use_udperms == 1) { |
|
143 | + if(!empty($user_groups)) { |
|
144 | + for($i = 0; $i < count($user_groups); $i++) { |
|
145 | + $f = array(); |
|
146 | + $f['user_group'] = (int)$user_groups[$i]; |
|
147 | + $f['member'] = $internalKey; |
|
148 | + $modx->getDatabase()->insert($f, $tbl_member_groups); |
|
149 | + } |
|
150 | + } |
|
151 | + } |
|
152 | + // end of user_groups stuff! |
|
153 | + |
|
154 | + if($passwordnotifymethod == 'e') { |
|
155 | 155 | sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL); |
156 | - if($input['stay'] != '') { |
|
157 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
158 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
159 | - header($header); |
|
160 | - } else { |
|
161 | - $header = "Location: index.php?a=75&r=2"; |
|
162 | - header($header); |
|
163 | - } |
|
164 | - } else { |
|
165 | - if($input['stay'] != '') { |
|
166 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
167 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
168 | - } else { |
|
169 | - $stayUrl = "index.php?a=75&r=2"; |
|
170 | - } |
|
171 | - |
|
172 | - include_once "header.inc.php"; |
|
173 | - ?> |
|
156 | + if($input['stay'] != '') { |
|
157 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
158 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
159 | + header($header); |
|
160 | + } else { |
|
161 | + $header = "Location: index.php?a=75&r=2"; |
|
162 | + header($header); |
|
163 | + } |
|
164 | + } else { |
|
165 | + if($input['stay'] != '') { |
|
166 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
167 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
168 | + } else { |
|
169 | + $stayUrl = "index.php?a=75&r=2"; |
|
170 | + } |
|
171 | + |
|
172 | + include_once "header.inc.php"; |
|
173 | + ?> |
|
174 | 174 | |
175 | 175 | <h1><?php echo $_lang['user_title']; ?></h1> |
176 | 176 | |
@@ -192,125 +192,125 @@ discard block |
||
192 | 192 | </div> |
193 | 193 | <?php |
194 | 194 | |
195 | - include_once "footer.inc.php"; |
|
196 | - } |
|
197 | - break; |
|
198 | - case '12' : // edit user |
|
199 | - // generate a new password for this user |
|
200 | - if($genpassword == 1) { |
|
201 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
202 | - if(strlen($specifiedpassword) < 6) { |
|
203 | - webAlertAndQuit("Password is too short!", 12); |
|
204 | - } else { |
|
205 | - $newpassword = $specifiedpassword; |
|
206 | - } |
|
207 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
208 | - webAlertAndQuit("You didn't specify a password for this user!", 12); |
|
209 | - } elseif($passwordgenmethod == 'g') { |
|
210 | - $newpassword = generate_password(8); |
|
211 | - } else { |
|
212 | - webAlertAndQuit("No password generation method specified!", 12); |
|
213 | - } |
|
214 | - } |
|
215 | - if($passwordnotifymethod == 'e') { |
|
195 | + include_once "footer.inc.php"; |
|
196 | + } |
|
197 | + break; |
|
198 | + case '12' : // edit user |
|
199 | + // generate a new password for this user |
|
200 | + if($genpassword == 1) { |
|
201 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
202 | + if(strlen($specifiedpassword) < 6) { |
|
203 | + webAlertAndQuit("Password is too short!", 12); |
|
204 | + } else { |
|
205 | + $newpassword = $specifiedpassword; |
|
206 | + } |
|
207 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
208 | + webAlertAndQuit("You didn't specify a password for this user!", 12); |
|
209 | + } elseif($passwordgenmethod == 'g') { |
|
210 | + $newpassword = generate_password(8); |
|
211 | + } else { |
|
212 | + webAlertAndQuit("No password generation method specified!", 12); |
|
213 | + } |
|
214 | + } |
|
215 | + if($passwordnotifymethod == 'e') { |
|
216 | 216 | sendMailMessageForUser($email, $newusername, $newpassword, $fullname, $signupemail_message, MODX_MANAGER_URL); |
217 | - } |
|
218 | - |
|
219 | - // check if the username already exist |
|
220 | - $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->getDatabase()->escape($newusername), $id)); |
|
221 | - $limit = $modx->getDatabase()->getValue($rs); |
|
222 | - if($limit > 0) { |
|
223 | - webAlertAndQuit("User name is already in use!", 12); |
|
224 | - } |
|
225 | - |
|
226 | - // check if the email address already exists |
|
227 | - $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->getDatabase()->escape($email), $id)); |
|
228 | - $limit = $modx->getDatabase()->getValue($rs); |
|
229 | - if($limit > 0) { |
|
230 | - webAlertAndQuit("Email is already in use!", 12); |
|
231 | - } |
|
232 | - |
|
233 | - // invoke OnBeforeUserFormSave event |
|
234 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
235 | - "mode" => "upd", |
|
236 | - "id" => $id |
|
237 | - )); |
|
238 | - |
|
239 | - // update user name and password |
|
240 | - $field = array(); |
|
241 | - $field['username'] = $modx->getDatabase()->escape($newusername); |
|
242 | - if($genpassword == 1) { |
|
243 | - $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
|
244 | - } |
|
245 | - $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$id}'"); |
|
246 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
247 | - $field = $modx->getDatabase()->escape($field); |
|
248 | - $modx->getDatabase()->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
249 | - |
|
250 | - // Save user settings |
|
217 | + } |
|
218 | + |
|
219 | + // check if the username already exist |
|
220 | + $rs = $modx->getDatabase()->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->getDatabase()->escape($newusername), $id)); |
|
221 | + $limit = $modx->getDatabase()->getValue($rs); |
|
222 | + if($limit > 0) { |
|
223 | + webAlertAndQuit("User name is already in use!", 12); |
|
224 | + } |
|
225 | + |
|
226 | + // check if the email address already exists |
|
227 | + $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->getDatabase()->escape($email), $id)); |
|
228 | + $limit = $modx->getDatabase()->getValue($rs); |
|
229 | + if($limit > 0) { |
|
230 | + webAlertAndQuit("Email is already in use!", 12); |
|
231 | + } |
|
232 | + |
|
233 | + // invoke OnBeforeUserFormSave event |
|
234 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
235 | + "mode" => "upd", |
|
236 | + "id" => $id |
|
237 | + )); |
|
238 | + |
|
239 | + // update user name and password |
|
240 | + $field = array(); |
|
241 | + $field['username'] = $modx->getDatabase()->escape($newusername); |
|
242 | + if($genpassword == 1) { |
|
243 | + $field['password'] = $modx->getPasswordHash()->HashPassword($newpassword); |
|
244 | + } |
|
245 | + $modx->getDatabase()->update($field, $tbl_manager_users, "id='{$id}'"); |
|
246 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
247 | + $field = $modx->getDatabase()->escape($field); |
|
248 | + $modx->getDatabase()->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
249 | + |
|
250 | + // Save user settings |
|
251 | 251 | saveManagerUserSettings($id); |
252 | 252 | |
253 | - // Set the item name for logger |
|
254 | - $_SESSION['itemname'] = $newusername; |
|
255 | - |
|
256 | - // invoke OnManagerSaveUser event |
|
257 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
258 | - "mode" => "upd", |
|
259 | - "userid" => $id, |
|
260 | - "username" => $newusername, |
|
261 | - "userpassword" => $newpassword, |
|
262 | - "useremail" => $email, |
|
263 | - "userfullname" => $fullname, |
|
264 | - "userroleid" => $role, |
|
265 | - "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
266 | - "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
267 | - )); |
|
268 | - |
|
269 | - // invoke OnManagerChangePassword event |
|
270 | - if($genpassword == 1) { |
|
271 | - $modx->invokeEvent("OnManagerChangePassword", array( |
|
272 | - "userid" => $id, |
|
273 | - "username" => $newusername, |
|
274 | - "userpassword" => $newpassword |
|
275 | - )); |
|
276 | - } |
|
277 | - |
|
278 | - // invoke OnUserFormSave event |
|
279 | - $modx->invokeEvent("OnUserFormSave", array( |
|
280 | - "mode" => "upd", |
|
281 | - "id" => $id |
|
282 | - )); |
|
283 | - |
|
284 | - /*******************************************************************************/ |
|
285 | - // put the user in the user_groups he/ she should be in |
|
286 | - // first, check that up_perms are switched on! |
|
287 | - if($use_udperms == 1) { |
|
288 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
289 | - $modx->getDatabase()->delete($tbl_member_groups, "member='{$id}'"); |
|
290 | - if(!empty($user_groups)) { |
|
291 | - for($i = 0; $i < count($user_groups); $i++) { |
|
292 | - $field = array(); |
|
293 | - $field['user_group'] = (int)$user_groups[$i]; |
|
294 | - $field['member'] = $id; |
|
295 | - $modx->getDatabase()->insert($field, $tbl_member_groups); |
|
296 | - } |
|
297 | - } |
|
298 | - } |
|
299 | - // end of user_groups stuff! |
|
300 | - /*******************************************************************************/ |
|
301 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
302 | - $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
303 | - } |
|
304 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
305 | - if($input['stay'] != '') { |
|
306 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
307 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
308 | - } else { |
|
309 | - $stayUrl = "index.php?a=75&r=2"; |
|
310 | - } |
|
311 | - |
|
312 | - include_once "header.inc.php"; |
|
313 | - ?> |
|
253 | + // Set the item name for logger |
|
254 | + $_SESSION['itemname'] = $newusername; |
|
255 | + |
|
256 | + // invoke OnManagerSaveUser event |
|
257 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
258 | + "mode" => "upd", |
|
259 | + "userid" => $id, |
|
260 | + "username" => $newusername, |
|
261 | + "userpassword" => $newpassword, |
|
262 | + "useremail" => $email, |
|
263 | + "userfullname" => $fullname, |
|
264 | + "userroleid" => $role, |
|
265 | + "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
266 | + "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
267 | + )); |
|
268 | + |
|
269 | + // invoke OnManagerChangePassword event |
|
270 | + if($genpassword == 1) { |
|
271 | + $modx->invokeEvent("OnManagerChangePassword", array( |
|
272 | + "userid" => $id, |
|
273 | + "username" => $newusername, |
|
274 | + "userpassword" => $newpassword |
|
275 | + )); |
|
276 | + } |
|
277 | + |
|
278 | + // invoke OnUserFormSave event |
|
279 | + $modx->invokeEvent("OnUserFormSave", array( |
|
280 | + "mode" => "upd", |
|
281 | + "id" => $id |
|
282 | + )); |
|
283 | + |
|
284 | + /*******************************************************************************/ |
|
285 | + // put the user in the user_groups he/ she should be in |
|
286 | + // first, check that up_perms are switched on! |
|
287 | + if($use_udperms == 1) { |
|
288 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
289 | + $modx->getDatabase()->delete($tbl_member_groups, "member='{$id}'"); |
|
290 | + if(!empty($user_groups)) { |
|
291 | + for($i = 0; $i < count($user_groups); $i++) { |
|
292 | + $field = array(); |
|
293 | + $field['user_group'] = (int)$user_groups[$i]; |
|
294 | + $field['member'] = $id; |
|
295 | + $modx->getDatabase()->insert($field, $tbl_member_groups); |
|
296 | + } |
|
297 | + } |
|
298 | + } |
|
299 | + // end of user_groups stuff! |
|
300 | + /*******************************************************************************/ |
|
301 | + if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
302 | + $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
303 | + } |
|
304 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
305 | + if($input['stay'] != '') { |
|
306 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
307 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
308 | + } else { |
|
309 | + $stayUrl = "index.php?a=75&r=2"; |
|
310 | + } |
|
311 | + |
|
312 | + include_once "header.inc.php"; |
|
313 | + ?> |
|
314 | 314 | |
315 | 315 | <h1><?php echo $_lang['user_title']; ?></h1> |
316 | 316 | |
@@ -330,18 +330,18 @@ discard block |
||
330 | 330 | </div> |
331 | 331 | <?php |
332 | 332 | |
333 | - include_once "footer.inc.php"; |
|
334 | - } else { |
|
335 | - if($input['stay'] != '') { |
|
336 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
337 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
338 | - header($header); |
|
339 | - } else { |
|
340 | - $header = "Location: index.php?a=75&r=2"; |
|
341 | - header($header); |
|
342 | - } |
|
343 | - } |
|
344 | - break; |
|
345 | - default: |
|
346 | - webAlertAndQuit("No operation set in request.", 12); |
|
333 | + include_once "footer.inc.php"; |
|
334 | + } else { |
|
335 | + if($input['stay'] != '') { |
|
336 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
337 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
338 | + header($header); |
|
339 | + } else { |
|
340 | + $header = "Location: index.php?a=75&r=2"; |
|
341 | + header($header); |
|
342 | + } |
|
343 | + } |
|
344 | + break; |
|
345 | + default: |
|
346 | + webAlertAndQuit("No operation set in request.", 12); |
|
347 | 347 | } |
@@ -3,7 +3,7 @@ discard block |
||
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('export_static')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $maxtime = (is_numeric($_POST['maxtime'])) ? $_POST['maxtime'] : 30; |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | $modx->getExportSite()->targetDir = $export_dir; |
16 | 16 | |
17 | 17 | if(strpos($modx->config['base_path'],"{$export_dir}/")===0 && 0 <= strlen(str_replace("{$export_dir}/",'',$modx->config['base_path']))) |
18 | - return $_lang['export_site.static.php6']; |
|
18 | + return $_lang['export_site.static.php6']; |
|
19 | 19 | elseif($modx->config['rb_base_dir'] === $export_dir . '/') |
20 | - return $modx->parsePlaceholder($_lang['export_site.static.php7'],'rb_base_url=' . $modx->config['base_url'] . $modx->config['rb_base_url']); |
|
20 | + return $modx->parsePlaceholder($_lang['export_site.static.php7'],'rb_base_url=' . $modx->config['base_url'] . $modx->config['rb_base_url']); |
|
21 | 21 | elseif(!is_writable($export_dir)) |
22 | - return $_lang['export_site_target_unwritable']; |
|
22 | + return $_lang['export_site_target_unwritable']; |
|
23 | 23 | |
24 | 24 | $modx->getExportSite()->generate_mode = $_POST['generate_mode']; |
25 | 25 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | ||$includenoncache!==$_POST['includenoncache'] |
36 | 36 | ||$repl_before!==$_POST['repl_before'] |
37 | 37 | ||$repl_after !==$_POST['repl_after']) { |
38 | - $modx->clearCache('full'); |
|
38 | + $modx->clearCache('full'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | $total = $modx->getExportSite()->getTotal($_POST['ignore_ids'], $modx->config['export_includenoncache']); |
@@ -1,8 +1,8 @@ discard block |
||
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('export_static')) { |
|
5 | +if (!$modx->hasPermission('export_static')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
@@ -10,15 +10,15 @@ discard block |
||
10 | 10 | @set_time_limit($maxtime); |
11 | 11 | |
12 | 12 | |
13 | -if(is_dir(MODX_BASE_PATH . 'temp')) $export_dir = MODX_BASE_PATH . 'temp/export'; |
|
14 | -elseif(is_dir(MODX_BASE_PATH . 'assets')) $export_dir = MODX_BASE_PATH . 'assets/export'; |
|
13 | +if (is_dir(MODX_BASE_PATH.'temp')) $export_dir = MODX_BASE_PATH.'temp/export'; |
|
14 | +elseif (is_dir(MODX_BASE_PATH.'assets')) $export_dir = MODX_BASE_PATH.'assets/export'; |
|
15 | 15 | $modx->getExportSite()->targetDir = $export_dir; |
16 | 16 | |
17 | -if(strpos($modx->config['base_path'],"{$export_dir}/")===0 && 0 <= strlen(str_replace("{$export_dir}/",'',$modx->config['base_path']))) |
|
17 | +if (strpos($modx->config['base_path'], "{$export_dir}/") === 0 && 0 <= strlen(str_replace("{$export_dir}/", '', $modx->config['base_path']))) |
|
18 | 18 | return $_lang['export_site.static.php6']; |
19 | -elseif($modx->config['rb_base_dir'] === $export_dir . '/') |
|
20 | - return $modx->parsePlaceholder($_lang['export_site.static.php7'],'rb_base_url=' . $modx->config['base_url'] . $modx->config['rb_base_url']); |
|
21 | -elseif(!is_writable($export_dir)) |
|
19 | +elseif ($modx->config['rb_base_dir'] === $export_dir.'/') |
|
20 | + return $modx->parsePlaceholder($_lang['export_site.static.php7'], 'rb_base_url='.$modx->config['base_url'].$modx->config['rb_base_url']); |
|
21 | +elseif (!is_writable($export_dir)) |
|
22 | 22 | return $_lang['export_site_target_unwritable']; |
23 | 23 | |
24 | 24 | $modx->getExportSite()->generate_mode = $_POST['generate_mode']; |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | $repl_after = $_POST['repl_after']; |
32 | 32 | $includenoncache = $_POST['includenoncache']; |
33 | 33 | |
34 | -if($ignore_ids!==$_POST['ignore_ids'] |
|
35 | - ||$includenoncache!==$_POST['includenoncache'] |
|
36 | - ||$repl_before!==$_POST['repl_before'] |
|
37 | - ||$repl_after !==$_POST['repl_after']) { |
|
34 | +if ($ignore_ids !== $_POST['ignore_ids'] |
|
35 | + ||$includenoncache !== $_POST['includenoncache'] |
|
36 | + ||$repl_before !== $_POST['repl_before'] |
|
37 | + ||$repl_after !== $_POST['repl_after']) { |
|
38 | 38 | $modx->clearCache('full'); |
39 | 39 | } |
40 | 40 | |
@@ -50,5 +50,5 @@ discard block |
||
50 | 50 | |
51 | 51 | $exportend = $modx->getExportSite()->get_mtime(); |
52 | 52 | $totaltime = ($exportend - $modx->getExportSite()->exportstart); |
53 | -$output .= sprintf ('<p>'.$_lang["export_site_time"].'</p>', round($totaltime, 3)); |
|
53 | +$output .= sprintf('<p>'.$_lang["export_site_time"].'</p>', round($totaltime, 3)); |
|
54 | 54 | return $output; |
@@ -10,16 +10,20 @@ |
||
10 | 10 | @set_time_limit($maxtime); |
11 | 11 | |
12 | 12 | |
13 | -if(is_dir(MODX_BASE_PATH . 'temp')) $export_dir = MODX_BASE_PATH . 'temp/export'; |
|
14 | -elseif(is_dir(MODX_BASE_PATH . 'assets')) $export_dir = MODX_BASE_PATH . 'assets/export'; |
|
13 | +if(is_dir(MODX_BASE_PATH . 'temp')) { |
|
14 | + $export_dir = MODX_BASE_PATH . 'temp/export'; |
|
15 | +} elseif(is_dir(MODX_BASE_PATH . 'assets')) { |
|
16 | + $export_dir = MODX_BASE_PATH . 'assets/export'; |
|
17 | +} |
|
15 | 18 | $modx->getExportSite()->targetDir = $export_dir; |
16 | 19 | |
17 | -if(strpos($modx->config['base_path'],"{$export_dir}/")===0 && 0 <= strlen(str_replace("{$export_dir}/",'',$modx->config['base_path']))) |
|
20 | +if(strpos($modx->config['base_path'],"{$export_dir}/")===0 && 0 <= strlen(str_replace("{$export_dir}/",'',$modx->config['base_path']))) { |
|
18 | 21 | return $_lang['export_site.static.php6']; |
19 | -elseif($modx->config['rb_base_dir'] === $export_dir . '/') |
|
22 | +} elseif($modx->config['rb_base_dir'] === $export_dir . '/') { |
|
20 | 23 | return $modx->parsePlaceholder($_lang['export_site.static.php7'],'rb_base_url=' . $modx->config['base_url'] . $modx->config['rb_base_url']); |
21 | -elseif(!is_writable($export_dir)) |
|
24 | +} elseif(!is_writable($export_dir)) { |
|
22 | 25 | return $_lang['export_site_target_unwritable']; |
26 | +} |
|
23 | 27 | |
24 | 28 | $modx->getExportSite()->generate_mode = $_POST['generate_mode']; |
25 | 29 |
@@ -1,12 +1,12 @@ discard block |
||
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('save_module')) { |
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = (int)$_POST['id']; |
|
9 | +$id = (int) $_POST['id']; |
|
10 | 10 | $name = $modx->getDatabase()->escape(trim($_POST['name'])); |
11 | 11 | $description = $modx->getDatabase()->escape($_POST['description']); |
12 | 12 | $resourcefile = $modx->getDatabase()->escape($_POST['resourcefile']); |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | |
26 | 26 | //Kyle Jaebker - added category support |
27 | 27 | if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { |
28 | - $categoryid = (int)$_POST['categoryid']; |
|
28 | + $categoryid = (int) $_POST['categoryid']; |
|
29 | 29 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
30 | 30 | $categoryid = 0; |
31 | 31 | } else { |
32 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
32 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
33 | 33 | $categoryid = checkCategory($_POST['newcategory']); |
34 | 34 | if (!$categoryid) { |
35 | 35 | $categoryid = newCategory($_POST['newcategory']); |
@@ -45,15 +45,15 @@ discard block |
||
45 | 45 | $name = isset($parsed['name']) ? $parsed['name'] : $name; |
46 | 46 | $properties = isset($parsed['properties']) ? $parsed['properties'] : $properties; |
47 | 47 | $guid = isset($parsed['guid']) ? $parsed['guid'] : $guid; |
48 | - $enable_sharedparams = isset($parsed['shareparams']) ? (int)$parsed['shareparams'] : $enable_sharedparams; |
|
48 | + $enable_sharedparams = isset($parsed['shareparams']) ? (int) $parsed['shareparams'] : $enable_sharedparams; |
|
49 | 49 | |
50 | 50 | $description = isset($parsed['description']) ? $parsed['description'] : $description; |
51 | - $version = isset($parsed['version']) ? '<b>' . $parsed['version'] . '</b> ' : ''; |
|
51 | + $version = isset($parsed['version']) ? '<b>'.$parsed['version'].'</b> ' : ''; |
|
52 | 52 | if ($version) { |
53 | - $description = $version . trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
53 | + $description = $version.trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
54 | 54 | } |
55 | 55 | if (isset($parsed['modx_category'])) { |
56 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
56 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
57 | 57 | $categoryid = getCategory($parsed['modx_category']); |
58 | 58 | } |
59 | 59 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | // finished emptying cache - redirect |
112 | 112 | if ($_POST['stay'] != '') { |
113 | 113 | $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107"; |
114 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
114 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
115 | 115 | header($header); |
116 | 116 | } else { |
117 | 117 | $header = "Location: index.php?a=106&r=2"; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | // finished emptying cache - redirect |
169 | 169 | if ($_POST['stay'] != '') { |
170 | 170 | $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107"; |
171 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
171 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
172 | 172 | header($header); |
173 | 173 | } else { |
174 | 174 | $modx->unlockElement(6, $id); |
@@ -59,123 +59,123 @@ |
||
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->getDatabase()->select('count(id)', $modx->getDatabase()->getFullTableName('site_modules'), "name='{$name}'"); |
|
71 | - $count = $modx->getDatabase()->getValue($rs); |
|
72 | - if ($count > 0) { |
|
73 | - $modx->getManagerApi()->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->getDatabase()->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->getDatabase()->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->getDatabase()->select('count(id)', $modx->getDatabase()->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'"); |
|
130 | - if ($modx->getDatabase()->getValue($rs) > 0) { |
|
131 | - $modx->getManagerApi()->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->getDatabase()->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->getDatabase()->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->getDatabase()->select('count(id)', $modx->getDatabase()->getFullTableName('site_modules'), "name='{$name}'"); |
|
71 | + $count = $modx->getDatabase()->getValue($rs); |
|
72 | + if ($count > 0) { |
|
73 | + $modx->getManagerApi()->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->getDatabase()->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->getDatabase()->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->getDatabase()->select('count(id)', $modx->getDatabase()->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'"); |
|
130 | + if ($modx->getDatabase()->getValue($rs) > 0) { |
|
131 | + $modx->getManagerApi()->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->getDatabase()->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->getDatabase()->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 | } |
@@ -60,110 +60,110 @@ discard block |
||
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->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
66 | - $limit = $modx->getDatabase()->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->getDatabase()->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
74 | - $limit = $modx->getDatabase()->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->getDatabase()->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->getDatabase()->escape($field); |
|
108 | - $modx->getDatabase()->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->getDatabase()->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->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
66 | + $limit = $modx->getDatabase()->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->getDatabase()->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
74 | + $limit = $modx->getDatabase()->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->getDatabase()->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->getDatabase()->escape($field); |
|
108 | + $modx->getDatabase()->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->getDatabase()->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 |
||
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->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
214 | - $limit = $modx->getDatabase()->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->getDatabase()->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
222 | - $limit = $modx->getDatabase()->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->getDatabase()->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->getDatabase()->escape($field); |
|
243 | - $modx->getDatabase()->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->getDatabase()->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->getDatabase()->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->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
214 | + $limit = $modx->getDatabase()->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->getDatabase()->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
222 | + $limit = $modx->getDatabase()->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->getDatabase()->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->getDatabase()->escape($field); |
|
243 | + $modx->getDatabase()->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->getDatabase()->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->getDatabase()->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 |
||
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 | } |
@@ -1,9 +1,9 @@ discard block |
||
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->getDatabase()->getFullTableName('web_users'); |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | $input = $_POST; |
14 | 14 | foreach($input as $k => $v) { |
15 | - if($k !== 'comment') { |
|
16 | - $v = $modx->getPhpCompat()->htmlspecialchars($v, ENT_NOQUOTES); |
|
17 | - } |
|
18 | - $input[$k] = $v; |
|
15 | + if($k !== 'comment') { |
|
16 | + $v = $modx->getPhpCompat()->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 |
||
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->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
66 | - $limit = $modx->getDatabase()->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->getDatabase()->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
74 | - $limit = $modx->getDatabase()->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->getDatabase()->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->getDatabase()->escape($field); |
|
108 | - $modx->getDatabase()->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->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
66 | + $limit = $modx->getDatabase()->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->getDatabase()->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
74 | + $limit = $modx->getDatabase()->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->getDatabase()->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->getDatabase()->escape($field); |
|
108 | + $modx->getDatabase()->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->getDatabase()->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->getDatabase()->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 |
||
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 |
||
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->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
214 | - $limit = $modx->getDatabase()->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->getDatabase()->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
222 | - $limit = $modx->getDatabase()->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->getDatabase()->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->getDatabase()->escape($field); |
|
243 | - $modx->getDatabase()->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->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
214 | + $limit = $modx->getDatabase()->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->getDatabase()->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
222 | + $limit = $modx->getDatabase()->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->getDatabase()->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->getDatabase()->escape($field); |
|
243 | + $modx->getDatabase()->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->getDatabase()->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->getDatabase()->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->getDatabase()->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->getDatabase()->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 |
||
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 |
||
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 | } |
@@ -1,8 +1,8 @@ discard block |
||
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 |
||
11 | 11 | $tbl_web_groups = $modx->getDatabase()->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->getPhpCompat()->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->getDatabase()->escape($newusername); |
@@ -50,21 +50,21 @@ discard block |
||
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->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
66 | 66 | $limit = $modx->getDatabase()->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 |
||
72 | 72 | if ($modx->config['allow_multiple_emails'] != 1) { |
73 | 73 | $rs = $modx->getDatabase()->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
74 | 74 | $limit = $modx->getDatabase()->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 |
||
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->getDatabase()->insert($f, $tbl_web_groups); |
126 | 126 | } |
@@ -144,20 +144,20 @@ discard block |
||
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 |
||
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->getDatabase()->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
214 | 214 | $limit = $modx->getDatabase()->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 |
||
220 | 220 | if ($modx->config['allow_multiple_emails'] != 1) { |
221 | 221 | $rs = $modx->getDatabase()->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
222 | 222 | $limit = $modx->getDatabase()->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 |
||
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->getDatabase()->update($field, $tbl_web_users, "id='{$id}'"); |
@@ -251,13 +251,13 @@ discard block |
||
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->getDatabase()->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->getDatabase()->insert($field, $tbl_web_groups); |
263 | 263 | } |
@@ -279,7 +279,7 @@ discard block |
||
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 |
||
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 |
||
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"; |
@@ -1,12 +1,12 @@ discard block |
||
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('save_snippet')) { |
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = (int)$_POST['id']; |
|
9 | +$id = (int) $_POST['id']; |
|
10 | 10 | $snippet = trim($_POST['post']); |
11 | 11 | $name = $modx->getDatabase()->escape(trim($_POST['name'])); |
12 | 12 | $description = $modx->getDatabase()->escape($_POST['description']); |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | |
34 | 34 | //Kyle Jaebker - added category support |
35 | 35 | if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { |
36 | - $categoryid = (int)$_POST['categoryid']; |
|
36 | + $categoryid = (int) $_POST['categoryid']; |
|
37 | 37 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
38 | 38 | $categoryid = 0; |
39 | 39 | } else { |
40 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
40 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
41 | 41 | $categoryid = checkCategory($_POST['newcategory']); |
42 | 42 | if (!$categoryid) { |
43 | 43 | $categoryid = newCategory($_POST['newcategory']); |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | $moduleguid = isset($parsed['guid']) ? $parsed['guid'] : $moduleguid; |
56 | 56 | |
57 | 57 | $description = isset($parsed['description']) ? $parsed['description'] : $description; |
58 | - $version = isset($parsed['version']) ? '<b>' . $parsed['version'] . '</b> ' : ''; |
|
58 | + $version = isset($parsed['version']) ? '<b>'.$parsed['version'].'</b> ' : ''; |
|
59 | 59 | if ($version) { |
60 | - $description = $version . trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
60 | + $description = $version.trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description)); |
|
61 | 61 | } |
62 | 62 | if (isset($parsed['modx_category'])) { |
63 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
63 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
64 | 64 | $categoryid = getCategory($parsed['modx_category']); |
65 | 65 | } |
66 | 66 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | // finished emptying cache - redirect |
112 | 112 | if ($_POST['stay'] != '') { |
113 | 113 | $a = ($_POST['stay'] == '2') ? "22&id=$newid" : "23"; |
114 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
114 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
115 | 115 | header($header); |
116 | 116 | } else { |
117 | 117 | $header = "Location: index.php?a=76&r=2"; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | // finished emptying cache - redirect |
164 | 164 | if ($_POST['stay'] != '') { |
165 | 165 | $a = ($_POST['stay'] == '2') ? "22&id=$id" : "23"; |
166 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
166 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
167 | 167 | header($header); |
168 | 168 | } else { |
169 | 169 | $modx->unlockElement(4, $id); |
@@ -66,111 +66,111 @@ |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | switch ($_POST['mode']) { |
69 | - case '23': // Save new snippet |
|
70 | - |
|
71 | - // invoke OnBeforeSnipFormSave event |
|
72 | - $modx->invokeEvent("OnBeforeSnipFormSave", array( |
|
73 | - "mode" => "new", |
|
74 | - "id" => $id |
|
75 | - )); |
|
76 | - |
|
77 | - // disallow duplicate names for new snippets |
|
78 | - $rs = $modx->getDatabase()->select('COUNT(id)', $modx->getDatabase()->getFullTableName('site_snippets'), "name='{$name}'"); |
|
79 | - $count = $modx->getDatabase()->getValue($rs); |
|
80 | - if ($count > 0) { |
|
81 | - $modx->getManagerApi()->saveFormValues(23); |
|
82 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=23"); |
|
83 | - } |
|
84 | - |
|
85 | - //do stuff to save the new doc |
|
86 | - $newid = $modx->getDatabase()->insert(array( |
|
87 | - 'name' => $name, |
|
88 | - 'description' => $description, |
|
89 | - 'snippet' => $snippet, |
|
90 | - 'moduleguid' => $moduleguid, |
|
91 | - 'locked' => $locked, |
|
92 | - 'properties' => $properties, |
|
93 | - 'category' => $categoryid, |
|
94 | - 'disabled' => $disabled, |
|
95 | - 'createdon' => $currentdate, |
|
96 | - 'editedon' => $currentdate |
|
97 | - ), $modx->getDatabase()->getFullTableName('site_snippets')); |
|
98 | - |
|
99 | - // invoke OnSnipFormSave event |
|
100 | - $modx->invokeEvent("OnSnipFormSave", 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') ? "22&id=$newid" : "23"; |
|
114 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
115 | - header($header); |
|
116 | - } else { |
|
117 | - $header = "Location: index.php?a=76&r=2"; |
|
118 | - header($header); |
|
119 | - } |
|
120 | - break; |
|
121 | - case '22': // Save existing snippet |
|
122 | - // invoke OnBeforeSnipFormSave event |
|
123 | - $modx->invokeEvent("OnBeforeSnipFormSave", array( |
|
124 | - "mode" => "upd", |
|
125 | - "id" => $id |
|
126 | - )); |
|
127 | - |
|
128 | - // disallow duplicate names for snippets |
|
129 | - $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getDatabase()->getFullTableName('site_snippets'), "name='{$name}' AND id!='{$id}'"); |
|
130 | - if ($modx->getDatabase()->getValue($rs) > 0) { |
|
131 | - $modx->getManagerApi()->saveFormValues(22); |
|
132 | - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=22&id={$id}"); |
|
133 | - } |
|
134 | - |
|
135 | - //do stuff to save the edited doc |
|
136 | - $modx->getDatabase()->update(array( |
|
137 | - 'name' => $name, |
|
138 | - 'description' => $description, |
|
139 | - 'snippet' => $snippet, |
|
140 | - 'moduleguid' => $moduleguid, |
|
141 | - 'locked' => $locked, |
|
142 | - 'properties' => $properties, |
|
143 | - 'category' => $categoryid, |
|
144 | - 'disabled' => $disabled, |
|
145 | - 'editedon' => $currentdate |
|
146 | - ), $modx->getDatabase()->getFullTableName('site_snippets'), "id='{$id}'"); |
|
147 | - |
|
148 | - // invoke OnSnipFormSave event |
|
149 | - $modx->invokeEvent("OnSnipFormSave", array( |
|
150 | - "mode" => "upd", |
|
151 | - "id" => $id |
|
152 | - )); |
|
153 | - |
|
154 | - // Set the item name for logger |
|
155 | - $_SESSION['itemname'] = $name; |
|
156 | - |
|
157 | - // empty cache |
|
158 | - $modx->clearCache('full'); |
|
159 | - |
|
160 | - if ($_POST['runsnippet']) { |
|
161 | - run_snippet($snippet); |
|
162 | - } |
|
163 | - // finished emptying cache - redirect |
|
164 | - if ($_POST['stay'] != '') { |
|
165 | - $a = ($_POST['stay'] == '2') ? "22&id=$id" : "23"; |
|
166 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
167 | - header($header); |
|
168 | - } else { |
|
169 | - $modx->unlockElement(4, $id); |
|
170 | - $header = "Location: index.php?a=76&r=2"; |
|
171 | - header($header); |
|
172 | - } |
|
173 | - break; |
|
174 | - default: |
|
175 | - $modx->webAlertAndQuit("No operation set in request."); |
|
69 | + case '23': // Save new snippet |
|
70 | + |
|
71 | + // invoke OnBeforeSnipFormSave event |
|
72 | + $modx->invokeEvent("OnBeforeSnipFormSave", array( |
|
73 | + "mode" => "new", |
|
74 | + "id" => $id |
|
75 | + )); |
|
76 | + |
|
77 | + // disallow duplicate names for new snippets |
|
78 | + $rs = $modx->getDatabase()->select('COUNT(id)', $modx->getDatabase()->getFullTableName('site_snippets'), "name='{$name}'"); |
|
79 | + $count = $modx->getDatabase()->getValue($rs); |
|
80 | + if ($count > 0) { |
|
81 | + $modx->getManagerApi()->saveFormValues(23); |
|
82 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=23"); |
|
83 | + } |
|
84 | + |
|
85 | + //do stuff to save the new doc |
|
86 | + $newid = $modx->getDatabase()->insert(array( |
|
87 | + 'name' => $name, |
|
88 | + 'description' => $description, |
|
89 | + 'snippet' => $snippet, |
|
90 | + 'moduleguid' => $moduleguid, |
|
91 | + 'locked' => $locked, |
|
92 | + 'properties' => $properties, |
|
93 | + 'category' => $categoryid, |
|
94 | + 'disabled' => $disabled, |
|
95 | + 'createdon' => $currentdate, |
|
96 | + 'editedon' => $currentdate |
|
97 | + ), $modx->getDatabase()->getFullTableName('site_snippets')); |
|
98 | + |
|
99 | + // invoke OnSnipFormSave event |
|
100 | + $modx->invokeEvent("OnSnipFormSave", 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') ? "22&id=$newid" : "23"; |
|
114 | + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
115 | + header($header); |
|
116 | + } else { |
|
117 | + $header = "Location: index.php?a=76&r=2"; |
|
118 | + header($header); |
|
119 | + } |
|
120 | + break; |
|
121 | + case '22': // Save existing snippet |
|
122 | + // invoke OnBeforeSnipFormSave event |
|
123 | + $modx->invokeEvent("OnBeforeSnipFormSave", array( |
|
124 | + "mode" => "upd", |
|
125 | + "id" => $id |
|
126 | + )); |
|
127 | + |
|
128 | + // disallow duplicate names for snippets |
|
129 | + $rs = $modx->getDatabase()->select('COUNT(*)', $modx->getDatabase()->getFullTableName('site_snippets'), "name='{$name}' AND id!='{$id}'"); |
|
130 | + if ($modx->getDatabase()->getValue($rs) > 0) { |
|
131 | + $modx->getManagerApi()->saveFormValues(22); |
|
132 | + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=22&id={$id}"); |
|
133 | + } |
|
134 | + |
|
135 | + //do stuff to save the edited doc |
|
136 | + $modx->getDatabase()->update(array( |
|
137 | + 'name' => $name, |
|
138 | + 'description' => $description, |
|
139 | + 'snippet' => $snippet, |
|
140 | + 'moduleguid' => $moduleguid, |
|
141 | + 'locked' => $locked, |
|
142 | + 'properties' => $properties, |
|
143 | + 'category' => $categoryid, |
|
144 | + 'disabled' => $disabled, |
|
145 | + 'editedon' => $currentdate |
|
146 | + ), $modx->getDatabase()->getFullTableName('site_snippets'), "id='{$id}'"); |
|
147 | + |
|
148 | + // invoke OnSnipFormSave event |
|
149 | + $modx->invokeEvent("OnSnipFormSave", array( |
|
150 | + "mode" => "upd", |
|
151 | + "id" => $id |
|
152 | + )); |
|
153 | + |
|
154 | + // Set the item name for logger |
|
155 | + $_SESSION['itemname'] = $name; |
|
156 | + |
|
157 | + // empty cache |
|
158 | + $modx->clearCache('full'); |
|
159 | + |
|
160 | + if ($_POST['runsnippet']) { |
|
161 | + run_snippet($snippet); |
|
162 | + } |
|
163 | + // finished emptying cache - redirect |
|
164 | + if ($_POST['stay'] != '') { |
|
165 | + $a = ($_POST['stay'] == '2') ? "22&id=$id" : "23"; |
|
166 | + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
167 | + header($header); |
|
168 | + } else { |
|
169 | + $modx->unlockElement(4, $id); |
|
170 | + $header = "Location: index.php?a=76&r=2"; |
|
171 | + header($header); |
|
172 | + } |
|
173 | + break; |
|
174 | + default: |
|
175 | + $modx->webAlertAndQuit("No operation set in request."); |
|
176 | 176 | } |
@@ -1,12 +1,12 @@ discard block |
||
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('save_template')) { |
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = (int)$_POST['id']; |
|
9 | +$id = (int) $_POST['id']; |
|
10 | 10 | $name = $modx->getDatabase()->escape(trim($_POST['name'])); |
11 | 11 | $description = $modx->getDatabase()->escape($_POST['description']); |
12 | 12 | $caption = $modx->getDatabase()->escape($_POST['caption']); |
@@ -17,17 +17,17 @@ discard block |
||
17 | 17 | $display = $modx->getDatabase()->escape($_POST['display']); |
18 | 18 | $params = $modx->getDatabase()->escape($_POST['params']); |
19 | 19 | $locked = $_POST['locked'] == 'on' ? 1 : 0; |
20 | -$origin = isset($_REQUEST['or']) ? (int)$_REQUEST['or'] : 76; |
|
21 | -$originId = isset($_REQUEST['oid']) ? (int)$_REQUEST['oid'] : null; |
|
20 | +$origin = isset($_REQUEST['or']) ? (int) $_REQUEST['or'] : 76; |
|
21 | +$originId = isset($_REQUEST['oid']) ? (int) $_REQUEST['oid'] : null; |
|
22 | 22 | $currentdate = time() + $modx->config['server_offset_time']; |
23 | 23 | |
24 | 24 | //Kyle Jaebker - added category support |
25 | 25 | if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { |
26 | - $categoryid = (int)$_POST['categoryid']; |
|
26 | + $categoryid = (int) $_POST['categoryid']; |
|
27 | 27 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
28 | 28 | $categoryid = 0; |
29 | 29 | } else { |
30 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
30 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
31 | 31 | $categoryid = checkCategory($_POST['newcategory']); |
32 | 32 | if (!$categoryid) { |
33 | 33 | $categoryid = newCategory($_POST['newcategory']); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | // finished emptying cache - redirect |
100 | 100 | if ($_POST['stay'] != '') { |
101 | 101 | $a = ($_POST['stay'] == '2') ? "301&id=$newid" : "300"; |
102 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
102 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
103 | 103 | header($header); |
104 | 104 | } else { |
105 | 105 | $header = "Location: index.php?a=76&r=2"; |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | // finished emptying cache - redirect |
161 | 161 | if ($_POST['stay'] != '') { |
162 | 162 | $a = ($_POST['stay'] == '2') ? "301&id=$id" : "300"; |
163 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'] . "&or=" . $origin . "&oid=" . $originId; |
|
163 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']."&or=".$origin."&oid=".$originId; |
|
164 | 164 | header($header); |
165 | 165 | } else { |
166 | 166 | $modx->unlockElement(2, $id); |
167 | - $header = "Location: index.php?a=" . $origin . "&r=2" . (empty($originId) ? '' : '&id=' . $originId); |
|
167 | + $header = "Location: index.php?a=".$origin."&r=2".(empty($originId) ? '' : '&id='.$originId); |
|
168 | 168 | header($header); |
169 | 169 | } |
170 | 170 |
@@ -1,12 +1,12 @@ discard block |
||
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('save_chunk')) { |
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = (int)$_POST['id']; |
|
9 | +$id = (int) $_POST['id']; |
|
10 | 10 | $snippet = $modx->getDatabase()->escape($_POST['post']); |
11 | 11 | $name = $modx->getDatabase()->escape(trim($_POST['name'])); |
12 | 12 | $description = $modx->getDatabase()->escape($_POST['description']); |
@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | |
17 | 17 | //Kyle Jaebker - added category support |
18 | 18 | if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { |
19 | - $categoryid = (int)$_POST['categoryid']; |
|
19 | + $categoryid = (int) $_POST['categoryid']; |
|
20 | 20 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
21 | 21 | $categoryid = 0; |
22 | 22 | } else { |
23 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
23 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
24 | 24 | $categoryid = checkCategory($_POST['newcategory']); |
25 | 25 | if (!$categoryid) { |
26 | 26 | $categoryid = newCategory($_POST['newcategory']); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | // finished emptying cache - redirect |
81 | 81 | if ($_POST['stay'] != '') { |
82 | 82 | $a = ($_POST['stay'] == '2') ? "78&id=$newid" : "77"; |
83 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
83 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
84 | 84 | header($header); |
85 | 85 | } else { |
86 | 86 | $header = "Location: index.php?a=76&r=2"; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | // finished emptying cache - redirect |
130 | 130 | if ($_POST['stay'] != '') { |
131 | 131 | $a = ($_POST['stay'] == '2') ? "78&id=$id" : "77"; |
132 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
132 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
133 | 133 | header($header); |
134 | 134 | } else { |
135 | 135 | $modx->unlockElement(3, $id); |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | * Initialize Document Parsing |
45 | 45 | * ----------------------------- |
46 | 46 | */ |
47 | -if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true); |
|
47 | +if (!isset($_SERVER['REQUEST_TIME_FLOAT'])) $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true); |
|
48 | 48 | |
49 | -$base_path = str_replace('\\','/',dirname(__FILE__)) . '/'; |
|
50 | -if(is_file($base_path . 'assets/cache/siteManager.php')) |
|
51 | - include_once($base_path . 'assets/cache/siteManager.php'); |
|
52 | -if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) |
|
49 | +$base_path = str_replace('\\', '/', dirname(__FILE__)).'/'; |
|
50 | +if (is_file($base_path.'assets/cache/siteManager.php')) |
|
51 | + include_once($base_path.'assets/cache/siteManager.php'); |
|
52 | +if (!defined('MGR_DIR') && is_dir("{$base_path}manager")) |
|
53 | 53 | define('MGR_DIR', 'manager'); |
54 | -if(is_file($base_path . 'assets/cache/siteHostnames.php')) |
|
55 | - include_once($base_path . 'assets/cache/siteHostnames.php'); |
|
56 | -if(!defined('MODX_SITE_HOSTNAMES')) |
|
54 | +if (is_file($base_path.'assets/cache/siteHostnames.php')) |
|
55 | + include_once($base_path.'assets/cache/siteHostnames.php'); |
|
56 | +if (!defined('MODX_SITE_HOSTNAMES')) |
|
57 | 57 | define('MODX_SITE_HOSTNAMES', ''); |
58 | 58 | |
59 | 59 | // get start time |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | // set some settings, and address some IE issues |
66 | 66 | @ini_set('url_rewriter.tags', ''); |
67 | 67 | @ini_set('session.use_trans_sid', 0); |
68 | -@ini_set('session.use_only_cookies',1); |
|
68 | +@ini_set('session.use_only_cookies', 1); |
|
69 | 69 | session_cache_limiter(''); |
70 | 70 | header('P3P: CP="NOI NID ADMa OUR IND UNI COM NAV"'); // header for weird cookie stuff. Blame IE. |
71 | 71 | header('Cache-Control: private, must-revalidate'); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | |
79 | 79 | define('IN_PARSER_MODE', true); |
80 | -if ( ! defined('IN_MANAGER_MODE')) { |
|
80 | +if (!defined('IN_MANAGER_MODE')) { |
|
81 | 81 | define('IN_MANAGER_MODE', false); |
82 | 82 | } |
83 | 83 | if (!defined('MODX_API_MODE')) { |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | // get the required includes |
88 | -if(! isset($database_user) || $database_user==="") { |
|
89 | - $rt = @include_once(__DIR__ . '/' . MGR_DIR . '/includes/config.inc.php'); |
|
88 | +if (!isset($database_user) || $database_user === "") { |
|
89 | + $rt = @include_once(__DIR__.'/'.MGR_DIR.'/includes/config.inc.php'); |
|
90 | 90 | $path = 'install/src/template/not_installed.tpl'; |
91 | 91 | // Be sure config.inc.php is there and that it contains some important values |
92 | 92 | if (!$rt || !$database_type || !$database_server || !$database_user || !$dbase) { |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | $modx->stopOnNotice = false; |
123 | 123 | |
124 | 124 | // Don't show PHP errors to the public |
125 | -if(!isset($_SESSION['mgrValidated']) || !$_SESSION['mgrValidated']) { |
|
126 | - @ini_set("display_errors","0"); |
|
125 | +if (!isset($_SESSION['mgrValidated']) || !$_SESSION['mgrValidated']) { |
|
126 | + @ini_set("display_errors", "0"); |
|
127 | 127 | } |
128 | 128 | |
129 | -if(MODX_CLI){ |
|
129 | +if (MODX_CLI) { |
|
130 | 130 | @set_time_limit(0); |
131 | - @ini_set('max_execution_time',0); |
|
131 | + @ini_set('max_execution_time', 0); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | // execute the parser if index.php was not included |
@@ -44,17 +44,23 @@ discard block |
||
44 | 44 | * Initialize Document Parsing |
45 | 45 | * ----------------------------- |
46 | 46 | */ |
47 | -if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true); |
|
47 | +if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) { |
|
48 | + $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true); |
|
49 | +} |
|
48 | 50 | |
49 | 51 | $base_path = str_replace('\\','/',dirname(__FILE__)) . '/'; |
50 | -if(is_file($base_path . 'assets/cache/siteManager.php')) |
|
52 | +if(is_file($base_path . 'assets/cache/siteManager.php')) { |
|
51 | 53 | include_once($base_path . 'assets/cache/siteManager.php'); |
52 | -if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) |
|
54 | +} |
|
55 | +if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) { |
|
53 | 56 | define('MGR_DIR', 'manager'); |
54 | -if(is_file($base_path . 'assets/cache/siteHostnames.php')) |
|
57 | +} |
|
58 | +if(is_file($base_path . 'assets/cache/siteHostnames.php')) { |
|
55 | 59 | include_once($base_path . 'assets/cache/siteHostnames.php'); |
56 | -if(!defined('MODX_SITE_HOSTNAMES')) |
|
60 | +} |
|
61 | +if(!defined('MODX_SITE_HOSTNAMES')) { |
|
57 | 62 | define('MODX_SITE_HOSTNAMES', ''); |
63 | +} |
|
58 | 64 | |
59 | 65 | // get start time |
60 | 66 | $mstart = memory_get_usage(); |
@@ -126,7 +132,7 @@ discard block |
||
126 | 132 | @ini_set("display_errors","0"); |
127 | 133 | } |
128 | 134 | |
129 | -if(MODX_CLI){ |
|
135 | +if(MODX_CLI) { |
|
130 | 136 | @set_time_limit(0); |
131 | 137 | @ini_set('max_execution_time',0); |
132 | 138 | } |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | if(is_file($base_path . 'assets/cache/siteManager.php')) |
51 | 51 | include_once($base_path . 'assets/cache/siteManager.php'); |
52 | 52 | if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) |
53 | - define('MGR_DIR', 'manager'); |
|
53 | + define('MGR_DIR', 'manager'); |
|
54 | 54 | if(is_file($base_path . 'assets/cache/siteHostnames.php')) |
55 | 55 | include_once($base_path . 'assets/cache/siteHostnames.php'); |
56 | 56 | if(!defined('MODX_SITE_HOSTNAMES')) |
57 | - define('MODX_SITE_HOSTNAMES', ''); |
|
57 | + define('MODX_SITE_HOSTNAMES', ''); |
|
58 | 58 | |
59 | 59 | // get start time |
60 | 60 | $mstart = memory_get_usage(); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | define('IN_PARSER_MODE', true); |
80 | 80 | if ( ! defined('IN_MANAGER_MODE')) { |
81 | - define('IN_MANAGER_MODE', false); |
|
81 | + define('IN_MANAGER_MODE', false); |
|
82 | 82 | } |
83 | 83 | if (!defined('MODX_API_MODE')) { |
84 | 84 | define('MODX_API_MODE', false); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | /** |
102 | 102 | * @param string $mode |
103 | 103 | * @param string $modifiers |
104 | - * @return bool|string |
|
104 | + * @return false|string |
|
105 | 105 | */ |
106 | 106 | public function _getDelim($mode, $modifiers) |
107 | 107 | { |
@@ -151,6 +151,13 @@ discard block |
||
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | + /** |
|
155 | + * @param string $mode |
|
156 | + * @param false|string $delim |
|
157 | + * @param string $modifiers |
|
158 | + * |
|
159 | + * @return string |
|
160 | + */ |
|
154 | 161 | public function _getRemainModifiers($mode, $delim, $modifiers) |
155 | 162 | { |
156 | 163 | if ($delim) { |
@@ -187,6 +194,9 @@ discard block |
||
187 | 194 | return substr($string, strpos($string, $delim) + $len); |
188 | 195 | } |
189 | 196 | |
197 | + /** |
|
198 | + * @param string $modifiers |
|
199 | + */ |
|
190 | 200 | public function splitEachModifiers($modifiers) |
191 | 201 | { |
192 | 202 | $modx = evolutionCMS(); |
@@ -259,6 +269,10 @@ discard block |
||
259 | 269 | return $result; |
260 | 270 | } |
261 | 271 | |
272 | + /** |
|
273 | + * @param string $key |
|
274 | + * @param string $value |
|
275 | + */ |
|
262 | 276 | public function parsePhx($key, $value, $modifiers) |
263 | 277 | { |
264 | 278 | $modx = evolutionCMS(); |
@@ -340,6 +354,10 @@ discard block |
||
340 | 354 | } |
341 | 355 | } |
342 | 356 | |
357 | + /** |
|
358 | + * @param string $cmd |
|
359 | + * @param string $opt |
|
360 | + */ |
|
343 | 361 | public function getValueFromPreset($key, $value, $cmd, $opt) |
344 | 362 | { |
345 | 363 | $modx = evolutionCMS(); |
@@ -1285,6 +1303,9 @@ discard block |
||
1285 | 1303 | return $value; |
1286 | 1304 | } |
1287 | 1305 | |
1306 | + /** |
|
1307 | + * @param string $cmd |
|
1308 | + */ |
|
1288 | 1309 | public function includeMdfFile($cmd) |
1289 | 1310 | { |
1290 | 1311 | $modx = evolutionCMS(); |
@@ -1477,6 +1498,10 @@ discard block |
||
1477 | 1498 | } |
1478 | 1499 | |
1479 | 1500 | // Sets a placeholder variable which can only be access by Modifiers |
1501 | + |
|
1502 | + /** |
|
1503 | + * @param string $value |
|
1504 | + */ |
|
1480 | 1505 | public function setModifiersVariable($key, $value) |
1481 | 1506 | { |
1482 | 1507 | if ($key != 'phx' && $key != 'dummy') { |
@@ -199,7 +199,8 @@ discard block |
||
199 | 199 | $c = substr($modifiers, 0, 1); |
200 | 200 | $modifiers = substr($modifiers, 1); |
201 | 201 | |
202 | - if ($c === ':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>= |
|
202 | + if ($c === ':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { |
|
203 | +// :=, :!=, :<=, :>=, :!<=, :!>= |
|
203 | 204 | $c = substr($modifiers, strlen($match[1]), 1); |
204 | 205 | $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]"; |
205 | 206 | if ($c === '(') { |
@@ -215,7 +216,8 @@ discard block |
||
215 | 216 | $result[] = array('cmd' => trim($match[1]), 'opt' => $opt, 'debuginfo' => $debuginfo); |
216 | 217 | $cmd = ''; |
217 | 218 | } elseif (in_array($c, array('+', '-', '*', '/')) && preg_match('@^[0-9]+@', $modifiers, |
218 | - $match)) { // :+3, :-3, :*3 ... |
|
219 | + $match)) { |
|
220 | +// :+3, :-3, :*3 ... |
|
219 | 221 | $modifiers = substr($modifiers, strlen($match[0])); |
220 | 222 | $result[] = array('cmd' => 'math', 'opt' => '%s' . $c . $match[0]); |
221 | 223 | $cmd = ''; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | $this->srcValue = $value; |
84 | 84 | $modifiers = trim($modifiers); |
85 | - $modifiers = ':' . trim($modifiers, ':'); |
|
85 | + $modifiers = ':'.trim($modifiers, ':'); |
|
86 | 86 | $modifiers = str_replace(array("\r\n", "\r"), "\n", $modifiers); |
87 | 87 | $modifiers = $this->splitEachModifiers($modifiers); |
88 | 88 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | { |
130 | 130 | if ($delim) { |
131 | 131 | if ($mode == '(') { |
132 | - return substr($modifiers, 1, strpos($modifiers, $delim . ')') - 1); |
|
132 | + return substr($modifiers, 1, strpos($modifiers, $delim.')') - 1); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | return substr($modifiers, 1, strpos($modifiers, $delim, 1) - 1); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | { |
156 | 156 | if ($delim) { |
157 | 157 | if ($mode == '(') { |
158 | - return $this->_fetchContent($modifiers, $delim . ')'); |
|
158 | + return $this->_fetchContent($modifiers, $delim.')'); |
|
159 | 159 | } else { |
160 | 160 | $modifiers = trim($modifiers); |
161 | 161 | $modifiers = substr($modifiers, 1); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | } elseif (in_array($c, array('+', '-', '*', '/')) && preg_match('@^[0-9]+@', $modifiers, |
218 | 218 | $match)) { // :+3, :-3, :*3 ... |
219 | 219 | $modifiers = substr($modifiers, strlen($match[0])); |
220 | - $result[] = array('cmd' => 'math', 'opt' => '%s' . $c . $match[0]); |
|
220 | + $result[] = array('cmd' => 'math', 'opt' => '%s'.$c.$match[0]); |
|
221 | 221 | $cmd = ''; |
222 | 222 | } elseif ($c === '(' || $c === '=') { |
223 | 223 | $modifiers = $m1 = trim($modifiers); |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | } |
333 | 333 | |
334 | 334 | $_ = explode(',', |
335 | - $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary'); |
|
335 | + $this->condModifiers.',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary'); |
|
336 | 336 | if (in_array($cmd, $_)) { |
337 | 337 | return false; |
338 | 338 | } else { |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | case 'eq': |
366 | 366 | case 'is': |
367 | 367 | case 'equals': |
368 | - $this->condition[] = (int)($value == $opt); |
|
368 | + $this->condition[] = (int) ($value == $opt); |
|
369 | 369 | break; |
370 | 370 | case 'neq': |
371 | 371 | case 'ne': |
@@ -373,59 +373,59 @@ discard block |
||
373 | 373 | case 'isnot': |
374 | 374 | case 'isnt': |
375 | 375 | case 'not': |
376 | - $this->condition[] = (int)($value != $opt); |
|
376 | + $this->condition[] = (int) ($value != $opt); |
|
377 | 377 | break; |
378 | 378 | case '%': |
379 | - $this->condition[] = (int)($value % $opt == 0); |
|
379 | + $this->condition[] = (int) ($value % $opt == 0); |
|
380 | 380 | break; |
381 | 381 | case 'isempty': |
382 | - $this->condition[] = (int)(empty($value)); |
|
382 | + $this->condition[] = (int) (empty($value)); |
|
383 | 383 | break; |
384 | 384 | case 'isntempty': |
385 | 385 | case 'isnotempty': |
386 | - $this->condition[] = (int)(!empty($value)); |
|
386 | + $this->condition[] = (int) (!empty($value)); |
|
387 | 387 | break; |
388 | 388 | case '>=': |
389 | 389 | case 'gte': |
390 | 390 | case 'eg': |
391 | 391 | case 'isgte': |
392 | - $this->condition[] = (int)($value >= $opt); |
|
392 | + $this->condition[] = (int) ($value >= $opt); |
|
393 | 393 | break; |
394 | 394 | case '<=': |
395 | 395 | case 'lte': |
396 | 396 | case 'el': |
397 | 397 | case 'islte': |
398 | - $this->condition[] = (int)($value <= $opt); |
|
398 | + $this->condition[] = (int) ($value <= $opt); |
|
399 | 399 | break; |
400 | 400 | case '>': |
401 | 401 | case 'gt': |
402 | 402 | case 'greaterthan': |
403 | 403 | case 'isgreaterthan': |
404 | 404 | case 'isgt': |
405 | - $this->condition[] = (int)($value > $opt); |
|
405 | + $this->condition[] = (int) ($value > $opt); |
|
406 | 406 | break; |
407 | 407 | case '<': |
408 | 408 | case 'lt': |
409 | 409 | case 'lowerthan': |
410 | 410 | case 'islowerthan': |
411 | 411 | case 'islt': |
412 | - $this->condition[] = (int)($value < $opt); |
|
412 | + $this->condition[] = (int) ($value < $opt); |
|
413 | 413 | break; |
414 | 414 | case 'find': |
415 | - $this->condition[] = (int)(strpos($value, $opt) !== false); |
|
415 | + $this->condition[] = (int) (strpos($value, $opt) !== false); |
|
416 | 416 | break; |
417 | 417 | case 'inarray': |
418 | 418 | case 'in_array': |
419 | 419 | case 'in': |
420 | 420 | $opt = explode(',', $opt); |
421 | - $this->condition[] = (int)(in_array($value, $opt) !== false); |
|
421 | + $this->condition[] = (int) (in_array($value, $opt) !== false); |
|
422 | 422 | break; |
423 | 423 | case 'wildcard_match': |
424 | 424 | case 'wcard_match': |
425 | 425 | case 'wildcard': |
426 | 426 | case 'wcard': |
427 | 427 | case 'fnmatch': |
428 | - $this->condition[] = (int)(fnmatch($opt, $value) !== false); |
|
428 | + $this->condition[] = (int) (fnmatch($opt, $value) !== false); |
|
429 | 429 | break; |
430 | 430 | case 'is_file': |
431 | 431 | case 'is_dir': |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | if (strpos($path, $modx->config['base_path']) === false) { |
444 | 444 | $path = ltrim($path, '/'); |
445 | 445 | } |
446 | - $this->condition[] = (int)($cmd($path) !== false); |
|
446 | + $this->condition[] = (int) ($cmd($path) !== false); |
|
447 | 447 | break; |
448 | 448 | case 'is_image': |
449 | 449 | if (!$opt) { |
@@ -456,13 +456,13 @@ discard block |
||
456 | 456 | break; |
457 | 457 | } |
458 | 458 | $_ = getimagesize($path); |
459 | - $this->condition[] = (int)($_[0]); |
|
459 | + $this->condition[] = (int) ($_[0]); |
|
460 | 460 | break; |
461 | 461 | case 'regex': |
462 | 462 | case 'preg': |
463 | 463 | case 'preg_match': |
464 | 464 | case 'isinrole': |
465 | - $this->condition[] = (int)(preg_match($opt, $value)); |
|
465 | + $this->condition[] = (int) (preg_match($opt, $value)); |
|
466 | 466 | break; |
467 | 467 | case 'ir': |
468 | 468 | case 'memberof': |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | case 'show': |
480 | 480 | case 'this': |
481 | 481 | $conditional = implode(' ', $this->condition); |
482 | - $isvalid = (int)(eval("return ({$conditional});")); |
|
482 | + $isvalid = (int) (eval("return ({$conditional});")); |
|
483 | 483 | if ($isvalid) { |
484 | 484 | return $this->srcValue; |
485 | 485 | } |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | return null; |
488 | 488 | case 'then': |
489 | 489 | $conditional = implode(' ', $this->condition); |
490 | - $isvalid = (int)eval("return ({$conditional});"); |
|
490 | + $isvalid = (int) eval("return ({$conditional});"); |
|
491 | 491 | if ($isvalid) { |
492 | 492 | return $opt; |
493 | 493 | } |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | return null; |
496 | 496 | case 'else': |
497 | 497 | $conditional = implode(' ', $this->condition); |
498 | - $isvalid = (int)eval("return ({$conditional});"); |
|
498 | + $isvalid = (int) eval("return ({$conditional});"); |
|
499 | 499 | if (!$isvalid) { |
500 | 500 | return $opt; |
501 | 501 | } |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | return $this->strpos($value, $opt); |
655 | 655 | case 'wordwrap': |
656 | 656 | // default: 70 |
657 | - $wrapat = (int)$opt > 0 ? (int)$opt : 70; |
|
657 | + $wrapat = (int) $opt > 0 ? (int) $opt : 70; |
|
658 | 658 | if (version_compare(PHP_VERSION, '5.3.0') >= 0) { |
659 | 659 | return $this->includeMdfFile('wordwrap'); |
660 | 660 | } else { |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | if (strpos($opt, ',') !== false) { |
687 | 687 | list($b, $e) = explode(',', $opt, 2); |
688 | 688 | |
689 | - return $this->substr($value, $b, (int)$e); |
|
689 | + return $this->substr($value, $b, (int) $e); |
|
690 | 690 | } else { |
691 | 691 | return $this->substr($value, $opt); |
692 | 692 | } |
@@ -705,9 +705,9 @@ discard block |
||
705 | 705 | $str = ''; |
706 | 706 | } |
707 | 707 | if (preg_match('/^[1-9][0-9]*$/', $len)) { |
708 | - return $this->substr($value, 0, $len) . $str; |
|
708 | + return $this->substr($value, 0, $len).$str; |
|
709 | 709 | } elseif (preg_match('/^\-[1-9][0-9]*$/', $len)) { |
710 | - return $str . $this->substr($value, $len); |
|
710 | + return $str.$this->substr($value, $len); |
|
711 | 711 | } |
712 | 712 | break; |
713 | 713 | case 'summary': |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | case 'concatenate': |
773 | 773 | case '.': |
774 | 774 | if ($value !== '') { |
775 | - return $value . $opt; |
|
775 | + return $value.$opt; |
|
776 | 776 | } |
777 | 777 | break; |
778 | 778 | case 'sprintf': |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | case 'money_format': |
791 | 791 | setlocale(LC_MONETARY, setlocale(LC_TIME, 0)); |
792 | 792 | if ($value !== '') { |
793 | - return money_format($opt, (double)$value); |
|
793 | + return money_format($opt, (double) $value); |
|
794 | 794 | } |
795 | 795 | break; |
796 | 796 | case 'tobool': |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | return strtotime($value); |
866 | 866 | ##### mathematical function |
867 | 867 | case 'toint': |
868 | - return (int)$value; |
|
868 | + return (int) $value; |
|
869 | 869 | case 'tofloat': |
870 | 870 | return floatval($value); |
871 | 871 | case 'round': |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | return $cmd($value); |
884 | 884 | case 'math': |
885 | 885 | case 'calc': |
886 | - $value = (int)$value; |
|
886 | + $value = (int) $value; |
|
887 | 887 | if (empty($value)) { |
888 | 888 | $value = '0'; |
889 | 889 | } |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | $where = implode(' AND ', $where); |
1027 | 1027 | $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where); |
1028 | 1028 | $result = array(); |
1029 | - foreach ((array)$children as $child) { |
|
1029 | + foreach ((array) $children as $child) { |
|
1030 | 1030 | $result[] = $child['id']; |
1031 | 1031 | } |
1032 | 1032 | |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | $opt .= '/'; |
1131 | 1131 | } |
1132 | 1132 | |
1133 | - $filename = MODX_BASE_PATH . $opt . $filename; |
|
1133 | + $filename = MODX_BASE_PATH.$opt.$filename; |
|
1134 | 1134 | |
1135 | 1135 | if (is_file($filename)) { |
1136 | 1136 | clearstatcache(); |
@@ -1291,7 +1291,7 @@ discard block |
||
1291 | 1291 | $value = $this->value; |
1292 | 1292 | $opt = $this->opt; |
1293 | 1293 | |
1294 | - return include(MODX_MANAGER_PATH . "includes/extenders/modifiers/mdf_{$cmd}.inc.php"); |
|
1294 | + return include(MODX_MANAGER_PATH."includes/extenders/modifiers/mdf_{$cmd}.inc.php"); |
|
1295 | 1295 | } |
1296 | 1296 | |
1297 | 1297 | public function getValueFromElement($key, $value, $cmd, $opt) |
@@ -1307,13 +1307,13 @@ discard block |
||
1307 | 1307 | $row = $modx->getDatabase()->getRow($result); |
1308 | 1308 | $php = $row['snippet']; |
1309 | 1309 | } elseif ($total == 0) { |
1310 | - $assets_path = MODX_BASE_PATH . 'assets/'; |
|
1311 | - if (is_file($assets_path . "modifiers/mdf_{$cmd}.inc.php")) { |
|
1312 | - $modifiers_path = $assets_path . "modifiers/mdf_{$cmd}.inc.php"; |
|
1313 | - } elseif (is_file($assets_path . "plugins/phx/modifiers/{$cmd}.phx.php")) { |
|
1314 | - $modifiers_path = $assets_path . "plugins/phx/modifiers/{$cmd}.phx.php"; |
|
1315 | - } elseif (is_file(MODX_MANAGER_PATH . "includes/extenders/modifiers/mdf_{$cmd}.inc.php")) { |
|
1316 | - $modifiers_path = MODX_MANAGER_PATH . "includes/extenders/modifiers/mdf_{$cmd}.inc.php"; |
|
1310 | + $assets_path = MODX_BASE_PATH.'assets/'; |
|
1311 | + if (is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) { |
|
1312 | + $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php"; |
|
1313 | + } elseif (is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) { |
|
1314 | + $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php"; |
|
1315 | + } elseif (is_file(MODX_MANAGER_PATH."includes/extenders/modifiers/mdf_{$cmd}.inc.php")) { |
|
1316 | + $modifiers_path = MODX_MANAGER_PATH."includes/extenders/modifiers/mdf_{$cmd}.inc.php"; |
|
1317 | 1317 | } else { |
1318 | 1318 | $modifiers_path = false; |
1319 | 1319 | } |
@@ -1331,7 +1331,7 @@ discard block |
||
1331 | 1331 | $php = substr($php, 0, -2); |
1332 | 1332 | } |
1333 | 1333 | if ($this->elmName !== '') { |
1334 | - $modx->snippetCache[$this->elmName . 'Props'] = ''; |
|
1334 | + $modx->snippetCache[$this->elmName.'Props'] = ''; |
|
1335 | 1335 | } |
1336 | 1336 | } else { |
1337 | 1337 | $php = false; |
@@ -1368,7 +1368,7 @@ discard block |
||
1368 | 1368 | $custom = eval($php); |
1369 | 1369 | $msg = ob_get_contents(); |
1370 | 1370 | if ($value === $this->bt) { |
1371 | - $value = $msg . $custom; |
|
1371 | + $value = $msg.$custom; |
|
1372 | 1372 | } |
1373 | 1373 | ob_end_clean(); |
1374 | 1374 | } elseif ($html !== false && isset($value) && $value !== '') { |
@@ -1542,7 +1542,7 @@ discard block |
||
1542 | 1542 | public function ucfirst($str) |
1543 | 1543 | { |
1544 | 1544 | if (function_exists('mb_strtoupper')) { |
1545 | - return mb_strtoupper($this->substr($str, 0, 1)) . $this->substr($str, 1, $this->strlen($str)); |
|
1545 | + return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
|
1546 | 1546 | } |
1547 | 1547 | |
1548 | 1548 | return ucfirst($str); |
@@ -1551,7 +1551,7 @@ discard block |
||
1551 | 1551 | public function lcfirst($str) |
1552 | 1552 | { |
1553 | 1553 | if (function_exists('mb_strtolower')) { |
1554 | - return mb_strtolower($this->substr($str, 0, 1)) . $this->substr($str, 1, $this->strlen($str)); |
|
1554 | + return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
|
1555 | 1555 | } |
1556 | 1556 | |
1557 | 1557 | return lcfirst($str); |