Completed
Push — develop ( 923a1c...1e9876 )
by Maxim
47s queued 29s
created
manager/processors/save_module.processor.php 1 patch
Switch Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -59,125 +59,125 @@
 block discarded – undo
59 59
 }
60 60
 
61 61
 switch ($_POST['mode']) {
62
-    case '107':
63
-        // invoke OnBeforeModFormSave event
64
-        $modx->invokeEvent("OnBeforeModFormSave", array(
65
-                "mode" => "new",
66
-                "id" => $id
67
-            ));
68
-
69
-        // disallow duplicate names for new modules
70
-        $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'");
71
-        $count = $modx->db->getValue($rs);
72
-        if ($count > 0) {
73
-            $modx->manager->saveFormValues(107);
74
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107");
75
-        }
62
+        case '107':
63
+            // invoke OnBeforeModFormSave event
64
+            $modx->invokeEvent("OnBeforeModFormSave", array(
65
+                    "mode" => "new",
66
+                    "id" => $id
67
+                ));
68
+
69
+            // disallow duplicate names for new modules
70
+            $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'");
71
+            $count = $modx->db->getValue($rs);
72
+            if ($count > 0) {
73
+                $modx->manager->saveFormValues(107);
74
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107");
75
+            }
76 76
 
77
-        // save the new module
78
-        $newid = $modx->db->insert(array(
79
-            'name' => $name,
80
-            'description' => $description,
81
-            'disabled' => $disabled,
82
-            'wrap' => $wrap,
83
-            'locked' => $locked,
84
-            'icon' => $icon,
85
-            'resourcefile' => $resourcefile,
86
-            'enable_resource' => $enable_resource,
87
-            'category' => $categoryid,
88
-            'enable_sharedparams' => $enable_sharedparams,
89
-            'guid' => $guid,
90
-            'modulecode' => $modulecode,
91
-            'properties' => $properties,
92
-            'createdon' => $currentdate,
93
-            'editedon' => $currentdate
94
-        ), $modx->getFullTableName('site_modules'));
95
-
96
-        // save user group access permissions
97
-        saveUserGroupAccessPermissons();
98
-
99
-        // invoke OnModFormSave event
100
-        $modx->invokeEvent("OnModFormSave", array(
101
-                "mode" => "new",
102
-                "id" => $newid
103
-            ));
104
-
105
-        // Set the item name for logger
106
-        $_SESSION['itemname'] = $name;
107
-
108
-        // empty cache
109
-        $modx->clearCache('full');
110
-
111
-        // finished emptying cache - redirect
112
-        if ($_POST['stay'] != '') {
113
-            $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107";
114
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
115
-            header($header);
116
-        } else {
117
-            $header = "Location: index.php?a=106&r=2";
118
-            header($header);
119
-        }
120
-        break;
121
-    case '108':
122
-        // invoke OnBeforeModFormSave event
123
-        $modx->invokeEvent("OnBeforeModFormSave", array(
124
-                "mode" => "upd",
125
-                "id" => $id
126
-            ));
127
-
128
-        // disallow duplicate names for new modules
129
-        $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'");
130
-        if ($modx->db->getValue($rs) > 0) {
131
-            $modx->manager->saveFormValues(108);
132
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}");
133
-        }
77
+            // save the new module
78
+            $newid = $modx->db->insert(array(
79
+                'name' => $name,
80
+                'description' => $description,
81
+                'disabled' => $disabled,
82
+                'wrap' => $wrap,
83
+                'locked' => $locked,
84
+                'icon' => $icon,
85
+                'resourcefile' => $resourcefile,
86
+                'enable_resource' => $enable_resource,
87
+                'category' => $categoryid,
88
+                'enable_sharedparams' => $enable_sharedparams,
89
+                'guid' => $guid,
90
+                'modulecode' => $modulecode,
91
+                'properties' => $properties,
92
+                'createdon' => $currentdate,
93
+                'editedon' => $currentdate
94
+            ), $modx->getFullTableName('site_modules'));
95
+
96
+            // save user group access permissions
97
+            saveUserGroupAccessPermissons();
98
+
99
+            // invoke OnModFormSave event
100
+            $modx->invokeEvent("OnModFormSave", array(
101
+                    "mode" => "new",
102
+                    "id" => $newid
103
+                ));
104
+
105
+            // Set the item name for logger
106
+            $_SESSION['itemname'] = $name;
107
+
108
+            // empty cache
109
+            $modx->clearCache('full');
110
+
111
+            // finished emptying cache - redirect
112
+            if ($_POST['stay'] != '') {
113
+                $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107";
114
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
115
+                header($header);
116
+            } else {
117
+                $header = "Location: index.php?a=106&r=2";
118
+                header($header);
119
+            }
120
+            break;
121
+        case '108':
122
+            // invoke OnBeforeModFormSave event
123
+            $modx->invokeEvent("OnBeforeModFormSave", array(
124
+                    "mode" => "upd",
125
+                    "id" => $id
126
+                ));
127
+
128
+            // disallow duplicate names for new modules
129
+            $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'");
130
+            if ($modx->db->getValue($rs) > 0) {
131
+                $modx->manager->saveFormValues(108);
132
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}");
133
+            }
134 134
 
135
-        // save the edited module
136
-        $modx->db->update(array(
137
-            'name' => $name,
138
-            'description' => $description,
139
-            'icon' => $icon,
140
-            'enable_resource' => $enable_resource,
141
-            'resourcefile' => $resourcefile,
142
-            'disabled' => $disabled,
143
-            'wrap' => $wrap,
144
-            'locked' => $locked,
145
-            'category' => $categoryid,
146
-            'enable_sharedparams' => $enable_sharedparams,
147
-            'guid' => $guid,
148
-            'modulecode' => $modulecode,
149
-            'properties' => $properties,
150
-            'editedon' => $currentdate
151
-        ), $modx->getFullTableName('site_modules'), "id='{$id}'");
152
-
153
-        // save user group access permissions
154
-        saveUserGroupAccessPermissons();
155
-
156
-        // invoke OnModFormSave event
157
-        $modx->invokeEvent("OnModFormSave", array(
158
-                "mode" => "upd",
159
-                "id" => $id
160
-            ));
161
-
162
-        // Set the item name for logger
163
-        $_SESSION['itemname'] = $name;
164
-
165
-        // empty cache
166
-        $modx->clearCache('full');
167
-
168
-        // finished emptying cache - redirect
169
-        if ($_POST['stay'] != '') {
170
-            $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107";
171
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
172
-            header($header);
173
-        } else {
174
-            $modx->unlockElement(6, $id);
175
-            $header = "Location: index.php?a=106&r=2";
176
-            header($header);
177
-        }
178
-        break;
179
-    default:
180
-        $modx->webAlertAndQuit("No operation set in request.");
135
+            // save the edited module
136
+            $modx->db->update(array(
137
+                'name' => $name,
138
+                'description' => $description,
139
+                'icon' => $icon,
140
+                'enable_resource' => $enable_resource,
141
+                'resourcefile' => $resourcefile,
142
+                'disabled' => $disabled,
143
+                'wrap' => $wrap,
144
+                'locked' => $locked,
145
+                'category' => $categoryid,
146
+                'enable_sharedparams' => $enable_sharedparams,
147
+                'guid' => $guid,
148
+                'modulecode' => $modulecode,
149
+                'properties' => $properties,
150
+                'editedon' => $currentdate
151
+            ), $modx->getFullTableName('site_modules'), "id='{$id}'");
152
+
153
+            // save user group access permissions
154
+            saveUserGroupAccessPermissons();
155
+
156
+            // invoke OnModFormSave event
157
+            $modx->invokeEvent("OnModFormSave", array(
158
+                    "mode" => "upd",
159
+                    "id" => $id
160
+                ));
161
+
162
+            // Set the item name for logger
163
+            $_SESSION['itemname'] = $name;
164
+
165
+            // empty cache
166
+            $modx->clearCache('full');
167
+
168
+            // finished emptying cache - redirect
169
+            if ($_POST['stay'] != '') {
170
+                $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107";
171
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
172
+                header($header);
173
+            } else {
174
+                $modx->unlockElement(6, $id);
175
+                $header = "Location: index.php?a=106&r=2";
176
+                header($header);
177
+            }
178
+            break;
179
+        default:
180
+            $modx->webAlertAndQuit("No operation set in request.");
181 181
 }
182 182
 
183 183
 // saves module user group access
Please login to merge, or discard this patch.
manager/processors/save_content.processor.php 1 patch
Switch Indentation   +220 added lines, -220 removed lines patch added patch discarded remove patch
@@ -273,11 +273,11 @@  discard block
 block discarded – undo
273 273
 }
274 274
 
275 275
 switch ($actionToTake) {
276
-    case 'new' :
276
+        case 'new' :
277 277
 
278
-        // invoke OnBeforeDocFormSave event
279
-        switch($modx->config['docid_incrmnt_method'])
280
-        {
278
+            // invoke OnBeforeDocFormSave event
279
+            switch($modx->config['docid_incrmnt_method'])
280
+            {
281 281
             case '1':
282 282
                 $from = "{$tbl_site_content} AS T0 LEFT JOIN {$tbl_site_content} AS T1 ON T0.id + 1 = T1.id";
283 283
                 $where = "T1.id IS NULL";
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
             
292 292
             default:
293 293
                 $id = '';
294
-        }
294
+            }
295 295
         
296 296
         $modx->invokeEvent("OnBeforeDocFormSave", array (
297 297
             "mode" => "new",
@@ -442,256 +442,256 @@  discard block
 block discarded – undo
442 442
 
443 443
 
444 444
         break;
445
-    case 'edit' :
445
+        case 'edit' :
446 446
 
447
-        // get the document's current parent
448
-        $oldparent = $existingDocument['parent'];
449
-        $doctype = $existingDocument['type'];
447
+            // get the document's current parent
448
+            $oldparent = $existingDocument['parent'];
449
+            $doctype = $existingDocument['type'];
450 450
 
451
-        if ($id == $site_start && $published == 0) {
452
-            $modx->manager->saveFormValues(27);
453
-            $modx->webAlertAndQuit("Document is linked to site_start variable and cannot be unpublished!");
454
-        }
455
-        $today = $_SERVER['REQUEST_TIME'] + $modx->config['server_offset_time'];
456
-        if ($id == $site_start && ($pub_date > $today || $unpub_date != "0")) {
457
-            $modx->manager->saveFormValues(27);
458
-            $modx->webAlertAndQuit("Document is linked to site_start variable and cannot have publish or unpublish dates set!");
459
-        }
460
-        if ($parent == $id) {
461
-            $modx->manager->saveFormValues(27);
462
-            $modx->webAlertAndQuit("Document can not be it's own parent!");
463
-        }
451
+            if ($id == $site_start && $published == 0) {
452
+                $modx->manager->saveFormValues(27);
453
+                $modx->webAlertAndQuit("Document is linked to site_start variable and cannot be unpublished!");
454
+            }
455
+            $today = $_SERVER['REQUEST_TIME'] + $modx->config['server_offset_time'];
456
+            if ($id == $site_start && ($pub_date > $today || $unpub_date != "0")) {
457
+                $modx->manager->saveFormValues(27);
458
+                $modx->webAlertAndQuit("Document is linked to site_start variable and cannot have publish or unpublish dates set!");
459
+            }
460
+            if ($parent == $id) {
461
+                $modx->manager->saveFormValues(27);
462
+                $modx->webAlertAndQuit("Document can not be it's own parent!");
463
+            }
464 464
 
465
-        $parents = $modx->getParentIds($parent);
466
-        if (in_array($id, $parents)) {
467
-            $modx->webAlertAndQuit("Document descendant can not be it's parent!");
468
-        }
465
+            $parents = $modx->getParentIds($parent);
466
+            if (in_array($id, $parents)) {
467
+                $modx->webAlertAndQuit("Document descendant can not be it's parent!");
468
+            }
469 469
         
470
-        // check to see document is a folder
471
-        $rs = $modx->db->select('count(id)', $tbl_site_content, "parent='{$id}'");
472
-        $count = $modx->db->getValue($rs);
473
-        if ($count > 0) {
474
-            $isfolder = 1;
475
-        }
476
-
477
-        // set publishedon and publishedby
478
-        $was_published = $existingDocument['published'];
479
-
480
-        // keep original publish state, if change is not permitted
481
-        if (!$modx->hasPermission('publish_document')) {
482
-            $published = $was_published;
483
-            $pub_date = 'pub_date';
484
-            $unpub_date = 'unpub_date';
485
-        }
470
+            // check to see document is a folder
471
+            $rs = $modx->db->select('count(id)', $tbl_site_content, "parent='{$id}'");
472
+            $count = $modx->db->getValue($rs);
473
+            if ($count > 0) {
474
+                $isfolder = 1;
475
+            }
486 476
 
487
-        // if it was changed from unpublished to published
488
-        if (!$was_published && $published) {
489
-            $publishedon = $currentdate;
490
-            $publishedby = $modx->getLoginUserID();
491
-            }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) {
492
-            $publishedon = $pub_date;
493
-            $publishedby = $modx->getLoginUserID();
494
-               }elseif ($was_published && !$published) {
495
-            $publishedon = 0;
496
-            $publishedby = 0;
497
-        } else {
498
-            $publishedon = 'publishedon';
499
-            $publishedby = 'publishedby';
500
-        }
477
+            // set publishedon and publishedby
478
+            $was_published = $existingDocument['published'];
501 479
 
502
-        // invoke OnBeforeDocFormSave event
503
-        $modx->invokeEvent("OnBeforeDocFormSave", array (
504
-            "mode" => "upd",
505
-            "id" => $id
506
-        ));
480
+            // keep original publish state, if change is not permitted
481
+            if (!$modx->hasPermission('publish_document')) {
482
+                $published = $was_published;
483
+                $pub_date = 'pub_date';
484
+                $unpub_date = 'unpub_date';
485
+            }
507 486
 
508
-        // update the document
509
-        $modx->db->update(
510
-            "introtext='{$introtext}', "
511
-            . "content='{$content}', "
512
-            . "pagetitle='{$pagetitle}', "
513
-            . "longtitle='{$longtitle}', "
514
-            . "type='{$type}', "
515
-            . "description='{$description}', "
516
-            . "alias='{$alias}', "
517
-            . "link_attributes='{$link_attributes}', "
518
-            . "isfolder={$isfolder}, "
519
-            . "richtext={$richtext}, "
520
-            . "published={$published}, "
521
-            . "pub_date={$pub_date}, "
522
-            . "unpub_date={$unpub_date}, "
523
-            . "parent={$parent}, "
524
-            . "template={$template}, "
525
-            . "menuindex={$menuindex}, "
526
-            . "searchable={$searchable}, "
527
-            . "cacheable={$cacheable}, "
528
-            . "editedby=" . $modx->getLoginUserID() . ", "
529
-            . "editedon={$currentdate}, "
530
-            . "publishedon={$publishedon}, "
531
-            . "publishedby={$publishedby}, "
532
-            . "contentType='{$contentType}', "
533
-            . "content_dispo={$contentdispo}, "
534
-            . "donthit={$donthit}, "
535
-            . "menutitle='{$menutitle}', "
536
-            . "hidemenu={$hidemenu}, "
537
-            . "alias_visible={$aliasvisible}"
538
-            , $tbl_site_content, "id='{$id}'");
539
-
540
-        // update template variables
541
-        $rs = $modx->db->select('id, tmplvarid', $tbl_site_tmplvar_contentvalues, "contentid='{$id}'");
542
-        $tvIds = array ();
543
-        while ($row = $modx->db->getRow($rs)) {
544
-            $tvIds[$row['tmplvarid']] = $row['id'];
545
-        }
546
-        $tvDeletions = array();
547
-        $tvChanges = array();
548
-        foreach ($tmplvars as $field => $value) {
549
-            if (!is_array($value)) {
550
-                if (isset($tvIds[$value])) $tvDeletions[] = $tvIds[$value];
487
+            // if it was changed from unpublished to published
488
+            if (!$was_published && $published) {
489
+                $publishedon = $currentdate;
490
+                $publishedby = $modx->getLoginUserID();
491
+                }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) {
492
+                $publishedon = $pub_date;
493
+                $publishedby = $modx->getLoginUserID();
494
+                   }elseif ($was_published && !$published) {
495
+                $publishedon = 0;
496
+                $publishedby = 0;
551 497
             } else {
552
-                $tvId = $value[0];
553
-                $tvVal = $value[1];
498
+                $publishedon = 'publishedon';
499
+                $publishedby = 'publishedby';
500
+            }
554 501
 
555
-                if (isset($tvIds[$tvId])) {
556
-                    $tvChanges[] = array(array('tmplvarid' => $tvId, 'contentid' => $id, 'value' => $modx->db->escape($tvVal)), array('id' => $tvIds[$tvId]));
502
+            // invoke OnBeforeDocFormSave event
503
+            $modx->invokeEvent("OnBeforeDocFormSave", array (
504
+                "mode" => "upd",
505
+                "id" => $id
506
+            ));
507
+
508
+            // update the document
509
+            $modx->db->update(
510
+                "introtext='{$introtext}', "
511
+                . "content='{$content}', "
512
+                . "pagetitle='{$pagetitle}', "
513
+                . "longtitle='{$longtitle}', "
514
+                . "type='{$type}', "
515
+                . "description='{$description}', "
516
+                . "alias='{$alias}', "
517
+                . "link_attributes='{$link_attributes}', "
518
+                . "isfolder={$isfolder}, "
519
+                . "richtext={$richtext}, "
520
+                . "published={$published}, "
521
+                . "pub_date={$pub_date}, "
522
+                . "unpub_date={$unpub_date}, "
523
+                . "parent={$parent}, "
524
+                . "template={$template}, "
525
+                . "menuindex={$menuindex}, "
526
+                . "searchable={$searchable}, "
527
+                . "cacheable={$cacheable}, "
528
+                . "editedby=" . $modx->getLoginUserID() . ", "
529
+                . "editedon={$currentdate}, "
530
+                . "publishedon={$publishedon}, "
531
+                . "publishedby={$publishedby}, "
532
+                . "contentType='{$contentType}', "
533
+                . "content_dispo={$contentdispo}, "
534
+                . "donthit={$donthit}, "
535
+                . "menutitle='{$menutitle}', "
536
+                . "hidemenu={$hidemenu}, "
537
+                . "alias_visible={$aliasvisible}"
538
+                , $tbl_site_content, "id='{$id}'");
539
+
540
+            // update template variables
541
+            $rs = $modx->db->select('id, tmplvarid', $tbl_site_tmplvar_contentvalues, "contentid='{$id}'");
542
+            $tvIds = array ();
543
+            while ($row = $modx->db->getRow($rs)) {
544
+                $tvIds[$row['tmplvarid']] = $row['id'];
545
+            }
546
+            $tvDeletions = array();
547
+            $tvChanges = array();
548
+            foreach ($tmplvars as $field => $value) {
549
+                if (!is_array($value)) {
550
+                    if (isset($tvIds[$value])) $tvDeletions[] = $tvIds[$value];
557 551
                 } else {
558
-                    $tvAdded[] = array('tmplvarid' => $tvId, 'contentid' => $id, 'value' => $modx->db->escape($tvVal));
552
+                    $tvId = $value[0];
553
+                    $tvVal = $value[1];
554
+
555
+                    if (isset($tvIds[$tvId])) {
556
+                        $tvChanges[] = array(array('tmplvarid' => $tvId, 'contentid' => $id, 'value' => $modx->db->escape($tvVal)), array('id' => $tvIds[$tvId]));
557
+                    } else {
558
+                        $tvAdded[] = array('tmplvarid' => $tvId, 'contentid' => $id, 'value' => $modx->db->escape($tvVal));
559
+                    }
559 560
                 }
560 561
             }
561
-        }
562 562
 
563
-        if (!empty($tvDeletions)) {
564
-            $modx->db->delete($tbl_site_tmplvar_contentvalues, 'id IN('.implode(',', $tvDeletions).')');
565
-        }
563
+            if (!empty($tvDeletions)) {
564
+                $modx->db->delete($tbl_site_tmplvar_contentvalues, 'id IN('.implode(',', $tvDeletions).')');
565
+            }
566 566
             
567
-        if (!empty($tvAdded)) {
568
-            foreach ($tvAdded as $tv) {
569
-                $modx->db->insert($tv, $tbl_site_tmplvar_contentvalues);
567
+            if (!empty($tvAdded)) {
568
+                foreach ($tvAdded as $tv) {
569
+                    $modx->db->insert($tv, $tbl_site_tmplvar_contentvalues);
570
+                }
570 571
             }
571
-        }
572 572
         
573
-        if (!empty($tvChanges)) {
574
-            foreach ($tvChanges as $tv) {
575
-                $modx->db->update($tv[0], $tbl_site_tmplvar_contentvalues, "id='{$tv[1]['id']}'");
573
+            if (!empty($tvChanges)) {
574
+                foreach ($tvChanges as $tv) {
575
+                    $modx->db->update($tv[0], $tbl_site_tmplvar_contentvalues, "id='{$tv[1]['id']}'");
576
+                }
576 577
             }
577
-        }
578 578
 
579
-        // set document permissions
580
-        if ($use_udperms == 1 && is_array($document_groups)) {
581
-            $new_groups = array();
582
-            // process the new input
583
-            foreach ($document_groups as $value_pair) {
584
-                list($group, $link_id) = explode(',', $value_pair); // @see actions/mutate_content.dynamic.php @ line 1138 (permissions list)
585
-                $new_groups[$group] = $link_id;
586
-            }
579
+            // set document permissions
580
+            if ($use_udperms == 1 && is_array($document_groups)) {
581
+                $new_groups = array();
582
+                // process the new input
583
+                foreach ($document_groups as $value_pair) {
584
+                    list($group, $link_id) = explode(',', $value_pair); // @see actions/mutate_content.dynamic.php @ line 1138 (permissions list)
585
+                    $new_groups[$group] = $link_id;
586
+                }
587 587
 
588
-            // grab the current set of permissions on this document the user can access
589
-            $isManager = $modx->hasPermission('access_permissions');
590
-            $isWeb     = $modx->hasPermission('web_access_permissions');
591
-            $rs = $modx->db->select(
592
-                'groups.id, groups.document_group',
593
-                "{$tbl_document_groups} AS groups
588
+                // grab the current set of permissions on this document the user can access
589
+                $isManager = $modx->hasPermission('access_permissions');
590
+                $isWeb     = $modx->hasPermission('web_access_permissions');
591
+                $rs = $modx->db->select(
592
+                    'groups.id, groups.document_group',
593
+                    "{$tbl_document_groups} AS groups
594 594
                     LEFT JOIN {$tbl_documentgroup_names} AS dgn ON dgn.id = groups.document_group",
595
-                "((1=".(int)$isManager." AND dgn.private_memgroup) OR (1=".(int)$isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'"
596
-                );
597
-            $old_groups = array();
598
-            while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id'];
599
-
600
-            // update the permissions in the database
601
-            $insertions = $deletions = array();
602
-            foreach ($new_groups as $group => $link_id) {
603
-                if (array_key_exists($group, $old_groups)) {
604
-                    unset($old_groups[$group]);
605
-                    continue;
606
-                } elseif ($link_id == 'new') {
607
-                    $insertions[] = '('.(int)$group.','.$id.')';
595
+                    "((1=".(int)$isManager." AND dgn.private_memgroup) OR (1=".(int)$isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'"
596
+                    );
597
+                $old_groups = array();
598
+                while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id'];
599
+
600
+                // update the permissions in the database
601
+                $insertions = $deletions = array();
602
+                foreach ($new_groups as $group => $link_id) {
603
+                    if (array_key_exists($group, $old_groups)) {
604
+                        unset($old_groups[$group]);
605
+                        continue;
606
+                    } elseif ($link_id == 'new') {
607
+                        $insertions[] = '('.(int)$group.','.$id.')';
608
+                    }
609
+                }
610
+                if (!empty($insertions)) {
611
+                    $modx->db->query("INSERT INTO {$tbl_document_groups} (document_group, document) VALUES ".implode(',', $insertions));
612
+                }
613
+                if (!empty($old_groups)) {
614
+                    $modx->db->delete($tbl_document_groups, "id IN (".implode(',', $old_groups).")");
615
+                }
616
+                // necessary to remove all permissions as document is public
617
+                if ((isset($_POST['chkalldocs']) && $_POST['chkalldocs'] == 'on')) {
618
+                    $modx->db->delete($tbl_document_groups, "document='{$id}'");
608 619
                 }
609 620
             }
610
-            if (!empty($insertions)) {
611
-                $modx->db->query("INSERT INTO {$tbl_document_groups} (document_group, document) VALUES ".implode(',', $insertions));
612
-            }
613
-            if (!empty($old_groups)) {
614
-                $modx->db->delete($tbl_document_groups, "id IN (".implode(',', $old_groups).")");
615
-            }
616
-            // necessary to remove all permissions as document is public
617
-            if ((isset($_POST['chkalldocs']) && $_POST['chkalldocs'] == 'on')) {
618
-                $modx->db->delete($tbl_document_groups, "document='{$id}'");
621
+
622
+            // do the parent stuff
623
+            if ($parent != 0) {
624
+                $fields = array('isfolder' => 1);
625
+                $modx->db->update($fields, $tbl_site_content, "id='{$_REQUEST['parent']}'");
619 626
             }
620
-        }
621 627
 
622
-        // do the parent stuff
623
-        if ($parent != 0) {
624
-            $fields = array('isfolder' => 1);
625
-            $modx->db->update($fields, $tbl_site_content, "id='{$_REQUEST['parent']}'");
626
-        }
628
+            // finished moving the document, now check to see if the old_parent should no longer be a folder
629
+            $rs = $modx->db->select('COUNT(id)', $tbl_site_content, "parent='{$oldparent}'");
630
+            $limit = $modx->db->getValue($rs);
627 631
 
628
-        // finished moving the document, now check to see if the old_parent should no longer be a folder
629
-        $rs = $modx->db->select('COUNT(id)', $tbl_site_content, "parent='{$oldparent}'");
630
-        $limit = $modx->db->getValue($rs);
632
+            if ($limit == 0) {
633
+                $fields = array('isfolder' => 0);
634
+                $modx->db->update($fields, $tbl_site_content, "id='{$oldparent}'");
635
+            }
631 636
 
632
-        if ($limit == 0) {
633
-            $fields = array('isfolder' => 0);
634
-            $modx->db->update($fields, $tbl_site_content, "id='{$oldparent}'");
635
-        }
636 637
 
638
+            // invoke OnDocFormSave event
639
+            $modx->invokeEvent("OnDocFormSave", array (
640
+                "mode" => "upd",
641
+                "id" => $id
642
+            ));
637 643
 
638
-        // invoke OnDocFormSave event
639
-        $modx->invokeEvent("OnDocFormSave", array (
640
-            "mode" => "upd",
641
-            "id" => $id
642
-        ));
644
+            // secure web documents - flag as private
645
+            include MODX_MANAGER_PATH . "includes/secure_web_documents.inc.php";
646
+            secureWebDocument($id);
643 647
 
644
-        // secure web documents - flag as private
645
-        include MODX_MANAGER_PATH . "includes/secure_web_documents.inc.php";
646
-        secureWebDocument($id);
648
+            // secure manager documents - flag as private
649
+            include MODX_MANAGER_PATH . "includes/secure_mgr_documents.inc.php";
650
+            secureMgrDocument($id);
647 651
 
648
-        // secure manager documents - flag as private
649
-        include MODX_MANAGER_PATH . "includes/secure_mgr_documents.inc.php";
650
-        secureMgrDocument($id);
651
-
652
-        // Set the item name for logger
653
-        $_SESSION['itemname'] = $no_esc_pagetitle;
652
+            // Set the item name for logger
653
+            $_SESSION['itemname'] = $no_esc_pagetitle;
654 654
 
655
-        if ($syncsite == 1) {
656
-            // empty cache
657
-            $keys = array('alias','parent','published','isfolder','menuindex','alias_visible');
658
-            $flag = '';
659
-            foreach($keys as $key) {
660
-                if ($existingDocument[$key]===$_POST[$key]) continue;
661
-                $flag = 'full';
662
-                break;
655
+            if ($syncsite == 1) {
656
+                // empty cache
657
+                $keys = array('alias','parent','published','isfolder','menuindex','alias_visible');
658
+                $flag = '';
659
+                foreach($keys as $key) {
660
+                    if ($existingDocument[$key]===$_POST[$key]) continue;
661
+                    $flag = 'full';
662
+                    break;
663
+                }
664
+                if($flag==='full') $modx->clearCache('full');
665
+                else               $modx->clearCache($id);
663 666
             }
664
-            if($flag==='full') $modx->clearCache('full');
665
-            else               $modx->clearCache($id);
666
-        }
667 667
         
668
-        if ($_POST['refresh_preview'] == '1')
669
-            $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev";
670
-        else {
671
-            if ($_POST['stay'] != '2' && $id > 0) {
672
-                $modx->unlockElement(7, $id);
673
-            }
674
-            if ($_POST['stay'] != '') {
675
-                $id = $_REQUEST['id'];
676
-                if ($type == "reference") {
677
-                    // weblink
678
-                    $a = ($_POST['stay'] == '2') ? "27&id=$id" : "72&pid=$parent";
668
+            if ($_POST['refresh_preview'] == '1')
669
+                $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev";
670
+            else {
671
+                if ($_POST['stay'] != '2' && $id > 0) {
672
+                    $modx->unlockElement(7, $id);
673
+                }
674
+                if ($_POST['stay'] != '') {
675
+                    $id = $_REQUEST['id'];
676
+                    if ($type == "reference") {
677
+                        // weblink
678
+                        $a = ($_POST['stay'] == '2') ? "27&id=$id" : "72&pid=$parent";
679
+                    } else {
680
+                        // document
681
+                        $a = ($_POST['stay'] == '2') ? "27&id=$id" : "4&pid=$parent";
682
+                    }
683
+                    $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay'].$add_path;
679 684
                 } else {
680
-                    // document
681
-                    $a = ($_POST['stay'] == '2') ? "27&id=$id" : "4&pid=$parent";
685
+                    $header = "Location: index.php?a=3&id=$id&r=1".$add_path;
682 686
                 }
683
-                $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay'].$add_path;
687
+            }
688
+            if (headers_sent()) {
689
+                $header = str_replace('Location: ','',$header);
690
+                echo "<script>document.location.href='$header';</script>\n";
684 691
             } else {
685
-                $header = "Location: index.php?a=3&id=$id&r=1".$add_path;
692
+                header($header);
686 693
             }
687
-        }
688
-        if (headers_sent()) {
689
-            $header = str_replace('Location: ','',$header);
690
-            echo "<script>document.location.href='$header';</script>\n";
691
-        } else {
692
-            header($header);
693
-        }
694
-        break;
695
-    default :
696
-        $modx->webAlertAndQuit("No operation set in request.");
694
+            break;
695
+        default :
696
+            $modx->webAlertAndQuit("No operation set in request.");
697 697
 }
Please login to merge, or discard this patch.
manager/processors/save_web_user.processor.php 1 patch
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.
manager/processors/save_snippet.processor.php 1 patch
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.