Completed
Push — develop ( 75b835...a38a21 )
by Maxim
09:33 queued 04:23
created
manager/processors/save_content.processor.php 4 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -491,7 +491,7 @@
 block discarded – undo
491 491
             }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) {
492 492
             $publishedon = $pub_date;
493 493
             $publishedby = $modx->getLoginUserID();
494
-               }elseif ($was_published && !$published) {
494
+                }elseif ($was_published && !$published) {
495 495
             $publishedon = 0;
496 496
             $publishedby = 0;
497 497
         } else {
Please login to merge, or discard this patch.
Switch Indentation   +220 added lines, -220 removed lines patch added patch discarded remove patch
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
 }
276 276
 
277 277
 switch ($actionToTake) {
278
-    case 'new' :
278
+        case 'new' :
279 279
 
280
-        // invoke OnBeforeDocFormSave event
281
-        switch($modx->config['docid_incrmnt_method'])
282
-        {
280
+            // invoke OnBeforeDocFormSave event
281
+            switch($modx->config['docid_incrmnt_method'])
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";
285 285
                 $where = "T1.id IS NULL";
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 
294 294
             default:
295 295
                 $id = '';
296
-        }
296
+            }
297 297
 
298 298
         $modx->invokeEvent("OnBeforeDocFormSave", array (
299 299
             "mode" => "new",
@@ -444,256 +444,256 @@  discard block
 block discarded – undo
444 444
 
445 445
 
446 446
         break;
447
-    case 'edit' :
448
-
449
-        // get the document's current parent
450
-        $oldparent = $existingDocument['parent'];
451
-        $doctype = $existingDocument['type'];
452
-
453
-        if ($id == $site_start && $published == 0) {
454
-            $modx->manager->saveFormValues(27);
455
-            $modx->webAlertAndQuit("Document is linked to site_start variable and cannot be unpublished!");
456
-        }
457
-        $today = $_SERVER['REQUEST_TIME'] + $modx->config['server_offset_time'];
458
-        if ($id == $site_start && ($pub_date > $today || $unpub_date != "0")) {
459
-            $modx->manager->saveFormValues(27);
460
-            $modx->webAlertAndQuit("Document is linked to site_start variable and cannot have publish or unpublish dates set!");
461
-        }
462
-        if ($parent == $id) {
463
-            $modx->manager->saveFormValues(27);
464
-            $modx->webAlertAndQuit("Document can not be it's own parent!");
465
-        }
447
+        case 'edit' :
466 448
 
467
-        $parents = $modx->getParentIds($parent);
468
-        if (in_array($id, $parents)) {
469
-            $modx->webAlertAndQuit("Document descendant can not be it's parent!");
470
-        }
449
+            // get the document's current parent
450
+            $oldparent = $existingDocument['parent'];
451
+            $doctype = $existingDocument['type'];
471 452
 
472
-        // check to see document is a folder
473
-        $rs = $modx->db->select('count(id)', $tbl_site_content, "parent='{$id}'");
474
-        $count = $modx->db->getValue($rs);
475
-        if ($count > 0) {
476
-            $isfolder = 1;
477
-        }
453
+            if ($id == $site_start && $published == 0) {
454
+                $modx->manager->saveFormValues(27);
455
+                $modx->webAlertAndQuit("Document is linked to site_start variable and cannot be unpublished!");
456
+            }
457
+            $today = $_SERVER['REQUEST_TIME'] + $modx->config['server_offset_time'];
458
+            if ($id == $site_start && ($pub_date > $today || $unpub_date != "0")) {
459
+                $modx->manager->saveFormValues(27);
460
+                $modx->webAlertAndQuit("Document is linked to site_start variable and cannot have publish or unpublish dates set!");
461
+            }
462
+            if ($parent == $id) {
463
+                $modx->manager->saveFormValues(27);
464
+                $modx->webAlertAndQuit("Document can not be it's own parent!");
465
+            }
478 466
 
479
-        // set publishedon and publishedby
480
-        $was_published = $existingDocument['published'];
467
+            $parents = $modx->getParentIds($parent);
468
+            if (in_array($id, $parents)) {
469
+                $modx->webAlertAndQuit("Document descendant can not be it's parent!");
470
+            }
481 471
 
482
-        // keep original publish state, if change is not permitted
483
-        if (!$modx->hasPermission('publish_document')) {
484
-            $published = $was_published;
485
-            $pub_date = 'pub_date';
486
-            $unpub_date = 'unpub_date';
487
-        }
472
+            // check to see document is a folder
473
+            $rs = $modx->db->select('count(id)', $tbl_site_content, "parent='{$id}'");
474
+            $count = $modx->db->getValue($rs);
475
+            if ($count > 0) {
476
+                $isfolder = 1;
477
+            }
488 478
 
489
-        // if it was changed from unpublished to published
490
-        if (!$was_published && $published) {
491
-            $publishedon = $currentdate;
492
-            $publishedby = $modx->getLoginUserID();
493
-            }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) {
494
-            $publishedon = $pub_date;
495
-            $publishedby = $modx->getLoginUserID();
496
-               }elseif ($was_published && !$published) {
497
-            $publishedon = 0;
498
-            $publishedby = 0;
499
-        } else {
500
-            $publishedon = 'publishedon';
501
-            $publishedby = 'publishedby';
502
-        }
479
+            // set publishedon and publishedby
480
+            $was_published = $existingDocument['published'];
503 481
 
504
-        // invoke OnBeforeDocFormSave event
505
-        $modx->invokeEvent("OnBeforeDocFormSave", array (
506
-            "mode" => "upd",
507
-            "id" => $id
508
-        ));
482
+            // keep original publish state, if change is not permitted
483
+            if (!$modx->hasPermission('publish_document')) {
484
+                $published = $was_published;
485
+                $pub_date = 'pub_date';
486
+                $unpub_date = 'unpub_date';
487
+            }
509 488
 
510
-        // update the document
511
-        $modx->db->update(
512
-            "introtext='{$introtext}', "
513
-            . "content='{$content}', "
514
-            . "pagetitle='{$pagetitle}', "
515
-            . "longtitle='{$longtitle}', "
516
-            . "type='{$type}', "
517
-            . "description='{$description}', "
518
-            . "alias='{$alias}', "
519
-            . "link_attributes='{$link_attributes}', "
520
-            . "isfolder={$isfolder}, "
521
-            . "richtext={$richtext}, "
522
-            . "published={$published}, "
523
-            . "pub_date={$pub_date}, "
524
-            . "unpub_date={$unpub_date}, "
525
-            . "parent={$parent}, "
526
-            . "template={$template}, "
527
-            . "menuindex={$menuindex}, "
528
-            . "searchable={$searchable}, "
529
-            . "cacheable={$cacheable}, "
530
-            . "editedby=" . $modx->getLoginUserID() . ", "
531
-            . "editedon={$currentdate}, "
532
-            . "publishedon={$publishedon}, "
533
-            . "publishedby={$publishedby}, "
534
-            . "contentType='{$contentType}', "
535
-            . "content_dispo={$contentdispo}, "
536
-            . "donthit={$donthit}, "
537
-            . "menutitle='{$menutitle}', "
538
-            . "hidemenu={$hidemenu}, "
539
-            . "alias_visible={$aliasvisible}"
540
-            , $tbl_site_content, "id='{$id}'");
541
-
542
-        // update template variables
543
-        $rs = $modx->db->select('id, tmplvarid', $tbl_site_tmplvar_contentvalues, "contentid='{$id}'");
544
-        $tvIds = array ();
545
-        while ($row = $modx->db->getRow($rs)) {
546
-            $tvIds[$row['tmplvarid']] = $row['id'];
547
-        }
548
-        $tvDeletions = array();
549
-        $tvChanges = array();
550
-        foreach ($tmplvars as $field => $value) {
551
-            if (!is_array($value)) {
552
-                if (isset($tvIds[$value])) $tvDeletions[] = $tvIds[$value];
489
+            // if it was changed from unpublished to published
490
+            if (!$was_published && $published) {
491
+                $publishedon = $currentdate;
492
+                $publishedby = $modx->getLoginUserID();
493
+                }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) {
494
+                $publishedon = $pub_date;
495
+                $publishedby = $modx->getLoginUserID();
496
+                   }elseif ($was_published && !$published) {
497
+                $publishedon = 0;
498
+                $publishedby = 0;
553 499
             } else {
554
-                $tvId = $value[0];
555
-                $tvVal = $value[1];
500
+                $publishedon = 'publishedon';
501
+                $publishedby = 'publishedby';
502
+            }
556 503
 
557
-                if (isset($tvIds[$tvId])) {
558
-                    $tvChanges[] = array(array('tmplvarid' => $tvId, 'contentid' => $id, 'value' => $modx->db->escape($tvVal)), array('id' => $tvIds[$tvId]));
504
+            // invoke OnBeforeDocFormSave event
505
+            $modx->invokeEvent("OnBeforeDocFormSave", array (
506
+                "mode" => "upd",
507
+                "id" => $id
508
+            ));
509
+
510
+            // update the document
511
+            $modx->db->update(
512
+                "introtext='{$introtext}', "
513
+                . "content='{$content}', "
514
+                . "pagetitle='{$pagetitle}', "
515
+                . "longtitle='{$longtitle}', "
516
+                . "type='{$type}', "
517
+                . "description='{$description}', "
518
+                . "alias='{$alias}', "
519
+                . "link_attributes='{$link_attributes}', "
520
+                . "isfolder={$isfolder}, "
521
+                . "richtext={$richtext}, "
522
+                . "published={$published}, "
523
+                . "pub_date={$pub_date}, "
524
+                . "unpub_date={$unpub_date}, "
525
+                . "parent={$parent}, "
526
+                . "template={$template}, "
527
+                . "menuindex={$menuindex}, "
528
+                . "searchable={$searchable}, "
529
+                . "cacheable={$cacheable}, "
530
+                . "editedby=" . $modx->getLoginUserID() . ", "
531
+                . "editedon={$currentdate}, "
532
+                . "publishedon={$publishedon}, "
533
+                . "publishedby={$publishedby}, "
534
+                . "contentType='{$contentType}', "
535
+                . "content_dispo={$contentdispo}, "
536
+                . "donthit={$donthit}, "
537
+                . "menutitle='{$menutitle}', "
538
+                . "hidemenu={$hidemenu}, "
539
+                . "alias_visible={$aliasvisible}"
540
+                , $tbl_site_content, "id='{$id}'");
541
+
542
+            // update template variables
543
+            $rs = $modx->db->select('id, tmplvarid', $tbl_site_tmplvar_contentvalues, "contentid='{$id}'");
544
+            $tvIds = array ();
545
+            while ($row = $modx->db->getRow($rs)) {
546
+                $tvIds[$row['tmplvarid']] = $row['id'];
547
+            }
548
+            $tvDeletions = array();
549
+            $tvChanges = array();
550
+            foreach ($tmplvars as $field => $value) {
551
+                if (!is_array($value)) {
552
+                    if (isset($tvIds[$value])) $tvDeletions[] = $tvIds[$value];
559 553
                 } else {
560
-                    $tvAdded[] = array('tmplvarid' => $tvId, 'contentid' => $id, 'value' => $modx->db->escape($tvVal));
554
+                    $tvId = $value[0];
555
+                    $tvVal = $value[1];
556
+
557
+                    if (isset($tvIds[$tvId])) {
558
+                        $tvChanges[] = array(array('tmplvarid' => $tvId, 'contentid' => $id, 'value' => $modx->db->escape($tvVal)), array('id' => $tvIds[$tvId]));
559
+                    } else {
560
+                        $tvAdded[] = array('tmplvarid' => $tvId, 'contentid' => $id, 'value' => $modx->db->escape($tvVal));
561
+                    }
561 562
                 }
562 563
             }
563
-        }
564 564
 
565
-        if (!empty($tvDeletions)) {
566
-            $modx->db->delete($tbl_site_tmplvar_contentvalues, 'id IN('.implode(',', $tvDeletions).')');
567
-        }
568
-
569
-        if (!empty($tvAdded)) {
570
-            foreach ($tvAdded as $tv) {
571
-                $modx->db->insert($tv, $tbl_site_tmplvar_contentvalues);
565
+            if (!empty($tvDeletions)) {
566
+                $modx->db->delete($tbl_site_tmplvar_contentvalues, 'id IN('.implode(',', $tvDeletions).')');
572 567
             }
573
-        }
574 568
 
575
-        if (!empty($tvChanges)) {
576
-            foreach ($tvChanges as $tv) {
577
-                $modx->db->update($tv[0], $tbl_site_tmplvar_contentvalues, "id='{$tv[1]['id']}'");
569
+            if (!empty($tvAdded)) {
570
+                foreach ($tvAdded as $tv) {
571
+                    $modx->db->insert($tv, $tbl_site_tmplvar_contentvalues);
572
+                }
578 573
             }
579
-        }
580 574
 
581
-        // set document permissions
582
-        if ($use_udperms == 1 && is_array($document_groups)) {
583
-            $new_groups = array();
584
-            // process the new input
585
-            foreach ($document_groups as $value_pair) {
586
-                list($group, $link_id) = explode(',', $value_pair); // @see actions/mutate_content.dynamic.php @ line 1138 (permissions list)
587
-                $new_groups[$group] = $link_id;
575
+            if (!empty($tvChanges)) {
576
+                foreach ($tvChanges as $tv) {
577
+                    $modx->db->update($tv[0], $tbl_site_tmplvar_contentvalues, "id='{$tv[1]['id']}'");
578
+                }
588 579
             }
589 580
 
590
-            // grab the current set of permissions on this document the user can access
591
-            $isManager = $modx->hasPermission('access_permissions');
592
-            $isWeb     = $modx->hasPermission('web_access_permissions');
593
-            $rs = $modx->db->select(
594
-                'groups.id, groups.document_group',
595
-                "{$tbl_document_groups} AS groups
581
+            // set document permissions
582
+            if ($use_udperms == 1 && is_array($document_groups)) {
583
+                $new_groups = array();
584
+                // process the new input
585
+                foreach ($document_groups as $value_pair) {
586
+                    list($group, $link_id) = explode(',', $value_pair); // @see actions/mutate_content.dynamic.php @ line 1138 (permissions list)
587
+                    $new_groups[$group] = $link_id;
588
+                }
589
+
590
+                // grab the current set of permissions on this document the user can access
591
+                $isManager = $modx->hasPermission('access_permissions');
592
+                $isWeb     = $modx->hasPermission('web_access_permissions');
593
+                $rs = $modx->db->select(
594
+                    'groups.id, groups.document_group',
595
+                    "{$tbl_document_groups} AS groups
596 596
                     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}'"
598
-                );
599
-            $old_groups = array();
600
-            while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id'];
601
-
602
-            // update the permissions in the database
603
-            $insertions = $deletions = array();
604
-            foreach ($new_groups as $group => $link_id) {
605
-                if (array_key_exists($group, $old_groups)) {
606
-                    unset($old_groups[$group]);
607
-                    continue;
608
-                } elseif ($link_id == 'new') {
609
-                    $insertions[] = '('.(int)$group.','.$id.')';
597
+                    "((1=".(int)$isManager." AND dgn.private_memgroup) OR (1=".(int)$isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'"
598
+                    );
599
+                $old_groups = array();
600
+                while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id'];
601
+
602
+                // update the permissions in the database
603
+                $insertions = $deletions = array();
604
+                foreach ($new_groups as $group => $link_id) {
605
+                    if (array_key_exists($group, $old_groups)) {
606
+                        unset($old_groups[$group]);
607
+                        continue;
608
+                    } elseif ($link_id == 'new') {
609
+                        $insertions[] = '('.(int)$group.','.$id.')';
610
+                    }
611
+                }
612
+                if (!empty($insertions)) {
613
+                    $modx->db->query("INSERT INTO {$tbl_document_groups} (document_group, document) VALUES ".implode(',', $insertions));
614
+                }
615
+                if (!empty($old_groups)) {
616
+                    $modx->db->delete($tbl_document_groups, "id IN (".implode(',', $old_groups).")");
617
+                }
618
+                // necessary to remove all permissions as document is public
619
+                if ((isset($_POST['chkalldocs']) && $_POST['chkalldocs'] == 'on')) {
620
+                    $modx->db->delete($tbl_document_groups, "document='{$id}'");
610 621
                 }
611 622
             }
612
-            if (!empty($insertions)) {
613
-                $modx->db->query("INSERT INTO {$tbl_document_groups} (document_group, document) VALUES ".implode(',', $insertions));
614
-            }
615
-            if (!empty($old_groups)) {
616
-                $modx->db->delete($tbl_document_groups, "id IN (".implode(',', $old_groups).")");
617
-            }
618
-            // necessary to remove all permissions as document is public
619
-            if ((isset($_POST['chkalldocs']) && $_POST['chkalldocs'] == 'on')) {
620
-                $modx->db->delete($tbl_document_groups, "document='{$id}'");
623
+
624
+            // do the parent stuff
625
+            if ($parent != 0) {
626
+                $fields = array('isfolder' => 1);
627
+                $modx->db->update($fields, $tbl_site_content, "id='{$_REQUEST['parent']}'");
621 628
             }
622
-        }
623 629
 
624
-        // do the parent stuff
625
-        if ($parent != 0) {
626
-            $fields = array('isfolder' => 1);
627
-            $modx->db->update($fields, $tbl_site_content, "id='{$_REQUEST['parent']}'");
628
-        }
630
+            // finished moving the document, now check to see if the old_parent should no longer be a folder
631
+            $rs = $modx->db->select('COUNT(id)', $tbl_site_content, "parent='{$oldparent}'");
632
+            $limit = $modx->db->getValue($rs);
629 633
 
630
-        // finished moving the document, now check to see if the old_parent should no longer be a folder
631
-        $rs = $modx->db->select('COUNT(id)', $tbl_site_content, "parent='{$oldparent}'");
632
-        $limit = $modx->db->getValue($rs);
634
+            if ($limit == 0) {
635
+                $fields = array('isfolder' => 0);
636
+                $modx->db->update($fields, $tbl_site_content, "id='{$oldparent}'");
637
+            }
633 638
 
634
-        if ($limit == 0) {
635
-            $fields = array('isfolder' => 0);
636
-            $modx->db->update($fields, $tbl_site_content, "id='{$oldparent}'");
637
-        }
638 639
 
640
+            // invoke OnDocFormSave event
641
+            $modx->invokeEvent("OnDocFormSave", array (
642
+                "mode" => "upd",
643
+                "id" => $id
644
+            ));
639 645
 
640
-        // invoke OnDocFormSave event
641
-        $modx->invokeEvent("OnDocFormSave", array (
642
-            "mode" => "upd",
643
-            "id" => $id
644
-        ));
646
+            // secure web documents - flag as private
647
+            include MODX_MANAGER_PATH . "includes/secure_web_documents.inc.php";
648
+            secureWebDocument($id);
645 649
 
646
-        // secure web documents - flag as private
647
-        include MODX_MANAGER_PATH . "includes/secure_web_documents.inc.php";
648
-        secureWebDocument($id);
649
-
650
-        // secure manager documents - flag as private
651
-        include MODX_MANAGER_PATH . "includes/secure_mgr_documents.inc.php";
652
-        secureMgrDocument($id);
650
+            // secure manager documents - flag as private
651
+            include MODX_MANAGER_PATH . "includes/secure_mgr_documents.inc.php";
652
+            secureMgrDocument($id);
653 653
 
654
-        // Set the item name for logger
655
-        $_SESSION['itemname'] = $no_esc_pagetitle;
654
+            // Set the item name for logger
655
+            $_SESSION['itemname'] = $no_esc_pagetitle;
656 656
 
657
-        if ($syncsite == 1) {
658
-            // empty cache
659
-            $keys = array('alias','parent','published','isfolder','menuindex','alias_visible');
660
-            $flag = '';
661
-            foreach($keys as $key) {
662
-                if ($existingDocument[$key]===$_POST[$key]) continue;
663
-                $flag = 'full';
664
-                break;
657
+            if ($syncsite == 1) {
658
+                // empty cache
659
+                $keys = array('alias','parent','published','isfolder','menuindex','alias_visible');
660
+                $flag = '';
661
+                foreach($keys as $key) {
662
+                    if ($existingDocument[$key]===$_POST[$key]) continue;
663
+                    $flag = 'full';
664
+                    break;
665
+                }
666
+                if($flag==='full') $modx->clearCache('full');
667
+                else               $modx->clearCache($id);
665 668
             }
666
-            if($flag==='full') $modx->clearCache('full');
667
-            else               $modx->clearCache($id);
668
-        }
669 669
 
670
-        if ($_POST['refresh_preview'] == '1')
671
-            $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev";
672
-        else {
673
-            if ($_POST['stay'] != '2' && $id > 0) {
674
-                $modx->unlockElement(7, $id);
675
-            }
676
-            if ($_POST['stay'] != '') {
677
-                $id = $_REQUEST['id'];
678
-                if ($type == "reference") {
679
-                    // weblink
680
-                    $a = ($_POST['stay'] == '2') ? "27&id=$id" : "72&pid=$parent";
670
+            if ($_POST['refresh_preview'] == '1')
671
+                $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev";
672
+            else {
673
+                if ($_POST['stay'] != '2' && $id > 0) {
674
+                    $modx->unlockElement(7, $id);
675
+                }
676
+                if ($_POST['stay'] != '') {
677
+                    $id = $_REQUEST['id'];
678
+                    if ($type == "reference") {
679
+                        // weblink
680
+                        $a = ($_POST['stay'] == '2') ? "27&id=$id" : "72&pid=$parent";
681
+                    } else {
682
+                        // document
683
+                        $a = ($_POST['stay'] == '2') ? "27&id=$id" : "4&pid=$parent";
684
+                    }
685
+                    $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay'].$add_path;
681 686
                 } else {
682
-                    // document
683
-                    $a = ($_POST['stay'] == '2') ? "27&id=$id" : "4&pid=$parent";
687
+                    $header = "Location: index.php?a=3&id=$id&r=1".$add_path;
684 688
                 }
685
-                $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay'].$add_path;
689
+            }
690
+            if (headers_sent()) {
691
+                $header = str_replace('Location: ','',$header);
692
+                echo "<script>document.location.href='$header';</script>\n";
686 693
             } else {
687
-                $header = "Location: index.php?a=3&id=$id&r=1".$add_path;
694
+                header($header);
688 695
             }
689
-        }
690
-        if (headers_sent()) {
691
-            $header = str_replace('Location: ','',$header);
692
-            echo "<script>document.location.href='$header';</script>\n";
693
-        } else {
694
-            header($header);
695
-        }
696
-        break;
697
-    default :
698
-        $modx->webAlertAndQuit("No operation set in request.");
696
+            break;
697
+        default :
698
+            $modx->webAlertAndQuit("No operation set in request.");
699 699
 }
Please login to merge, or discard this patch.
Spacing   +84 added lines, -85 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if (!$modx->hasPermission('save_document')) {
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Braces   +33 added lines, -24 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
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;
@@ -134,8 +134,7 @@  discard block
 block discarded – undo
134 134
         }
135 135
         //end webber
136 136
     }
137
-}
138
-elseif ($alias) {
137
+} elseif ($alias) {
139 138
     $alias = $modx->stripAlias($alias);
140 139
 }
141 140
 
@@ -149,8 +148,7 @@  discard block
 block discarded – undo
149 148
 
150 149
     if ($pub_date < $currentdate) {
151 150
         $published = 1;
152
-    }
153
-    elseif ($pub_date > $currentdate) {
151
+    } elseif ($pub_date > $currentdate) {
154 152
         $published = 0;
155 153
     }
156 154
 }
@@ -278,8 +276,7 @@  discard block
 block discarded – undo
278 276
     case 'new' :
279 277
 
280 278
         // invoke OnBeforeDocFormSave event
281
-        switch($modx->config['docid_incrmnt_method'])
282
-        {
279
+        switch($modx->config['docid_incrmnt_method']) {
283 280
             case '1':
284 281
                 $from = "{$tbl_site_content} AS T0 LEFT JOIN {$tbl_site_content} AS T1 ON T0.id + 1 = T1.id";
285 282
                 $where = "T1.id IS NULL";
@@ -310,7 +307,7 @@  discard block
 block discarded – undo
310 307
         $publishedon = ($published ? $currentdate : 0);
311 308
         $publishedby = ($published ? $modx->getLoginUserID() : 0);
312 309
 
313
-        if ((!empty($pub_date))&&($published)){
310
+        if ((!empty($pub_date))&&($published)) {
314 311
             $publishedon=$pub_date;
315 312
         }
316 313
 
@@ -348,8 +345,9 @@  discard block
 block discarded – undo
348 345
             "alias_visible"    => $aliasvisible
349 346
         );
350 347
 
351
-        if ($id != '')
352
-            $dbInsert["id"] = $id;
348
+        if ($id != '') {
349
+                    $dbInsert["id"] = $id;
350
+        }
353 351
 
354 352
         $key = $modx->db->insert( $dbInsert, $tbl_site_content);
355 353
 
@@ -425,11 +423,13 @@  discard block
 block discarded – undo
425 423
         // redirect/stay options
426 424
         if ($_POST['stay'] != '') {
427 425
             // weblink
428
-            if ($_POST['mode'] == "72")
429
-                $a = ($_POST['stay'] == '2') ? "27&id=$key" : "72&pid=$parent";
426
+            if ($_POST['mode'] == "72") {
427
+                            $a = ($_POST['stay'] == '2') ? "27&id=$key" : "72&pid=$parent";
428
+            }
430 429
             // document
431
-            if ($_POST['mode'] == "4")
432
-                $a = ($_POST['stay'] == '2') ? "27&id=$key" : "4&pid=$parent";
430
+            if ($_POST['mode'] == "4") {
431
+                            $a = ($_POST['stay'] == '2') ? "27&id=$key" : "4&pid=$parent";
432
+            }
433 433
             $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay'];
434 434
         } else {
435 435
             $header = "Location: index.php?a=3&id=$key&r=1";
@@ -490,10 +490,10 @@  discard block
 block discarded – undo
490 490
         if (!$was_published && $published) {
491 491
             $publishedon = $currentdate;
492 492
             $publishedby = $modx->getLoginUserID();
493
-            }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) {
493
+            } elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) {
494 494
             $publishedon = $pub_date;
495 495
             $publishedby = $modx->getLoginUserID();
496
-               }elseif ($was_published && !$published) {
496
+               } elseif ($was_published && !$published) {
497 497
             $publishedon = 0;
498 498
             $publishedby = 0;
499 499
         } else {
@@ -549,7 +549,9 @@  discard block
 block discarded – undo
549 549
         $tvChanges = array();
550 550
         foreach ($tmplvars as $field => $value) {
551 551
             if (!is_array($value)) {
552
-                if (isset($tvIds[$value])) $tvDeletions[] = $tvIds[$value];
552
+                if (isset($tvIds[$value])) {
553
+                    $tvDeletions[] = $tvIds[$value];
554
+                }
553 555
             } else {
554 556
                 $tvId = $value[0];
555 557
                 $tvVal = $value[1];
@@ -597,7 +599,9 @@  discard block
 block discarded – undo
597 599
                 "((1=".(int)$isManager." AND dgn.private_memgroup) OR (1=".(int)$isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'"
598 600
                 );
599 601
             $old_groups = array();
600
-            while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id'];
602
+            while ($row = $modx->db->getRow($rs)) {
603
+                $old_groups[$row['document_group']] = $row['id'];
604
+            }
601 605
 
602 606
             // update the permissions in the database
603 607
             $insertions = $deletions = array();
@@ -659,17 +663,22 @@  discard block
 block discarded – undo
659 663
             $keys = array('alias','parent','published','isfolder','menuindex','alias_visible');
660 664
             $flag = '';
661 665
             foreach($keys as $key) {
662
-                if ($existingDocument[$key]===$_POST[$key]) continue;
666
+                if ($existingDocument[$key]===$_POST[$key]) {
667
+                    continue;
668
+                }
663 669
                 $flag = 'full';
664 670
                 break;
665 671
             }
666
-            if($flag==='full') $modx->clearCache('full');
667
-            else               $modx->clearCache($id);
672
+            if($flag==='full') {
673
+                $modx->clearCache('full');
674
+            } else {
675
+                $modx->clearCache($id);
676
+            }
668 677
         }
669 678
 
670
-        if ($_POST['refresh_preview'] == '1')
671
-            $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev";
672
-        else {
679
+        if ($_POST['refresh_preview'] == '1') {
680
+                    $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev";
681
+        } else {
673 682
             if ($_POST['stay'] != '2' && $id > 0) {
674 683
                 $modx->unlockElement(7, $id);
675 684
             }
Please login to merge, or discard this patch.
manager/processors/save_web_user.processor.php 4 patches
Switch Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -60,108 +60,108 @@  discard block
 block discarded – undo
60 60
 }
61 61
 
62 62
 switch($input['mode']) {
63
-	case '87' : // new user
64
-		// check if this user name already exist
65
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
-		$limit = $modx->db->getValue($rs);
67
-		if($limit > 0) {
68
-			webAlertAndQuit("User name is already in use!");
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'] = intval($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'] = intval($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
 block discarded – undo
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'] = intval($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'] = intval($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
 block discarded – undo
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
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -335,7 +335,8 @@  discard block
 block discarded – undo
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 340
 	$crlf = "\n";
340 341
 	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
341 342
 	$f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
@@ -347,7 +348,8 @@  discard block
 block discarded – undo
347 348
 }
348 349
 
349 350
 // Send an email to the user
350
-function sendMailMessage($email, $uid, $pwd, $ufn) {
351
+function sendMailMessage($email, $uid, $pwd, $ufn)
352
+{
351 353
 	global $modx, $_lang, $websignupemail_message;
352 354
 	global $emailsubject, $emailsender;
353 355
 	global $site_name, $site_url;
@@ -375,7 +377,8 @@  discard block
 block discarded – undo
375 377
 }
376 378
 
377 379
 // Save User Settings
378
-function saveUserSettings($id) {
380
+function saveUserSettings($id)
381
+{
379 382
 	global $modx;
380 383
 	$tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
381 384
 
@@ -404,7 +407,8 @@  discard block
 block discarded – undo
404 407
 }
405 408
 
406 409
 // Web alert -  sends an alert to web browser
407
-function webAlertAndQuit($msg) {
410
+function webAlertAndQuit($msg)
411
+{
408 412
 	global $id, $modx;
409 413
 	$mode = $_POST['mode'];
410 414
 	$modx->manager->saveFormValues($mode);
@@ -412,7 +416,8 @@  discard block
 block discarded – undo
412 416
 }
413 417
 
414 418
 // Generate password
415
-function generate_password($length = 10) {
419
+function generate_password($length = 10)
420
+{
416 421
 	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
417 422
 	$ps_len = strlen($allowable_characters);
418 423
 	mt_srand((double) microtime() * 1000000);
@@ -423,7 +428,8 @@  discard block
 block discarded – undo
423 428
 	return $pass;
424 429
 }
425 430
 
426
-function sanitize($str = '', $safecount = 0) {
431
+function sanitize($str = '', $safecount = 0)
432
+{
427 433
 	global $modx;
428 434
 	$safecount++;
429 435
 	if(1000 < $safecount) {
Please login to merge, or discard this patch.
Indentation   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3
-	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3
+    die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('save_web_user')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $tbl_web_users = $modx->getFullTableName('web_users');
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 $input = $_POST;
14 14
 foreach($input as $k => $v) {
15
-	if($k !== 'comment') {
16
-		$v = 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 = intval($input['id']);
@@ -51,80 +51,80 @@  discard block
 block discarded – undo
51 51
 
52 52
 // verify password
53 53
 if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
54
-	webAlertAndQuit("Password typed is mismatched");
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'] = intval($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'] = intval($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
 block discarded – undo
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
 block discarded – undo
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'] = intval($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'] = intval($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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
 	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('save_web_user')) {
5
+if (!$modx->hasPermission('save_web_user')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
 $tbl_web_groups = $modx->getFullTableName('web_groups');
12 12
 
13 13
 $input = $_POST;
14
-foreach($input as $k => $v) {
15
-	if($k !== 'comment') {
14
+foreach ($input as $k => $v) {
15
+	if ($k !== 'comment') {
16 16
 		$v = sanitize($v);
17 17
 	}
18 18
 	$input[$k] = $v;
@@ -50,41 +50,41 @@  discard block
 block discarded – undo
50 50
 $user_groups = $input['user_groups'];
51 51
 
52 52
 // verify password
53
-if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
53
+if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
54 54
 	webAlertAndQuit("Password typed is mismatched");
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,9 +114,9 @@  discard block
 block discarded – undo
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 121
 					$f['webgroup'] = intval($user_groups[$i]);
122 122
 					$f['webuser'] = $internalKey;
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,11 +247,11 @@  discard block
 block discarded – undo
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 256
 					$field['webgroup'] = intval($user_groups[$i]);
257 257
 					$field['webuser'] = $id;
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 {
Please login to merge, or discard this patch.
manager/processors/save_snippet.processor.php 2 patches
Switch Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -66,111 +66,111 @@
 block discarded – undo
66 66
 }
67 67
 
68 68
 switch ($_POST['mode']) {
69
-    case '23': // Save new snippet
70
-
71
-        // invoke OnBeforeSnipFormSave event
72
-        $modx->invokeEvent("OnBeforeSnipFormSave", array(
73
-            "mode" => "new",
74
-            "id" => $id
75
-        ));
76
-
77
-        // disallow duplicate names for new snippets
78
-        $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_snippets'), "name='{$name}'");
79
-        $count = $modx->db->getValue($rs);
80
-        if ($count > 0) {
81
-            $modx->manager->saveFormValues(23);
82
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=23");
83
-        }
84
-
85
-        //do stuff to save the new doc
86
-        $newid = $modx->db->insert(array(
87
-            'name' => $name,
88
-            'description' => $description,
89
-            'snippet' => $snippet,
90
-            'moduleguid' => $moduleguid,
91
-            'locked' => $locked,
92
-            'properties' => $properties,
93
-            'category' => $categoryid,
94
-            'disabled' => $disabled,
95
-            'createdon' => $currentdate,
96
-            'editedon' => $currentdate
97
-        ), $modx->getFullTableName('site_snippets'));
98
-
99
-        // invoke OnSnipFormSave event
100
-        $modx->invokeEvent("OnSnipFormSave", array(
101
-            "mode" => "new",
102
-            "id" => $newid
103
-        ));
104
-
105
-        // Set the item name for logger
106
-        $_SESSION['itemname'] = $name;
107
-
108
-        // empty cache
109
-        $modx->clearCache('full');
110
-
111
-        // finished emptying cache - redirect
112
-        if ($_POST['stay'] != '') {
113
-            $a = ($_POST['stay'] == '2') ? "22&id=$newid" : "23";
114
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
115
-            header($header);
116
-        } else {
117
-            $header = "Location: index.php?a=76&r=2";
118
-            header($header);
119
-        }
120
-        break;
121
-    case '22': // Save existing snippet
122
-        // invoke OnBeforeSnipFormSave event
123
-        $modx->invokeEvent("OnBeforeSnipFormSave", array(
124
-            "mode" => "upd",
125
-            "id" => $id
126
-        ));
127
-
128
-        // disallow duplicate names for snippets
129
-        $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_snippets'), "name='{$name}' AND id!='{$id}'");
130
-        if ($modx->db->getValue($rs) > 0) {
131
-            $modx->manager->saveFormValues(22);
132
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=22&id={$id}");
133
-        }
134
-
135
-        //do stuff to save the edited doc
136
-        $modx->db->update(array(
137
-            'name' => $name,
138
-            'description' => $description,
139
-            'snippet' => $snippet,
140
-            'moduleguid' => $moduleguid,
141
-            'locked' => $locked,
142
-            'properties' => $properties,
143
-            'category' => $categoryid,
144
-            'disabled' => $disabled,
145
-            'editedon' => $currentdate
146
-        ), $modx->getFullTableName('site_snippets'), "id='{$id}'");
147
-
148
-        // invoke OnSnipFormSave event
149
-        $modx->invokeEvent("OnSnipFormSave", array(
150
-            "mode" => "upd",
151
-            "id" => $id
152
-        ));
153
-
154
-        // Set the item name for logger
155
-        $_SESSION['itemname'] = $name;
156
-
157
-        // empty cache
158
-        $modx->clearCache('full');
159
-
160
-        if ($_POST['runsnippet']) {
161
-            run_snippet($snippet);
162
-        }
163
-        // finished emptying cache - redirect
164
-        if ($_POST['stay'] != '') {
165
-            $a = ($_POST['stay'] == '2') ? "22&id=$id" : "23";
166
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
167
-            header($header);
168
-        } else {
169
-            $modx->unlockElement(4, $id);
170
-            $header = "Location: index.php?a=76&r=2";
171
-            header($header);
172
-        }
173
-        break;
174
-    default:
175
-        $modx->webAlertAndQuit("No operation set in request.");
69
+        case '23': // Save new snippet
70
+
71
+            // invoke OnBeforeSnipFormSave event
72
+            $modx->invokeEvent("OnBeforeSnipFormSave", array(
73
+                "mode" => "new",
74
+                "id" => $id
75
+            ));
76
+
77
+            // disallow duplicate names for new snippets
78
+            $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_snippets'), "name='{$name}'");
79
+            $count = $modx->db->getValue($rs);
80
+            if ($count > 0) {
81
+                $modx->manager->saveFormValues(23);
82
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=23");
83
+            }
84
+
85
+            //do stuff to save the new doc
86
+            $newid = $modx->db->insert(array(
87
+                'name' => $name,
88
+                'description' => $description,
89
+                'snippet' => $snippet,
90
+                'moduleguid' => $moduleguid,
91
+                'locked' => $locked,
92
+                'properties' => $properties,
93
+                'category' => $categoryid,
94
+                'disabled' => $disabled,
95
+                'createdon' => $currentdate,
96
+                'editedon' => $currentdate
97
+            ), $modx->getFullTableName('site_snippets'));
98
+
99
+            // invoke OnSnipFormSave event
100
+            $modx->invokeEvent("OnSnipFormSave", array(
101
+                "mode" => "new",
102
+                "id" => $newid
103
+            ));
104
+
105
+            // Set the item name for logger
106
+            $_SESSION['itemname'] = $name;
107
+
108
+            // empty cache
109
+            $modx->clearCache('full');
110
+
111
+            // finished emptying cache - redirect
112
+            if ($_POST['stay'] != '') {
113
+                $a = ($_POST['stay'] == '2') ? "22&id=$newid" : "23";
114
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
115
+                header($header);
116
+            } else {
117
+                $header = "Location: index.php?a=76&r=2";
118
+                header($header);
119
+            }
120
+            break;
121
+        case '22': // Save existing snippet
122
+            // invoke OnBeforeSnipFormSave event
123
+            $modx->invokeEvent("OnBeforeSnipFormSave", array(
124
+                "mode" => "upd",
125
+                "id" => $id
126
+            ));
127
+
128
+            // disallow duplicate names for snippets
129
+            $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_snippets'), "name='{$name}' AND id!='{$id}'");
130
+            if ($modx->db->getValue($rs) > 0) {
131
+                $modx->manager->saveFormValues(22);
132
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=22&id={$id}");
133
+            }
134
+
135
+            //do stuff to save the edited doc
136
+            $modx->db->update(array(
137
+                'name' => $name,
138
+                'description' => $description,
139
+                'snippet' => $snippet,
140
+                'moduleguid' => $moduleguid,
141
+                'locked' => $locked,
142
+                'properties' => $properties,
143
+                'category' => $categoryid,
144
+                'disabled' => $disabled,
145
+                'editedon' => $currentdate
146
+            ), $modx->getFullTableName('site_snippets'), "id='{$id}'");
147
+
148
+            // invoke OnSnipFormSave event
149
+            $modx->invokeEvent("OnSnipFormSave", array(
150
+                "mode" => "upd",
151
+                "id" => $id
152
+            ));
153
+
154
+            // Set the item name for logger
155
+            $_SESSION['itemname'] = $name;
156
+
157
+            // empty cache
158
+            $modx->clearCache('full');
159
+
160
+            if ($_POST['runsnippet']) {
161
+                run_snippet($snippet);
162
+            }
163
+            // finished emptying cache - redirect
164
+            if ($_POST['stay'] != '') {
165
+                $a = ($_POST['stay'] == '2') ? "22&id=$id" : "23";
166
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
167
+                header($header);
168
+            } else {
169
+                $modx->unlockElement(4, $id);
170
+                $header = "Location: index.php?a=76&r=2";
171
+                header($header);
172
+            }
173
+            break;
174
+        default:
175
+            $modx->webAlertAndQuit("No operation set in request.");
176 176
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if (!$modx->hasPermission('save_snippet')) {
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) {
38 38
     $categoryid = 0;
39 39
 } else {
40
-    include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
40
+    include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
41 41
     $categoryid = checkCategory($_POST['newcategory']);
42 42
     if (!$categoryid) {
43 43
         $categoryid = newCategory($_POST['newcategory']);
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
     $moduleguid = isset($parsed['guid']) ? $parsed['guid'] : $moduleguid;
56 56
 
57 57
     $description = isset($parsed['description']) ? $parsed['description'] : $description;
58
-    $version = isset($parsed['version']) ? '<b>' . $parsed['version'] . '</b> ' : '';
58
+    $version = isset($parsed['version']) ? '<b>'.$parsed['version'].'</b> ' : '';
59 59
     if ($version) {
60
-        $description = $version . trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description));
60
+        $description = $version.trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description));
61 61
     }
62 62
     if (isset($parsed['modx_category'])) {
63
-        include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
63
+        include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
64 64
         $categoryid = getCategory($parsed['modx_category']);
65 65
     }
66 66
 }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         // finished emptying cache - redirect
112 112
         if ($_POST['stay'] != '') {
113 113
             $a = ($_POST['stay'] == '2') ? "22&id=$newid" : "23";
114
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
114
+            $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay'];
115 115
             header($header);
116 116
         } else {
117 117
             $header = "Location: index.php?a=76&r=2";
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         // finished emptying cache - redirect
164 164
         if ($_POST['stay'] != '') {
165 165
             $a = ($_POST['stay'] == '2') ? "22&id=$id" : "23";
166
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
166
+            $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay'];
167 167
             header($header);
168 168
         } else {
169 169
             $modx->unlockElement(4, $id);
Please login to merge, or discard this patch.
manager/processors/login.processor.php 4 patches
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
3
-	header('HTTP/1.0 404 Not Found');
4
-	exit('error');
3
+    header('HTTP/1.0 404 Not Found');
4
+    exit('error');
5 5
 }
6 6
 define('IN_MANAGER_MODE', true);  // we use this to make sure files are accessed through
7 7
 define('MODX_API_MODE', true);
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 include_once("{$core_path}lang/english.inc.php");
19 19
 
20 20
 if($manager_language !== 'english' && is_file("{$core_path}lang/{$manager_language}.inc.php")) {
21
-	include_once("{$core_path}lang/{$manager_language}.inc.php");
21
+    include_once("{$core_path}lang/{$manager_language}.inc.php");
22 22
 }
23 23
 
24 24
 // include the logger
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 // Initialize System Alert Message Queque
28 28
 if(!isset($_SESSION['SystemAlertMsgQueque'])) {
29
-	$_SESSION['SystemAlertMsgQueque'] = array();
29
+    $_SESSION['SystemAlertMsgQueque'] = array();
30 30
 }
31 31
 $SystemAlertMsgQueque = &$_SESSION['SystemAlertMsgQueque'];
32 32
 
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
 
42 42
 // invoke OnBeforeManagerLogin event
43 43
 $modx->invokeEvent('OnBeforeManagerLogin', array(
44
-		'username' => $username,
45
-		'userpassword' => $givenPassword,
46
-		'rememberme' => $rememberme
47
-	));
44
+        'username' => $username,
45
+        'userpassword' => $givenPassword,
46
+        'rememberme' => $rememberme
47
+    ));
48 48
 $fields = 'mu.*, ua.*';
49 49
 $from = '[+prefix+]manager_users AS mu, [+prefix+]user_attributes AS ua';
50 50
 $where = "BINARY mu.username='{$username}' and ua.internalKey=mu.id";
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 $limit = $modx->db->getRecordCount($rs);
53 53
 
54 54
 if($limit == 0 || $limit > 1) {
55
-	jsAlert($_lang['login_processor_unknown_user']);
56
-	return;
55
+    jsAlert($_lang['login_processor_unknown_user']);
56
+    return;
57 57
 }
58 58
 
59 59
 $row = $modx->db->getRow($rs);
@@ -74,127 +74,127 @@  discard block
 block discarded – undo
74 74
 // get the user settings from the database
75 75
 $rs = $modx->db->select('setting_name, setting_value', '[+prefix+]user_settings', "user='{$internalKey}' AND setting_value!=''");
76 76
 while($row = $modx->db->getRow($rs)) {
77
-	extract($row);
78
-	${$setting_name} = $setting_value;
77
+    extract($row);
78
+    ${$setting_name} = $setting_value;
79 79
 }
80 80
 
81 81
 // blocked due to number of login errors.
82 82
 if($failedlogins >= $failed_allowed && $blockeduntildate > time()) {
83
-	@session_destroy();
84
-	session_unset();
85
-	if($cip = getenv("HTTP_CLIENT_IP")) {
86
-		$ip = $cip;
87
-	} elseif($cip = getenv("HTTP_X_FORWARDED_FOR")) {
88
-		$ip = $cip;
89
-	} elseif($cip = getenv("REMOTE_ADDR")) {
90
-		$ip = $cip;
91
-	} else {
92
-		$ip = "UNKNOWN";
93
-	}
94
-	$log = new logHandler;
95
-	$log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: " . $ip);
96
-	jsAlert($_lang['login_processor_many_failed_logins']);
97
-	return;
83
+    @session_destroy();
84
+    session_unset();
85
+    if($cip = getenv("HTTP_CLIENT_IP")) {
86
+        $ip = $cip;
87
+    } elseif($cip = getenv("HTTP_X_FORWARDED_FOR")) {
88
+        $ip = $cip;
89
+    } elseif($cip = getenv("REMOTE_ADDR")) {
90
+        $ip = $cip;
91
+    } else {
92
+        $ip = "UNKNOWN";
93
+    }
94
+    $log = new logHandler;
95
+    $log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: " . $ip);
96
+    jsAlert($_lang['login_processor_many_failed_logins']);
97
+    return;
98 98
 }
99 99
 
100 100
 // blocked due to number of login errors, but get to try again
101 101
 if($failedlogins >= $failed_allowed && $blockeduntildate < time()) {
102
-	$fields = array();
103
-	$fields['failedlogincount'] = '0';
104
-	$fields['blockeduntil'] = time() - 1;
105
-	$modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
102
+    $fields = array();
103
+    $fields['failedlogincount'] = '0';
104
+    $fields['blockeduntil'] = time() - 1;
105
+    $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
106 106
 }
107 107
 
108 108
 // this user has been blocked by an admin, so no way he's loggin in!
109 109
 if($blocked == '1') {
110
-	@session_destroy();
111
-	session_unset();
112
-	jsAlert($_lang['login_processor_blocked1']);
113
-	return;
110
+    @session_destroy();
111
+    session_unset();
112
+    jsAlert($_lang['login_processor_blocked1']);
113
+    return;
114 114
 }
115 115
 
116 116
 // blockuntil: this user has a block until date
117 117
 if($blockeduntildate > time()) {
118
-	@session_destroy();
119
-	session_unset();
120
-	jsAlert($_lang['login_processor_blocked2']);
121
-	return;
118
+    @session_destroy();
119
+    session_unset();
120
+    jsAlert($_lang['login_processor_blocked2']);
121
+    return;
122 122
 }
123 123
 
124 124
 // blockafter: this user has a block after date
125 125
 if($blockedafterdate > 0 && $blockedafterdate < time()) {
126
-	@session_destroy();
127
-	session_unset();
128
-	jsAlert($_lang['login_processor_blocked3']);
129
-	return;
126
+    @session_destroy();
127
+    session_unset();
128
+    jsAlert($_lang['login_processor_blocked3']);
129
+    return;
130 130
 }
131 131
 
132 132
 // allowed ip
133 133
 if($allowed_ip) {
134
-	if(($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) {
135
-		if(gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) {
136
-			jsAlert($_lang['login_processor_remotehost_ip']);
137
-			return;
138
-		}
139
-	}
140
-	if(!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) {
141
-		jsAlert($_lang['login_processor_remote_ip']);
142
-		return;
143
-	}
134
+    if(($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) {
135
+        if(gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) {
136
+            jsAlert($_lang['login_processor_remotehost_ip']);
137
+            return;
138
+        }
139
+    }
140
+    if(!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) {
141
+        jsAlert($_lang['login_processor_remote_ip']);
142
+        return;
143
+    }
144 144
 }
145 145
 
146 146
 // allowed days
147 147
 if($allowed_days) {
148
-	$date = getdate();
149
-	$day = $date['wday'] + 1;
150
-	if(strpos($allowed_days, $day) === false) {
151
-		jsAlert($_lang['login_processor_date']);
152
-		return;
153
-	}
148
+    $date = getdate();
149
+    $day = $date['wday'] + 1;
150
+    if(strpos($allowed_days, $day) === false) {
151
+        jsAlert($_lang['login_processor_date']);
152
+        return;
153
+    }
154 154
 }
155 155
 
156 156
 // invoke OnManagerAuthentication event
157 157
 $rt = $modx->invokeEvent('OnManagerAuthentication', array(
158
-		'userid' => $internalKey,
159
-		'username' => $username,
160
-		'userpassword' => $givenPassword,
161
-		'savedpassword' => $dbasePassword,
162
-		'rememberme' => $rememberme
163
-	));
158
+        'userid' => $internalKey,
159
+        'username' => $username,
160
+        'userpassword' => $givenPassword,
161
+        'savedpassword' => $dbasePassword,
162
+        'rememberme' => $rememberme
163
+    ));
164 164
 
165 165
 // check if plugin authenticated the user
166 166
 $matchPassword = false;
167 167
 if(!isset($rt) || !$rt || (is_array($rt) && !in_array(true, $rt))) {
168
-	// check user password - local authentication
169
-	$hashType = $modx->manager->getHashType($dbasePassword);
170
-	if($hashType == 'phpass') {
171
-		$matchPassword = login($username, $_REQUEST['password'], $dbasePassword);
172
-	} elseif($hashType == 'md5') {
173
-		$matchPassword = loginMD5($internalKey, $_REQUEST['password'], $dbasePassword, $username);
174
-	} elseif($hashType == 'v1') {
175
-		$matchPassword = loginV1($internalKey, $_REQUEST['password'], $dbasePassword, $username);
176
-	} else {
177
-		$matchPassword = false;
178
-	}
168
+    // check user password - local authentication
169
+    $hashType = $modx->manager->getHashType($dbasePassword);
170
+    if($hashType == 'phpass') {
171
+        $matchPassword = login($username, $_REQUEST['password'], $dbasePassword);
172
+    } elseif($hashType == 'md5') {
173
+        $matchPassword = loginMD5($internalKey, $_REQUEST['password'], $dbasePassword, $username);
174
+    } elseif($hashType == 'v1') {
175
+        $matchPassword = loginV1($internalKey, $_REQUEST['password'], $dbasePassword, $username);
176
+    } else {
177
+        $matchPassword = false;
178
+    }
179 179
 } else if($rt === true || (is_array($rt) && in_array(true, $rt))) {
180
-	$matchPassword = true;
180
+    $matchPassword = true;
181 181
 }
182 182
 
183 183
 if(!$matchPassword) {
184
-	jsAlert($_lang['login_processor_wrong_password']);
185
-	incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes);
186
-	return;
184
+    jsAlert($_lang['login_processor_wrong_password']);
185
+    incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes);
186
+    return;
187 187
 }
188 188
 
189 189
 if($modx->config['use_captcha'] == 1) {
190
-	if(!isset ($_SESSION['veriword'])) {
191
-		jsAlert($_lang['login_processor_captcha_config']);
192
-		return;
193
-	} elseif($_SESSION['veriword'] != $captcha_code) {
194
-		jsAlert($_lang['login_processor_bad_code']);
195
-		incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes);
196
-		return;
197
-	}
190
+    if(!isset ($_SESSION['veriword'])) {
191
+        jsAlert($_lang['login_processor_captcha_config']);
192
+        return;
193
+    } elseif($_SESSION['veriword'] != $captcha_code) {
194
+        jsAlert($_lang['login_processor_bad_code']);
195
+        incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes);
196
+        return;
197
+    }
198 198
 }
199 199
 
200 200
 $modx->cleanupExpiredLocks();
@@ -229,36 +229,36 @@  discard block
 block discarded – undo
229 229
 $_SESSION['mgrToken'] = md5($currentsessionid);
230 230
 
231 231
 if($rememberme == '1') {
232
-	$_SESSION['modx.mgr.session.cookie.lifetime'] = intval($modx->config['session.cookie.lifetime']);
233
-
234
-	// Set a cookie separate from the session cookie with the username in it. 
235
-	// Are we using secure connection? If so, make sure the cookie is secure
236
-	global $https_port;
237
-
238
-	$secure = ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port);
239
-	if(version_compare(PHP_VERSION, '5.2', '<')) {
240
-		setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, '; HttpOnly', $secure);
241
-	} else {
242
-		setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, NULL, $secure, true);
243
-	}
232
+    $_SESSION['modx.mgr.session.cookie.lifetime'] = intval($modx->config['session.cookie.lifetime']);
233
+
234
+    // Set a cookie separate from the session cookie with the username in it. 
235
+    // Are we using secure connection? If so, make sure the cookie is secure
236
+    global $https_port;
237
+
238
+    $secure = ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port);
239
+    if(version_compare(PHP_VERSION, '5.2', '<')) {
240
+        setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, '; HttpOnly', $secure);
241
+    } else {
242
+        setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, NULL, $secure, true);
243
+    }
244 244
 } else {
245
-	$_SESSION['modx.mgr.session.cookie.lifetime'] = 0;
245
+    $_SESSION['modx.mgr.session.cookie.lifetime'] = 0;
246 246
 
247
-	// Remove the Remember Me cookie
248
-	setcookie('modx_remember_manager', '', time() - 3600, MODX_BASE_URL);
247
+    // Remove the Remember Me cookie
248
+    setcookie('modx_remember_manager', '', time() - 3600, MODX_BASE_URL);
249 249
 }
250 250
 
251 251
 // Check if user already has an active session, if not check if user pressed logout end of last session
252 252
 $rs = $modx->db->select('lasthit', $modx->getFullTableName('active_user_sessions'), "internalKey='{$internalKey}'");
253 253
 $activeSession = $modx->db->getValue($rs);
254 254
 if(!$activeSession) {
255
-	$rs = $modx->db->select('lasthit', $modx->getFullTableName('active_users'), "internalKey='{$internalKey}' AND action != 8");
256
-	if($lastHit = $modx->db->getValue($rs)) {
257
-		$_SESSION['show_logout_reminder'] = array(
258
-			'type' => 'logout_reminder',
259
-			'lastHit' => $lastHit
260
-		);
261
-	}
255
+    $rs = $modx->db->select('lasthit', $modx->getFullTableName('active_users'), "internalKey='{$internalKey}' AND action != 8");
256
+    if($lastHit = $modx->db->getValue($rs)) {
257
+        $_SESSION['show_logout_reminder'] = array(
258
+            'type' => 'logout_reminder',
259
+            'lastHit' => $lastHit
260
+        );
261
+    }
262 262
 }
263 263
 
264 264
 $log = new logHandler;
@@ -266,109 +266,109 @@  discard block
 block discarded – undo
266 266
 
267 267
 // invoke OnManagerLogin event
268 268
 $modx->invokeEvent('OnManagerLogin', array(
269
-		'userid' => $internalKey,
270
-		'username' => $username,
271
-		'userpassword' => $givenPassword,
272
-		'rememberme' => $rememberme
273
-	));
269
+        'userid' => $internalKey,
270
+        'username' => $username,
271
+        'userpassword' => $givenPassword,
272
+        'rememberme' => $rememberme
273
+    ));
274 274
 
275 275
 // check if we should redirect user to a web page
276 276
 $rs = $modx->db->select('setting_value', '[+prefix+]user_settings', "user='{$internalKey}' AND setting_name='manager_login_startup'");
277 277
 $id = intval($modx->db->getValue($rs));
278 278
 if($id > 0) {
279
-	$header = 'Location: ' . $modx->makeUrl($id, '', '', 'full');
280
-	if($_POST['ajax'] == 1) {
281
-		echo $header;
282
-	} else {
283
-		header($header);
284
-	}
279
+    $header = 'Location: ' . $modx->makeUrl($id, '', '', 'full');
280
+    if($_POST['ajax'] == 1) {
281
+        echo $header;
282
+    } else {
283
+        header($header);
284
+    }
285 285
 } else {
286
-	$header = 'Location: ' . MODX_MANAGER_URL;
287
-	if($_POST['ajax'] == 1) {
288
-		echo $header;
289
-	} else {
290
-		header($header);
291
-	}
286
+    $header = 'Location: ' . MODX_MANAGER_URL;
287
+    if($_POST['ajax'] == 1) {
288
+        echo $header;
289
+    } else {
290
+        header($header);
291
+    }
292 292
 }
293 293
 
294 294
 // show javascript alert
295 295
 function jsAlert($msg) {
296
-	global $modx;
297
-	if($_POST['ajax'] != 1) {
298
-		echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>";
299
-	} else {
300
-		echo $msg . "\n";
301
-	}
296
+    global $modx;
297
+    if($_POST['ajax'] != 1) {
298
+        echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>";
299
+    } else {
300
+        echo $msg . "\n";
301
+    }
302 302
 }
303 303
 
304 304
 function login($username, $givenPassword, $dbasePassword) {
305
-	global $modx;
306
-	return $modx->phpass->CheckPassword($givenPassword, $dbasePassword);
305
+    global $modx;
306
+    return $modx->phpass->CheckPassword($givenPassword, $dbasePassword);
307 307
 }
308 308
 
309 309
 function loginV1($internalKey, $givenPassword, $dbasePassword, $username) {
310
-	global $modx;
310
+    global $modx;
311 311
 
312
-	$user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey);
312
+    $user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey);
313 313
 
314
-	if(!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) {
315
-		$modx->config['pwd_hash_algo'] = 'UNCRYPT';
316
-	}
314
+    if(!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) {
315
+        $modx->config['pwd_hash_algo'] = 'UNCRYPT';
316
+    }
317 317
 
318
-	if($user_algo !== $modx->config['pwd_hash_algo']) {
319
-		$bk_pwd_hash_algo = $modx->config['pwd_hash_algo'];
320
-		$modx->config['pwd_hash_algo'] = $user_algo;
321
-	}
318
+    if($user_algo !== $modx->config['pwd_hash_algo']) {
319
+        $bk_pwd_hash_algo = $modx->config['pwd_hash_algo'];
320
+        $modx->config['pwd_hash_algo'] = $user_algo;
321
+    }
322 322
 
323
-	if($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) {
324
-		return false;
325
-	}
323
+    if($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) {
324
+        return false;
325
+    }
326 326
 
327
-	updateNewHash($username, $givenPassword);
327
+    updateNewHash($username, $givenPassword);
328 328
 
329
-	return true;
329
+    return true;
330 330
 }
331 331
 
332 332
 function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) {
333
-	global $modx;
333
+    global $modx;
334 334
 
335
-	if($dbasePassword != md5($givenPassword)) {
336
-		return false;
337
-	}
338
-	updateNewHash($username, $givenPassword);
339
-	return true;
335
+    if($dbasePassword != md5($givenPassword)) {
336
+        return false;
337
+    }
338
+    updateNewHash($username, $givenPassword);
339
+    return true;
340 340
 }
341 341
 
342 342
 function updateNewHash($username, $password) {
343
-	global $modx;
343
+    global $modx;
344 344
 
345
-	$field = array();
346
-	$field['password'] = $modx->phpass->HashPassword($password);
347
-	$modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'");
345
+    $field = array();
346
+    $field['password'] = $modx->phpass->HashPassword($password);
347
+    $modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'");
348 348
 }
349 349
 
350 350
 function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) {
351
-	global $modx;
352
-
353
-	$failedlogins += 1;
354
-
355
-	$fields = array('failedlogincount' => $failedlogins);
356
-	if($failedlogins >= $failed_allowed) //block user for too many fail attempts
357
-	{
358
-		$fields['blockeduntil'] = time() + ($blocked_minutes * 60);
359
-	}
360
-
361
-	$modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
362
-
363
-	if($failedlogins < $failed_allowed) {
364
-		//sleep to help prevent brute force attacks
365
-		$sleep = (int) $failedlogins / 2;
366
-		if($sleep > 5) {
367
-			$sleep = 5;
368
-		}
369
-		sleep($sleep);
370
-	}
371
-	@session_destroy();
372
-	session_unset();
373
-	return;
351
+    global $modx;
352
+
353
+    $failedlogins += 1;
354
+
355
+    $fields = array('failedlogincount' => $failedlogins);
356
+    if($failedlogins >= $failed_allowed) //block user for too many fail attempts
357
+    {
358
+        $fields['blockeduntil'] = time() + ($blocked_minutes * 60);
359
+    }
360
+
361
+    $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
362
+
363
+    if($failedlogins < $failed_allowed) {
364
+        //sleep to help prevent brute force attacks
365
+        $sleep = (int) $failedlogins / 2;
366
+        if($sleep > 5) {
367
+            $sleep = 5;
368
+        }
369
+        sleep($sleep);
370
+    }
371
+    @session_destroy();
372
+    session_unset();
373
+    return;
374 374
 }
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
2
+if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
3 3
 	header('HTTP/1.0 404 Not Found');
4 4
 	exit('error');
5 5
 }
6
-define('IN_MANAGER_MODE', true);  // we use this to make sure files are accessed through
6
+define('IN_MANAGER_MODE', true); // we use this to make sure files are accessed through
7 7
 define('MODX_API_MODE', true);
8
-include_once(__DIR__ . '/../../index.php');
8
+include_once(__DIR__.'/../../index.php');
9 9
 $modx->db->connect();
10 10
 $modx->getSettings();
11 11
 $modx->invokeEvent('OnManagerPageInit');
12 12
 $modx->loadExtension('ManagerAPI');
13 13
 $modx->loadExtension('phpass');
14 14
 
15
-$core_path = MODX_MANAGER_PATH . 'includes/';
15
+$core_path = MODX_MANAGER_PATH.'includes/';
16 16
 // include_once the language file
17 17
 $_lang = array();
18 18
 include_once("{$core_path}lang/english.inc.php");
19 19
 
20
-if($manager_language !== 'english' && is_file("{$core_path}lang/{$manager_language}.inc.php")) {
20
+if ($manager_language !== 'english' && is_file("{$core_path}lang/{$manager_language}.inc.php")) {
21 21
 	include_once("{$core_path}lang/{$manager_language}.inc.php");
22 22
 }
23 23
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 include_once("{$core_path}log.class.inc.php");
26 26
 
27 27
 // Initialize System Alert Message Queque
28
-if(!isset($_SESSION['SystemAlertMsgQueque'])) {
28
+if (!isset($_SESSION['SystemAlertMsgQueque'])) {
29 29
 	$_SESSION['SystemAlertMsgQueque'] = array();
30 30
 }
31 31
 $SystemAlertMsgQueque = &$_SESSION['SystemAlertMsgQueque'];
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 $rs = $modx->db->select($fields, $from, $where);
52 52
 $limit = $modx->db->getRecordCount($rs);
53 53
 
54
-if($limit == 0 || $limit > 1) {
54
+if ($limit == 0 || $limit > 1) {
55 55
 	jsAlert($_lang['login_processor_unknown_user']);
56 56
 	return;
57 57
 }
@@ -73,32 +73,32 @@  discard block
 block discarded – undo
73 73
 
74 74
 // get the user settings from the database
75 75
 $rs = $modx->db->select('setting_name, setting_value', '[+prefix+]user_settings', "user='{$internalKey}' AND setting_value!=''");
76
-while($row = $modx->db->getRow($rs)) {
76
+while ($row = $modx->db->getRow($rs)) {
77 77
 	extract($row);
78 78
 	${$setting_name} = $setting_value;
79 79
 }
80 80
 
81 81
 // blocked due to number of login errors.
82
-if($failedlogins >= $failed_allowed && $blockeduntildate > time()) {
82
+if ($failedlogins >= $failed_allowed && $blockeduntildate > time()) {
83 83
 	@session_destroy();
84 84
 	session_unset();
85
-	if($cip = getenv("HTTP_CLIENT_IP")) {
85
+	if ($cip = getenv("HTTP_CLIENT_IP")) {
86 86
 		$ip = $cip;
87
-	} elseif($cip = getenv("HTTP_X_FORWARDED_FOR")) {
87
+	} elseif ($cip = getenv("HTTP_X_FORWARDED_FOR")) {
88 88
 		$ip = $cip;
89
-	} elseif($cip = getenv("REMOTE_ADDR")) {
89
+	} elseif ($cip = getenv("REMOTE_ADDR")) {
90 90
 		$ip = $cip;
91 91
 	} else {
92 92
 		$ip = "UNKNOWN";
93 93
 	}
94 94
 	$log = new logHandler;
95
-	$log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: " . $ip);
95
+	$log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: ".$ip);
96 96
 	jsAlert($_lang['login_processor_many_failed_logins']);
97 97
 	return;
98 98
 }
99 99
 
100 100
 // blocked due to number of login errors, but get to try again
101
-if($failedlogins >= $failed_allowed && $blockeduntildate < time()) {
101
+if ($failedlogins >= $failed_allowed && $blockeduntildate < time()) {
102 102
 	$fields = array();
103 103
 	$fields['failedlogincount'] = '0';
104 104
 	$fields['blockeduntil'] = time() - 1;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 }
107 107
 
108 108
 // this user has been blocked by an admin, so no way he's loggin in!
109
-if($blocked == '1') {
109
+if ($blocked == '1') {
110 110
 	@session_destroy();
111 111
 	session_unset();
112 112
 	jsAlert($_lang['login_processor_blocked1']);
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 }
115 115
 
116 116
 // blockuntil: this user has a block until date
117
-if($blockeduntildate > time()) {
117
+if ($blockeduntildate > time()) {
118 118
 	@session_destroy();
119 119
 	session_unset();
120 120
 	jsAlert($_lang['login_processor_blocked2']);
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 }
123 123
 
124 124
 // blockafter: this user has a block after date
125
-if($blockedafterdate > 0 && $blockedafterdate < time()) {
125
+if ($blockedafterdate > 0 && $blockedafterdate < time()) {
126 126
 	@session_destroy();
127 127
 	session_unset();
128 128
 	jsAlert($_lang['login_processor_blocked3']);
@@ -130,24 +130,24 @@  discard block
 block discarded – undo
130 130
 }
131 131
 
132 132
 // allowed ip
133
-if($allowed_ip) {
134
-	if(($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) {
135
-		if(gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) {
133
+if ($allowed_ip) {
134
+	if (($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) {
135
+		if (gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) {
136 136
 			jsAlert($_lang['login_processor_remotehost_ip']);
137 137
 			return;
138 138
 		}
139 139
 	}
140
-	if(!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) {
140
+	if (!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) {
141 141
 		jsAlert($_lang['login_processor_remote_ip']);
142 142
 		return;
143 143
 	}
144 144
 }
145 145
 
146 146
 // allowed days
147
-if($allowed_days) {
147
+if ($allowed_days) {
148 148
 	$date = getdate();
149 149
 	$day = $date['wday'] + 1;
150
-	if(strpos($allowed_days, $day) === false) {
150
+	if (strpos($allowed_days, $day) === false) {
151 151
 		jsAlert($_lang['login_processor_date']);
152 152
 		return;
153 153
 	}
@@ -164,33 +164,33 @@  discard block
 block discarded – undo
164 164
 
165 165
 // check if plugin authenticated the user
166 166
 $matchPassword = false;
167
-if(!isset($rt) || !$rt || (is_array($rt) && !in_array(true, $rt))) {
167
+if (!isset($rt) || !$rt || (is_array($rt) && !in_array(true, $rt))) {
168 168
 	// check user password - local authentication
169 169
 	$hashType = $modx->manager->getHashType($dbasePassword);
170
-	if($hashType == 'phpass') {
170
+	if ($hashType == 'phpass') {
171 171
 		$matchPassword = login($username, $_REQUEST['password'], $dbasePassword);
172
-	} elseif($hashType == 'md5') {
172
+	} elseif ($hashType == 'md5') {
173 173
 		$matchPassword = loginMD5($internalKey, $_REQUEST['password'], $dbasePassword, $username);
174
-	} elseif($hashType == 'v1') {
174
+	} elseif ($hashType == 'v1') {
175 175
 		$matchPassword = loginV1($internalKey, $_REQUEST['password'], $dbasePassword, $username);
176 176
 	} else {
177 177
 		$matchPassword = false;
178 178
 	}
179
-} else if($rt === true || (is_array($rt) && in_array(true, $rt))) {
179
+} else if ($rt === true || (is_array($rt) && in_array(true, $rt))) {
180 180
 	$matchPassword = true;
181 181
 }
182 182
 
183
-if(!$matchPassword) {
183
+if (!$matchPassword) {
184 184
 	jsAlert($_lang['login_processor_wrong_password']);
185 185
 	incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes);
186 186
 	return;
187 187
 }
188 188
 
189
-if($modx->config['use_captcha'] == 1) {
190
-	if(!isset ($_SESSION['veriword'])) {
189
+if ($modx->config['use_captcha'] == 1) {
190
+	if (!isset ($_SESSION['veriword'])) {
191 191
 		jsAlert($_lang['login_processor_captcha_config']);
192 192
 		return;
193
-	} elseif($_SESSION['veriword'] != $captcha_code) {
193
+	} elseif ($_SESSION['veriword'] != $captcha_code) {
194 194
 		jsAlert($_lang['login_processor_bad_code']);
195 195
 		incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes);
196 196
 		return;
@@ -218,17 +218,17 @@  discard block
 block discarded – undo
218 218
 $_SESSION['mgrPermissions'] = $modx->db->getRow($rs);
219 219
 
220 220
 // successful login so reset fail count and update key values
221
-$modx->db->update('failedlogincount=0, ' . 'logincount=logincount+1, ' . 'lastlogin=thislogin, ' . 'thislogin=' . time() . ', ' . "sessionid='{$currentsessionid}'", '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
221
+$modx->db->update('failedlogincount=0, '.'logincount=logincount+1, '.'lastlogin=thislogin, '.'thislogin='.time().', '."sessionid='{$currentsessionid}'", '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
222 222
 
223 223
 // get user's document groups
224 224
 $i = 0;
225
-$rs = $modx->db->select('uga.documentgroup', $modx->getFullTableName('member_groups') . ' ug
226
-		INNER JOIN ' . $modx->getFullTableName('membergroup_access') . ' uga ON uga.membergroup=ug.user_group', "ug.member='{$internalKey}'");
225
+$rs = $modx->db->select('uga.documentgroup', $modx->getFullTableName('member_groups').' ug
226
+		INNER JOIN ' . $modx->getFullTableName('membergroup_access').' uga ON uga.membergroup=ug.user_group', "ug.member='{$internalKey}'");
227 227
 $_SESSION['mgrDocgroups'] = $modx->db->getColumn('documentgroup', $rs);
228 228
 
229 229
 $_SESSION['mgrToken'] = md5($currentsessionid);
230 230
 
231
-if($rememberme == '1') {
231
+if ($rememberme == '1') {
232 232
 	$_SESSION['modx.mgr.session.cookie.lifetime'] = intval($modx->config['session.cookie.lifetime']);
233 233
 
234 234
 	// Set a cookie separate from the session cookie with the username in it. 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	global $https_port;
237 237
 
238 238
 	$secure = ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port);
239
-	if(version_compare(PHP_VERSION, '5.2', '<')) {
239
+	if (version_compare(PHP_VERSION, '5.2', '<')) {
240 240
 		setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, '; HttpOnly', $secure);
241 241
 	} else {
242 242
 		setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, NULL, $secure, true);
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
 // Check if user already has an active session, if not check if user pressed logout end of last session
252 252
 $rs = $modx->db->select('lasthit', $modx->getFullTableName('active_user_sessions'), "internalKey='{$internalKey}'");
253 253
 $activeSession = $modx->db->getValue($rs);
254
-if(!$activeSession) {
254
+if (!$activeSession) {
255 255
 	$rs = $modx->db->select('lasthit', $modx->getFullTableName('active_users'), "internalKey='{$internalKey}' AND action != 8");
256
-	if($lastHit = $modx->db->getValue($rs)) {
256
+	if ($lastHit = $modx->db->getValue($rs)) {
257 257
 		$_SESSION['show_logout_reminder'] = array(
258 258
 			'type' => 'logout_reminder',
259 259
 			'lastHit' => $lastHit
@@ -275,16 +275,16 @@  discard block
 block discarded – undo
275 275
 // check if we should redirect user to a web page
276 276
 $rs = $modx->db->select('setting_value', '[+prefix+]user_settings', "user='{$internalKey}' AND setting_name='manager_login_startup'");
277 277
 $id = intval($modx->db->getValue($rs));
278
-if($id > 0) {
279
-	$header = 'Location: ' . $modx->makeUrl($id, '', '', 'full');
280
-	if($_POST['ajax'] == 1) {
278
+if ($id > 0) {
279
+	$header = 'Location: '.$modx->makeUrl($id, '', '', 'full');
280
+	if ($_POST['ajax'] == 1) {
281 281
 		echo $header;
282 282
 	} else {
283 283
 		header($header);
284 284
 	}
285 285
 } else {
286
-	$header = 'Location: ' . MODX_MANAGER_URL;
287
-	if($_POST['ajax'] == 1) {
286
+	$header = 'Location: '.MODX_MANAGER_URL;
287
+	if ($_POST['ajax'] == 1) {
288 288
 		echo $header;
289 289
 	} else {
290 290
 		header($header);
@@ -292,35 +292,35 @@  discard block
 block discarded – undo
292 292
 }
293 293
 
294 294
 // show javascript alert
295
-function jsAlert($msg) {
295
+function jsAlert($msg){
296 296
 	global $modx;
297
-	if($_POST['ajax'] != 1) {
298
-		echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>";
297
+	if ($_POST['ajax'] != 1) {
298
+		echo "<script>window.setTimeout(\"alert('".addslashes($modx->db->escape($msg))."')\",10);history.go(-1)</script>";
299 299
 	} else {
300
-		echo $msg . "\n";
300
+		echo $msg."\n";
301 301
 	}
302 302
 }
303 303
 
304
-function login($username, $givenPassword, $dbasePassword) {
304
+function login($username, $givenPassword, $dbasePassword){
305 305
 	global $modx;
306 306
 	return $modx->phpass->CheckPassword($givenPassword, $dbasePassword);
307 307
 }
308 308
 
309
-function loginV1($internalKey, $givenPassword, $dbasePassword, $username) {
309
+function loginV1($internalKey, $givenPassword, $dbasePassword, $username){
310 310
 	global $modx;
311 311
 
312 312
 	$user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey);
313 313
 
314
-	if(!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) {
314
+	if (!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) {
315 315
 		$modx->config['pwd_hash_algo'] = 'UNCRYPT';
316 316
 	}
317 317
 
318
-	if($user_algo !== $modx->config['pwd_hash_algo']) {
318
+	if ($user_algo !== $modx->config['pwd_hash_algo']) {
319 319
 		$bk_pwd_hash_algo = $modx->config['pwd_hash_algo'];
320 320
 		$modx->config['pwd_hash_algo'] = $user_algo;
321 321
 	}
322 322
 
323
-	if($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) {
323
+	if ($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) {
324 324
 		return false;
325 325
 	}
326 326
 
@@ -329,17 +329,17 @@  discard block
 block discarded – undo
329 329
 	return true;
330 330
 }
331 331
 
332
-function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) {
332
+function loginMD5($internalKey, $givenPassword, $dbasePassword, $username){
333 333
 	global $modx;
334 334
 
335
-	if($dbasePassword != md5($givenPassword)) {
335
+	if ($dbasePassword != md5($givenPassword)) {
336 336
 		return false;
337 337
 	}
338 338
 	updateNewHash($username, $givenPassword);
339 339
 	return true;
340 340
 }
341 341
 
342
-function updateNewHash($username, $password) {
342
+function updateNewHash($username, $password){
343 343
 	global $modx;
344 344
 
345 345
 	$field = array();
@@ -347,23 +347,23 @@  discard block
 block discarded – undo
347 347
 	$modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'");
348 348
 }
349 349
 
350
-function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) {
350
+function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes){
351 351
 	global $modx;
352 352
 
353 353
 	$failedlogins += 1;
354 354
 
355 355
 	$fields = array('failedlogincount' => $failedlogins);
356
-	if($failedlogins >= $failed_allowed) //block user for too many fail attempts
356
+	if ($failedlogins >= $failed_allowed) //block user for too many fail attempts
357 357
 	{
358 358
 		$fields['blockeduntil'] = time() + ($blocked_minutes * 60);
359 359
 	}
360 360
 
361 361
 	$modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
362 362
 
363
-	if($failedlogins < $failed_allowed) {
363
+	if ($failedlogins < $failed_allowed) {
364 364
 		//sleep to help prevent brute force attacks
365 365
 		$sleep = (int) $failedlogins / 2;
366
-		if($sleep > 5) {
366
+		if ($sleep > 5) {
367 367
 			$sleep = 5;
368 368
 		}
369 369
 		sleep($sleep);
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -292,7 +292,8 @@  discard block
 block discarded – undo
292 292
 }
293 293
 
294 294
 // show javascript alert
295
-function jsAlert($msg) {
295
+function jsAlert($msg)
296
+{
296 297
 	global $modx;
297 298
 	if($_POST['ajax'] != 1) {
298 299
 		echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>";
@@ -301,12 +302,14 @@  discard block
 block discarded – undo
301 302
 	}
302 303
 }
303 304
 
304
-function login($username, $givenPassword, $dbasePassword) {
305
+function login($username, $givenPassword, $dbasePassword)
306
+{
305 307
 	global $modx;
306 308
 	return $modx->phpass->CheckPassword($givenPassword, $dbasePassword);
307 309
 }
308 310
 
309
-function loginV1($internalKey, $givenPassword, $dbasePassword, $username) {
311
+function loginV1($internalKey, $givenPassword, $dbasePassword, $username)
312
+{
310 313
 	global $modx;
311 314
 
312 315
 	$user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey);
@@ -329,7 +332,8 @@  discard block
 block discarded – undo
329 332
 	return true;
330 333
 }
331 334
 
332
-function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) {
335
+function loginMD5($internalKey, $givenPassword, $dbasePassword, $username)
336
+{
333 337
 	global $modx;
334 338
 
335 339
 	if($dbasePassword != md5($givenPassword)) {
@@ -339,7 +343,8 @@  discard block
 block discarded – undo
339 343
 	return true;
340 344
 }
341 345
 
342
-function updateNewHash($username, $password) {
346
+function updateNewHash($username, $password)
347
+{
343 348
 	global $modx;
344 349
 
345 350
 	$field = array();
@@ -347,16 +352,19 @@  discard block
 block discarded – undo
347 352
 	$modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'");
348 353
 }
349 354
 
350
-function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) {
355
+function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes)
356
+{
351 357
 	global $modx;
352 358
 
353 359
 	$failedlogins += 1;
354 360
 
355 361
 	$fields = array('failedlogincount' => $failedlogins);
356
-	if($failedlogins >= $failed_allowed) //block user for too many fail attempts
362
+	if($failedlogins >= $failed_allowed) {
363
+	    //block user for too many fail attempts
357 364
 	{
358 365
 		$fields['blockeduntil'] = time() + ($blocked_minutes * 60);
359 366
 	}
367
+	}
360 368
 
361 369
 	$modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
362 370
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@
 block discarded – undo
239 239
 	if(version_compare(PHP_VERSION, '5.2', '<')) {
240 240
 		setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, '; HttpOnly', $secure);
241 241
 	} else {
242
-		setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, NULL, $secure, true);
242
+		setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, null, $secure, true);
243 243
 	}
244 244
 } else {
245 245
 	$_SESSION['modx.mgr.session.cookie.lifetime'] = 0;
Please login to merge, or discard this patch.
manager/frames/1.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -236,9 +236,9 @@
 block discarded – undo
236 236
         lockedElementsTranslation: <?= json_encode($unlockTranslations, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE) . "\n" ?>
237 237
       };
238 238
       <?php
239
-      $opened = array_filter(array_map('intval', explode('|', $_SESSION['openedArray'])));
240
-      echo (empty($opened) ? '' : 'modx.openedArray[' . implode("] = 1;\n		modx.openedArray[", $opened) . '] = 1;') . "\n";
241
-      ?>
239
+        $opened = array_filter(array_map('intval', explode('|', $_SESSION['openedArray'])));
240
+        echo (empty($opened) ? '' : 'modx.openedArray[' . implode("] = 1;\n		modx.openedArray[", $opened) . '] = 1;') . "\n";
241
+        ?>
242 242
     </script>
243 243
     <script src="media/style/<?= $modx->config['manager_theme'] ?>/js/modx.min.js?v=<?= $lastInstallTime ?>"></script>
244 244
     <?php if ($modx->config['show_picker'] != "0") { ?>
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 header("X-XSS-Protection: 0");
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 }
47 47
 
48 48
 if (isset($_COOKIE['MODX_themeColor'])) {
49
-    $body_class .= ' ' . $_COOKIE['MODX_themeColor'];
49
+    $body_class .= ' '.$_COOKIE['MODX_themeColor'];
50 50
 }
51 51
 
52 52
 if (isset($modx->pluginCache['ElementsInTree'])) {
@@ -74,36 +74,36 @@  discard block
 block discarded – undo
74 74
     $user['which_browser'] = $modx->config['which_browser'];
75 75
 }
76 76
 
77
-$css = 'media/style/' . $modx->config['manager_theme'] . '/css/page.css?v=' . $lastInstallTime;
77
+$css = 'media/style/'.$modx->config['manager_theme'].'/css/page.css?v='.$lastInstallTime;
78 78
 
79 79
 if ($modx->config['manager_theme'] == 'default') {
80
-    if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) {
81
-        require_once MODX_BASE_PATH . 'assets/lib/Formatter/CSSMinify.php';
80
+    if (!file_exists(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/styles.min.css') && is_writable(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css')) {
81
+        require_once MODX_BASE_PATH.'assets/lib/Formatter/CSSMinify.php';
82 82
         $minifier = new Formatter\CSSMinify();
83
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/common/bootstrap/css/bootstrap.min.css');
84
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/common/font-awesome/css/font-awesome.min.css');
85
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/fonts.css');
86
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/forms.css');
87
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/mainmenu.css');
88
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/tree.css');
89
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/custom.css');
90
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/tabpane.css');
91
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/contextmenu.css');
92
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/index.css');
93
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/main.css');
83
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/common/bootstrap/css/bootstrap.min.css');
84
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/common/font-awesome/css/font-awesome.min.css');
85
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/fonts.css');
86
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/forms.css');
87
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/mainmenu.css');
88
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/tree.css');
89
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/custom.css');
90
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/tabpane.css');
91
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/contextmenu.css');
92
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/index.css');
93
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/main.css');
94 94
         $css = $minifier->minify();
95
-        file_put_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css', $css);
95
+        file_put_contents(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/styles.min.css', $css);
96 96
     }
97
-    if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) {
98
-        $css = 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css?v=' . $lastInstallTime;
97
+    if (file_exists(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/styles.min.css')) {
98
+        $css = 'media/style/'.$modx->config['manager_theme'].'/css/styles.min.css?v='.$lastInstallTime;
99 99
     }
100 100
 }
101 101
 
102
-$modx->config['global_tabs'] = (int)($modx->config['global_tabs'] && ($user['role'] == 1 || $modx->hasPermission('edit_template') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_plugin')));
102
+$modx->config['global_tabs'] = (int) ($modx->config['global_tabs'] && ($user['role'] == 1 || $modx->hasPermission('edit_template') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_plugin')));
103 103
 
104 104
 ?>
105 105
 <!DOCTYPE html>
106
-<html <?= (isset($modx_textdir) && $modx_textdir ? 'dir="rtl" lang="' : 'lang="') . $mxla . '" xml:lang="' . $mxla . '"' ?>>
106
+<html <?= (isset($modx_textdir) && $modx_textdir ? 'dir="rtl" lang="' : 'lang="').$mxla.'" xml:lang="'.$mxla.'"' ?>>
107 107
 <head>
108 108
     <title><?= $site_name ?>- (EVO CMS Manager)</title>
109 109
     <meta http-equiv="Content-Type" content="text/html; charset=<?= $modx_manager_charset ?>" />
@@ -134,20 +134,20 @@  discard block
 block discarded – undo
134 134
         MODX_SITE_URL: '<?= MODX_SITE_URL ?>',
135 135
         MODX_MANAGER_URL: '<?= MODX_MANAGER_URL ?>',
136 136
         user: {
137
-          role: <?= (int)$user['role'] ?>,
137
+          role: <?= (int) $user['role'] ?>,
138 138
           username: '<?= $user['username'] ?>'
139 139
         },
140 140
         config: {
141 141
           mail_check_timeperiod: <?= $modx->config['mail_check_timeperiod'] ?>,
142
-          menu_height: <?= (int)$menu_height ?>,
143
-          tree_width: <?= (int)$tree_width ?>,
144
-          tree_min_width: <?= (int)$tree_min_width ?>,
145
-          session_timeout: <?= (int)$modx->config['session_timeout'] ?>,
146
-          site_start: <?= (int)$modx->config['site_start'] ?>,
147
-          tree_page_click: <?=(!empty($modx->config['tree_page_click']) ? (int)$modx->config['tree_page_click'] : 27) ?>,
142
+          menu_height: <?= (int) $menu_height ?>,
143
+          tree_width: <?= (int) $tree_width ?>,
144
+          tree_min_width: <?= (int) $tree_min_width ?>,
145
+          session_timeout: <?= (int) $modx->config['session_timeout'] ?>,
146
+          site_start: <?= (int) $modx->config['site_start'] ?>,
147
+          tree_page_click: <?=(!empty($modx->config['tree_page_click']) ? (int) $modx->config['tree_page_click'] : 27) ?>,
148 148
           theme: '<?= $modx->config['manager_theme'] ?>',
149 149
           which_browser: '<?= $user['which_browser'] ?>',
150
-          layout: <?= (int)$manager_layout ?>,
150
+          layout: <?= (int) $manager_layout ?>,
151 151
           textdir: '<?= $modx_textdir ?>',
152 152
           global_tabs: <?= $modx->config['global_tabs'] ?>
153 153
 
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
           delete a[b];
233 233
         },
234 234
         openedArray: [],
235
-        lockedElementsTranslation: <?= json_encode($unlockTranslations, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE) . "\n" ?>
235
+        lockedElementsTranslation: <?= json_encode($unlockTranslations, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE)."\n" ?>
236 236
       };
237 237
       <?php
238 238
       $opened = array_filter(array_map('intval', explode('|', $_SESSION['openedArray'])));
239
-      echo (empty($opened) ? '' : 'modx.openedArray[' . implode("] = 1;\n		modx.openedArray[", $opened) . '] = 1;') . "\n";
239
+      echo (empty($opened) ? '' : 'modx.openedArray['.implode("] = 1;\n		modx.openedArray[", $opened).'] = 1;')."\n";
240 240
       ?>
241 241
     </script>
242 242
     <script src="media/style/<?= $modx->config['manager_theme'] ?>/js/modx.min.js?v=<?= $lastInstallTime ?>"></script>
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
                             <a href="javascript:;" class="dropdown-toggle" onclick="return false;">
366 366
                                 <span class="username"><?= $user['username'] ?></span>
367 367
                                 <?php if ($user['photo']) { ?>
368
-                                    <span class="icon photo" style="background-image: url(<?= MODX_SITE_URL . $user['photo'] ?>);"></span>
368
+                                    <span class="icon photo" style="background-image: url(<?= MODX_SITE_URL.$user['photo'] ?>);"></span>
369 369
                                 <?php } else { ?>
370 370
                                     <span class="icon"><?= $_style['menu_user'] ?></span>
371 371
                                 <?php } ?>
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
                                 $version = 'Evolution';
393 393
                                 ?>
394 394
                                 <?php
395
-                                echo sprintf('<li><span class="dropdown-item" title="%s &ndash; %s" %s>' . $version . ' %s</span></li>', $site_name, $modx->getVersionData('full_appname'), $style, $modx->config['settings_version']);
395
+                                echo sprintf('<li><span class="dropdown-item" title="%s &ndash; %s" %s>'.$version.' %s</span></li>', $site_name, $modx->getVersionData('full_appname'), $style, $modx->config['settings_version']);
396 396
                                 ?>
397 397
                             </ul>
398 398
                         </li>
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
     <script type="text/javascript">
532 532
 
533 533
       if (document.getElementById('treeMenu')) {
534
-          <?php if($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin')) { ?>
534
+          <?php if ($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin')) { ?>
535 535
 
536 536
         document.getElementById('treeMenu_openelements').onclick = function(e) {
537 537
           e.preventDefault();
@@ -549,12 +549,12 @@  discard block
 block discarded – undo
549 549
           }
550 550
         };
551 551
           <?php } ?>
552
-          <?php if($use_browser && $modx->hasPermission('assets_images')) { ?>
552
+          <?php if ($use_browser && $modx->hasPermission('assets_images')) { ?>
553 553
 
554 554
         document.getElementById('treeMenu_openimages').onclick = function(e) {
555 555
           e.preventDefault();
556 556
           if (modx.config.global_tabs && !e.shiftKey) {
557
-            modx.tabs({url: '<?= MODX_MANAGER_URL . 'media/browser/' . $which_browser . '/browse.php?filemanager=media/browser/' . $which_browser . '/browse.php&type=images' ?>', title: '<?= $_lang["images_management"] ?>'});
557
+            modx.tabs({url: '<?= MODX_MANAGER_URL.'media/browser/'.$which_browser.'/browse.php?filemanager=media/browser/'.$which_browser.'/browse.php&type=images' ?>', title: '<?= $_lang["images_management"] ?>'});
558 558
           } else {
559 559
             var randomNum = '<?= $_lang["files_files"] ?>';
560 560
             if (e.shiftKey) {
@@ -567,12 +567,12 @@  discard block
 block discarded – undo
567 567
           }
568 568
         };
569 569
           <?php } ?>
570
-          <?php if($use_browser && $modx->hasPermission('assets_files')) { ?>
570
+          <?php if ($use_browser && $modx->hasPermission('assets_files')) { ?>
571 571
 
572 572
         document.getElementById('treeMenu_openfiles').onclick = function(e) {
573 573
           e.preventDefault();
574 574
           if (modx.config.global_tabs && !e.shiftKey) {
575
-            modx.tabs({url: '<?= MODX_MANAGER_URL . 'media/browser/' . $which_browser . '/browse.php?filemanager=media/browser/' . $which_browser . '/browse.php&type=files' ?>', title: '<?= $_lang["files_files"] ?>'});
575
+            modx.tabs({url: '<?= MODX_MANAGER_URL.'media/browser/'.$which_browser.'/browse.php?filemanager=media/browser/'.$which_browser.'/browse.php&type=files' ?>', title: '<?= $_lang["files_files"] ?>'});
576 576
           } else {
577 577
             var randomNum = '<?= $_lang["files_files"] ?>';
578 578
             if (e.shiftKey) {
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 
627 627
 </div>
628 628
 <?php if ($modx->config['show_picker'] != "0") {
629
-    include('media/style/' . $modx->config['manager_theme'] . '/color.switcher.php');
629
+    include('media/style/'.$modx->config['manager_theme'].'/color.switcher.php');
630 630
 } ?>
631 631
 </body>
632 632
 </html>
Please login to merge, or discard this patch.
Braces   +29 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 header("X-XSS-Protection: 0");
@@ -11,22 +11,22 @@  discard block
 block discarded – undo
11 11
 
12 12
 $mxla = $modx_lang_attribute ? $modx_lang_attribute : 'en';
13 13
 
14
-if (!isset($modx->config['manager_menu_height'])) {
14
+if (!isset($modx->config['manager_menu_height'])) {
15 15
     $modx->config['manager_menu_height'] = 2.2; // rem
16 16
 }
17 17
 
18
-if (!isset($modx->config['manager_tree_width'])) {
18
+if (!isset($modx->config['manager_tree_width'])) {
19 19
     $modx->config['manager_tree_width'] = 20; // rem
20 20
 }
21 21
 
22
-if (isset($_SESSION['onLoginForwardToAction']) && is_int($_SESSION['onLoginForwardToAction'])) {
22
+if (isset($_SESSION['onLoginForwardToAction']) && is_int($_SESSION['onLoginForwardToAction'])) {
23 23
     $initMainframeAction = $_SESSION['onLoginForwardToAction'];
24 24
     unset($_SESSION['onLoginForwardToAction']);
25
-} else {
25
+} else {
26 26
     $initMainframeAction = 2; // welcome.static
27 27
 }
28 28
 
29
-if (!isset($_SESSION['tree_show_only_folders'])) {
29
+if (!isset($_SESSION['tree_show_only_folders'])) {
30 30
     $_SESSION['tree_show_only_folders'] = 0;
31 31
 }
32 32
 
@@ -35,21 +35,21 @@  discard block
 block discarded – undo
35 35
 $tree_width = $modx->config['manager_tree_width'];
36 36
 $tree_min_width = 0;
37 37
 
38
-if (isset($_COOKIE['MODX_widthSideBar'])) {
38
+if (isset($_COOKIE['MODX_widthSideBar'])) {
39 39
     $MODX_widthSideBar = $_COOKIE['MODX_widthSideBar'];
40
-} else {
40
+} else {
41 41
     $MODX_widthSideBar = $tree_width;
42 42
 }
43 43
 
44
-if (!$MODX_widthSideBar) {
44
+if (!$MODX_widthSideBar) {
45 45
     $body_class .= 'sidebar-closed';
46 46
 }
47 47
 
48
-if (isset($_COOKIE['MODX_themeColor'])) {
48
+if (isset($_COOKIE['MODX_themeColor'])) {
49 49
     $body_class .= ' ' . $_COOKIE['MODX_themeColor'];
50 50
 }
51 51
 
52
-if (isset($modx->pluginCache['ElementsInTree'])) {
52
+if (isset($modx->pluginCache['ElementsInTree'])) {
53 53
     $body_class .= ' ElementsInTree';
54 54
 }
55 55
 
@@ -65,19 +65,19 @@  discard block
 block discarded – undo
65 65
     'type8' => $_lang["lock_element_type_8"]
66 66
 );
67 67
 
68
-foreach ($unlockTranslations as $key => $value) {
68
+foreach ($unlockTranslations as $key => $value) {
69 69
     $unlockTranslations[$key] = iconv($modx->config["modx_charset"], "utf-8", $value);
70 70
 }
71 71
 
72 72
 $user = $modx->getUserInfo($modx->getLoginUserID());
73
-if ($user['which_browser'] == 'default') {
73
+if ($user['which_browser'] == 'default') {
74 74
     $user['which_browser'] = $modx->config['which_browser'];
75 75
 }
76 76
 
77 77
 $css = 'media/style/' . $modx->config['manager_theme'] . '/css/page.css?v=' . $lastInstallTime;
78 78
 
79
-if ($modx->config['manager_theme'] == 'default') {
80
-    if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) {
79
+if ($modx->config['manager_theme'] == 'default') {
80
+    if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) {
81 81
         require_once MODX_BASE_PATH . 'assets/lib/Formatter/CSSMinify.php';
82 82
         $minifier = new Formatter\CSSMinify();
83 83
         $minifier->addFile(MODX_MANAGER_PATH . 'media/style/common/bootstrap/css/bootstrap.min.css');
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
         $css = $minifier->minify();
95 95
         file_put_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css', $css);
96 96
     }
97
-    if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) {
97
+    if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) {
98 98
         $css = 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css?v=' . $lastInstallTime;
99 99
     }
100 100
 }
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
     <?php
249 249
     // invoke OnManagerTopPrerender event
250 250
     $evtOut = $modx->invokeEvent('OnManagerTopPrerender', $_REQUEST);
251
-    if (is_array($evtOut)) {
251
+    if (is_array($evtOut)) {
252 252
         echo implode("\n", $evtOut);
253 253
     }
254 254
     ?>
@@ -419,9 +419,12 @@  discard block
 block discarded – undo
419 419
             <div id="evo-tab-page-home" class="evo-tab-page show">
420 420
                 <iframe id="mainframe" src="index.php?a=<?= $initMainframeAction ?>" scrolling="auto" frameborder="0" onload="modx.main.onload(event);"></iframe>
421 421
             </div>
422
-        <?php else: ?>
422
+        <?php else {
423
+    : ?>
423 424
             <iframe id="mainframe" name="main" src="index.php?a=<?= $initMainframeAction ?>" scrolling="auto" frameborder="0" onload="modx.main.onload(event);"></iframe>
424
-        <?php endif; ?>
425
+        <?php endif;
426
+}
427
+?>
425 428
         <div id="mainloader"></div>
426 429
     </div>
427 430
     <div id="resizer"></div>
@@ -434,11 +437,11 @@  discard block
 block discarded – undo
434 437
             'tree_sortdir',
435 438
             'tree_nodename'
436 439
         );
437
-        foreach ($sortParams as $param) {
438
-            if (isset($_REQUEST[$param])) {
440
+        foreach ($sortParams as $param) {
441
+            if (isset($_REQUEST[$param])) {
439 442
                 $modx->manager->saveLastUserSetting($param, $_REQUEST[$param]);
440 443
                 $_SESSION[$param] = $_REQUEST[$param];
441
-            } else if (!isset($_SESSION[$param])) {
444
+            } else if (!isset($_SESSION[$param])) {
442 445
                 $_SESSION[$param] = $modx->manager->getLastUserSetting($param);
443 446
             }
444 447
         }
@@ -518,9 +521,9 @@  discard block
 block discarded – undo
518 521
     </div>
519 522
 
520 523
     <?php
521
-    function constructLink($action, $img, $text, $allowed)
522
-    {
523
-        if ($allowed == 1) {
524
+    function constructLink($action, $img, $text, $allowed)
525
+    {
526
+        if ($allowed == 1) {
524 527
             echo sprintf('<div class="menuLink" id="item%s" onclick="modx.tree.menuHandler(%s);">', $action, $action);
525 528
             echo sprintf('<i class="%s"></i> %s</div>', $img, $text);
526 529
         }
@@ -625,7 +628,7 @@  discard block
 block discarded – undo
625 628
     ?>
626 629
 
627 630
 </div>
628
-<?php if ($modx->config['show_picker'] != "0") {
631
+<?php if ($modx->config['show_picker'] != "0") {
629 632
     include('media/style/' . $modx->config['manager_theme'] . '/color.switcher.php');
630 633
 } ?>
631 634
 </body>
Please login to merge, or discard this patch.
manager/frames/mainmenu.php 3 patches
Indentation   +325 added lines, -325 removed lines patch added patch discarded remove patch
@@ -4,237 +4,237 @@  discard block
 block discarded – undo
4 4
 */
5 5
 
6 6
 $sitemenu['bars'] = array(
7
-	'bars',
8
-	'main',
9
-	'<i class="fa fa-bars"></i>',
10
-	'javascript:;',
11
-	$_lang['home'],
12
-	'modx.resizer.toggle(); return false;',
13
-	' return false;',
14
-	'',
15
-	0,
16
-	10,
17
-	''
7
+    'bars',
8
+    'main',
9
+    '<i class="fa fa-bars"></i>',
10
+    'javascript:;',
11
+    $_lang['home'],
12
+    'modx.resizer.toggle(); return false;',
13
+    ' return false;',
14
+    '',
15
+    0,
16
+    10,
17
+    ''
18 18
 );
19 19
 
20 20
 //mainMenu
21 21
 $sitemenu['site'] = array(
22
-	'site',
23
-	'main',
24
-	'<i class="fa fa-home"></i>' . $_lang['home'],
25
-	'index.php?a=2',
26
-	$_lang['home'],
27
-	'',
28
-	'',
29
-	'main',
30
-	0,
31
-	10,
32
-	'active'
22
+    'site',
23
+    'main',
24
+    '<i class="fa fa-home"></i>' . $_lang['home'],
25
+    'index.php?a=2',
26
+    $_lang['home'],
27
+    '',
28
+    '',
29
+    'main',
30
+    0,
31
+    10,
32
+    'active'
33 33
 );
34 34
 
35 35
 if($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('file_manager')) {
36
-	$sitemenu['elements'] = array(
37
-		'elements',
38
-		'main',
39
-		'<i class="fa fa-th"></i>' . $_lang['elements'],
40
-		'javascript:;',
41
-		$_lang['elements'],
42
-		' return false;',
43
-		'',
44
-		'',
45
-		0,
46
-		20,
47
-		''
48
-	);
36
+    $sitemenu['elements'] = array(
37
+        'elements',
38
+        'main',
39
+        '<i class="fa fa-th"></i>' . $_lang['elements'],
40
+        'javascript:;',
41
+        $_lang['elements'],
42
+        ' return false;',
43
+        '',
44
+        '',
45
+        0,
46
+        20,
47
+        ''
48
+    );
49 49
 }
50 50
 
51 51
 if($modx->hasPermission('exec_module')) {
52
-	$sitemenu['modules'] = array(
53
-		'modules',
54
-		'main',
55
-		'<i class="'.$_style['icons_modules'] .'"></i>' . $_lang['modules'],
56
-		'javascript:;',
57
-		$_lang['modules'],
58
-		' return false;',
59
-		'',
60
-		'',
61
-		0,
62
-		30,
63
-		''
64
-	);
52
+    $sitemenu['modules'] = array(
53
+        'modules',
54
+        'main',
55
+        '<i class="'.$_style['icons_modules'] .'"></i>' . $_lang['modules'],
56
+        'javascript:;',
57
+        $_lang['modules'],
58
+        ' return false;',
59
+        '',
60
+        '',
61
+        0,
62
+        30,
63
+        ''
64
+    );
65 65
 }
66 66
 
67 67
 if($modx->hasPermission('edit_user') || $modx->hasPermission('edit_web_user') || $modx->hasPermission('edit_role') || $modx->hasPermission('access_permissions') || $modx->hasPermission('web_access_permissions')) {
68
-	$sitemenu['users'] = array(
69
-		'users',
70
-		'main',
71
-		'<i class="fa fa-users"></i>' . $_lang['users'],
72
-		'javascript:;',
73
-		$_lang['users'],
74
-		' return false;',
75
-		'edit_user',
76
-		'',
77
-		0,
78
-		40,
79
-		''
80
-	);
68
+    $sitemenu['users'] = array(
69
+        'users',
70
+        'main',
71
+        '<i class="fa fa-users"></i>' . $_lang['users'],
72
+        'javascript:;',
73
+        $_lang['users'],
74
+        ' return false;',
75
+        'edit_user',
76
+        '',
77
+        0,
78
+        40,
79
+        ''
80
+    );
81 81
 }
82 82
 
83 83
 if($modx->hasPermission('empty_cache') || $modx->hasPermission('bk_manager') || $modx->hasPermission('remove_locks') || $modx->hasPermission('import_static') || $modx->hasPermission('export_static')) {
84
-	$sitemenu['tools'] = array(
85
-		'tools',
86
-		'main',
87
-		'<i class="fa fa-wrench"></i>' . $_lang['tools'],
88
-		'javascript:;',
89
-		$_lang['tools'],
90
-		' return false;',
91
-		'',
92
-		'',
93
-		0,
94
-		50,
95
-		''
96
-	);
84
+    $sitemenu['tools'] = array(
85
+        'tools',
86
+        'main',
87
+        '<i class="fa fa-wrench"></i>' . $_lang['tools'],
88
+        'javascript:;',
89
+        $_lang['tools'],
90
+        ' return false;',
91
+        '',
92
+        '',
93
+        0,
94
+        50,
95
+        ''
96
+    );
97 97
 }
98 98
 
99 99
 $tab = 0;
100 100
 if($modx->hasPermission('edit_template')) {
101
-	$sitemenu['element_templates'] = array(
102
-		'element_templates',
103
-		'elements',
104
-		'<i class="fa fa-newspaper-o"></i>' . $_lang['manage_templates'] . '<i class="fa fa-angle-right toggle"></i>',
105
-		'index.php?a=76&tab=' . $tab++,
106
-		$_lang['manage_templates'],
107
-		'',
108
-		'new_template,edit_template',
109
-		'main',
110
-		0,
111
-		10,
112
-		'dropdown-toggle'
113
-	);
101
+    $sitemenu['element_templates'] = array(
102
+        'element_templates',
103
+        'elements',
104
+        '<i class="fa fa-newspaper-o"></i>' . $_lang['manage_templates'] . '<i class="fa fa-angle-right toggle"></i>',
105
+        'index.php?a=76&tab=' . $tab++,
106
+        $_lang['manage_templates'],
107
+        '',
108
+        'new_template,edit_template',
109
+        'main',
110
+        0,
111
+        10,
112
+        'dropdown-toggle'
113
+    );
114 114
 }
115 115
 if($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
116
-	$sitemenu['element_tplvars'] = array(
117
-		'element_tplvars',
118
-		'elements',
119
-		'<i class="fa fa-list-alt"></i>' . $_lang['tmplvars'] . '<i class="fa fa-angle-right toggle"></i>',
120
-		'index.php?a=76&tab=' . $tab++,
121
-		$_lang['tmplvars'],
122
-		'',
123
-		'new_template,edit_template',
124
-		'main',
125
-		0,
126
-		20,
127
-		'dropdown-toggle'
128
-	);
116
+    $sitemenu['element_tplvars'] = array(
117
+        'element_tplvars',
118
+        'elements',
119
+        '<i class="fa fa-list-alt"></i>' . $_lang['tmplvars'] . '<i class="fa fa-angle-right toggle"></i>',
120
+        'index.php?a=76&tab=' . $tab++,
121
+        $_lang['tmplvars'],
122
+        '',
123
+        'new_template,edit_template',
124
+        'main',
125
+        0,
126
+        20,
127
+        'dropdown-toggle'
128
+    );
129 129
 }
130 130
 if($modx->hasPermission('edit_chunk')) {
131
-	$sitemenu['element_htmlsnippets'] = array(
132
-		'element_htmlsnippets',
133
-		'elements',
134
-		'<i class="fa fa-th-large"></i>' . $_lang['manage_htmlsnippets'] . '<i class="fa fa-angle-right toggle"></i>',
135
-		'index.php?a=76&tab=' . $tab++,
136
-		$_lang['manage_htmlsnippets'],
137
-		'',
138
-		'new_chunk,edit_chunk',
139
-		'main',
140
-		0,
141
-		30,
142
-		'dropdown-toggle'
143
-	);
131
+    $sitemenu['element_htmlsnippets'] = array(
132
+        'element_htmlsnippets',
133
+        'elements',
134
+        '<i class="fa fa-th-large"></i>' . $_lang['manage_htmlsnippets'] . '<i class="fa fa-angle-right toggle"></i>',
135
+        'index.php?a=76&tab=' . $tab++,
136
+        $_lang['manage_htmlsnippets'],
137
+        '',
138
+        'new_chunk,edit_chunk',
139
+        'main',
140
+        0,
141
+        30,
142
+        'dropdown-toggle'
143
+    );
144 144
 }
145 145
 if($modx->hasPermission('edit_snippet')) {
146
-	$sitemenu['element_snippets'] = array(
147
-		'element_snippets',
148
-		'elements',
149
-		'<i class="fa fa-code"></i>' . $_lang['manage_snippets'] . '<i class="fa fa-angle-right toggle"></i>',
150
-		'index.php?a=76&tab=' . $tab++,
151
-		$_lang['manage_snippets'],
152
-		'',
153
-		'new_snippet,edit_snippet',
154
-		'main',
155
-		0,
156
-		40,
157
-		'dropdown-toggle'
158
-	);
146
+    $sitemenu['element_snippets'] = array(
147
+        'element_snippets',
148
+        'elements',
149
+        '<i class="fa fa-code"></i>' . $_lang['manage_snippets'] . '<i class="fa fa-angle-right toggle"></i>',
150
+        'index.php?a=76&tab=' . $tab++,
151
+        $_lang['manage_snippets'],
152
+        '',
153
+        'new_snippet,edit_snippet',
154
+        'main',
155
+        0,
156
+        40,
157
+        'dropdown-toggle'
158
+    );
159 159
 }
160 160
 if($modx->hasPermission('edit_plugin')) {
161
-	$sitemenu['element_plugins'] = array(
162
-		'element_plugins',
163
-		'elements',
164
-		'<i class="fa fa-plug"></i>' . $_lang['manage_plugins'] . '<i class="fa fa-angle-right toggle"></i>',
165
-		'index.php?a=76&tab=' . $tab++,
166
-		$_lang['manage_plugins'],
167
-		'',
168
-		'new_plugin,edit_plugin',
169
-		'main',
170
-		0,
171
-		50,
172
-		'dropdown-toggle'
173
-	);
161
+    $sitemenu['element_plugins'] = array(
162
+        'element_plugins',
163
+        'elements',
164
+        '<i class="fa fa-plug"></i>' . $_lang['manage_plugins'] . '<i class="fa fa-angle-right toggle"></i>',
165
+        'index.php?a=76&tab=' . $tab++,
166
+        $_lang['manage_plugins'],
167
+        '',
168
+        'new_plugin,edit_plugin',
169
+        'main',
170
+        0,
171
+        50,
172
+        'dropdown-toggle'
173
+    );
174 174
 }
175 175
 //$sitemenu['element_categories']     = array('element_categories','elements',$_lang['element_categories'],'index.php?a=76&tab=5',$_lang['element_categories'],'','new_template,edit_template,new_snippet,edit_snippet,new_chunk,edit_chunk,new_plugin,edit_plugin','main',1,60,'');
176 176
 
177 177
 if($modx->hasPermission('file_manager')) {
178
-	$sitemenu['manage_files'] = array(
179
-		'manage_files',
180
-		'elements',
181
-		'<i class="fa fa-folder-open-o"></i>' . $_lang['manage_files'],
182
-		'index.php?a=31',
183
-		$_lang['manage_files'],
184
-		'',
185
-		'file_manager',
186
-		'main',
187
-		0,
188
-		70,
189
-		''
190
-	);
178
+    $sitemenu['manage_files'] = array(
179
+        'manage_files',
180
+        'elements',
181
+        '<i class="fa fa-folder-open-o"></i>' . $_lang['manage_files'],
182
+        'index.php?a=31',
183
+        $_lang['manage_files'],
184
+        '',
185
+        'file_manager',
186
+        'main',
187
+        0,
188
+        70,
189
+        ''
190
+    );
191 191
 }
192 192
 if($modx->hasPermission('category_manager')) {
193
-	$sitemenu['manage_categories'] = array(
194
-		'manage_categories',
195
-		'elements',
196
-		'<i class="fa fa-object-group"></i>' . $_lang['manage_categories'],
197
-		'index.php?a=120',
198
-		$_lang['manage_categories'],
199
-		'',
200
-		'category_manager',
201
-		'main',
202
-		0,
203
-		80,
204
-		''
205
-	);
193
+    $sitemenu['manage_categories'] = array(
194
+        'manage_categories',
195
+        'elements',
196
+        '<i class="fa fa-object-group"></i>' . $_lang['manage_categories'],
197
+        'index.php?a=120',
198
+        $_lang['manage_categories'],
199
+        '',
200
+        'category_manager',
201
+        'main',
202
+        0,
203
+        80,
204
+        ''
205
+    );
206 206
 }
207 207
 
208 208
 // Modules Menu Items
209 209
 if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module') || $modx->hasPermission('save_module')) {
210
-	$sitemenu['new_module'] = array(
211
-		'new_module',
212
-		'modules',
213
-		'<i class="'.$_style['icons_modules'] .'"></i>' . $_lang['module_management'],
214
-		'index.php?a=106',
215
-		$_lang['module_management'],
216
-		'',
217
-		'new_module,edit_module',
218
-		'main',
219
-		1,
220
-		0,
221
-		''
222
-	);
210
+    $sitemenu['new_module'] = array(
211
+        'new_module',
212
+        'modules',
213
+        '<i class="'.$_style['icons_modules'] .'"></i>' . $_lang['module_management'],
214
+        'index.php?a=106',
215
+        $_lang['module_management'],
216
+        '',
217
+        'new_module,edit_module',
218
+        'main',
219
+        1,
220
+        0,
221
+        ''
222
+    );
223 223
 }
224 224
 
225 225
 if($modx->hasPermission('exec_module')) {
226
-	if($_SESSION['mgrRole'] != 1 && !empty($modx->config['use_udperms'])) {
227
-		$rs = $modx->db->query('SELECT DISTINCT sm.id, sm.name, sm.icon, mg.member
226
+    if($_SESSION['mgrRole'] != 1 && !empty($modx->config['use_udperms'])) {
227
+        $rs = $modx->db->query('SELECT DISTINCT sm.id, sm.name, sm.icon, mg.member
228 228
 				FROM ' . $modx->getFullTableName('site_modules') . ' AS sm
229 229
 				LEFT JOIN ' . $modx->getFullTableName('site_module_access') . ' AS sma ON sma.module = sm.id
230 230
 				LEFT JOIN ' . $modx->getFullTableName('member_groups') . ' AS mg ON sma.usergroup = mg.user_group
231 231
                 WHERE (mg.member IS NULL OR mg.member = ' . $modx->getLoginUserID() . ') AND sm.disabled != 1 AND sm.locked != 1
232 232
                 ORDER BY sm.name');
233
-	} else {
234
-		$rs = $modx->db->select('*', $modx->getFullTableName('site_modules'), 'disabled != 1', 'name');
235
-	}
236
-	if($modx->db->getRecordCount($rs)) {
237
-	    while ($row = $modx->db->getRow($rs)) {
233
+    } else {
234
+        $rs = $modx->db->select('*', $modx->getFullTableName('site_modules'), 'disabled != 1', 'name');
235
+    }
236
+    if($modx->db->getRecordCount($rs)) {
237
+        while ($row = $modx->db->getRow($rs)) {
238 238
             $sitemenu['module' . $row['id']] = array(
239 239
                 'module' . $row['id'],
240 240
                 'modules',
@@ -255,83 +255,83 @@  discard block
 block discarded – undo
255 255
 // security menu items (users)
256 256
 
257 257
 if($modx->hasPermission('edit_user')) {
258
-	$sitemenu['user_management_title'] = array(
259
-		'user_management_title',
260
-		'users',
261
-		'<i class="fa fa fa-user"></i>' . $_lang['user_management_title'] . '<i class="fa fa-angle-right toggle"></i>',
262
-		'index.php?a=75',
263
-		$_lang['user_management_title'],
264
-		'',
265
-		'edit_user',
266
-		'main',
267
-		0,
268
-		10,
269
-		'dropdown-toggle'
270
-	);
258
+    $sitemenu['user_management_title'] = array(
259
+        'user_management_title',
260
+        'users',
261
+        '<i class="fa fa fa-user"></i>' . $_lang['user_management_title'] . '<i class="fa fa-angle-right toggle"></i>',
262
+        'index.php?a=75',
263
+        $_lang['user_management_title'],
264
+        '',
265
+        'edit_user',
266
+        'main',
267
+        0,
268
+        10,
269
+        'dropdown-toggle'
270
+    );
271 271
 }
272 272
 
273 273
 if($modx->hasPermission('edit_web_user')) {
274
-	$sitemenu['web_user_management_title'] = array(
275
-		'web_user_management_title',
276
-		'users',
277
-		'<i class="fa fa-users"></i>' . $_lang['web_user_management_title'] . '<i class="fa fa-angle-right toggle"></i>',
278
-		'index.php?a=99',
279
-		$_lang['web_user_management_title'],
280
-		'',
281
-		'edit_web_user',
282
-		'main',
283
-		0,
284
-		20,
285
-		'dropdown-toggle'
286
-	);
274
+    $sitemenu['web_user_management_title'] = array(
275
+        'web_user_management_title',
276
+        'users',
277
+        '<i class="fa fa-users"></i>' . $_lang['web_user_management_title'] . '<i class="fa fa-angle-right toggle"></i>',
278
+        'index.php?a=99',
279
+        $_lang['web_user_management_title'],
280
+        '',
281
+        'edit_web_user',
282
+        'main',
283
+        0,
284
+        20,
285
+        'dropdown-toggle'
286
+    );
287 287
 }
288 288
 
289 289
 if($modx->hasPermission('edit_role')) {
290
-	$sitemenu['role_management_title'] = array(
291
-		'role_management_title',
292
-		'users',
293
-		'<i class="fa fa-legal"></i>' . $_lang['role_management_title'],
294
-		'index.php?a=86',
295
-		$_lang['role_management_title'],
296
-		'',
297
-		'new_role,edit_role,delete_role',
298
-		'main',
299
-		0,
300
-		30,
301
-		''
302
-	);
290
+    $sitemenu['role_management_title'] = array(
291
+        'role_management_title',
292
+        'users',
293
+        '<i class="fa fa-legal"></i>' . $_lang['role_management_title'],
294
+        'index.php?a=86',
295
+        $_lang['role_management_title'],
296
+        '',
297
+        'new_role,edit_role,delete_role',
298
+        'main',
299
+        0,
300
+        30,
301
+        ''
302
+    );
303 303
 }
304 304
 
305 305
 if($modx->hasPermission('access_permissions')) {
306
-	$sitemenu['manager_permissions'] = array(
307
-		'manager_permissions',
308
-		'users',
309
-		'<i class="fa fa-male"></i>' . $_lang['manager_permissions'],
310
-		'index.php?a=40',
311
-		$_lang['manager_permissions'],
312
-		'',
313
-		'access_permissions',
314
-		'main',
315
-		0,
316
-		40,
317
-		''
318
-	);
306
+    $sitemenu['manager_permissions'] = array(
307
+        'manager_permissions',
308
+        'users',
309
+        '<i class="fa fa-male"></i>' . $_lang['manager_permissions'],
310
+        'index.php?a=40',
311
+        $_lang['manager_permissions'],
312
+        '',
313
+        'access_permissions',
314
+        'main',
315
+        0,
316
+        40,
317
+        ''
318
+    );
319 319
 }
320 320
 
321 321
 if($modx->hasPermission('web_access_permissions')) {
322
-	$sitemenu['web_permissions'] = array(
323
-		'web_permissions',
324
-		'users',
325
-		'<i class="fa fa-universal-access"></i>' . $_lang['web_permissions'],
326
-		'index.php?a=91',
327
-		$_lang['web_permissions'],
328
-		'',
329
-		'web_access_permissions',
330
-		'main',
331
-		0,
332
-		50,
333
-		''
334
-	);
322
+    $sitemenu['web_permissions'] = array(
323
+        'web_permissions',
324
+        'users',
325
+        '<i class="fa fa-universal-access"></i>' . $_lang['web_permissions'],
326
+        'index.php?a=91',
327
+        $_lang['web_permissions'],
328
+        '',
329
+        'web_access_permissions',
330
+        'main',
331
+        0,
332
+        50,
333
+        ''
334
+    );
335 335
 }
336 336
 
337 337
 // Tools Menu
@@ -361,104 +361,104 @@  discard block
 block discarded – undo
361 361
 );
362 362
 
363 363
 $sitemenu['search'] = array(
364
-	'search',
365
-	'tools',
366
-	'<i class="fa fa-search"></i>' . $_lang['search'],
367
-	'index.php?a=71',
368
-	$_lang['search'],
369
-	'',
370
-	'',
371
-	'main',
372
-	1,
373
-	9,
374
-	''
364
+    'search',
365
+    'tools',
366
+    '<i class="fa fa-search"></i>' . $_lang['search'],
367
+    'index.php?a=71',
368
+    $_lang['search'],
369
+    '',
370
+    '',
371
+    'main',
372
+    1,
373
+    9,
374
+    ''
375 375
 );
376 376
 
377 377
 if($modx->hasPermission('bk_manager')) {
378
-	$sitemenu['bk_manager'] = array(
379
-		'bk_manager',
380
-		'tools',
381
-		'<i class="fa fa-database"></i>' . $_lang['bk_manager'],
382
-		'index.php?a=93',
383
-		$_lang['bk_manager'],
384
-		'',
385
-		'bk_manager',
386
-		'main',
387
-		0,
388
-		10,
389
-		''
390
-	);
378
+    $sitemenu['bk_manager'] = array(
379
+        'bk_manager',
380
+        'tools',
381
+        '<i class="fa fa-database"></i>' . $_lang['bk_manager'],
382
+        'index.php?a=93',
383
+        $_lang['bk_manager'],
384
+        '',
385
+        'bk_manager',
386
+        'main',
387
+        0,
388
+        10,
389
+        ''
390
+    );
391 391
 }
392 392
 
393 393
 if($modx->hasPermission('remove_locks')) {
394
-	$sitemenu['remove_locks'] = array(
395
-		'remove_locks',
396
-		'tools',
397
-		'<i class="fa fa-hourglass"></i>' . $_lang['remove_locks'],
398
-		'javascript:modx.removeLocks();',
399
-		$_lang['remove_locks'],
400
-		'',
401
-		'remove_locks',
402
-		'',
403
-		0,
404
-		20,
405
-		''
406
-	);
394
+    $sitemenu['remove_locks'] = array(
395
+        'remove_locks',
396
+        'tools',
397
+        '<i class="fa fa-hourglass"></i>' . $_lang['remove_locks'],
398
+        'javascript:modx.removeLocks();',
399
+        $_lang['remove_locks'],
400
+        '',
401
+        'remove_locks',
402
+        '',
403
+        0,
404
+        20,
405
+        ''
406
+    );
407 407
 }
408 408
 
409 409
 if($modx->hasPermission('import_static')) {
410
-	$sitemenu['import_site'] = array(
411
-		'import_site',
412
-		'tools',
413
-		'<i class="fa fa-upload"></i>' . $_lang['import_site'],
414
-		'index.php?a=95',
415
-		$_lang['import_site'],
416
-		'',
417
-		'import_static',
418
-		'main',
419
-		0,
420
-		30,
421
-		''
422
-	);
410
+    $sitemenu['import_site'] = array(
411
+        'import_site',
412
+        'tools',
413
+        '<i class="fa fa-upload"></i>' . $_lang['import_site'],
414
+        'index.php?a=95',
415
+        $_lang['import_site'],
416
+        '',
417
+        'import_static',
418
+        'main',
419
+        0,
420
+        30,
421
+        ''
422
+    );
423 423
 }
424 424
 
425 425
 if($modx->hasPermission('export_static')) {
426
-	$sitemenu['export_site'] = array(
427
-		'export_site',
428
-		'tools',
429
-		'<i class="fa fa-download"></i>' . $_lang['export_site'],
430
-		'index.php?a=83',
431
-		$_lang['export_site'],
432
-		'',
433
-		'export_static',
434
-		'main',
435
-		1,
436
-		40,
437
-		''
438
-	);
426
+    $sitemenu['export_site'] = array(
427
+        'export_site',
428
+        'tools',
429
+        '<i class="fa fa-download"></i>' . $_lang['export_site'],
430
+        'index.php?a=83',
431
+        $_lang['export_site'],
432
+        '',
433
+        'export_static',
434
+        'main',
435
+        1,
436
+        40,
437
+        ''
438
+    );
439 439
 }
440 440
 
441 441
 $menu = $modx->invokeEvent("OnManagerMenuPrerender", array('menu' => $sitemenu));
442 442
 if(is_array($menu)) {
443
-	$newmenu = array();
444
-	foreach($menu as $item){
445
-		if(is_array(unserialize($item))){
446
-			$newmenu = array_merge($newmenu, unserialize($item));
447
-		}
448
-	}
449
-	if(count($newmenu)> 0) $sitemenu = $newmenu;
443
+    $newmenu = array();
444
+    foreach($menu as $item){
445
+        if(is_array(unserialize($item))){
446
+            $newmenu = array_merge($newmenu, unserialize($item));
447
+        }
448
+    }
449
+    if(count($newmenu)> 0) $sitemenu = $newmenu;
450 450
 }
451 451
 
452 452
 if(file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/includes/menu.class.inc.php')) {
453
-	include_once(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/includes/menu.class.inc.php');
453
+    include_once(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/includes/menu.class.inc.php');
454 454
 } else {
455
-	include_once(MODX_MANAGER_PATH . 'includes/menu.class.inc.php');
455
+    include_once(MODX_MANAGER_PATH . 'includes/menu.class.inc.php');
456 456
 }
457 457
 $menu = new EVOmenu();
458 458
 $menu->Build($sitemenu, array(
459
-	'outerClass' => 'nav',
460
-	'innerClass' => 'dropdown-menu',
461
-	'parentClass' => 'dropdown',
459
+    'outerClass' => 'nav',
460
+    'innerClass' => 'dropdown-menu',
461
+    'parentClass' => 'dropdown',
462 462
     'parentLinkClass' => 'dropdown-toggle',
463 463
     'parentLinkAttr' => '',
464 464
     'parentLinkIn' => ''
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 $sitemenu['site'] = array(
22 22
 	'site',
23 23
 	'main',
24
-	'<i class="fa fa-home"></i>' . $_lang['home'],
24
+	'<i class="fa fa-home"></i>'.$_lang['home'],
25 25
 	'index.php?a=2',
26 26
 	$_lang['home'],
27 27
 	'',
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
 	'active'
33 33
 );
34 34
 
35
-if($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('file_manager')) {
35
+if ($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('file_manager')) {
36 36
 	$sitemenu['elements'] = array(
37 37
 		'elements',
38 38
 		'main',
39
-		'<i class="fa fa-th"></i>' . $_lang['elements'],
39
+		'<i class="fa fa-th"></i>'.$_lang['elements'],
40 40
 		'javascript:;',
41 41
 		$_lang['elements'],
42 42
 		' return false;',
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
 	);
49 49
 }
50 50
 
51
-if($modx->hasPermission('exec_module')) {
51
+if ($modx->hasPermission('exec_module')) {
52 52
 	$sitemenu['modules'] = array(
53 53
 		'modules',
54 54
 		'main',
55
-		'<i class="'.$_style['icons_modules'] .'"></i>' . $_lang['modules'],
55
+		'<i class="'.$_style['icons_modules'].'"></i>'.$_lang['modules'],
56 56
 		'javascript:;',
57 57
 		$_lang['modules'],
58 58
 		' return false;',
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 	);
65 65
 }
66 66
 
67
-if($modx->hasPermission('edit_user') || $modx->hasPermission('edit_web_user') || $modx->hasPermission('edit_role') || $modx->hasPermission('access_permissions') || $modx->hasPermission('web_access_permissions')) {
67
+if ($modx->hasPermission('edit_user') || $modx->hasPermission('edit_web_user') || $modx->hasPermission('edit_role') || $modx->hasPermission('access_permissions') || $modx->hasPermission('web_access_permissions')) {
68 68
 	$sitemenu['users'] = array(
69 69
 		'users',
70 70
 		'main',
71
-		'<i class="fa fa-users"></i>' . $_lang['users'],
71
+		'<i class="fa fa-users"></i>'.$_lang['users'],
72 72
 		'javascript:;',
73 73
 		$_lang['users'],
74 74
 		' return false;',
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	);
81 81
 }
82 82
 
83
-if($modx->hasPermission('empty_cache') || $modx->hasPermission('bk_manager') || $modx->hasPermission('remove_locks') || $modx->hasPermission('import_static') || $modx->hasPermission('export_static')) {
83
+if ($modx->hasPermission('empty_cache') || $modx->hasPermission('bk_manager') || $modx->hasPermission('remove_locks') || $modx->hasPermission('import_static') || $modx->hasPermission('export_static')) {
84 84
 	$sitemenu['tools'] = array(
85 85
 		'tools',
86 86
 		'main',
87
-		'<i class="fa fa-wrench"></i>' . $_lang['tools'],
87
+		'<i class="fa fa-wrench"></i>'.$_lang['tools'],
88 88
 		'javascript:;',
89 89
 		$_lang['tools'],
90 90
 		' return false;',
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 }
98 98
 
99 99
 $tab = 0;
100
-if($modx->hasPermission('edit_template')) {
100
+if ($modx->hasPermission('edit_template')) {
101 101
 	$sitemenu['element_templates'] = array(
102 102
 		'element_templates',
103 103
 		'elements',
104
-		'<i class="fa fa-newspaper-o"></i>' . $_lang['manage_templates'] . '<i class="fa fa-angle-right toggle"></i>',
105
-		'index.php?a=76&tab=' . $tab++,
104
+		'<i class="fa fa-newspaper-o"></i>'.$_lang['manage_templates'].'<i class="fa fa-angle-right toggle"></i>',
105
+		'index.php?a=76&tab='.$tab++,
106 106
 		$_lang['manage_templates'],
107 107
 		'',
108 108
 		'new_template,edit_template',
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 		'dropdown-toggle'
113 113
 	);
114 114
 }
115
-if($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
115
+if ($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
116 116
 	$sitemenu['element_tplvars'] = array(
117 117
 		'element_tplvars',
118 118
 		'elements',
119
-		'<i class="fa fa-list-alt"></i>' . $_lang['tmplvars'] . '<i class="fa fa-angle-right toggle"></i>',
120
-		'index.php?a=76&tab=' . $tab++,
119
+		'<i class="fa fa-list-alt"></i>'.$_lang['tmplvars'].'<i class="fa fa-angle-right toggle"></i>',
120
+		'index.php?a=76&tab='.$tab++,
121 121
 		$_lang['tmplvars'],
122 122
 		'',
123 123
 		'new_template,edit_template',
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
 		'dropdown-toggle'
128 128
 	);
129 129
 }
130
-if($modx->hasPermission('edit_chunk')) {
130
+if ($modx->hasPermission('edit_chunk')) {
131 131
 	$sitemenu['element_htmlsnippets'] = array(
132 132
 		'element_htmlsnippets',
133 133
 		'elements',
134
-		'<i class="fa fa-th-large"></i>' . $_lang['manage_htmlsnippets'] . '<i class="fa fa-angle-right toggle"></i>',
135
-		'index.php?a=76&tab=' . $tab++,
134
+		'<i class="fa fa-th-large"></i>'.$_lang['manage_htmlsnippets'].'<i class="fa fa-angle-right toggle"></i>',
135
+		'index.php?a=76&tab='.$tab++,
136 136
 		$_lang['manage_htmlsnippets'],
137 137
 		'',
138 138
 		'new_chunk,edit_chunk',
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
 		'dropdown-toggle'
143 143
 	);
144 144
 }
145
-if($modx->hasPermission('edit_snippet')) {
145
+if ($modx->hasPermission('edit_snippet')) {
146 146
 	$sitemenu['element_snippets'] = array(
147 147
 		'element_snippets',
148 148
 		'elements',
149
-		'<i class="fa fa-code"></i>' . $_lang['manage_snippets'] . '<i class="fa fa-angle-right toggle"></i>',
150
-		'index.php?a=76&tab=' . $tab++,
149
+		'<i class="fa fa-code"></i>'.$_lang['manage_snippets'].'<i class="fa fa-angle-right toggle"></i>',
150
+		'index.php?a=76&tab='.$tab++,
151 151
 		$_lang['manage_snippets'],
152 152
 		'',
153 153
 		'new_snippet,edit_snippet',
@@ -157,12 +157,12 @@  discard block
 block discarded – undo
157 157
 		'dropdown-toggle'
158 158
 	);
159 159
 }
160
-if($modx->hasPermission('edit_plugin')) {
160
+if ($modx->hasPermission('edit_plugin')) {
161 161
 	$sitemenu['element_plugins'] = array(
162 162
 		'element_plugins',
163 163
 		'elements',
164
-		'<i class="fa fa-plug"></i>' . $_lang['manage_plugins'] . '<i class="fa fa-angle-right toggle"></i>',
165
-		'index.php?a=76&tab=' . $tab++,
164
+		'<i class="fa fa-plug"></i>'.$_lang['manage_plugins'].'<i class="fa fa-angle-right toggle"></i>',
165
+		'index.php?a=76&tab='.$tab++,
166 166
 		$_lang['manage_plugins'],
167 167
 		'',
168 168
 		'new_plugin,edit_plugin',
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 }
175 175
 //$sitemenu['element_categories']     = array('element_categories','elements',$_lang['element_categories'],'index.php?a=76&tab=5',$_lang['element_categories'],'','new_template,edit_template,new_snippet,edit_snippet,new_chunk,edit_chunk,new_plugin,edit_plugin','main',1,60,'');
176 176
 
177
-if($modx->hasPermission('file_manager')) {
177
+if ($modx->hasPermission('file_manager')) {
178 178
 	$sitemenu['manage_files'] = array(
179 179
 		'manage_files',
180 180
 		'elements',
181
-		'<i class="fa fa-folder-open-o"></i>' . $_lang['manage_files'],
181
+		'<i class="fa fa-folder-open-o"></i>'.$_lang['manage_files'],
182 182
 		'index.php?a=31',
183 183
 		$_lang['manage_files'],
184 184
 		'',
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
 		''
190 190
 	);
191 191
 }
192
-if($modx->hasPermission('category_manager')) {
192
+if ($modx->hasPermission('category_manager')) {
193 193
 	$sitemenu['manage_categories'] = array(
194 194
 		'manage_categories',
195 195
 		'elements',
196
-		'<i class="fa fa-object-group"></i>' . $_lang['manage_categories'],
196
+		'<i class="fa fa-object-group"></i>'.$_lang['manage_categories'],
197 197
 		'index.php?a=120',
198 198
 		$_lang['manage_categories'],
199 199
 		'',
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
 }
207 207
 
208 208
 // Modules Menu Items
209
-if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module') || $modx->hasPermission('save_module')) {
209
+if ($modx->hasPermission('new_module') || $modx->hasPermission('edit_module') || $modx->hasPermission('save_module')) {
210 210
 	$sitemenu['new_module'] = array(
211 211
 		'new_module',
212 212
 		'modules',
213
-		'<i class="'.$_style['icons_modules'] .'"></i>' . $_lang['module_management'],
213
+		'<i class="'.$_style['icons_modules'].'"></i>'.$_lang['module_management'],
214 214
 		'index.php?a=106',
215 215
 		$_lang['module_management'],
216 216
 		'',
@@ -222,24 +222,24 @@  discard block
 block discarded – undo
222 222
 	);
223 223
 }
224 224
 
225
-if($modx->hasPermission('exec_module')) {
226
-	if($_SESSION['mgrRole'] != 1 && !empty($modx->config['use_udperms'])) {
225
+if ($modx->hasPermission('exec_module')) {
226
+	if ($_SESSION['mgrRole'] != 1 && !empty($modx->config['use_udperms'])) {
227 227
 		$rs = $modx->db->query('SELECT DISTINCT sm.id, sm.name, sm.icon, mg.member
228
-				FROM ' . $modx->getFullTableName('site_modules') . ' AS sm
229
-				LEFT JOIN ' . $modx->getFullTableName('site_module_access') . ' AS sma ON sma.module = sm.id
230
-				LEFT JOIN ' . $modx->getFullTableName('member_groups') . ' AS mg ON sma.usergroup = mg.user_group
231
-                WHERE (mg.member IS NULL OR mg.member = ' . $modx->getLoginUserID() . ') AND sm.disabled != 1 AND sm.locked != 1
228
+				FROM ' . $modx->getFullTableName('site_modules').' AS sm
229
+				LEFT JOIN ' . $modx->getFullTableName('site_module_access').' AS sma ON sma.module = sm.id
230
+				LEFT JOIN ' . $modx->getFullTableName('member_groups').' AS mg ON sma.usergroup = mg.user_group
231
+                WHERE (mg.member IS NULL OR mg.member = ' . $modx->getLoginUserID().') AND sm.disabled != 1 AND sm.locked != 1
232 232
                 ORDER BY sm.name');
233 233
 	} else {
234 234
 		$rs = $modx->db->select('*', $modx->getFullTableName('site_modules'), 'disabled != 1', 'name');
235 235
 	}
236
-	if($modx->db->getRecordCount($rs)) {
236
+	if ($modx->db->getRecordCount($rs)) {
237 237
 	    while ($row = $modx->db->getRow($rs)) {
238
-            $sitemenu['module' . $row['id']] = array(
239
-                'module' . $row['id'],
238
+            $sitemenu['module'.$row['id']] = array(
239
+                'module'.$row['id'],
240 240
                 'modules',
241
-                ($row['icon'] != '' ? '<i class="'.$row['icon'].'"></i>' : '<i class="'.$_style['icons_module'].'"></i>') . $row['name'],
242
-                'index.php?a=112&id=' . $row['id'],
241
+                ($row['icon'] != '' ? '<i class="'.$row['icon'].'"></i>' : '<i class="'.$_style['icons_module'].'"></i>').$row['name'],
242
+                'index.php?a=112&id='.$row['id'],
243 243
                 $row['name'],
244 244
                 '',
245 245
                 '',
@@ -254,11 +254,11 @@  discard block
 block discarded – undo
254 254
 
255 255
 // security menu items (users)
256 256
 
257
-if($modx->hasPermission('edit_user')) {
257
+if ($modx->hasPermission('edit_user')) {
258 258
 	$sitemenu['user_management_title'] = array(
259 259
 		'user_management_title',
260 260
 		'users',
261
-		'<i class="fa fa fa-user"></i>' . $_lang['user_management_title'] . '<i class="fa fa-angle-right toggle"></i>',
261
+		'<i class="fa fa fa-user"></i>'.$_lang['user_management_title'].'<i class="fa fa-angle-right toggle"></i>',
262 262
 		'index.php?a=75',
263 263
 		$_lang['user_management_title'],
264 264
 		'',
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 	);
271 271
 }
272 272
 
273
-if($modx->hasPermission('edit_web_user')) {
273
+if ($modx->hasPermission('edit_web_user')) {
274 274
 	$sitemenu['web_user_management_title'] = array(
275 275
 		'web_user_management_title',
276 276
 		'users',
277
-		'<i class="fa fa-users"></i>' . $_lang['web_user_management_title'] . '<i class="fa fa-angle-right toggle"></i>',
277
+		'<i class="fa fa-users"></i>'.$_lang['web_user_management_title'].'<i class="fa fa-angle-right toggle"></i>',
278 278
 		'index.php?a=99',
279 279
 		$_lang['web_user_management_title'],
280 280
 		'',
@@ -286,11 +286,11 @@  discard block
 block discarded – undo
286 286
 	);
287 287
 }
288 288
 
289
-if($modx->hasPermission('edit_role')) {
289
+if ($modx->hasPermission('edit_role')) {
290 290
 	$sitemenu['role_management_title'] = array(
291 291
 		'role_management_title',
292 292
 		'users',
293
-		'<i class="fa fa-legal"></i>' . $_lang['role_management_title'],
293
+		'<i class="fa fa-legal"></i>'.$_lang['role_management_title'],
294 294
 		'index.php?a=86',
295 295
 		$_lang['role_management_title'],
296 296
 		'',
@@ -302,11 +302,11 @@  discard block
 block discarded – undo
302 302
 	);
303 303
 }
304 304
 
305
-if($modx->hasPermission('access_permissions')) {
305
+if ($modx->hasPermission('access_permissions')) {
306 306
 	$sitemenu['manager_permissions'] = array(
307 307
 		'manager_permissions',
308 308
 		'users',
309
-		'<i class="fa fa-male"></i>' . $_lang['manager_permissions'],
309
+		'<i class="fa fa-male"></i>'.$_lang['manager_permissions'],
310 310
 		'index.php?a=40',
311 311
 		$_lang['manager_permissions'],
312 312
 		'',
@@ -318,11 +318,11 @@  discard block
 block discarded – undo
318 318
 	);
319 319
 }
320 320
 
321
-if($modx->hasPermission('web_access_permissions')) {
321
+if ($modx->hasPermission('web_access_permissions')) {
322 322
 	$sitemenu['web_permissions'] = array(
323 323
 		'web_permissions',
324 324
 		'users',
325
-		'<i class="fa fa-universal-access"></i>' . $_lang['web_permissions'],
325
+		'<i class="fa fa-universal-access"></i>'.$_lang['web_permissions'],
326 326
 		'index.php?a=91',
327 327
 		$_lang['web_permissions'],
328 328
 		'',
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 $sitemenu['refresh_site'] = array(
340 340
     'refresh_site',
341 341
     'tools',
342
-    '<i class="fa fa-recycle"></i>' . $_lang['refresh_site'],
342
+    '<i class="fa fa-recycle"></i>'.$_lang['refresh_site'],
343 343
     'index.php?a=26',
344 344
     $_lang['refresh_site'],
345 345
     '',
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
             'a', // tag
354 354
             'javascript:;', // href
355 355
             'btn btn-secondary', // class or btn-success
356
-            'modx.popup({url:\'index.php?a=26\', title:\'' . $_lang['refresh_site'] . '\', icon: \'fa-recycle\', iframe: \'ajax\', selector: \'.tab-page>.container\', position: \'right top\', width: \'auto\', maxheight: \'50%\', wrap: \'body\' })', // onclick
356
+            'modx.popup({url:\'index.php?a=26\', title:\''.$_lang['refresh_site'].'\', icon: \'fa-recycle\', iframe: \'ajax\', selector: \'.tab-page>.container\', position: \'right top\', width: \'auto\', maxheight: \'50%\', wrap: \'body\' })', // onclick
357 357
             $_lang['refresh_site'], // title
358 358
             '<i class="fa fa-recycle"></i>' // innerHTML
359 359
         )
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 $sitemenu['search'] = array(
364 364
 	'search',
365 365
 	'tools',
366
-	'<i class="fa fa-search"></i>' . $_lang['search'],
366
+	'<i class="fa fa-search"></i>'.$_lang['search'],
367 367
 	'index.php?a=71',
368 368
 	$_lang['search'],
369 369
 	'',
@@ -374,11 +374,11 @@  discard block
 block discarded – undo
374 374
 	''
375 375
 );
376 376
 
377
-if($modx->hasPermission('bk_manager')) {
377
+if ($modx->hasPermission('bk_manager')) {
378 378
 	$sitemenu['bk_manager'] = array(
379 379
 		'bk_manager',
380 380
 		'tools',
381
-		'<i class="fa fa-database"></i>' . $_lang['bk_manager'],
381
+		'<i class="fa fa-database"></i>'.$_lang['bk_manager'],
382 382
 		'index.php?a=93',
383 383
 		$_lang['bk_manager'],
384 384
 		'',
@@ -390,11 +390,11 @@  discard block
 block discarded – undo
390 390
 	);
391 391
 }
392 392
 
393
-if($modx->hasPermission('remove_locks')) {
393
+if ($modx->hasPermission('remove_locks')) {
394 394
 	$sitemenu['remove_locks'] = array(
395 395
 		'remove_locks',
396 396
 		'tools',
397
-		'<i class="fa fa-hourglass"></i>' . $_lang['remove_locks'],
397
+		'<i class="fa fa-hourglass"></i>'.$_lang['remove_locks'],
398 398
 		'javascript:modx.removeLocks();',
399 399
 		$_lang['remove_locks'],
400 400
 		'',
@@ -406,11 +406,11 @@  discard block
 block discarded – undo
406 406
 	);
407 407
 }
408 408
 
409
-if($modx->hasPermission('import_static')) {
409
+if ($modx->hasPermission('import_static')) {
410 410
 	$sitemenu['import_site'] = array(
411 411
 		'import_site',
412 412
 		'tools',
413
-		'<i class="fa fa-upload"></i>' . $_lang['import_site'],
413
+		'<i class="fa fa-upload"></i>'.$_lang['import_site'],
414 414
 		'index.php?a=95',
415 415
 		$_lang['import_site'],
416 416
 		'',
@@ -422,11 +422,11 @@  discard block
 block discarded – undo
422 422
 	);
423 423
 }
424 424
 
425
-if($modx->hasPermission('export_static')) {
425
+if ($modx->hasPermission('export_static')) {
426 426
 	$sitemenu['export_site'] = array(
427 427
 		'export_site',
428 428
 		'tools',
429
-		'<i class="fa fa-download"></i>' . $_lang['export_site'],
429
+		'<i class="fa fa-download"></i>'.$_lang['export_site'],
430 430
 		'index.php?a=83',
431 431
 		$_lang['export_site'],
432 432
 		'',
@@ -439,20 +439,20 @@  discard block
 block discarded – undo
439 439
 }
440 440
 
441 441
 $menu = $modx->invokeEvent("OnManagerMenuPrerender", array('menu' => $sitemenu));
442
-if(is_array($menu)) {
442
+if (is_array($menu)) {
443 443
 	$newmenu = array();
444
-	foreach($menu as $item){
445
-		if(is_array(unserialize($item))){
444
+	foreach ($menu as $item) {
445
+		if (is_array(unserialize($item))) {
446 446
 			$newmenu = array_merge($newmenu, unserialize($item));
447 447
 		}
448 448
 	}
449
-	if(count($newmenu)> 0) $sitemenu = $newmenu;
449
+	if (count($newmenu) > 0) $sitemenu = $newmenu;
450 450
 }
451 451
 
452
-if(file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/includes/menu.class.inc.php')) {
453
-	include_once(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/includes/menu.class.inc.php');
452
+if (file_exists(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/includes/menu.class.inc.php')) {
453
+	include_once(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/includes/menu.class.inc.php');
454 454
 } else {
455
-	include_once(MODX_MANAGER_PATH . 'includes/menu.class.inc.php');
455
+	include_once(MODX_MANAGER_PATH.'includes/menu.class.inc.php');
456 456
 }
457 457
 $menu = new EVOmenu();
458 458
 $menu->Build($sitemenu, array(
Please login to merge, or discard this patch.
Braces   +35 added lines, -33 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	'active'
33 33
 );
34 34
 
35
-if($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('file_manager')) {
35
+if($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('file_manager')) {
36 36
 	$sitemenu['elements'] = array(
37 37
 		'elements',
38 38
 		'main',
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	);
49 49
 }
50 50
 
51
-if($modx->hasPermission('exec_module')) {
51
+if($modx->hasPermission('exec_module')) {
52 52
 	$sitemenu['modules'] = array(
53 53
 		'modules',
54 54
 		'main',
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	);
65 65
 }
66 66
 
67
-if($modx->hasPermission('edit_user') || $modx->hasPermission('edit_web_user') || $modx->hasPermission('edit_role') || $modx->hasPermission('access_permissions') || $modx->hasPermission('web_access_permissions')) {
67
+if($modx->hasPermission('edit_user') || $modx->hasPermission('edit_web_user') || $modx->hasPermission('edit_role') || $modx->hasPermission('access_permissions') || $modx->hasPermission('web_access_permissions')) {
68 68
 	$sitemenu['users'] = array(
69 69
 		'users',
70 70
 		'main',
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	);
81 81
 }
82 82
 
83
-if($modx->hasPermission('empty_cache') || $modx->hasPermission('bk_manager') || $modx->hasPermission('remove_locks') || $modx->hasPermission('import_static') || $modx->hasPermission('export_static')) {
83
+if($modx->hasPermission('empty_cache') || $modx->hasPermission('bk_manager') || $modx->hasPermission('remove_locks') || $modx->hasPermission('import_static') || $modx->hasPermission('export_static')) {
84 84
 	$sitemenu['tools'] = array(
85 85
 		'tools',
86 86
 		'main',
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 }
98 98
 
99 99
 $tab = 0;
100
-if($modx->hasPermission('edit_template')) {
100
+if($modx->hasPermission('edit_template')) {
101 101
 	$sitemenu['element_templates'] = array(
102 102
 		'element_templates',
103 103
 		'elements',
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		'dropdown-toggle'
113 113
 	);
114 114
 }
115
-if($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
115
+if($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
116 116
 	$sitemenu['element_tplvars'] = array(
117 117
 		'element_tplvars',
118 118
 		'elements',
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		'dropdown-toggle'
128 128
 	);
129 129
 }
130
-if($modx->hasPermission('edit_chunk')) {
130
+if($modx->hasPermission('edit_chunk')) {
131 131
 	$sitemenu['element_htmlsnippets'] = array(
132 132
 		'element_htmlsnippets',
133 133
 		'elements',
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		'dropdown-toggle'
143 143
 	);
144 144
 }
145
-if($modx->hasPermission('edit_snippet')) {
145
+if($modx->hasPermission('edit_snippet')) {
146 146
 	$sitemenu['element_snippets'] = array(
147 147
 		'element_snippets',
148 148
 		'elements',
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		'dropdown-toggle'
158 158
 	);
159 159
 }
160
-if($modx->hasPermission('edit_plugin')) {
160
+if($modx->hasPermission('edit_plugin')) {
161 161
 	$sitemenu['element_plugins'] = array(
162 162
 		'element_plugins',
163 163
 		'elements',
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 }
175 175
 //$sitemenu['element_categories']     = array('element_categories','elements',$_lang['element_categories'],'index.php?a=76&tab=5',$_lang['element_categories'],'','new_template,edit_template,new_snippet,edit_snippet,new_chunk,edit_chunk,new_plugin,edit_plugin','main',1,60,'');
176 176
 
177
-if($modx->hasPermission('file_manager')) {
177
+if($modx->hasPermission('file_manager')) {
178 178
 	$sitemenu['manage_files'] = array(
179 179
 		'manage_files',
180 180
 		'elements',
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		''
190 190
 	);
191 191
 }
192
-if($modx->hasPermission('category_manager')) {
192
+if($modx->hasPermission('category_manager')) {
193 193
 	$sitemenu['manage_categories'] = array(
194 194
 		'manage_categories',
195 195
 		'elements',
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 }
207 207
 
208 208
 // Modules Menu Items
209
-if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module') || $modx->hasPermission('save_module')) {
209
+if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module') || $modx->hasPermission('save_module')) {
210 210
 	$sitemenu['new_module'] = array(
211 211
 		'new_module',
212 212
 		'modules',
@@ -222,19 +222,19 @@  discard block
 block discarded – undo
222 222
 	);
223 223
 }
224 224
 
225
-if($modx->hasPermission('exec_module')) {
226
-	if($_SESSION['mgrRole'] != 1 && !empty($modx->config['use_udperms'])) {
225
+if($modx->hasPermission('exec_module')) {
226
+	if($_SESSION['mgrRole'] != 1 && !empty($modx->config['use_udperms'])) {
227 227
 		$rs = $modx->db->query('SELECT DISTINCT sm.id, sm.name, sm.icon, mg.member
228 228
 				FROM ' . $modx->getFullTableName('site_modules') . ' AS sm
229 229
 				LEFT JOIN ' . $modx->getFullTableName('site_module_access') . ' AS sma ON sma.module = sm.id
230 230
 				LEFT JOIN ' . $modx->getFullTableName('member_groups') . ' AS mg ON sma.usergroup = mg.user_group
231 231
                 WHERE (mg.member IS NULL OR mg.member = ' . $modx->getLoginUserID() . ') AND sm.disabled != 1 AND sm.locked != 1
232 232
                 ORDER BY sm.name');
233
-	} else {
233
+	} else {
234 234
 		$rs = $modx->db->select('*', $modx->getFullTableName('site_modules'), 'disabled != 1', 'name');
235 235
 	}
236
-	if($modx->db->getRecordCount($rs)) {
237
-	    while ($row = $modx->db->getRow($rs)) {
236
+	if($modx->db->getRecordCount($rs)) {
237
+	    while ($row = $modx->db->getRow($rs)) {
238 238
             $sitemenu['module' . $row['id']] = array(
239 239
                 'module' . $row['id'],
240 240
                 'modules',
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 
255 255
 // security menu items (users)
256 256
 
257
-if($modx->hasPermission('edit_user')) {
257
+if($modx->hasPermission('edit_user')) {
258 258
 	$sitemenu['user_management_title'] = array(
259 259
 		'user_management_title',
260 260
 		'users',
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	);
271 271
 }
272 272
 
273
-if($modx->hasPermission('edit_web_user')) {
273
+if($modx->hasPermission('edit_web_user')) {
274 274
 	$sitemenu['web_user_management_title'] = array(
275 275
 		'web_user_management_title',
276 276
 		'users',
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	);
287 287
 }
288 288
 
289
-if($modx->hasPermission('edit_role')) {
289
+if($modx->hasPermission('edit_role')) {
290 290
 	$sitemenu['role_management_title'] = array(
291 291
 		'role_management_title',
292 292
 		'users',
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	);
303 303
 }
304 304
 
305
-if($modx->hasPermission('access_permissions')) {
305
+if($modx->hasPermission('access_permissions')) {
306 306
 	$sitemenu['manager_permissions'] = array(
307 307
 		'manager_permissions',
308 308
 		'users',
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 	);
319 319
 }
320 320
 
321
-if($modx->hasPermission('web_access_permissions')) {
321
+if($modx->hasPermission('web_access_permissions')) {
322 322
 	$sitemenu['web_permissions'] = array(
323 323
 		'web_permissions',
324 324
 		'users',
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 	''
375 375
 );
376 376
 
377
-if($modx->hasPermission('bk_manager')) {
377
+if($modx->hasPermission('bk_manager')) {
378 378
 	$sitemenu['bk_manager'] = array(
379 379
 		'bk_manager',
380 380
 		'tools',
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 	);
391 391
 }
392 392
 
393
-if($modx->hasPermission('remove_locks')) {
393
+if($modx->hasPermission('remove_locks')) {
394 394
 	$sitemenu['remove_locks'] = array(
395 395
 		'remove_locks',
396 396
 		'tools',
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 	);
407 407
 }
408 408
 
409
-if($modx->hasPermission('import_static')) {
409
+if($modx->hasPermission('import_static')) {
410 410
 	$sitemenu['import_site'] = array(
411 411
 		'import_site',
412 412
 		'tools',
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	);
423 423
 }
424 424
 
425
-if($modx->hasPermission('export_static')) {
425
+if($modx->hasPermission('export_static')) {
426 426
 	$sitemenu['export_site'] = array(
427 427
 		'export_site',
428 428
 		'tools',
@@ -439,19 +439,21 @@  discard block
 block discarded – undo
439 439
 }
440 440
 
441 441
 $menu = $modx->invokeEvent("OnManagerMenuPrerender", array('menu' => $sitemenu));
442
-if(is_array($menu)) {
442
+if(is_array($menu)) {
443 443
 	$newmenu = array();
444
-	foreach($menu as $item){
445
-		if(is_array(unserialize($item))){
444
+	foreach($menu as $item) {
445
+		if(is_array(unserialize($item))) {
446 446
 			$newmenu = array_merge($newmenu, unserialize($item));
447 447
 		}
448 448
 	}
449
-	if(count($newmenu)> 0) $sitemenu = $newmenu;
450
-}
449
+	if(count($newmenu)> 0) {
450
+	    $sitemenu = $newmenu;
451
+	}
452
+	}
451 453
 
452
-if(file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/includes/menu.class.inc.php')) {
454
+if(file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/includes/menu.class.inc.php')) {
453 455
 	include_once(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/includes/menu.class.inc.php');
454
-} else {
456
+} else {
455 457
 	include_once(MODX_MANAGER_PATH . 'includes/menu.class.inc.php');
456 458
 }
457 459
 $menu = new EVOmenu();
Please login to merge, or discard this patch.
manager/media/calendar/datepicker.inc.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class DATEPICKER {
4
-	function __construct() {
5
-	}
4
+    function __construct() {
5
+    }
6 6
 
7
-	function getDP() {
8
-		global $modx, $_lang;
7
+    function getDP() {
8
+        global $modx, $_lang;
9 9
 
10
-		$tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl');
11
-		return $modx->parseText($tpl, $_lang, '[%', '%]');
12
-	}
10
+        $tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl');
11
+        return $modx->parseText($tpl, $_lang, '[%', '%]');
12
+    }
13 13
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-class DATEPICKER {
4
-	function __construct() {
3
+class DATEPICKER{
4
+	function __construct(){
5 5
 	}
6 6
 
7
-	function getDP() {
7
+	function getDP(){
8 8
 		global $modx, $_lang;
9 9
 
10
-		$tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl');
10
+		$tpl = file_get_contents(dirname(__FILE__).'/datepicker.tpl');
11 11
 		return $modx->parseText($tpl, $_lang, '[%', '%]');
12 12
 	}
13 13
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,10 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-class DATEPICKER {
4
-	function __construct() {
3
+class DATEPICKER
4
+{
5
+	function __construct()
6
+	{
5 7
 	}
6 8
 
7
-	function getDP() {
9
+	function getDP()
10
+	{
8 11
 		global $modx, $_lang;
9 12
 
10 13
 		$tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl');
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/core/types/type_img.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc Image detection class
6
-  *   @package KCFinder
7
-  *   @version 2.54
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010-2014 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc Image detection class
6
+ *   @package KCFinder
7
+ *   @version 2.54
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010-2014 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 class type_img {
16 16
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class type_img {
15
+class type_img{
16 16
 
17
-    public function checkFile($file, array $config) {
17
+    public function checkFile($file, array $config){
18 18
 
19 19
         $driver = isset($config['imageDriversPriority'])
20 20
             ? image::getDriver(explode(" ", $config['imageDriversPriority'])) : "gd";
Please login to merge, or discard this patch.
Braces   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,17 +12,20 @@
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class type_img {
15
+class type_img
16
+{
16 17
 
17
-    public function checkFile($file, array $config) {
18
+    public function checkFile($file, array $config)
19
+    {
18 20
 
19 21
         $driver = isset($config['imageDriversPriority'])
20 22
             ? image::getDriver(explode(" ", $config['imageDriversPriority'])) : "gd";
21 23
 
22 24
         $img = image::factory($driver, $file);
23 25
 
24
-        if ($img->initError)
25
-            return "Unknown image format/encoding.";
26
+        if ($img->initError) {
27
+                    return "Unknown image format/encoding.";
28
+        }
26 29
 
27 30
         return true;
28 31
     }
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/core/types/type_mime.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc MIME type detection class
6
-  *   @package KCFinder
7
-  *   @version 2.54
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010-2014 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc MIME type detection class
6
+ *   @package KCFinder
7
+ *   @version 2.54
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010-2014 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 class type_mime {
16 16
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class type_mime {
15
+class type_mime{
16 16
 
17
-    public function checkFile($file, array $config) {
17
+    public function checkFile($file, array $config){
18 18
         if (!class_exists("finfo"))
19 19
             return "Fileinfo PECL extension is missing.";
20 20
 
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
         $mimes = $config['params'];
34 34
         if (substr($mimes, 0, 1) == "!") {
35 35
             $mimes = trim(substr($mimes, 1));
36
-            return in_array($type , explode(" ", $mimes))
36
+            return in_array($type, explode(" ", $mimes))
37 37
                 ? "You can't upload such files."
38 38
                 : true;
39 39
         }
40 40
 
41
-        return !in_array($type , explode(" ", $mimes))
41
+        return !in_array($type, explode(" ", $mimes))
42 42
             ? "You can't upload such files."
43 43
             : true;
44 44
     }
Please login to merge, or discard this patch.
Braces   +13 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,20 +12,25 @@
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class type_mime {
15
+class type_mime
16
+{
16 17
 
17
-    public function checkFile($file, array $config) {
18
-        if (!class_exists("finfo"))
19
-            return "Fileinfo PECL extension is missing.";
18
+    public function checkFile($file, array $config)
19
+    {
20
+        if (!class_exists("finfo")) {
21
+                    return "Fileinfo PECL extension is missing.";
22
+        }
20 23
 
21
-        if (!isset($config['params']))
22
-            return "Undefined MIME types.";
24
+        if (!isset($config['params'])) {
25
+                    return "Undefined MIME types.";
26
+        }
23 27
 
24 28
         $finfo = strlen($config['mime_magic'])
25 29
             ? new finfo(FILEINFO_MIME, $config['mime_magic'])
26 30
             : new finfo(FILEINFO_MIME);
27
-        if (!$finfo)
28
-            return "Opening fileinfo database failed.";
31
+        if (!$finfo) {
32
+                    return "Opening fileinfo database failed.";
33
+        }
29 34
 
30 35
         $type = $finfo->file($file);
31 36
         $type = substr($type, 0, strrpos($type, ";"));
Please login to merge, or discard this patch.