@@ -1,13 +1,13 @@ 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_plugin') && !$modx->hasPermission('save_snippet') && !$modx->hasPermission('save_template') && !$modx->hasPermission('save_module')) { |
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_GET['catId'])? (int)$_GET['catId'] : 0; |
|
10 | -if ($id==0) { |
|
9 | +$id = isset($_GET['catId']) ? (int) $_GET['catId'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
@@ -19,5 +19,5 @@ discard block |
||
19 | 19 | deleteCategory($id); |
20 | 20 | |
21 | 21 | // finished emptying cache - redirect |
22 | -$header="Location: index.php?a=76"; |
|
22 | +$header = "Location: index.php?a=76"; |
|
23 | 23 | header($header); |
@@ -1,5 +1,5 @@ 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_document')) { |
@@ -28,18 +28,18 @@ discard block |
||
28 | 28 | $document_groups = (isset($_POST['chkalldocs']) && $_POST['chkalldocs'] == 'on') ? array() : $_POST['docgroups']; |
29 | 29 | $type = $_POST['type']; |
30 | 30 | $contentType = $modx->db->escape($_POST['contentType']); |
31 | -$contentdispo = (int)$_POST['content_dispo']; |
|
31 | +$contentdispo = (int) $_POST['content_dispo']; |
|
32 | 32 | $longtitle = $modx->db->escape($_POST['longtitle']); |
33 | -$donthit = (int)$_POST['donthit']; |
|
33 | +$donthit = (int) $_POST['donthit']; |
|
34 | 34 | $menutitle = $modx->db->escape($_POST['menutitle']); |
35 | -$hidemenu = (int)$_POST['hidemenu']; |
|
35 | +$hidemenu = (int) $_POST['hidemenu']; |
|
36 | 36 | $aliasvisible = $_POST['alias_visible']; |
37 | 37 | |
38 | 38 | /************* webber ********/ |
39 | -$sd=isset($_POST['dir'])?'&dir='.$_POST['dir']:'&dir=DESC'; |
|
40 | -$sb=isset($_POST['sort'])?'&sort='.$_POST['sort']:'&sort=pub_date'; |
|
41 | -$pg=isset($_POST['page'])?'&page='.(int)$_POST['page']:''; |
|
42 | -$add_path=$sd.$sb.$pg; |
|
39 | +$sd = isset($_POST['dir']) ? '&dir='.$_POST['dir'] : '&dir=DESC'; |
|
40 | +$sb = isset($_POST['sort']) ? '&sort='.$_POST['sort'] : '&sort=pub_date'; |
|
41 | +$pg = isset($_POST['page']) ? '&page='.(int) $_POST['page'] : ''; |
|
42 | +$add_path = $sd.$sb.$pg; |
|
43 | 43 | |
44 | 44 | |
45 | 45 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | // auto assign alias |
74 | 74 | if (!$alias && $automatic_alias) { |
75 | 75 | $alias = strtolower($modx->stripAlias(trim($pagetitle))); |
76 | - if(!$allow_duplicate_alias) { |
|
76 | + if (!$allow_duplicate_alias) { |
|
77 | 77 | if ($modx->db->getValue($modx->db->select('COUNT(id)', $tbl_site_content, "id<>'$id' AND alias='$alias'")) != 0) { |
78 | 78 | $cnt = 1; |
79 | 79 | $tempAlias = $alias; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } |
85 | 85 | $alias = $tempAlias; |
86 | 86 | } |
87 | - }else{ |
|
87 | + } else { |
|
88 | 88 | if ($modx->db->getValue($modx->db->select('COUNT(id)', $tbl_site_content, "id<>'$id' AND parent=$parent AND alias='$alias'")) != 0) { |
89 | 89 | $cnt = 1; |
90 | 90 | $tempAlias = $alias; |
@@ -165,19 +165,19 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | // get document groups for current user |
168 | -$tmplvars = array (); |
|
168 | +$tmplvars = array(); |
|
169 | 169 | if ($_SESSION['mgrDocgroups']) { |
170 | 170 | $docgrp = implode(",", $_SESSION['mgrDocgroups']); |
171 | 171 | } |
172 | 172 | |
173 | 173 | // ensure that user has not made this document inaccessible to themselves |
174 | -if($_SESSION['mgrRole'] != 1 && is_array($document_groups)) { |
|
174 | +if ($_SESSION['mgrRole'] != 1 && is_array($document_groups)) { |
|
175 | 175 | $document_group_list = implode(',', $document_groups); |
176 | - $document_group_list = implode(',', array_filter(explode(',',$document_group_list), 'is_numeric')); |
|
177 | - if(!empty($document_group_list)) { |
|
176 | + $document_group_list = implode(',', array_filter(explode(',', $document_group_list), 'is_numeric')); |
|
177 | + if (!empty($document_group_list)) { |
|
178 | 178 | $rs = $modx->db->select('COUNT(mg.id)', "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg", "mga.membergroup = mg.user_group AND mga.documentgroup IN({$document_group_list}) AND mg.member = {$_SESSION['mgrInternalKey']}"); |
179 | 179 | $count = $modx->db->getValue($rs); |
180 | - if($count == 0) { |
|
180 | + if ($count == 0) { |
|
181 | 181 | if ($actionToTake == 'edit') { |
182 | 182 | $modx->manager->saveFormValues(27); |
183 | 183 | $modx->webAlertAndQuit(sprintf($_lang["resource_permissions_error"]), "index.php?a=27&id={$id}"); |
@@ -195,45 +195,45 @@ discard block |
||
195 | 195 | INNER JOIN {$tbl_site_tmplvar_templates} AS tvtpl ON tvtpl.tmplvarid = tv.id |
196 | 196 | LEFT JOIN {$tbl_site_tmplvar_contentvalues} AS tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$id}' |
197 | 197 | LEFT JOIN {$tbl_site_tmplvar_access} AS tva ON tva.tmplvarid=tv.id", |
198 | - "tvtpl.templateid = '{$template}' AND (1='{$_SESSION['mgrRole']}' OR ISNULL(tva.documentgroup)" . ((!$docgrp) ? "" : " OR tva.documentgroup IN ($docgrp)") . ")", |
|
198 | + "tvtpl.templateid = '{$template}' AND (1='{$_SESSION['mgrRole']}' OR ISNULL(tva.documentgroup)".((!$docgrp) ? "" : " OR tva.documentgroup IN ($docgrp)").")", |
|
199 | 199 | "tv.rank" |
200 | 200 | ); |
201 | 201 | while ($row = $modx->db->getRow($rs)) { |
202 | 202 | $tmplvar = ''; |
203 | 203 | switch ($row['type']) { |
204 | 204 | case 'url': |
205 | - $tmplvar = $_POST["tv" . $row['id']]; |
|
206 | - if ($_POST["tv" . $row['id'] . '_prefix'] != '--') { |
|
207 | - $tmplvar = str_replace(array ( |
|
205 | + $tmplvar = $_POST["tv".$row['id']]; |
|
206 | + if ($_POST["tv".$row['id'].'_prefix'] != '--') { |
|
207 | + $tmplvar = str_replace(array( |
|
208 | 208 | "feed://", |
209 | 209 | "ftp://", |
210 | 210 | "http://", |
211 | 211 | "https://", |
212 | 212 | "mailto:" |
213 | 213 | ), "", $tmplvar); |
214 | - $tmplvar = $_POST["tv" . $row['id'] . '_prefix'] . $tmplvar; |
|
214 | + $tmplvar = $_POST["tv".$row['id'].'_prefix'].$tmplvar; |
|
215 | 215 | } |
216 | 216 | break; |
217 | 217 | case 'file': |
218 | - $tmplvar = $_POST["tv" . $row['id']]; |
|
218 | + $tmplvar = $_POST["tv".$row['id']]; |
|
219 | 219 | break; |
220 | 220 | default: |
221 | - if (is_array($_POST["tv" . $row['id']])) { |
|
221 | + if (is_array($_POST["tv".$row['id']])) { |
|
222 | 222 | // handles checkboxes & multiple selects elements |
223 | - $feature_insert = array (); |
|
224 | - $lst = $_POST["tv" . $row['id']]; |
|
223 | + $feature_insert = array(); |
|
224 | + $lst = $_POST["tv".$row['id']]; |
|
225 | 225 | while (list ($featureValue, $feature_item) = each($lst)) { |
226 | 226 | $feature_insert[count($feature_insert)] = $feature_item; |
227 | 227 | } |
228 | 228 | $tmplvar = implode("||", $feature_insert); |
229 | 229 | } else { |
230 | - $tmplvar = $_POST["tv" . $row['id']]; |
|
230 | + $tmplvar = $_POST["tv".$row['id']]; |
|
231 | 231 | } |
232 | 232 | break; |
233 | 233 | } |
234 | 234 | // save value if it was modified |
235 | 235 | if (strlen($tmplvar) > 0 && $tmplvar != $row['default_text']) { |
236 | - $tmplvars[$row['id']] = array ( |
|
236 | + $tmplvars[$row['id']] = array( |
|
237 | 237 | $row['id'], |
238 | 238 | $tmplvar |
239 | 239 | ); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | // check to see if the user is allowed to save the document in the place he wants to save it in |
257 | 257 | if ($use_udperms == 1) { |
258 | 258 | if ($existingDocument['parent'] != $parent) { |
259 | - include_once MODX_MANAGER_PATH ."processors/user_documents_permissions.class.php"; |
|
259 | + include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php"; |
|
260 | 260 | $udperms = new udperms(); |
261 | 261 | $udperms->user = $modx->getLoginUserID(); |
262 | 262 | $udperms->document = $parent; |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | case 'new' : |
279 | 279 | |
280 | 280 | // invoke OnBeforeDocFormSave event |
281 | - switch($modx->config['docid_incrmnt_method']) |
|
281 | + switch ($modx->config['docid_incrmnt_method']) |
|
282 | 282 | { |
283 | 283 | case '1': |
284 | 284 | $from = "{$tbl_site_content} AS T0 LEFT JOIN {$tbl_site_content} AS T1 ON T0.id + 1 = T1.id"; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $id = $modx->db->getValue($rs); |
288 | 288 | break; |
289 | 289 | case '2': |
290 | - $rs = $modx->db->select('MAX(id)+1',$tbl_site_content); |
|
290 | + $rs = $modx->db->select('MAX(id)+1', $tbl_site_content); |
|
291 | 291 | $id = $modx->db->getValue($rs); |
292 | 292 | break; |
293 | 293 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | $id = ''; |
296 | 296 | } |
297 | 297 | |
298 | - $modx->invokeEvent("OnBeforeDocFormSave", array ( |
|
298 | + $modx->invokeEvent("OnBeforeDocFormSave", array( |
|
299 | 299 | "mode" => "new", |
300 | 300 | "id" => $id |
301 | 301 | )); |
@@ -310,48 +310,47 @@ discard block |
||
310 | 310 | $publishedon = ($published ? $currentdate : 0); |
311 | 311 | $publishedby = ($published ? $modx->getLoginUserID() : 0); |
312 | 312 | |
313 | - if ((!empty($pub_date))&&($published)){ |
|
314 | - $publishedon=$pub_date; |
|
315 | - } |
|
316 | - |
|
317 | - $dbInsert = array |
|
318 | - ( |
|
319 | - "introtext" => $introtext , |
|
320 | - "content" => $content , |
|
321 | - "pagetitle" => $pagetitle , |
|
322 | - "longtitle" => $longtitle , |
|
323 | - "type" => $type , |
|
324 | - "description" => $description , |
|
325 | - "alias" => $alias , |
|
326 | - "link_attributes" => $link_attributes , |
|
327 | - "isfolder" => $isfolder , |
|
328 | - "richtext" => $richtext , |
|
329 | - "published" => $published , |
|
330 | - "parent" => $parent , |
|
331 | - "template" => $template , |
|
332 | - "menuindex" => $menuindex , |
|
333 | - "searchable" => $searchable , |
|
334 | - "cacheable" => $cacheable , |
|
335 | - "createdby" => $modx->getLoginUserID() , |
|
336 | - "createdon" => $currentdate , |
|
337 | - "editedby" => $modx->getLoginUserID() , |
|
338 | - "editedon" => $currentdate , |
|
339 | - "publishedby" => $publishedby , |
|
340 | - "publishedon" => $publishedon , |
|
341 | - "pub_date" => $pub_date , |
|
342 | - "unpub_date" => $unpub_date , |
|
343 | - "contentType" => $contentType , |
|
344 | - "content_dispo" => $contentdispo , |
|
345 | - "donthit" => $donthit , |
|
346 | - "menutitle" => $menutitle , |
|
347 | - "hidemenu" => $hidemenu , |
|
313 | + if ((!empty($pub_date)) && ($published)) { |
|
314 | + $publishedon = $pub_date; |
|
315 | + } |
|
316 | + |
|
317 | + $dbInsert = array( |
|
318 | + "introtext" => $introtext, |
|
319 | + "content" => $content, |
|
320 | + "pagetitle" => $pagetitle, |
|
321 | + "longtitle" => $longtitle, |
|
322 | + "type" => $type, |
|
323 | + "description" => $description, |
|
324 | + "alias" => $alias, |
|
325 | + "link_attributes" => $link_attributes, |
|
326 | + "isfolder" => $isfolder, |
|
327 | + "richtext" => $richtext, |
|
328 | + "published" => $published, |
|
329 | + "parent" => $parent, |
|
330 | + "template" => $template, |
|
331 | + "menuindex" => $menuindex, |
|
332 | + "searchable" => $searchable, |
|
333 | + "cacheable" => $cacheable, |
|
334 | + "createdby" => $modx->getLoginUserID(), |
|
335 | + "createdon" => $currentdate, |
|
336 | + "editedby" => $modx->getLoginUserID(), |
|
337 | + "editedon" => $currentdate, |
|
338 | + "publishedby" => $publishedby, |
|
339 | + "publishedon" => $publishedon, |
|
340 | + "pub_date" => $pub_date, |
|
341 | + "unpub_date" => $unpub_date, |
|
342 | + "contentType" => $contentType, |
|
343 | + "content_dispo" => $contentdispo, |
|
344 | + "donthit" => $donthit, |
|
345 | + "menutitle" => $menutitle, |
|
346 | + "hidemenu" => $hidemenu, |
|
348 | 347 | "alias_visible" => $aliasvisible |
349 | 348 | ); |
350 | 349 | |
351 | 350 | if ($id != '') |
352 | 351 | $dbInsert["id"] = $id; |
353 | 352 | |
354 | - $key = $modx->db->insert( $dbInsert, $tbl_site_content); |
|
353 | + $key = $modx->db->insert($dbInsert, $tbl_site_content); |
|
355 | 354 | |
356 | 355 | $tvChanges = array(); |
357 | 356 | foreach ($tmplvars as $field => $value) { |
@@ -373,7 +372,7 @@ discard block |
||
373 | 372 | foreach ($document_groups as $value_pair) { |
374 | 373 | // first, split the pair (this is a new document, so ignore the second value |
375 | 374 | list($group) = explode(',', $value_pair); // @see actions/mutate_content.dynamic.php @ line 1138 (permissions list) |
376 | - $new_groups[] = '('.(int)$group.','.$key.')'; |
|
375 | + $new_groups[] = '('.(int) $group.','.$key.')'; |
|
377 | 376 | } |
378 | 377 | $saved = true; |
379 | 378 | if (!empty($new_groups)) { |
@@ -382,7 +381,7 @@ discard block |
||
382 | 381 | } else { |
383 | 382 | $isManager = $modx->hasPermission('access_permissions'); |
384 | 383 | $isWeb = $modx->hasPermission('web_access_permissions'); |
385 | - if($use_udperms && !($isManager || $isWeb) && $parent != 0) { |
|
384 | + if ($use_udperms && !($isManager || $isWeb) && $parent != 0) { |
|
386 | 385 | // inherit document access permissions |
387 | 386 | $modx->db->insert( |
388 | 387 | array( |
@@ -401,17 +400,17 @@ discard block |
||
401 | 400 | } |
402 | 401 | |
403 | 402 | // invoke OnDocFormSave event |
404 | - $modx->invokeEvent("OnDocFormSave", array ( |
|
403 | + $modx->invokeEvent("OnDocFormSave", array( |
|
405 | 404 | "mode" => "new", |
406 | 405 | "id" => $key |
407 | 406 | )); |
408 | 407 | |
409 | 408 | // secure web documents - flag as private |
410 | - include MODX_MANAGER_PATH . "includes/secure_web_documents.inc.php"; |
|
409 | + include MODX_MANAGER_PATH."includes/secure_web_documents.inc.php"; |
|
411 | 410 | secureWebDocument($key); |
412 | 411 | |
413 | 412 | // secure manager documents - flag as private |
414 | - include MODX_MANAGER_PATH . "includes/secure_mgr_documents.inc.php"; |
|
413 | + include MODX_MANAGER_PATH."includes/secure_mgr_documents.inc.php"; |
|
415 | 414 | secureMgrDocument($key); |
416 | 415 | |
417 | 416 | // Set the item name for logger |
@@ -430,13 +429,13 @@ discard block |
||
430 | 429 | // document |
431 | 430 | if ($_POST['mode'] == "4") |
432 | 431 | $a = ($_POST['stay'] == '2') ? "27&id=$key" : "4&pid=$parent"; |
433 | - $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay']; |
|
432 | + $header = "Location: index.php?a=".$a."&r=1&stay=".$_POST['stay']; |
|
434 | 433 | } else { |
435 | 434 | $header = "Location: index.php?a=3&id=$key&r=1"; |
436 | 435 | } |
437 | 436 | |
438 | 437 | if (headers_sent()) { |
439 | - $header = str_replace('Location: ','',$header); |
|
438 | + $header = str_replace('Location: ', '', $header); |
|
440 | 439 | echo "<script>document.location.href='$header';</script>\n"; |
441 | 440 | } else { |
442 | 441 | header($header); |
@@ -490,7 +489,7 @@ discard block |
||
490 | 489 | if (!$was_published && $published) { |
491 | 490 | $publishedon = $currentdate; |
492 | 491 | $publishedby = $modx->getLoginUserID(); |
493 | - }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
|
492 | + }elseif ((!empty($pub_date) && $pub_date <= $currentdate && $published)) { |
|
494 | 493 | $publishedon = $pub_date; |
495 | 494 | $publishedby = $modx->getLoginUserID(); |
496 | 495 | }elseif ($was_published && !$published) { |
@@ -502,7 +501,7 @@ discard block |
||
502 | 501 | } |
503 | 502 | |
504 | 503 | // invoke OnBeforeDocFormSave event |
505 | - $modx->invokeEvent("OnBeforeDocFormSave", array ( |
|
504 | + $modx->invokeEvent("OnBeforeDocFormSave", array( |
|
506 | 505 | "mode" => "upd", |
507 | 506 | "id" => $id |
508 | 507 | )); |
@@ -527,7 +526,7 @@ discard block |
||
527 | 526 | . "menuindex={$menuindex}, " |
528 | 527 | . "searchable={$searchable}, " |
529 | 528 | . "cacheable={$cacheable}, " |
530 | - . "editedby=" . $modx->getLoginUserID() . ", " |
|
529 | + . "editedby=".$modx->getLoginUserID().", " |
|
531 | 530 | . "editedon={$currentdate}, " |
532 | 531 | . "publishedon={$publishedon}, " |
533 | 532 | . "publishedby={$publishedby}, " |
@@ -541,7 +540,7 @@ discard block |
||
541 | 540 | |
542 | 541 | // update template variables |
543 | 542 | $rs = $modx->db->select('id, tmplvarid', $tbl_site_tmplvar_contentvalues, "contentid='{$id}'"); |
544 | - $tvIds = array (); |
|
543 | + $tvIds = array(); |
|
545 | 544 | while ($row = $modx->db->getRow($rs)) { |
546 | 545 | $tvIds[$row['tmplvarid']] = $row['id']; |
547 | 546 | } |
@@ -594,7 +593,7 @@ discard block |
||
594 | 593 | 'groups.id, groups.document_group', |
595 | 594 | "{$tbl_document_groups} AS groups |
596 | 595 | LEFT JOIN {$tbl_documentgroup_names} AS dgn ON dgn.id = groups.document_group", |
597 | - "((1=".(int)$isManager." AND dgn.private_memgroup) OR (1=".(int)$isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'" |
|
596 | + "((1=".(int) $isManager." AND dgn.private_memgroup) OR (1=".(int) $isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'" |
|
598 | 597 | ); |
599 | 598 | $old_groups = array(); |
600 | 599 | while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id']; |
@@ -606,7 +605,7 @@ discard block |
||
606 | 605 | unset($old_groups[$group]); |
607 | 606 | continue; |
608 | 607 | } elseif ($link_id == 'new') { |
609 | - $insertions[] = '('.(int)$group.','.$id.')'; |
|
608 | + $insertions[] = '('.(int) $group.','.$id.')'; |
|
610 | 609 | } |
611 | 610 | } |
612 | 611 | if (!empty($insertions)) { |
@@ -638,17 +637,17 @@ discard block |
||
638 | 637 | |
639 | 638 | |
640 | 639 | // invoke OnDocFormSave event |
641 | - $modx->invokeEvent("OnDocFormSave", array ( |
|
640 | + $modx->invokeEvent("OnDocFormSave", array( |
|
642 | 641 | "mode" => "upd", |
643 | 642 | "id" => $id |
644 | 643 | )); |
645 | 644 | |
646 | 645 | // secure web documents - flag as private |
647 | - include MODX_MANAGER_PATH . "includes/secure_web_documents.inc.php"; |
|
646 | + include MODX_MANAGER_PATH."includes/secure_web_documents.inc.php"; |
|
648 | 647 | secureWebDocument($id); |
649 | 648 | |
650 | 649 | // secure manager documents - flag as private |
651 | - include MODX_MANAGER_PATH . "includes/secure_mgr_documents.inc.php"; |
|
650 | + include MODX_MANAGER_PATH."includes/secure_mgr_documents.inc.php"; |
|
652 | 651 | secureMgrDocument($id); |
653 | 652 | |
654 | 653 | // Set the item name for logger |
@@ -656,14 +655,14 @@ discard block |
||
656 | 655 | |
657 | 656 | if ($syncsite == 1) { |
658 | 657 | // empty cache |
659 | - $keys = array('alias','parent','published','isfolder','menuindex','alias_visible'); |
|
658 | + $keys = array('alias', 'parent', 'published', 'isfolder', 'menuindex', 'alias_visible'); |
|
660 | 659 | $flag = ''; |
661 | - foreach($keys as $key) { |
|
662 | - if ($existingDocument[$key]===$_POST[$key]) continue; |
|
660 | + foreach ($keys as $key) { |
|
661 | + if ($existingDocument[$key] === $_POST[$key]) continue; |
|
663 | 662 | $flag = 'full'; |
664 | 663 | break; |
665 | 664 | } |
666 | - if($flag==='full') $modx->clearCache('full'); |
|
665 | + if ($flag === 'full') $modx->clearCache('full'); |
|
667 | 666 | else $modx->clearCache($id); |
668 | 667 | } |
669 | 668 | |
@@ -682,13 +681,13 @@ discard block |
||
682 | 681 | // document |
683 | 682 | $a = ($_POST['stay'] == '2') ? "27&id=$id" : "4&pid=$parent"; |
684 | 683 | } |
685 | - $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay'].$add_path; |
|
684 | + $header = "Location: index.php?a=".$a."&r=1&stay=".$_POST['stay'].$add_path; |
|
686 | 685 | } else { |
687 | 686 | $header = "Location: index.php?a=3&id=$id&r=1".$add_path; |
688 | 687 | } |
689 | 688 | } |
690 | 689 | if (headers_sent()) { |
691 | - $header = str_replace('Location: ','',$header); |
|
690 | + $header = str_replace('Location: ', '', $header); |
|
692 | 691 | echo "<script>document.location.href='$header';</script>\n"; |
693 | 692 | } else { |
694 | 693 | header($header); |
@@ -3,12 +3,12 @@ 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('new_plugin')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
10 | 10 | if($id==0) { |
11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | // count duplicates |
@@ -19,25 +19,25 @@ discard block |
||
19 | 19 | |
20 | 20 | // duplicate Plugin |
21 | 21 | $newid = $modx->db->insert( |
22 | - array( |
|
23 | - 'name'=>'', |
|
24 | - 'description'=>'', |
|
25 | - 'disabled'=>'', |
|
26 | - 'moduleguid'=>'', |
|
27 | - 'plugincode'=>'', |
|
28 | - 'properties'=>'', |
|
29 | - 'category'=>'', |
|
30 | - ), $modx->getFullTableName('site_plugins'), // Insert into |
|
31 | - "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, moduleguid, plugincode, properties, category", $modx->getFullTableName('site_plugins'), "id='{$id}'"); // Copy from |
|
22 | + array( |
|
23 | + 'name'=>'', |
|
24 | + 'description'=>'', |
|
25 | + 'disabled'=>'', |
|
26 | + 'moduleguid'=>'', |
|
27 | + 'plugincode'=>'', |
|
28 | + 'properties'=>'', |
|
29 | + 'category'=>'', |
|
30 | + ), $modx->getFullTableName('site_plugins'), // Insert into |
|
31 | + "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, moduleguid, plugincode, properties, category", $modx->getFullTableName('site_plugins'), "id='{$id}'"); // Copy from |
|
32 | 32 | |
33 | 33 | // duplicate Plugin Event Listeners |
34 | 34 | $modx->db->insert( |
35 | - array( |
|
36 | - 'pluginid'=>'', |
|
37 | - 'evtid'=>'', |
|
38 | - 'priority'=>'', |
|
39 | - ), $modx->getFullTableName('site_plugin_events'), // Insert into |
|
40 | - "'{$newid}', evtid, priority", $modx->getFullTableName('site_plugin_events'), "pluginid='{$id}'"); // Copy from |
|
35 | + array( |
|
36 | + 'pluginid'=>'', |
|
37 | + 'evtid'=>'', |
|
38 | + 'priority'=>'', |
|
39 | + ), $modx->getFullTableName('site_plugin_events'), // Insert into |
|
40 | + "'{$newid}', evtid, priority", $modx->getFullTableName('site_plugin_events'), "pluginid='{$id}'"); // Copy from |
|
41 | 41 | |
42 | 42 | // Set the item name for logger |
43 | 43 | $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_plugins'), "id='{$newid}'")); |
@@ -1,20 +1,20 @@ 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('new_plugin')) { |
|
5 | +if (!$modx->hasPermission('new_plugin')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
10 | -if($id==0) { |
|
9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
14 | 14 | // count duplicates |
15 | 15 | $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_plugins'), "id='{$id}'")); |
16 | 16 | $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_plugins'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
17 | -if($count>=1) $count = ' '.($count+1); |
|
17 | +if ($count >= 1) $count = ' '.($count + 1); |
|
18 | 18 | else $count = ''; |
19 | 19 | |
20 | 20 | // duplicate Plugin |
@@ -44,5 +44,5 @@ discard block |
||
44 | 44 | $_SESSION['itemname'] = $name; |
45 | 45 | |
46 | 46 | // finish duplicating - redirect to new plugin |
47 | -$header="Location: index.php?r=2&a=102&id=$newid"; |
|
47 | +$header = "Location: index.php?r=2&a=102&id=$newid"; |
|
48 | 48 | header($header); |
@@ -1,27 +1,27 @@ 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 | $template = $modx->db->escape($_POST['post']); |
11 | 11 | $templatename = $modx->db->escape(trim($_POST['templatename'])); |
12 | 12 | $description = $modx->db->escape($_POST['description']); |
13 | 13 | $locked = $_POST['locked'] == 'on' ? 1 : 0; |
14 | -$selectable = $id == $modx->config['default_template'] ? 1 : // Force selectable |
|
14 | +$selectable = $id == $modx->config['default_template'] ? 1 : // Force selectable |
|
15 | 15 | $_POST['selectable'] == 'on' ? 1 : 0; |
16 | 16 | $currentdate = time() + $modx->config['server_offset_time']; |
17 | 17 | |
18 | 18 | //Kyle Jaebker - added category support |
19 | 19 | if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { |
20 | - $categoryid = (int)$_POST['categoryid']; |
|
20 | + $categoryid = (int) $_POST['categoryid']; |
|
21 | 21 | } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { |
22 | 22 | $categoryid = 0; |
23 | 23 | } else { |
24 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
24 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
25 | 25 | $categoryid = checkCategory($_POST['newcategory']); |
26 | 26 | if (!$categoryid) { |
27 | 27 | $categoryid = newCategory($_POST['newcategory']); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | // finished emptying cache - redirect |
79 | 79 | if ($_POST['stay'] != '') { |
80 | 80 | $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19"; |
81 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
81 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
82 | 82 | header($header); |
83 | 83 | } else { |
84 | 84 | $header = "Location: index.php?a=76&r=2"; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | // finished emptying cache - redirect |
131 | 131 | if ($_POST['stay'] != '') { |
132 | 132 | $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19"; |
133 | - $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; |
|
133 | + $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; |
|
134 | 134 | header($header); |
135 | 135 | } else { |
136 | 136 | $modx->unlockElement(1, $id); |
@@ -3,17 +3,17 @@ 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('delete_user')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
10 | 10 | if($id==0) { |
11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | // delete the user, but first check if we are deleting our own record |
15 | 15 | if($id==$modx->getLoginUserID()) { |
16 | - $modx->webAlertAndQuit("You can't delete yourself!"); |
|
16 | + $modx->webAlertAndQuit("You can't delete yourself!"); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | // Set the item name for logger |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | |
23 | 23 | // invoke OnBeforeUserFormDelete event |
24 | 24 | $modx->invokeEvent("OnBeforeUserFormDelete", |
25 | - array( |
|
26 | - "id" => $id |
|
27 | - )); |
|
25 | + array( |
|
26 | + "id" => $id |
|
27 | + )); |
|
28 | 28 | |
29 | 29 | // delete the user. |
30 | 30 | $modx->db->delete($modx->getFullTableName('manager_users'), "id='{$id}'"); |
@@ -39,16 +39,16 @@ discard block |
||
39 | 39 | |
40 | 40 | // invoke OnManagerDeleteUser event |
41 | 41 | $modx->invokeEvent("OnManagerDeleteUser", |
42 | - array( |
|
43 | - "userid" => $id, |
|
44 | - "username" => $username |
|
45 | - )); |
|
42 | + array( |
|
43 | + "userid" => $id, |
|
44 | + "username" => $username |
|
45 | + )); |
|
46 | 46 | |
47 | 47 | // invoke OnUserFormDelete event |
48 | 48 | $modx->invokeEvent("OnUserFormDelete", |
49 | - array( |
|
50 | - "id" => $id |
|
51 | - )); |
|
49 | + array( |
|
50 | + "id" => $id |
|
51 | + )); |
|
52 | 52 | |
53 | 53 | $header="Location: index.php?a=75"; |
54 | 54 | header($header); |
@@ -1,18 +1,18 @@ 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('delete_user')) { |
|
5 | +if (!$modx->hasPermission('delete_user')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
10 | -if($id==0) { |
|
9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
14 | 14 | // delete the user, but first check if we are deleting our own record |
15 | -if($id==$modx->getLoginUserID()) { |
|
15 | +if ($id == $modx->getLoginUserID()) { |
|
16 | 16 | $modx->webAlertAndQuit("You can't delete yourself!"); |
17 | 17 | } |
18 | 18 | |
@@ -50,5 +50,5 @@ discard block |
||
50 | 50 | "id" => $id |
51 | 51 | )); |
52 | 52 | |
53 | -$header="Location: index.php?a=75"; |
|
53 | +$header = "Location: index.php?a=75"; |
|
54 | 54 | header($header); |
@@ -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->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 = sanitize($v); |
|
17 | - } |
|
18 | - $input[$k] = $v; |
|
15 | + if($k !== 'comment') { |
|
16 | + $v = sanitize($v); |
|
17 | + } |
|
18 | + $input[$k] = $v; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | $id = (int)$input['id']; |
@@ -51,80 +51,80 @@ discard block |
||
51 | 51 | |
52 | 52 | // verify password |
53 | 53 | if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
54 | - webAlertAndQuit("Password typed is mismatched"); |
|
54 | + webAlertAndQuit("Password typed is mismatched"); |
|
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!"); |
|
59 | + webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | switch($input['mode']) { |
63 | - case '87' : // new user |
|
64 | - // check if this user name already exist |
|
65 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
66 | - $limit = $modx->db->getValue($rs); |
|
67 | - if($limit > 0) { |
|
68 | - webAlertAndQuit("User name is already in use!"); |
|
69 | - } |
|
70 | - |
|
71 | - // check if the email address already exist |
|
72 | - $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
73 | - $limit = $modx->db->getValue($rs); |
|
74 | - if($limit > 0) { |
|
75 | - webAlertAndQuit("Email is already in use!"); |
|
76 | - } |
|
77 | - |
|
78 | - // generate a new password for this user |
|
79 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
80 | - if(strlen($specifiedpassword) < 6) { |
|
81 | - webAlertAndQuit("Password is too short!"); |
|
82 | - } else { |
|
83 | - $newpassword = $specifiedpassword; |
|
84 | - } |
|
85 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
86 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
87 | - } elseif($passwordgenmethod == 'g') { |
|
88 | - $newpassword = generate_password(8); |
|
89 | - } else { |
|
90 | - webAlertAndQuit("No password generation method specified!"); |
|
91 | - } |
|
92 | - |
|
93 | - // invoke OnBeforeWUsrFormSave event |
|
94 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
95 | - "mode" => "new", |
|
96 | - )); |
|
97 | - |
|
98 | - // create the user account |
|
99 | - $field = array(); |
|
100 | - $field['username'] = $esc_newusername; |
|
101 | - $field['password'] = md5($newpassword); |
|
102 | - $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
103 | - |
|
104 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
105 | - $field = $modx->db->escape($field); |
|
106 | - $modx->db->insert($field, $tbl_web_user_attributes); |
|
107 | - |
|
108 | - // Save User Settings |
|
109 | - saveUserSettings($internalKey); |
|
110 | - |
|
111 | - // Set the item name for logger |
|
112 | - $_SESSION['itemname'] = $newusername; |
|
113 | - |
|
114 | - /*******************************************************************************/ |
|
115 | - // put the user in the user_groups he/ she should be in |
|
116 | - // first, check that up_perms are switched on! |
|
117 | - if($use_udperms == 1) { |
|
118 | - if(!empty($user_groups)) { |
|
119 | - for($i = 0; $i < count($user_groups); $i++) { |
|
120 | - $f = array(); |
|
121 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
122 | - $f['webuser'] = $internalKey; |
|
123 | - $modx->db->insert($f, $tbl_web_groups); |
|
124 | - } |
|
125 | - } |
|
126 | - } |
|
127 | - // end of user_groups stuff! |
|
63 | + case '87' : // new user |
|
64 | + // check if this user name already exist |
|
65 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
66 | + $limit = $modx->db->getValue($rs); |
|
67 | + if($limit > 0) { |
|
68 | + webAlertAndQuit("User name is already in use!"); |
|
69 | + } |
|
70 | + |
|
71 | + // check if the email address already exist |
|
72 | + $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
73 | + $limit = $modx->db->getValue($rs); |
|
74 | + if($limit > 0) { |
|
75 | + webAlertAndQuit("Email is already in use!"); |
|
76 | + } |
|
77 | + |
|
78 | + // generate a new password for this user |
|
79 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
80 | + if(strlen($specifiedpassword) < 6) { |
|
81 | + webAlertAndQuit("Password is too short!"); |
|
82 | + } else { |
|
83 | + $newpassword = $specifiedpassword; |
|
84 | + } |
|
85 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
86 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
87 | + } elseif($passwordgenmethod == 'g') { |
|
88 | + $newpassword = generate_password(8); |
|
89 | + } else { |
|
90 | + webAlertAndQuit("No password generation method specified!"); |
|
91 | + } |
|
92 | + |
|
93 | + // invoke OnBeforeWUsrFormSave event |
|
94 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
95 | + "mode" => "new", |
|
96 | + )); |
|
97 | + |
|
98 | + // create the user account |
|
99 | + $field = array(); |
|
100 | + $field['username'] = $esc_newusername; |
|
101 | + $field['password'] = md5($newpassword); |
|
102 | + $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
103 | + |
|
104 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
105 | + $field = $modx->db->escape($field); |
|
106 | + $modx->db->insert($field, $tbl_web_user_attributes); |
|
107 | + |
|
108 | + // Save User Settings |
|
109 | + saveUserSettings($internalKey); |
|
110 | + |
|
111 | + // Set the item name for logger |
|
112 | + $_SESSION['itemname'] = $newusername; |
|
113 | + |
|
114 | + /*******************************************************************************/ |
|
115 | + // put the user in the user_groups he/ she should be in |
|
116 | + // first, check that up_perms are switched on! |
|
117 | + if($use_udperms == 1) { |
|
118 | + if(!empty($user_groups)) { |
|
119 | + for($i = 0; $i < count($user_groups); $i++) { |
|
120 | + $f = array(); |
|
121 | + $f['webgroup'] = (int)$user_groups[$i]; |
|
122 | + $f['webuser'] = $internalKey; |
|
123 | + $modx->db->insert($f, $tbl_web_groups); |
|
124 | + } |
|
125 | + } |
|
126 | + } |
|
127 | + // end of user_groups stuff! |
|
128 | 128 | |
129 | 129 | // invoke OnWebSaveUser event |
130 | 130 | $modx->invokeEvent("OnWebSaveUser", array( |
@@ -142,26 +142,26 @@ discard block |
||
142 | 142 | "id" => $internalKey |
143 | 143 | )); |
144 | 144 | |
145 | - if($passwordnotifymethod == 'e') { |
|
146 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
147 | - if($input['stay'] != '') { |
|
148 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
149 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
150 | - header($header); |
|
151 | - } else { |
|
152 | - $header = "Location: index.php?a=99&r=2"; |
|
153 | - header($header); |
|
154 | - } |
|
155 | - } else { |
|
156 | - if($input['stay'] != '') { |
|
157 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
158 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
159 | - } else { |
|
160 | - $stayUrl = "index.php?a=99&r=2"; |
|
161 | - } |
|
162 | - |
|
163 | - include_once "header.inc.php"; |
|
164 | - ?> |
|
145 | + if($passwordnotifymethod == 'e') { |
|
146 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
147 | + if($input['stay'] != '') { |
|
148 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
149 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
150 | + header($header); |
|
151 | + } else { |
|
152 | + $header = "Location: index.php?a=99&r=2"; |
|
153 | + header($header); |
|
154 | + } |
|
155 | + } else { |
|
156 | + if($input['stay'] != '') { |
|
157 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
158 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
159 | + } else { |
|
160 | + $stayUrl = "index.php?a=99&r=2"; |
|
161 | + } |
|
162 | + |
|
163 | + include_once "header.inc.php"; |
|
164 | + ?> |
|
165 | 165 | |
166 | 166 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
167 | 167 | |
@@ -183,84 +183,84 @@ discard block |
||
183 | 183 | </div> |
184 | 184 | <?php |
185 | 185 | |
186 | - include_once "footer.inc.php"; |
|
187 | - } |
|
188 | - break; |
|
189 | - case '88' : // edit user |
|
190 | - // generate a new password for this user |
|
191 | - if($genpassword == 1) { |
|
192 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
193 | - if(strlen($specifiedpassword) < 6) { |
|
194 | - webAlertAndQuit("Password is too short!"); |
|
195 | - } else { |
|
196 | - $newpassword = $specifiedpassword; |
|
197 | - } |
|
198 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
199 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
200 | - } elseif($passwordgenmethod == 'g') { |
|
201 | - $newpassword = generate_password(8); |
|
202 | - } else { |
|
203 | - webAlertAndQuit("No password generation method specified!"); |
|
204 | - } |
|
205 | - } |
|
206 | - if($passwordnotifymethod == 'e') { |
|
207 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
208 | - } |
|
209 | - |
|
210 | - // check if the username already exist |
|
211 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
212 | - $limit = $modx->db->getValue($rs); |
|
213 | - if($limit > 0) { |
|
214 | - webAlertAndQuit("User name is already in use!"); |
|
215 | - } |
|
216 | - |
|
217 | - // check if the email address already exists |
|
218 | - $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
219 | - $limit = $modx->db->getValue($rs); |
|
220 | - if($limit > 0) { |
|
221 | - webAlertAndQuit("Email is already in use!"); |
|
222 | - } |
|
223 | - |
|
224 | - // invoke OnBeforeWUsrFormSave event |
|
225 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
226 | - "mode" => "upd", |
|
227 | - "id" => $id |
|
228 | - )); |
|
229 | - |
|
230 | - // update user name and password |
|
231 | - $field = array(); |
|
232 | - $field['username'] = $esc_newusername; |
|
233 | - if($genpassword == 1) { |
|
234 | - $field['password'] = md5($newpassword); |
|
235 | - } |
|
236 | - $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
237 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
238 | - $field = $modx->db->escape($field); |
|
239 | - $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
240 | - |
|
241 | - // Save User Settings |
|
242 | - saveUserSettings($id); |
|
243 | - |
|
244 | - // Set the item name for logger |
|
245 | - $_SESSION['itemname'] = $newusername; |
|
246 | - |
|
247 | - /*******************************************************************************/ |
|
248 | - // put the user in the user_groups he/ she should be in |
|
249 | - // first, check that up_perms are switched on! |
|
250 | - if($use_udperms == 1) { |
|
251 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
252 | - $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
253 | - if(!empty($user_groups)) { |
|
254 | - for($i = 0; $i < count($user_groups); $i++) { |
|
255 | - $field = array(); |
|
256 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
257 | - $field['webuser'] = $id; |
|
258 | - $modx->db->insert($field, $tbl_web_groups); |
|
259 | - } |
|
260 | - } |
|
261 | - } |
|
262 | - // end of user_groups stuff! |
|
263 | - /*******************************************************************************/ |
|
186 | + include_once "footer.inc.php"; |
|
187 | + } |
|
188 | + break; |
|
189 | + case '88' : // edit user |
|
190 | + // generate a new password for this user |
|
191 | + if($genpassword == 1) { |
|
192 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
193 | + if(strlen($specifiedpassword) < 6) { |
|
194 | + webAlertAndQuit("Password is too short!"); |
|
195 | + } else { |
|
196 | + $newpassword = $specifiedpassword; |
|
197 | + } |
|
198 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
199 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
200 | + } elseif($passwordgenmethod == 'g') { |
|
201 | + $newpassword = generate_password(8); |
|
202 | + } else { |
|
203 | + webAlertAndQuit("No password generation method specified!"); |
|
204 | + } |
|
205 | + } |
|
206 | + if($passwordnotifymethod == 'e') { |
|
207 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
208 | + } |
|
209 | + |
|
210 | + // check if the username already exist |
|
211 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
212 | + $limit = $modx->db->getValue($rs); |
|
213 | + if($limit > 0) { |
|
214 | + webAlertAndQuit("User name is already in use!"); |
|
215 | + } |
|
216 | + |
|
217 | + // check if the email address already exists |
|
218 | + $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
219 | + $limit = $modx->db->getValue($rs); |
|
220 | + if($limit > 0) { |
|
221 | + webAlertAndQuit("Email is already in use!"); |
|
222 | + } |
|
223 | + |
|
224 | + // invoke OnBeforeWUsrFormSave event |
|
225 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
226 | + "mode" => "upd", |
|
227 | + "id" => $id |
|
228 | + )); |
|
229 | + |
|
230 | + // update user name and password |
|
231 | + $field = array(); |
|
232 | + $field['username'] = $esc_newusername; |
|
233 | + if($genpassword == 1) { |
|
234 | + $field['password'] = md5($newpassword); |
|
235 | + } |
|
236 | + $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
237 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
238 | + $field = $modx->db->escape($field); |
|
239 | + $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
240 | + |
|
241 | + // Save User Settings |
|
242 | + saveUserSettings($id); |
|
243 | + |
|
244 | + // Set the item name for logger |
|
245 | + $_SESSION['itemname'] = $newusername; |
|
246 | + |
|
247 | + /*******************************************************************************/ |
|
248 | + // put the user in the user_groups he/ she should be in |
|
249 | + // first, check that up_perms are switched on! |
|
250 | + if($use_udperms == 1) { |
|
251 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
252 | + $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
253 | + if(!empty($user_groups)) { |
|
254 | + for($i = 0; $i < count($user_groups); $i++) { |
|
255 | + $field = array(); |
|
256 | + $field['webgroup'] = (int)$user_groups[$i]; |
|
257 | + $field['webuser'] = $id; |
|
258 | + $modx->db->insert($field, $tbl_web_groups); |
|
259 | + } |
|
260 | + } |
|
261 | + } |
|
262 | + // end of user_groups stuff! |
|
263 | + /*******************************************************************************/ |
|
264 | 264 | |
265 | 265 | // invoke OnWebSaveUser event |
266 | 266 | $modx->invokeEvent("OnWebSaveUser", array( |
@@ -289,16 +289,16 @@ discard block |
||
289 | 289 | "id" => $id |
290 | 290 | )); |
291 | 291 | |
292 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
293 | - if($input['stay'] != '') { |
|
294 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
295 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
296 | - } else { |
|
297 | - $stayUrl = "index.php?a=99&r=2"; |
|
298 | - } |
|
292 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
293 | + if($input['stay'] != '') { |
|
294 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
295 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
296 | + } else { |
|
297 | + $stayUrl = "index.php?a=99&r=2"; |
|
298 | + } |
|
299 | 299 | |
300 | - include_once "header.inc.php"; |
|
301 | - ?> |
|
300 | + include_once "header.inc.php"; |
|
301 | + ?> |
|
302 | 302 | |
303 | 303 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
304 | 304 | |
@@ -318,124 +318,124 @@ discard block |
||
318 | 318 | </div> |
319 | 319 | <?php |
320 | 320 | |
321 | - include_once "footer.inc.php"; |
|
322 | - } else { |
|
323 | - if($input['stay'] != '') { |
|
324 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
325 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
326 | - header($header); |
|
327 | - } else { |
|
328 | - $header = "Location: index.php?a=99&r=2"; |
|
329 | - header($header); |
|
330 | - } |
|
331 | - } |
|
332 | - break; |
|
333 | - default : |
|
334 | - webAlertAndQuit("No operation set in request."); |
|
321 | + include_once "footer.inc.php"; |
|
322 | + } else { |
|
323 | + if($input['stay'] != '') { |
|
324 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
325 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
326 | + header($header); |
|
327 | + } else { |
|
328 | + $header = "Location: index.php?a=99&r=2"; |
|
329 | + header($header); |
|
330 | + } |
|
331 | + } |
|
332 | + break; |
|
333 | + default : |
|
334 | + webAlertAndQuit("No operation set in request."); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | // in case any plugins include a quoted_printable function |
338 | 338 | function save_user_quoted_printable($string) { |
339 | - $crlf = "\n"; |
|
340 | - $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
341 | - $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
|
342 | - $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
|
343 | - $f[] = '/([\011\040])' . $crlf . '/e'; |
|
344 | - $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
345 | - $string = preg_replace($f, $r, $string); |
|
346 | - return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
339 | + $crlf = "\n"; |
|
340 | + $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
341 | + $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
|
342 | + $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
|
343 | + $f[] = '/([\011\040])' . $crlf . '/e'; |
|
344 | + $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
345 | + $string = preg_replace($f, $r, $string); |
|
346 | + return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | // Send an email to the user |
350 | 350 | function sendMailMessage($email, $uid, $pwd, $ufn) { |
351 | - global $modx, $_lang, $websignupemail_message; |
|
352 | - global $emailsubject, $emailsender; |
|
353 | - global $site_name, $site_url; |
|
354 | - $message = sprintf($websignupemail_message, $uid, $pwd); // use old method |
|
355 | - // replace placeholders |
|
356 | - $message = str_replace("[+uid+]", $uid, $message); |
|
357 | - $message = str_replace("[+pwd+]", $pwd, $message); |
|
358 | - $message = str_replace("[+ufn+]", $ufn, $message); |
|
359 | - $message = str_replace("[+sname+]", $site_name, $message); |
|
360 | - $message = str_replace("[+saddr+]", $emailsender, $message); |
|
361 | - $message = str_replace("[+semail+]", $emailsender, $message); |
|
362 | - $message = str_replace("[+surl+]", $site_url, $message); |
|
363 | - |
|
364 | - $param = array(); |
|
365 | - $param['from'] = "{$site_name}<{$emailsender}>"; |
|
366 | - $param['subject'] = $emailsubject; |
|
367 | - $param['body'] = $message; |
|
368 | - $param['to'] = $email; |
|
369 | - $param['type'] = 'text'; |
|
370 | - $rs = $modx->sendmail($param); |
|
371 | - if(!$rs) { |
|
372 | - $modx->manager->saveFormValues(); |
|
373 | - $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
374 | - } |
|
351 | + global $modx, $_lang, $websignupemail_message; |
|
352 | + global $emailsubject, $emailsender; |
|
353 | + global $site_name, $site_url; |
|
354 | + $message = sprintf($websignupemail_message, $uid, $pwd); // use old method |
|
355 | + // replace placeholders |
|
356 | + $message = str_replace("[+uid+]", $uid, $message); |
|
357 | + $message = str_replace("[+pwd+]", $pwd, $message); |
|
358 | + $message = str_replace("[+ufn+]", $ufn, $message); |
|
359 | + $message = str_replace("[+sname+]", $site_name, $message); |
|
360 | + $message = str_replace("[+saddr+]", $emailsender, $message); |
|
361 | + $message = str_replace("[+semail+]", $emailsender, $message); |
|
362 | + $message = str_replace("[+surl+]", $site_url, $message); |
|
363 | + |
|
364 | + $param = array(); |
|
365 | + $param['from'] = "{$site_name}<{$emailsender}>"; |
|
366 | + $param['subject'] = $emailsubject; |
|
367 | + $param['body'] = $message; |
|
368 | + $param['to'] = $email; |
|
369 | + $param['type'] = 'text'; |
|
370 | + $rs = $modx->sendmail($param); |
|
371 | + if(!$rs) { |
|
372 | + $modx->manager->saveFormValues(); |
|
373 | + $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
374 | + } |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | // Save User Settings |
378 | 378 | function saveUserSettings($id) { |
379 | - global $modx; |
|
380 | - $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
|
381 | - |
|
382 | - $settings = array( |
|
383 | - "login_home", |
|
384 | - "allowed_ip", |
|
385 | - "allowed_days" |
|
386 | - ); |
|
387 | - |
|
388 | - $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
|
389 | - |
|
390 | - foreach($settings as $n) { |
|
391 | - $vl = $_POST[$n]; |
|
392 | - if(is_array($vl)) { |
|
393 | - $vl = implode(",", $vl); |
|
394 | - } |
|
395 | - if($vl != '') { |
|
396 | - $f = array(); |
|
397 | - $f['webuser'] = $id; |
|
398 | - $f['setting_name'] = $n; |
|
399 | - $f['setting_value'] = $vl; |
|
400 | - $f = $modx->db->escape($f); |
|
401 | - $modx->db->insert($f, $tbl_web_user_settings); |
|
402 | - } |
|
403 | - } |
|
379 | + global $modx; |
|
380 | + $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
|
381 | + |
|
382 | + $settings = array( |
|
383 | + "login_home", |
|
384 | + "allowed_ip", |
|
385 | + "allowed_days" |
|
386 | + ); |
|
387 | + |
|
388 | + $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
|
389 | + |
|
390 | + foreach($settings as $n) { |
|
391 | + $vl = $_POST[$n]; |
|
392 | + if(is_array($vl)) { |
|
393 | + $vl = implode(",", $vl); |
|
394 | + } |
|
395 | + if($vl != '') { |
|
396 | + $f = array(); |
|
397 | + $f['webuser'] = $id; |
|
398 | + $f['setting_name'] = $n; |
|
399 | + $f['setting_value'] = $vl; |
|
400 | + $f = $modx->db->escape($f); |
|
401 | + $modx->db->insert($f, $tbl_web_user_settings); |
|
402 | + } |
|
403 | + } |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | // Web alert - sends an alert to web browser |
407 | 407 | function webAlertAndQuit($msg) { |
408 | - global $id, $modx; |
|
409 | - $mode = $_POST['mode']; |
|
410 | - $modx->manager->saveFormValues($mode); |
|
411 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
408 | + global $id, $modx; |
|
409 | + $mode = $_POST['mode']; |
|
410 | + $modx->manager->saveFormValues($mode); |
|
411 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | // Generate password |
415 | 415 | function generate_password($length = 10) { |
416 | - $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
417 | - $ps_len = strlen($allowable_characters); |
|
418 | - mt_srand((double) microtime() * 1000000); |
|
419 | - $pass = ""; |
|
420 | - for($i = 0; $i < $length; $i++) { |
|
421 | - $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
422 | - } |
|
423 | - return $pass; |
|
416 | + $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
417 | + $ps_len = strlen($allowable_characters); |
|
418 | + mt_srand((double) microtime() * 1000000); |
|
419 | + $pass = ""; |
|
420 | + for($i = 0; $i < $length; $i++) { |
|
421 | + $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
422 | + } |
|
423 | + return $pass; |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | function sanitize($str = '', $safecount = 0) { |
427 | - global $modx; |
|
428 | - $safecount++; |
|
429 | - if(1000 < $safecount) { |
|
430 | - exit("error too many loops '{$safecount}'"); |
|
431 | - } |
|
432 | - if(is_array($str)) { |
|
433 | - foreach($str as $i => $v) { |
|
434 | - $str[$i] = sanitize($v, $safecount); |
|
435 | - } |
|
436 | - } else { |
|
437 | - // $str = strip_tags($str); // LEAVE < and > intact |
|
438 | - $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
439 | - } |
|
440 | - return $str; |
|
427 | + global $modx; |
|
428 | + $safecount++; |
|
429 | + if(1000 < $safecount) { |
|
430 | + exit("error too many loops '{$safecount}'"); |
|
431 | + } |
|
432 | + if(is_array($str)) { |
|
433 | + foreach($str as $i => $v) { |
|
434 | + $str[$i] = sanitize($v, $safecount); |
|
435 | + } |
|
436 | + } else { |
|
437 | + // $str = strip_tags($str); // LEAVE < and > intact |
|
438 | + $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
439 | + } |
|
440 | + return $str; |
|
441 | 441 | } |
@@ -60,108 +60,108 @@ 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->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
66 | - $limit = $modx->db->getValue($rs); |
|
67 | - if($limit > 0) { |
|
68 | - webAlertAndQuit("User name is already in use!"); |
|
69 | - } |
|
70 | - |
|
71 | - // check if the email address already exist |
|
72 | - $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
73 | - $limit = $modx->db->getValue($rs); |
|
74 | - if($limit > 0) { |
|
75 | - webAlertAndQuit("Email is already in use!"); |
|
76 | - } |
|
63 | + case '87' : // new user |
|
64 | + // check if this user name already exist |
|
65 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
66 | + $limit = $modx->db->getValue($rs); |
|
67 | + if($limit > 0) { |
|
68 | + webAlertAndQuit("User name is already in use!"); |
|
69 | + } |
|
70 | + |
|
71 | + // check if the email address already exist |
|
72 | + $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
73 | + $limit = $modx->db->getValue($rs); |
|
74 | + if($limit > 0) { |
|
75 | + webAlertAndQuit("Email is already in use!"); |
|
76 | + } |
|
77 | + |
|
78 | + // generate a new password for this user |
|
79 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
80 | + if(strlen($specifiedpassword) < 6) { |
|
81 | + webAlertAndQuit("Password is too short!"); |
|
82 | + } else { |
|
83 | + $newpassword = $specifiedpassword; |
|
84 | + } |
|
85 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
86 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
87 | + } elseif($passwordgenmethod == 'g') { |
|
88 | + $newpassword = generate_password(8); |
|
89 | + } else { |
|
90 | + webAlertAndQuit("No password generation method specified!"); |
|
91 | + } |
|
92 | + |
|
93 | + // invoke OnBeforeWUsrFormSave event |
|
94 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
95 | + "mode" => "new", |
|
96 | + )); |
|
97 | + |
|
98 | + // create the user account |
|
99 | + $field = array(); |
|
100 | + $field['username'] = $esc_newusername; |
|
101 | + $field['password'] = md5($newpassword); |
|
102 | + $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
103 | + |
|
104 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
105 | + $field = $modx->db->escape($field); |
|
106 | + $modx->db->insert($field, $tbl_web_user_attributes); |
|
107 | + |
|
108 | + // Save User Settings |
|
109 | + saveUserSettings($internalKey); |
|
110 | + |
|
111 | + // Set the item name for logger |
|
112 | + $_SESSION['itemname'] = $newusername; |
|
113 | + |
|
114 | + /*******************************************************************************/ |
|
115 | + // put the user in the user_groups he/ she should be in |
|
116 | + // first, check that up_perms are switched on! |
|
117 | + if($use_udperms == 1) { |
|
118 | + if(!empty($user_groups)) { |
|
119 | + for($i = 0; $i < count($user_groups); $i++) { |
|
120 | + $f = array(); |
|
121 | + $f['webgroup'] = (int)$user_groups[$i]; |
|
122 | + $f['webuser'] = $internalKey; |
|
123 | + $modx->db->insert($f, $tbl_web_groups); |
|
124 | + } |
|
125 | + } |
|
126 | + } |
|
127 | + // end of user_groups stuff! |
|
128 | + |
|
129 | + // invoke OnWebSaveUser event |
|
130 | + $modx->invokeEvent("OnWebSaveUser", array( |
|
131 | + "mode" => "new", |
|
132 | + "userid" => $internalKey, |
|
133 | + "username" => $newusername, |
|
134 | + "userpassword" => $newpassword, |
|
135 | + "useremail" => $email, |
|
136 | + "userfullname" => $fullname |
|
137 | + )); |
|
77 | 138 | |
78 | - // generate a new password for this user |
|
79 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
80 | - if(strlen($specifiedpassword) < 6) { |
|
81 | - webAlertAndQuit("Password is too short!"); |
|
82 | - } else { |
|
83 | - $newpassword = $specifiedpassword; |
|
84 | - } |
|
85 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
86 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
87 | - } elseif($passwordgenmethod == 'g') { |
|
88 | - $newpassword = generate_password(8); |
|
89 | - } else { |
|
90 | - webAlertAndQuit("No password generation method specified!"); |
|
91 | - } |
|
139 | + // invoke OnWUsrFormSave event |
|
140 | + $modx->invokeEvent("OnWUsrFormSave", array( |
|
141 | + "mode" => "new", |
|
142 | + "id" => $internalKey |
|
143 | + )); |
|
92 | 144 | |
93 | - // invoke OnBeforeWUsrFormSave event |
|
94 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
95 | - "mode" => "new", |
|
96 | - )); |
|
97 | - |
|
98 | - // create the user account |
|
99 | - $field = array(); |
|
100 | - $field['username'] = $esc_newusername; |
|
101 | - $field['password'] = md5($newpassword); |
|
102 | - $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
103 | - |
|
104 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
105 | - $field = $modx->db->escape($field); |
|
106 | - $modx->db->insert($field, $tbl_web_user_attributes); |
|
107 | - |
|
108 | - // Save User Settings |
|
109 | - saveUserSettings($internalKey); |
|
110 | - |
|
111 | - // Set the item name for logger |
|
112 | - $_SESSION['itemname'] = $newusername; |
|
113 | - |
|
114 | - /*******************************************************************************/ |
|
115 | - // put the user in the user_groups he/ she should be in |
|
116 | - // first, check that up_perms are switched on! |
|
117 | - if($use_udperms == 1) { |
|
118 | - if(!empty($user_groups)) { |
|
119 | - for($i = 0; $i < count($user_groups); $i++) { |
|
120 | - $f = array(); |
|
121 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
122 | - $f['webuser'] = $internalKey; |
|
123 | - $modx->db->insert($f, $tbl_web_groups); |
|
124 | - } |
|
125 | - } |
|
126 | - } |
|
127 | - // end of user_groups stuff! |
|
128 | - |
|
129 | - // invoke OnWebSaveUser event |
|
130 | - $modx->invokeEvent("OnWebSaveUser", array( |
|
131 | - "mode" => "new", |
|
132 | - "userid" => $internalKey, |
|
133 | - "username" => $newusername, |
|
134 | - "userpassword" => $newpassword, |
|
135 | - "useremail" => $email, |
|
136 | - "userfullname" => $fullname |
|
137 | - )); |
|
138 | - |
|
139 | - // invoke OnWUsrFormSave event |
|
140 | - $modx->invokeEvent("OnWUsrFormSave", array( |
|
141 | - "mode" => "new", |
|
142 | - "id" => $internalKey |
|
143 | - )); |
|
144 | - |
|
145 | - if($passwordnotifymethod == 'e') { |
|
146 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
147 | - if($input['stay'] != '') { |
|
148 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
149 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
150 | - header($header); |
|
151 | - } else { |
|
152 | - $header = "Location: index.php?a=99&r=2"; |
|
153 | - header($header); |
|
154 | - } |
|
155 | - } else { |
|
156 | - if($input['stay'] != '') { |
|
157 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
158 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
159 | - } else { |
|
160 | - $stayUrl = "index.php?a=99&r=2"; |
|
161 | - } |
|
162 | - |
|
163 | - include_once "header.inc.php"; |
|
164 | - ?> |
|
145 | + if($passwordnotifymethod == 'e') { |
|
146 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
147 | + if($input['stay'] != '') { |
|
148 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
149 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
150 | + header($header); |
|
151 | + } else { |
|
152 | + $header = "Location: index.php?a=99&r=2"; |
|
153 | + header($header); |
|
154 | + } |
|
155 | + } else { |
|
156 | + if($input['stay'] != '') { |
|
157 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
158 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
159 | + } else { |
|
160 | + $stayUrl = "index.php?a=99&r=2"; |
|
161 | + } |
|
162 | + |
|
163 | + include_once "header.inc.php"; |
|
164 | + ?> |
|
165 | 165 | |
166 | 166 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
167 | 167 | |
@@ -183,122 +183,122 @@ discard block |
||
183 | 183 | </div> |
184 | 184 | <?php |
185 | 185 | |
186 | - include_once "footer.inc.php"; |
|
187 | - } |
|
188 | - break; |
|
189 | - case '88' : // edit user |
|
190 | - // generate a new password for this user |
|
191 | - if($genpassword == 1) { |
|
192 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
193 | - if(strlen($specifiedpassword) < 6) { |
|
194 | - webAlertAndQuit("Password is too short!"); |
|
195 | - } else { |
|
196 | - $newpassword = $specifiedpassword; |
|
197 | - } |
|
198 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
199 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
200 | - } elseif($passwordgenmethod == 'g') { |
|
201 | - $newpassword = generate_password(8); |
|
202 | - } else { |
|
203 | - webAlertAndQuit("No password generation method specified!"); |
|
204 | - } |
|
205 | - } |
|
206 | - if($passwordnotifymethod == 'e') { |
|
207 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
208 | - } |
|
209 | - |
|
210 | - // check if the username already exist |
|
211 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
212 | - $limit = $modx->db->getValue($rs); |
|
213 | - if($limit > 0) { |
|
214 | - webAlertAndQuit("User name is already in use!"); |
|
215 | - } |
|
216 | - |
|
217 | - // check if the email address already exists |
|
218 | - $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
219 | - $limit = $modx->db->getValue($rs); |
|
220 | - if($limit > 0) { |
|
221 | - webAlertAndQuit("Email is already in use!"); |
|
222 | - } |
|
223 | - |
|
224 | - // invoke OnBeforeWUsrFormSave event |
|
225 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
226 | - "mode" => "upd", |
|
227 | - "id" => $id |
|
228 | - )); |
|
229 | - |
|
230 | - // update user name and password |
|
231 | - $field = array(); |
|
232 | - $field['username'] = $esc_newusername; |
|
233 | - if($genpassword == 1) { |
|
234 | - $field['password'] = md5($newpassword); |
|
235 | - } |
|
236 | - $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
237 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
238 | - $field = $modx->db->escape($field); |
|
239 | - $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
240 | - |
|
241 | - // Save User Settings |
|
242 | - saveUserSettings($id); |
|
243 | - |
|
244 | - // Set the item name for logger |
|
245 | - $_SESSION['itemname'] = $newusername; |
|
246 | - |
|
247 | - /*******************************************************************************/ |
|
248 | - // put the user in the user_groups he/ she should be in |
|
249 | - // first, check that up_perms are switched on! |
|
250 | - if($use_udperms == 1) { |
|
251 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
252 | - $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
253 | - if(!empty($user_groups)) { |
|
254 | - for($i = 0; $i < count($user_groups); $i++) { |
|
255 | - $field = array(); |
|
256 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
257 | - $field['webuser'] = $id; |
|
258 | - $modx->db->insert($field, $tbl_web_groups); |
|
259 | - } |
|
260 | - } |
|
261 | - } |
|
262 | - // end of user_groups stuff! |
|
263 | - /*******************************************************************************/ |
|
264 | - |
|
265 | - // invoke OnWebSaveUser event |
|
266 | - $modx->invokeEvent("OnWebSaveUser", array( |
|
267 | - "mode" => "upd", |
|
268 | - "userid" => $id, |
|
269 | - "username" => $newusername, |
|
270 | - "userpassword" => $newpassword, |
|
271 | - "useremail" => $email, |
|
272 | - "userfullname" => $fullname, |
|
273 | - "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
274 | - "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
275 | - )); |
|
276 | - |
|
277 | - // invoke OnWebChangePassword event |
|
278 | - if($genpassword == 1) { |
|
279 | - $modx->invokeEvent("OnWebChangePassword", array( |
|
186 | + include_once "footer.inc.php"; |
|
187 | + } |
|
188 | + break; |
|
189 | + case '88' : // edit user |
|
190 | + // generate a new password for this user |
|
191 | + if($genpassword == 1) { |
|
192 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
193 | + if(strlen($specifiedpassword) < 6) { |
|
194 | + webAlertAndQuit("Password is too short!"); |
|
195 | + } else { |
|
196 | + $newpassword = $specifiedpassword; |
|
197 | + } |
|
198 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
199 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
200 | + } elseif($passwordgenmethod == 'g') { |
|
201 | + $newpassword = generate_password(8); |
|
202 | + } else { |
|
203 | + webAlertAndQuit("No password generation method specified!"); |
|
204 | + } |
|
205 | + } |
|
206 | + if($passwordnotifymethod == 'e') { |
|
207 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
208 | + } |
|
209 | + |
|
210 | + // check if the username already exist |
|
211 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
212 | + $limit = $modx->db->getValue($rs); |
|
213 | + if($limit > 0) { |
|
214 | + webAlertAndQuit("User name is already in use!"); |
|
215 | + } |
|
216 | + |
|
217 | + // check if the email address already exists |
|
218 | + $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
219 | + $limit = $modx->db->getValue($rs); |
|
220 | + if($limit > 0) { |
|
221 | + webAlertAndQuit("Email is already in use!"); |
|
222 | + } |
|
223 | + |
|
224 | + // invoke OnBeforeWUsrFormSave event |
|
225 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
226 | + "mode" => "upd", |
|
227 | + "id" => $id |
|
228 | + )); |
|
229 | + |
|
230 | + // update user name and password |
|
231 | + $field = array(); |
|
232 | + $field['username'] = $esc_newusername; |
|
233 | + if($genpassword == 1) { |
|
234 | + $field['password'] = md5($newpassword); |
|
235 | + } |
|
236 | + $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
237 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
238 | + $field = $modx->db->escape($field); |
|
239 | + $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
240 | + |
|
241 | + // Save User Settings |
|
242 | + saveUserSettings($id); |
|
243 | + |
|
244 | + // Set the item name for logger |
|
245 | + $_SESSION['itemname'] = $newusername; |
|
246 | + |
|
247 | + /*******************************************************************************/ |
|
248 | + // put the user in the user_groups he/ she should be in |
|
249 | + // first, check that up_perms are switched on! |
|
250 | + if($use_udperms == 1) { |
|
251 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
252 | + $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
253 | + if(!empty($user_groups)) { |
|
254 | + for($i = 0; $i < count($user_groups); $i++) { |
|
255 | + $field = array(); |
|
256 | + $field['webgroup'] = (int)$user_groups[$i]; |
|
257 | + $field['webuser'] = $id; |
|
258 | + $modx->db->insert($field, $tbl_web_groups); |
|
259 | + } |
|
260 | + } |
|
261 | + } |
|
262 | + // end of user_groups stuff! |
|
263 | + /*******************************************************************************/ |
|
264 | + |
|
265 | + // invoke OnWebSaveUser event |
|
266 | + $modx->invokeEvent("OnWebSaveUser", array( |
|
267 | + "mode" => "upd", |
|
280 | 268 | "userid" => $id, |
281 | 269 | "username" => $newusername, |
282 | - "userpassword" => $newpassword |
|
270 | + "userpassword" => $newpassword, |
|
271 | + "useremail" => $email, |
|
272 | + "userfullname" => $fullname, |
|
273 | + "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
274 | + "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
283 | 275 | )); |
284 | - } |
|
285 | 276 | |
286 | - // invoke OnWUsrFormSave event |
|
287 | - $modx->invokeEvent("OnWUsrFormSave", array( |
|
288 | - "mode" => "upd", |
|
289 | - "id" => $id |
|
290 | - )); |
|
277 | + // invoke OnWebChangePassword event |
|
278 | + if($genpassword == 1) { |
|
279 | + $modx->invokeEvent("OnWebChangePassword", array( |
|
280 | + "userid" => $id, |
|
281 | + "username" => $newusername, |
|
282 | + "userpassword" => $newpassword |
|
283 | + )); |
|
284 | + } |
|
285 | + |
|
286 | + // invoke OnWUsrFormSave event |
|
287 | + $modx->invokeEvent("OnWUsrFormSave", array( |
|
288 | + "mode" => "upd", |
|
289 | + "id" => $id |
|
290 | + )); |
|
291 | 291 | |
292 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
293 | - if($input['stay'] != '') { |
|
294 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
295 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
296 | - } else { |
|
297 | - $stayUrl = "index.php?a=99&r=2"; |
|
298 | - } |
|
292 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
293 | + if($input['stay'] != '') { |
|
294 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
295 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
296 | + } else { |
|
297 | + $stayUrl = "index.php?a=99&r=2"; |
|
298 | + } |
|
299 | 299 | |
300 | - include_once "header.inc.php"; |
|
301 | - ?> |
|
300 | + include_once "header.inc.php"; |
|
301 | + ?> |
|
302 | 302 | |
303 | 303 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
304 | 304 | |
@@ -318,20 +318,20 @@ discard block |
||
318 | 318 | </div> |
319 | 319 | <?php |
320 | 320 | |
321 | - include_once "footer.inc.php"; |
|
322 | - } else { |
|
323 | - if($input['stay'] != '') { |
|
324 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
325 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
326 | - header($header); |
|
327 | - } else { |
|
328 | - $header = "Location: index.php?a=99&r=2"; |
|
329 | - header($header); |
|
330 | - } |
|
331 | - } |
|
332 | - break; |
|
333 | - default : |
|
334 | - webAlertAndQuit("No operation set in request."); |
|
321 | + include_once "footer.inc.php"; |
|
322 | + } else { |
|
323 | + if($input['stay'] != '') { |
|
324 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
325 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
326 | + header($header); |
|
327 | + } else { |
|
328 | + $header = "Location: index.php?a=99&r=2"; |
|
329 | + header($header); |
|
330 | + } |
|
331 | + } |
|
332 | + break; |
|
333 | + default : |
|
334 | + webAlertAndQuit("No operation set in request."); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | // in case any plugins include a quoted_printable function |
@@ -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->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 = sanitize($v); |
17 | 17 | } |
18 | 18 | $input[$k] = $v; |
19 | 19 | } |
20 | 20 | |
21 | -$id = (int)$input['id']; |
|
21 | +$id = (int) $input['id']; |
|
22 | 22 | $oldusername = $input['oldusername']; |
23 | 23 | $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User"; |
24 | 24 | $esc_newusername = $modx->db->escape($newusername); |
@@ -50,41 +50,41 @@ 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"); |
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!"); |
60 | 60 | } |
61 | 61 | |
62 | -switch($input['mode']) { |
|
62 | +switch ($input['mode']) { |
|
63 | 63 | case '87' : // new user |
64 | 64 | // check if this user name already exist |
65 | 65 | $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
66 | 66 | $limit = $modx->db->getValue($rs); |
67 | - if($limit > 0) { |
|
67 | + if ($limit > 0) { |
|
68 | 68 | webAlertAndQuit("User name is already in use!"); |
69 | 69 | } |
70 | 70 | |
71 | 71 | // check if the email address already exist |
72 | 72 | $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
73 | 73 | $limit = $modx->db->getValue($rs); |
74 | - if($limit > 0) { |
|
74 | + if ($limit > 0) { |
|
75 | 75 | webAlertAndQuit("Email is already in use!"); |
76 | 76 | } |
77 | 77 | |
78 | 78 | // generate a new password for this user |
79 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
80 | - if(strlen($specifiedpassword) < 6) { |
|
79 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
80 | + if (strlen($specifiedpassword) < 6) { |
|
81 | 81 | webAlertAndQuit("Password is too short!"); |
82 | 82 | } else { |
83 | 83 | $newpassword = $specifiedpassword; |
84 | 84 | } |
85 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
85 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
86 | 86 | webAlertAndQuit("You didn't specify a password for this user!"); |
87 | - } elseif($passwordgenmethod == 'g') { |
|
87 | + } elseif ($passwordgenmethod == 'g') { |
|
88 | 88 | $newpassword = generate_password(8); |
89 | 89 | } else { |
90 | 90 | webAlertAndQuit("No password generation method specified!"); |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | /*******************************************************************************/ |
115 | 115 | // put the user in the user_groups he/ she should be in |
116 | 116 | // first, check that up_perms are switched on! |
117 | - if($use_udperms == 1) { |
|
118 | - if(!empty($user_groups)) { |
|
119 | - for($i = 0; $i < count($user_groups); $i++) { |
|
117 | + if ($use_udperms == 1) { |
|
118 | + if (!empty($user_groups)) { |
|
119 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
120 | 120 | $f = array(); |
121 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
121 | + $f['webgroup'] = (int) $user_groups[$i]; |
|
122 | 122 | $f['webuser'] = $internalKey; |
123 | 123 | $modx->db->insert($f, $tbl_web_groups); |
124 | 124 | } |
@@ -142,20 +142,20 @@ discard block |
||
142 | 142 | "id" => $internalKey |
143 | 143 | )); |
144 | 144 | |
145 | - if($passwordnotifymethod == 'e') { |
|
145 | + if ($passwordnotifymethod == 'e') { |
|
146 | 146 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
147 | - if($input['stay'] != '') { |
|
147 | + if ($input['stay'] != '') { |
|
148 | 148 | $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
149 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
149 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
150 | 150 | header($header); |
151 | 151 | } else { |
152 | 152 | $header = "Location: index.php?a=99&r=2"; |
153 | 153 | header($header); |
154 | 154 | } |
155 | 155 | } else { |
156 | - if($input['stay'] != '') { |
|
156 | + if ($input['stay'] != '') { |
|
157 | 157 | $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
158 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
158 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
159 | 159 | } else { |
160 | 160 | $stayUrl = "index.php?a=99&r=2"; |
161 | 161 | } |
@@ -188,36 +188,36 @@ discard block |
||
188 | 188 | break; |
189 | 189 | case '88' : // edit user |
190 | 190 | // generate a new password for this user |
191 | - if($genpassword == 1) { |
|
192 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
193 | - if(strlen($specifiedpassword) < 6) { |
|
191 | + if ($genpassword == 1) { |
|
192 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
193 | + if (strlen($specifiedpassword) < 6) { |
|
194 | 194 | webAlertAndQuit("Password is too short!"); |
195 | 195 | } else { |
196 | 196 | $newpassword = $specifiedpassword; |
197 | 197 | } |
198 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
198 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
199 | 199 | webAlertAndQuit("You didn't specify a password for this user!"); |
200 | - } elseif($passwordgenmethod == 'g') { |
|
200 | + } elseif ($passwordgenmethod == 'g') { |
|
201 | 201 | $newpassword = generate_password(8); |
202 | 202 | } else { |
203 | 203 | webAlertAndQuit("No password generation method specified!"); |
204 | 204 | } |
205 | 205 | } |
206 | - if($passwordnotifymethod == 'e') { |
|
206 | + if ($passwordnotifymethod == 'e') { |
|
207 | 207 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
208 | 208 | } |
209 | 209 | |
210 | 210 | // check if the username already exist |
211 | 211 | $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
212 | 212 | $limit = $modx->db->getValue($rs); |
213 | - if($limit > 0) { |
|
213 | + if ($limit > 0) { |
|
214 | 214 | webAlertAndQuit("User name is already in use!"); |
215 | 215 | } |
216 | 216 | |
217 | 217 | // check if the email address already exists |
218 | 218 | $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
219 | 219 | $limit = $modx->db->getValue($rs); |
220 | - if($limit > 0) { |
|
220 | + if ($limit > 0) { |
|
221 | 221 | webAlertAndQuit("Email is already in use!"); |
222 | 222 | } |
223 | 223 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | // update user name and password |
231 | 231 | $field = array(); |
232 | 232 | $field['username'] = $esc_newusername; |
233 | - if($genpassword == 1) { |
|
233 | + if ($genpassword == 1) { |
|
234 | 234 | $field['password'] = md5($newpassword); |
235 | 235 | } |
236 | 236 | $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
@@ -247,13 +247,13 @@ discard block |
||
247 | 247 | /*******************************************************************************/ |
248 | 248 | // put the user in the user_groups he/ she should be in |
249 | 249 | // first, check that up_perms are switched on! |
250 | - if($use_udperms == 1) { |
|
250 | + if ($use_udperms == 1) { |
|
251 | 251 | // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
252 | 252 | $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
253 | - if(!empty($user_groups)) { |
|
254 | - for($i = 0; $i < count($user_groups); $i++) { |
|
253 | + if (!empty($user_groups)) { |
|
254 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
255 | 255 | $field = array(); |
256 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
256 | + $field['webgroup'] = (int) $user_groups[$i]; |
|
257 | 257 | $field['webuser'] = $id; |
258 | 258 | $modx->db->insert($field, $tbl_web_groups); |
259 | 259 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | )); |
276 | 276 | |
277 | 277 | // invoke OnWebChangePassword event |
278 | - if($genpassword == 1) { |
|
278 | + if ($genpassword == 1) { |
|
279 | 279 | $modx->invokeEvent("OnWebChangePassword", array( |
280 | 280 | "userid" => $id, |
281 | 281 | "username" => $newusername, |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | "id" => $id |
290 | 290 | )); |
291 | 291 | |
292 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
293 | - if($input['stay'] != '') { |
|
292 | + if ($genpassword == 1 && $passwordnotifymethod == 's') { |
|
293 | + if ($input['stay'] != '') { |
|
294 | 294 | $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
295 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
295 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
296 | 296 | } else { |
297 | 297 | $stayUrl = "index.php?a=99&r=2"; |
298 | 298 | } |
@@ -320,9 +320,9 @@ discard block |
||
320 | 320 | |
321 | 321 | include_once "footer.inc.php"; |
322 | 322 | } else { |
323 | - if($input['stay'] != '') { |
|
323 | + if ($input['stay'] != '') { |
|
324 | 324 | $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
325 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
325 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
326 | 326 | header($header); |
327 | 327 | } else { |
328 | 328 | $header = "Location: index.php?a=99&r=2"; |
@@ -335,19 +335,19 @@ discard block |
||
335 | 335 | } |
336 | 336 | |
337 | 337 | // in case any plugins include a quoted_printable function |
338 | -function save_user_quoted_printable($string) { |
|
338 | +function save_user_quoted_printable($string){ |
|
339 | 339 | $crlf = "\n"; |
340 | - $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
340 | + $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string).$crlf; |
|
341 | 341 | $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
342 | 342 | $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
343 | - $f[] = '/([\011\040])' . $crlf . '/e'; |
|
344 | - $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
343 | + $f[] = '/([\011\040])'.$crlf.'/e'; |
|
344 | + $r[] = "'=' . sprintf('%02X', ord('\\1')) . '".$crlf."'"; |
|
345 | 345 | $string = preg_replace($f, $r, $string); |
346 | - return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
346 | + return trim(wordwrap($string, 70, ' ='.$crlf)); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | // Send an email to the user |
350 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
350 | +function sendMailMessage($email, $uid, $pwd, $ufn){ |
|
351 | 351 | global $modx, $_lang, $websignupemail_message; |
352 | 352 | global $emailsubject, $emailsender; |
353 | 353 | global $site_name, $site_url; |
@@ -368,14 +368,14 @@ discard block |
||
368 | 368 | $param['to'] = $email; |
369 | 369 | $param['type'] = 'text'; |
370 | 370 | $rs = $modx->sendmail($param); |
371 | - if(!$rs) { |
|
371 | + if (!$rs) { |
|
372 | 372 | $modx->manager->saveFormValues(); |
373 | 373 | $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
377 | 377 | // Save User Settings |
378 | -function saveUserSettings($id) { |
|
378 | +function saveUserSettings($id){ |
|
379 | 379 | global $modx; |
380 | 380 | $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
381 | 381 | |
@@ -387,12 +387,12 @@ discard block |
||
387 | 387 | |
388 | 388 | $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
389 | 389 | |
390 | - foreach($settings as $n) { |
|
390 | + foreach ($settings as $n) { |
|
391 | 391 | $vl = $_POST[$n]; |
392 | - if(is_array($vl)) { |
|
392 | + if (is_array($vl)) { |
|
393 | 393 | $vl = implode(",", $vl); |
394 | 394 | } |
395 | - if($vl != '') { |
|
395 | + if ($vl != '') { |
|
396 | 396 | $f = array(); |
397 | 397 | $f['webuser'] = $id; |
398 | 398 | $f['setting_name'] = $n; |
@@ -404,33 +404,33 @@ discard block |
||
404 | 404 | } |
405 | 405 | |
406 | 406 | // Web alert - sends an alert to web browser |
407 | -function webAlertAndQuit($msg) { |
|
407 | +function webAlertAndQuit($msg){ |
|
408 | 408 | global $id, $modx; |
409 | 409 | $mode = $_POST['mode']; |
410 | 410 | $modx->manager->saveFormValues($mode); |
411 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
411 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '88' ? "&id={$id}" : '')); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | // Generate password |
415 | -function generate_password($length = 10) { |
|
415 | +function generate_password($length = 10){ |
|
416 | 416 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
417 | 417 | $ps_len = strlen($allowable_characters); |
418 | 418 | mt_srand((double) microtime() * 1000000); |
419 | 419 | $pass = ""; |
420 | - for($i = 0; $i < $length; $i++) { |
|
420 | + for ($i = 0; $i < $length; $i++) { |
|
421 | 421 | $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
422 | 422 | } |
423 | 423 | return $pass; |
424 | 424 | } |
425 | 425 | |
426 | -function sanitize($str = '', $safecount = 0) { |
|
426 | +function sanitize($str = '', $safecount = 0){ |
|
427 | 427 | global $modx; |
428 | 428 | $safecount++; |
429 | - if(1000 < $safecount) { |
|
429 | + if (1000 < $safecount) { |
|
430 | 430 | exit("error too many loops '{$safecount}'"); |
431 | 431 | } |
432 | - if(is_array($str)) { |
|
433 | - foreach($str as $i => $v) { |
|
432 | + if (is_array($str)) { |
|
433 | + foreach ($str as $i => $v) { |
|
434 | 434 | $str[$i] = sanitize($v, $safecount); |
435 | 435 | } |
436 | 436 | } else { |
@@ -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->db->escape(trim($_POST['name'])); |
11 | 11 | $description = $modx->db->escape($_POST['description']); |
12 | 12 | $resourcefile = $modx->db->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); |
@@ -9,34 +9,34 @@ discard block |
||
9 | 9 | |
10 | 10 | public function checkPermissions() { |
11 | 11 | |
12 | - global $udperms_allowroot; |
|
13 | - global $modx; |
|
12 | + global $udperms_allowroot; |
|
13 | + global $modx; |
|
14 | 14 | |
15 | - $tblsc = $modx->getFullTableName('site_content'); |
|
16 | - $tbldg = $modx->getFullTableName('document_groups'); |
|
17 | - $tbldgn = $modx->getFullTableName('documentgroup_names'); |
|
15 | + $tblsc = $modx->getFullTableName('site_content'); |
|
16 | + $tbldg = $modx->getFullTableName('document_groups'); |
|
17 | + $tbldgn = $modx->getFullTableName('documentgroup_names'); |
|
18 | 18 | |
19 | - $document = $this->document; |
|
20 | - $role = $this->role; |
|
19 | + $document = $this->document; |
|
20 | + $role = $this->role; |
|
21 | 21 | |
22 | - if($role==1) { |
|
23 | - return true; // administrator - grant all document permissions |
|
24 | - } |
|
22 | + if($role==1) { |
|
23 | + return true; // administrator - grant all document permissions |
|
24 | + } |
|
25 | 25 | |
26 | - if($modx->config['use_udperms']==0 || $modx->config['use_udperms']=="" || !isset($modx->config['use_udperms'])) { |
|
27 | - return true; // permissions aren't in use |
|
28 | - } |
|
26 | + if($modx->config['use_udperms']==0 || $modx->config['use_udperms']=="" || !isset($modx->config['use_udperms'])) { |
|
27 | + return true; // permissions aren't in use |
|
28 | + } |
|
29 | 29 | |
30 | - $parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'")); |
|
31 | - if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
32 | - if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) { |
|
33 | - return false; // deny duplicate || create new document at root if Allow Root is No |
|
34 | - } |
|
30 | + $parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'")); |
|
31 | + if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
32 | + if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) { |
|
33 | + return false; // deny duplicate || create new document at root if Allow Root is No |
|
34 | + } |
|
35 | 35 | |
36 | - // get document groups for current user |
|
36 | + // get document groups for current user |
|
37 | 37 | $docgrp = empty($_SESSION['mgrDocgroups']) ? '' : implode(' || dg.document_group = ', $_SESSION['mgrDocgroups']); |
38 | 38 | |
39 | - /* Note: |
|
39 | + /* Note: |
|
40 | 40 | A document is flagged as private whenever the document group that it |
41 | 41 | belongs to is assigned or links to a user group. In other words if |
42 | 42 | the document is assigned to a document group that is not yet linked |
@@ -44,18 +44,18 @@ discard block |
||
44 | 44 | are private to the manager users will not be private to web users if the |
45 | 45 | document group is not assigned to a web user group and visa versa. |
46 | 46 | */ |
47 | - $permissionsok = false; // set permissions to false |
|
47 | + $permissionsok = false; // set permissions to false |
|
48 | 48 | |
49 | - $rs = $modx->db->select( |
|
50 | - 'count(DISTINCT sc.id)', |
|
51 | - "{$tblsc} AS sc |
|
49 | + $rs = $modx->db->select( |
|
50 | + 'count(DISTINCT sc.id)', |
|
51 | + "{$tblsc} AS sc |
|
52 | 52 | LEFT JOIN {$tbldg} AS dg on dg.document = sc.id |
53 | 53 | LEFT JOIN {$tbldgn} dgn ON dgn.id = dg.document_group", |
54 | - "sc.id='{$this->document}' AND (". (empty($docgrp) ? '' : "dg.document_group = ".$docgrp." ||" ) . " sc.privatemgr = 0)" |
|
55 | - ); |
|
56 | - $limit = $modx->db->getValue($rs); |
|
57 | - if($limit==1) $permissionsok = true; |
|
54 | + "sc.id='{$this->document}' AND (". (empty($docgrp) ? '' : "dg.document_group = ".$docgrp." ||" ) . " sc.privatemgr = 0)" |
|
55 | + ); |
|
56 | + $limit = $modx->db->getValue($rs); |
|
57 | + if($limit==1) $permissionsok = true; |
|
58 | 58 | |
59 | - return $permissionsok; |
|
60 | - } |
|
59 | + return $permissionsok; |
|
60 | + } |
|
61 | 61 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | public $role; |
8 | 8 | public $duplicateDoc = false; |
9 | 9 | |
10 | - public function checkPermissions() { |
|
10 | + public function checkPermissions(){ |
|
11 | 11 | |
12 | 12 | global $udperms_allowroot; |
13 | 13 | global $modx; |
@@ -19,17 +19,17 @@ discard block |
||
19 | 19 | $document = $this->document; |
20 | 20 | $role = $this->role; |
21 | 21 | |
22 | - if($role==1) { |
|
23 | - return true; // administrator - grant all document permissions |
|
22 | + if ($role == 1) { |
|
23 | + return true; // administrator - grant all document permissions |
|
24 | 24 | } |
25 | 25 | |
26 | - if($modx->config['use_udperms']==0 || $modx->config['use_udperms']=="" || !isset($modx->config['use_udperms'])) { |
|
26 | + if ($modx->config['use_udperms'] == 0 || $modx->config['use_udperms'] == "" || !isset($modx->config['use_udperms'])) { |
|
27 | 27 | return true; // permissions aren't in use |
28 | 28 | } |
29 | 29 | |
30 | 30 | $parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'")); |
31 | - if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
32 | - if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) { |
|
31 | + if ($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
32 | + if (($this->duplicateDoc == true || $document == 0) && $parent == 0 && $udperms_allowroot == 0) { |
|
33 | 33 | return false; // deny duplicate || create new document at root if Allow Root is No |
34 | 34 | } |
35 | 35 | |
@@ -44,17 +44,17 @@ discard block |
||
44 | 44 | are private to the manager users will not be private to web users if the |
45 | 45 | document group is not assigned to a web user group and visa versa. |
46 | 46 | */ |
47 | - $permissionsok = false; // set permissions to false |
|
47 | + $permissionsok = false; // set permissions to false |
|
48 | 48 | |
49 | 49 | $rs = $modx->db->select( |
50 | 50 | 'count(DISTINCT sc.id)', |
51 | 51 | "{$tblsc} AS sc |
52 | 52 | LEFT JOIN {$tbldg} AS dg on dg.document = sc.id |
53 | 53 | LEFT JOIN {$tbldgn} dgn ON dgn.id = dg.document_group", |
54 | - "sc.id='{$this->document}' AND (". (empty($docgrp) ? '' : "dg.document_group = ".$docgrp." ||" ) . " sc.privatemgr = 0)" |
|
54 | + "sc.id='{$this->document}' AND (".(empty($docgrp) ? '' : "dg.document_group = ".$docgrp." ||")." sc.privatemgr = 0)" |
|
55 | 55 | ); |
56 | 56 | $limit = $modx->db->getValue($rs); |
57 | - if($limit==1) $permissionsok = true; |
|
57 | + if ($limit == 1) $permissionsok = true; |
|
58 | 58 | |
59 | 59 | return $permissionsok; |
60 | 60 | } |
@@ -1,13 +1,15 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class udperms{ |
|
3 | +class udperms |
|
4 | +{ |
|
4 | 5 | |
5 | 6 | public $user; |
6 | 7 | public $document; |
7 | 8 | public $role; |
8 | 9 | public $duplicateDoc = false; |
9 | 10 | |
10 | - public function checkPermissions() { |
|
11 | + public function checkPermissions() |
|
12 | + { |
|
11 | 13 | |
12 | 14 | global $udperms_allowroot; |
13 | 15 | global $modx; |
@@ -28,7 +30,10 @@ discard block |
||
28 | 30 | } |
29 | 31 | |
30 | 32 | $parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'")); |
31 | - if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
33 | + if($document == 0 && $parent == NULL && $udperms_allowroot == 1) { |
|
34 | + return true; |
|
35 | + } |
|
36 | + // User is allowed to create new document in root |
|
32 | 37 | if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) { |
33 | 38 | return false; // deny duplicate || create new document at root if Allow Root is No |
34 | 39 | } |
@@ -54,7 +59,9 @@ discard block |
||
54 | 59 | "sc.id='{$this->document}' AND (". (empty($docgrp) ? '' : "dg.document_group = ".$docgrp." ||" ) . " sc.privatemgr = 0)" |
55 | 60 | ); |
56 | 61 | $limit = $modx->db->getValue($rs); |
57 | - if($limit==1) $permissionsok = true; |
|
62 | + if($limit==1) { |
|
63 | + $permissionsok = true; |
|
64 | + } |
|
58 | 65 | |
59 | 66 | return $permissionsok; |
60 | 67 | } |
@@ -3,21 +3,21 @@ 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('new_module')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
10 | 10 | if($id==0) { |
11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | // create globally unique identifiers (guid) |
15 | 15 | function createGUID(){ |
16 | - srand((double)microtime()*1000000); |
|
17 | - $r = rand() ; |
|
18 | - $u = uniqid(getmypid() . $r . (double)microtime()*1000000,1); |
|
19 | - $m = md5 ($u); |
|
20 | - return $m; |
|
16 | + srand((double)microtime()*1000000); |
|
17 | + $r = rand() ; |
|
18 | + $u = uniqid(getmypid() . $r . (double)microtime()*1000000,1); |
|
19 | + $m = md5 ($u); |
|
20 | + return $m; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | // count duplicates |
@@ -28,40 +28,40 @@ discard block |
||
28 | 28 | |
29 | 29 | // duplicate module |
30 | 30 | $newid = $modx->db->insert( |
31 | - array( |
|
32 | - 'name'=>'', |
|
33 | - 'description'=>'', |
|
34 | - 'disabled'=>'', |
|
35 | - 'category'=>'', |
|
36 | - 'wrap'=>'', |
|
37 | - 'icon'=>'', |
|
38 | - 'enable_resource'=>'', |
|
39 | - 'resourcefile'=>'', |
|
40 | - 'createdon'=>'', |
|
41 | - 'editedon'=>'', |
|
42 | - 'guid'=>'', |
|
43 | - 'enable_sharedparams'=>'', |
|
44 | - 'properties'=>'', |
|
45 | - 'modulecode'=>'', |
|
46 | - ), $modx->getFullTableName('site_modules'), // Insert into |
|
47 | - "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, category, wrap, icon, enable_resource, resourcefile, createdon, editedon, '".createGUID()."' AS guid, enable_sharedparams, properties, modulecode", $modx->getFullTableName('site_modules'), "id='{$id}'"); // Copy from |
|
31 | + array( |
|
32 | + 'name'=>'', |
|
33 | + 'description'=>'', |
|
34 | + 'disabled'=>'', |
|
35 | + 'category'=>'', |
|
36 | + 'wrap'=>'', |
|
37 | + 'icon'=>'', |
|
38 | + 'enable_resource'=>'', |
|
39 | + 'resourcefile'=>'', |
|
40 | + 'createdon'=>'', |
|
41 | + 'editedon'=>'', |
|
42 | + 'guid'=>'', |
|
43 | + 'enable_sharedparams'=>'', |
|
44 | + 'properties'=>'', |
|
45 | + 'modulecode'=>'', |
|
46 | + ), $modx->getFullTableName('site_modules'), // Insert into |
|
47 | + "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, category, wrap, icon, enable_resource, resourcefile, createdon, editedon, '".createGUID()."' AS guid, enable_sharedparams, properties, modulecode", $modx->getFullTableName('site_modules'), "id='{$id}'"); // Copy from |
|
48 | 48 | |
49 | 49 | // duplicate module dependencies |
50 | 50 | $modx->db->insert( |
51 | - array( |
|
52 | - 'module'=>'', |
|
53 | - 'resource'=>'', |
|
54 | - 'type'=>'', |
|
55 | - ), $modx->getFullTableName('site_module_depobj'), // Insert into |
|
56 | - "'{$newid}', resource, type", $modx->getFullTableName('site_module_depobj'), "module='{$id}'"); // Copy from |
|
51 | + array( |
|
52 | + 'module'=>'', |
|
53 | + 'resource'=>'', |
|
54 | + 'type'=>'', |
|
55 | + ), $modx->getFullTableName('site_module_depobj'), // Insert into |
|
56 | + "'{$newid}', resource, type", $modx->getFullTableName('site_module_depobj'), "module='{$id}'"); // Copy from |
|
57 | 57 | |
58 | 58 | // duplicate module user group access |
59 | 59 | $modx->db->insert( |
60 | - array( |
|
61 | - 'module'=>'', |
|
62 | - 'usergroup'=>'', |
|
63 | - ), $modx->getFullTableName('site_module_access'), // Insert into |
|
64 | - "'{$newid}', usergroup", $modx->getFullTableName('site_module_access'), "module='{$id}'"); // Copy from |
|
60 | + array( |
|
61 | + 'module'=>'', |
|
62 | + 'usergroup'=>'', |
|
63 | + ), $modx->getFullTableName('site_module_access'), // Insert into |
|
64 | + "'{$newid}', usergroup", $modx->getFullTableName('site_module_access'), "module='{$id}'"); // Copy from |
|
65 | 65 | |
66 | 66 | // Set the item name for logger |
67 | 67 | $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_modules'), "id='{$newid}'")); |
@@ -1,29 +1,29 @@ 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('new_module')) { |
|
5 | +if (!$modx->hasPermission('new_module')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
10 | -if($id==0) { |
|
9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
14 | 14 | // create globally unique identifiers (guid) |
15 | 15 | function createGUID(){ |
16 | - srand((double)microtime()*1000000); |
|
17 | - $r = rand() ; |
|
18 | - $u = uniqid(getmypid() . $r . (double)microtime()*1000000,1); |
|
19 | - $m = md5 ($u); |
|
16 | + srand((double) microtime() * 1000000); |
|
17 | + $r = rand(); |
|
18 | + $u = uniqid(getmypid().$r.(double) microtime() * 1000000, 1); |
|
19 | + $m = md5($u); |
|
20 | 20 | return $m; |
21 | 21 | } |
22 | 22 | |
23 | 23 | // count duplicates |
24 | 24 | $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_modules'), "id='{$id}'")); |
25 | 25 | $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_modules'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
26 | -if($count>=1) $count = ' '.($count+1); |
|
26 | +if ($count >= 1) $count = ' '.($count + 1); |
|
27 | 27 | else $count = ''; |
28 | 28 | |
29 | 29 | // duplicate module |
@@ -68,5 +68,5 @@ discard block |
||
68 | 68 | $_SESSION['itemname'] = $name; |
69 | 69 | |
70 | 70 | // finish duplicating - redirect to new module |
71 | -$header="Location: index.php?r=2&a=108&id=$newid"; |
|
71 | +$header = "Location: index.php?r=2&a=108&id=$newid"; |
|
72 | 72 | header($header); |