Completed
Push — develop ( 4e806c...6a553b )
by Agel_Nash
10:03
created
manager/actions/mutate_content.dynamic.php 1 patch
Indentation   +371 added lines, -371 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  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
 
6 6
 /********************/
@@ -12,29 +12,29 @@  discard block
 block discarded – undo
12 12
 
13 13
 // check permissions
14 14
 switch($modx->getManagerApi()->action) {
15
-	case 27:
16
-		if(!$modx->hasPermission('edit_document')) {
17
-			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
18
-		}
19
-		break;
20
-	case 85:
21
-	case 72:
22
-	case 4:
23
-		if(!$modx->hasPermission('new_document')) {
24
-			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
25
-		} elseif(isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') {
26
-			// check user has permissions for parent
27
-			$udperms = new EvolutionCMS\Legacy\Permissions();
28
-			$udperms->user = $modx->getLoginUserID();
29
-			$udperms->document = empty($_REQUEST['pid']) ? 0 : $_REQUEST['pid'];
30
-			$udperms->role = $_SESSION['mgrRole'];
31
-			if(!$udperms->checkPermissions()) {
32
-				$modx->webAlertAndQuit($_lang["access_permission_denied"]);
33
-			}
34
-		}
35
-		break;
36
-	default:
37
-		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
15
+    case 27:
16
+        if(!$modx->hasPermission('edit_document')) {
17
+            $modx->webAlertAndQuit($_lang["error_no_privileges"]);
18
+        }
19
+        break;
20
+    case 85:
21
+    case 72:
22
+    case 4:
23
+        if(!$modx->hasPermission('new_document')) {
24
+            $modx->webAlertAndQuit($_lang["error_no_privileges"]);
25
+        } elseif(isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') {
26
+            // check user has permissions for parent
27
+            $udperms = new EvolutionCMS\Legacy\Permissions();
28
+            $udperms->user = $modx->getLoginUserID();
29
+            $udperms->document = empty($_REQUEST['pid']) ? 0 : $_REQUEST['pid'];
30
+            $udperms->role = $_SESSION['mgrRole'];
31
+            if(!$udperms->checkPermissions()) {
32
+                $modx->webAlertAndQuit($_lang["access_permission_denied"]);
33
+            }
34
+        }
35
+        break;
36
+    default:
37
+        $modx->webAlertAndQuit($_lang["error_no_privileges"]);
38 38
 }
39 39
 
40 40
 $id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
@@ -53,21 +53,21 @@  discard block
 block discarded – undo
53 53
 $tbl_site_tmplvars = $modx->getDatabase()->getFullTableName('site_tmplvars');
54 54
 
55 55
 if($modx->getManagerApi()->action == 27) {
56
-	//editing an existing document
57
-	// check permissions on the document
58
-	$udperms = new EvolutionCMS\Legacy\Permissions();
59
-	$udperms->user = $modx->getLoginUserID();
60
-	$udperms->document = $id;
61
-	$udperms->role = $_SESSION['mgrRole'];
62
-
63
-	if(!$udperms->checkPermissions()) {
64
-		$modx->webAlertAndQuit($_lang["access_permission_denied"]);
65
-	}
56
+    //editing an existing document
57
+    // check permissions on the document
58
+    $udperms = new EvolutionCMS\Legacy\Permissions();
59
+    $udperms->user = $modx->getLoginUserID();
60
+    $udperms->document = $id;
61
+    $udperms->role = $_SESSION['mgrRole'];
62
+
63
+    if(!$udperms->checkPermissions()) {
64
+        $modx->webAlertAndQuit($_lang["access_permission_denied"]);
65
+    }
66 66
 }
67 67
 
68 68
 // check to see if resource isn't locked
69 69
 if($lockedEl = $modx->elementIsLocked(7, $id)) {
70
-	$modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['resource']));
70
+    $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['resource']));
71 71
 }
72 72
 // end check for lock
73 73
 
@@ -76,74 +76,74 @@  discard block
 block discarded – undo
76 76
 
77 77
 // get document groups for current user
78 78
 if($_SESSION['mgrDocgroups']) {
79
-	$docgrp = implode(',', $_SESSION['mgrDocgroups']);
79
+    $docgrp = implode(',', $_SESSION['mgrDocgroups']);
80 80
 }
81 81
 
82 82
 if(!empty ($id)) {
83
-	$access = sprintf("1='%s' OR sc.privatemgr=0", $_SESSION['mgrRole']);
84
-	if($docgrp) {
85
-		$access .= " OR dg.document_group IN ({$docgrp})";
86
-	}
87
-	$rs = $modx->getDatabase()->select('sc.*', "{$tbl_site_content} AS sc LEFT JOIN {$tbl_document_groups} AS dg ON dg.document=sc.id", "sc.id='{$id}' AND ({$access})");
88
-	$content = array();
89
-	$content = $modx->getDatabase()->getRow($rs);
90
-	$modx->documentObject = &$content;
91
-	if(!$content) {
92
-		$modx->webAlertAndQuit($_lang["access_permission_denied"]);
93
-	}
94
-	$_SESSION['itemname'] = $content['pagetitle'];
83
+    $access = sprintf("1='%s' OR sc.privatemgr=0", $_SESSION['mgrRole']);
84
+    if($docgrp) {
85
+        $access .= " OR dg.document_group IN ({$docgrp})";
86
+    }
87
+    $rs = $modx->getDatabase()->select('sc.*', "{$tbl_site_content} AS sc LEFT JOIN {$tbl_document_groups} AS dg ON dg.document=sc.id", "sc.id='{$id}' AND ({$access})");
88
+    $content = array();
89
+    $content = $modx->getDatabase()->getRow($rs);
90
+    $modx->documentObject = &$content;
91
+    if(!$content) {
92
+        $modx->webAlertAndQuit($_lang["access_permission_denied"]);
93
+    }
94
+    $_SESSION['itemname'] = $content['pagetitle'];
95 95
 } else {
96
-	$content = array();
96
+    $content = array();
97 97
 
98
-	if(isset($_REQUEST['newtemplate'])) {
99
-		$content['template'] = $_REQUEST['newtemplate'];
100
-	} else {
101
-		$content['template'] = getDefaultTemplate();
102
-	}
98
+    if(isset($_REQUEST['newtemplate'])) {
99
+        $content['template'] = $_REQUEST['newtemplate'];
100
+    } else {
101
+        $content['template'] = getDefaultTemplate();
102
+    }
103 103
 
104
-	$_SESSION['itemname'] = $_lang["new_resource"];
104
+    $_SESSION['itemname'] = $_lang["new_resource"];
105 105
 }
106 106
 
107 107
 // restore saved form
108 108
 $formRestored = $modx->getManagerApi()->loadFormValues();
109 109
 if(isset($_REQUEST['newtemplate'])) {
110
-	$formRestored = true;
110
+    $formRestored = true;
111 111
 }
112 112
 
113 113
 // retain form values if template was changed
114 114
 // edited to convert pub_date and unpub_date
115 115
 // sottwell 02-09-2006
116 116
 if($formRestored == true) {
117
-	$content = array_merge($content, $_POST);
118
-	$content['content'] = $_POST['ta'];
119
-	if(empty ($content['pub_date'])) {
120
-		unset ($content['pub_date']);
121
-	} else {
122
-		$content['pub_date'] = $modx->toTimeStamp($content['pub_date']);
123
-	}
124
-	if(empty ($content['unpub_date'])) {
125
-		unset ($content['unpub_date']);
126
-	} else {
127
-		$content['unpub_date'] = $modx->toTimeStamp($content['unpub_date']);
128
-	}
117
+    $content = array_merge($content, $_POST);
118
+    $content['content'] = $_POST['ta'];
119
+    if(empty ($content['pub_date'])) {
120
+        unset ($content['pub_date']);
121
+    } else {
122
+        $content['pub_date'] = $modx->toTimeStamp($content['pub_date']);
123
+    }
124
+    if(empty ($content['unpub_date'])) {
125
+        unset ($content['unpub_date']);
126
+    } else {
127
+        $content['unpub_date'] = $modx->toTimeStamp($content['unpub_date']);
128
+    }
129 129
 }
130 130
 
131 131
 // increase menu index if this is a new document
132 132
 if(!isset ($_REQUEST['id'])) {
133
-	if(!isset ($modx->config['auto_menuindex'])) {
134
-		$modx->config['auto_menuindex'] = 1;
135
-	}
136
-	if($modx->config['auto_menuindex']) {
137
-		$pid = (int)$_REQUEST['pid'];
138
-		$rs = $modx->getDatabase()->select('count(*)', $tbl_site_content, "parent='{$pid}'");
139
-		$content['menuindex'] = $modx->getDatabase()->getValue($rs);
140
-	} else {
141
-		$content['menuindex'] = 0;
142
-	}
133
+    if(!isset ($modx->config['auto_menuindex'])) {
134
+        $modx->config['auto_menuindex'] = 1;
135
+    }
136
+    if($modx->config['auto_menuindex']) {
137
+        $pid = (int)$_REQUEST['pid'];
138
+        $rs = $modx->getDatabase()->select('count(*)', $tbl_site_content, "parent='{$pid}'");
139
+        $content['menuindex'] = $modx->getDatabase()->getValue($rs);
140
+    } else {
141
+        $content['menuindex'] = 0;
142
+    }
143 143
 }
144 144
 
145 145
 if(isset ($_POST['which_editor'])) {
146
-	$modx->config['which_editor'] = $_POST['which_editor'];
146
+    $modx->config['which_editor'] = $_POST['which_editor'];
147 147
 }
148 148
 
149 149
 // Add lock-element JS-Script
@@ -543,23 +543,23 @@  discard block
 block discarded – undo
543 543
 
544 544
 	<form name="mutate" id="mutate" class="content" method="post" enctype="multipart/form-data" action="index.php" onsubmit="documentDirty=false;">
545 545
 		<?php
546
-		// invoke OnDocFormPrerender event
547
-		$evtOut = $modx->invokeEvent('OnDocFormPrerender', array(
548
-			'id' => $id,
549
-			'template' => $content['template']
550
-		));
551
-
552
-		if(is_array($evtOut)) {
553
-			echo implode('', $evtOut);
554
-		}
555
-
556
-		/*************************/
557
-		$dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : '';
558
-		$sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'createdon';
559
-		$page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : '';
560
-		/*************************/
561
-
562
-		?>
546
+        // invoke OnDocFormPrerender event
547
+        $evtOut = $modx->invokeEvent('OnDocFormPrerender', array(
548
+            'id' => $id,
549
+            'template' => $content['template']
550
+        ));
551
+
552
+        if(is_array($evtOut)) {
553
+            echo implode('', $evtOut);
554
+        }
555
+
556
+        /*************************/
557
+        $dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : '';
558
+        $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'createdon';
559
+        $page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : '';
560
+        /*************************/
561
+
562
+        ?>
563 563
 		<input type="hidden" name="a" value="5" />
564 564
 		<input type="hidden" name="id" value="<?= $content['id'] ?>" />
565 565
 		<input type="hidden" name="mode" value="<?= $modx->getManagerApi()->action ?>" />
@@ -574,54 +574,54 @@  discard block
 block discarded – undo
574 574
 
575 575
 			<h1>
576 576
 				<i class="fa fa-pencil-square-o"></i><?php if(isset($_REQUEST['id'])) {
577
-					echo iconv_substr($content['pagetitle'], 0, 50, $modx->config['modx_charset']) . (iconv_strlen($content['pagetitle'], $modx->config['modx_charset']) > 50 ? '...' : '') . '<small>(' . $_REQUEST['id'] . ')</small>';
578
-				} else {
579
-				    if ($modx->getManagerApi()->action == '4') {
577
+                    echo iconv_substr($content['pagetitle'], 0, 50, $modx->config['modx_charset']) . (iconv_strlen($content['pagetitle'], $modx->config['modx_charset']) > 50 ? '...' : '') . '<small>(' . $_REQUEST['id'] . ')</small>';
578
+                } else {
579
+                    if ($modx->getManagerApi()->action == '4') {
580 580
                         echo $_lang['add_resource'];
581 581
                     } else if ($modx->getManagerApi()->action == '72') {
582 582
                         echo $_lang['add_weblink'];
583 583
                     } else {
584 584
                         echo $_lang['create_resource_title'];
585 585
                     }
586
-				} ?>
586
+                } ?>
587 587
 			</h1>
588 588
 
589 589
 			<?= $_style['actionbuttons']['dynamic']['document'] ?>
590 590
 
591 591
 			<?php
592
-			// breadcrumbs
593
-			if($modx->config['use_breadcrumbs']) {
594
-				$temp = array();
595
-				$title = isset($content['pagetitle']) ? $content['pagetitle'] : $_lang['create_resource_title'];
596
-
597
-				if(isset($_REQUEST['id']) && $content['parent'] != 0) {
598
-					$bID = (int) $_REQUEST['id'];
599
-					$temp = $modx->getParentIds($bID);
600
-				} else if(isset($_REQUEST['pid'])) {
601
-					$bID = (int) $_REQUEST['pid'];
602
-					$temp = $modx->getParentIds($bID);
603
-					array_unshift($temp, $bID);
604
-				}
605
-
606
-				if($temp) {
607
-					$parents = implode(',', $temp);
608
-
609
-					if(!empty($parents)) {
610
-						$where = "FIND_IN_SET(id,'{$parents}') DESC";
611
-						$rs = $modx->getDatabase()->select('id, pagetitle', $tbl_site_content, "id IN ({$parents})", $where);
612
-						while($row = $modx->getDatabase()->getRow($rs)) {
613
-							$out .= '<li class="breadcrumbs__li">
592
+            // breadcrumbs
593
+            if($modx->config['use_breadcrumbs']) {
594
+                $temp = array();
595
+                $title = isset($content['pagetitle']) ? $content['pagetitle'] : $_lang['create_resource_title'];
596
+
597
+                if(isset($_REQUEST['id']) && $content['parent'] != 0) {
598
+                    $bID = (int) $_REQUEST['id'];
599
+                    $temp = $modx->getParentIds($bID);
600
+                } else if(isset($_REQUEST['pid'])) {
601
+                    $bID = (int) $_REQUEST['pid'];
602
+                    $temp = $modx->getParentIds($bID);
603
+                    array_unshift($temp, $bID);
604
+                }
605
+
606
+                if($temp) {
607
+                    $parents = implode(',', $temp);
608
+
609
+                    if(!empty($parents)) {
610
+                        $where = "FIND_IN_SET(id,'{$parents}') DESC";
611
+                        $rs = $modx->getDatabase()->select('id, pagetitle', $tbl_site_content, "id IN ({$parents})", $where);
612
+                        while($row = $modx->getDatabase()->getRow($rs)) {
613
+                            $out .= '<li class="breadcrumbs__li">
614 614
                                 <a href="index.php?a=27&id=' . $row['id'] . '" class="breadcrumbs__a">' . htmlspecialchars($row['pagetitle'], ENT_QUOTES, $modx->config['modx_charset']) . '</a>
615 615
                                 <span class="breadcrumbs__sep">&gt;</span>
616 616
                             </li>';
617
-						}
618
-					}
619
-				}
617
+                        }
618
+                    }
619
+                }
620 620
 
621
-				$out .= '<li class="breadcrumbs__li breadcrumbs__li_current">' . $title . '</li>';
622
-				echo '<ul class="breadcrumbs">' . $out . '</ul>';
623
-			}
624
-			?>
621
+                $out .= '<li class="breadcrumbs__li breadcrumbs__li_current">' . $title . '</li>';
622
+                echo '<ul class="breadcrumbs">' . $out . '</ul>';
623
+            }
624
+            ?>
625 625
 
626 626
 			<!-- start main wrapper -->
627 627
 			<div class="sectionBody">
@@ -633,13 +633,13 @@  discard block
 block discarded – undo
633 633
 
634 634
 					<!-- General -->
635 635
 					<?php
636
-					$evtOut = $modx->invokeEvent('OnDocFormTemplateRender', array(
637
-						'id' => $id
638
-					));
639
-					if(is_array($evtOut)) {
640
-						echo implode('', $evtOut);
641
-					} else {
642
-						?>
636
+                    $evtOut = $modx->invokeEvent('OnDocFormTemplateRender', array(
637
+                        'id' => $id
638
+                    ));
639
+                    if(is_array($evtOut)) {
640
+                        echo implode('', $evtOut);
641
+                    } else {
642
+                        ?>
643 643
 						<div class="tab-page" id="tabGeneral">
644 644
 							<h2 class="tab"><?= $_lang['settings_general'] ?></h2>
645 645
 							<script type="text/javascript">tpSettings.addTabPage(document.getElementById("tabGeneral"));</script>
@@ -724,36 +724,36 @@  discard block
 block discarded – undo
724 724
 										<select id="template" name="template" class="inputBox" onchange="templateWarning();">
725 725
 											<option value="0">(blank)</option>
726 726
 											<?php
727
-											$field = "t.templatename, t.selectable, t.id, c.category";
728
-											$from = "{$tbl_site_templates} AS t LEFT JOIN {$tbl_categories} AS c ON t.category = c.id";
729
-											$rs = $modx->getDatabase()->select($field, $from, '', 'c.category, t.templatename ASC');
730
-											$currentCategory = '';
731
-											while($row = $modx->getDatabase()->getRow($rs)) {
732
-												if($row['selectable'] != 1 && $row['id'] != $content['template']) {
733
-													continue;
734
-												};
735
-												// Skip if not selectable but show if selected!
736
-												$thisCategory = $row['category'];
737
-												if($thisCategory == null) {
738
-													$thisCategory = $_lang["no_category"];
739
-												}
740
-												if($thisCategory != $currentCategory) {
741
-													if($closeOptGroup) {
742
-														echo "\t\t\t\t\t</optgroup>\n";
743
-													}
744
-													echo "\t\t\t\t\t<optgroup label=\"$thisCategory\">\n";
745
-													$closeOptGroup = true;
746
-												}
727
+                                            $field = "t.templatename, t.selectable, t.id, c.category";
728
+                                            $from = "{$tbl_site_templates} AS t LEFT JOIN {$tbl_categories} AS c ON t.category = c.id";
729
+                                            $rs = $modx->getDatabase()->select($field, $from, '', 'c.category, t.templatename ASC');
730
+                                            $currentCategory = '';
731
+                                            while($row = $modx->getDatabase()->getRow($rs)) {
732
+                                                if($row['selectable'] != 1 && $row['id'] != $content['template']) {
733
+                                                    continue;
734
+                                                };
735
+                                                // Skip if not selectable but show if selected!
736
+                                                $thisCategory = $row['category'];
737
+                                                if($thisCategory == null) {
738
+                                                    $thisCategory = $_lang["no_category"];
739
+                                                }
740
+                                                if($thisCategory != $currentCategory) {
741
+                                                    if($closeOptGroup) {
742
+                                                        echo "\t\t\t\t\t</optgroup>\n";
743
+                                                    }
744
+                                                    echo "\t\t\t\t\t<optgroup label=\"$thisCategory\">\n";
745
+                                                    $closeOptGroup = true;
746
+                                                }
747 747
 
748
-												$selectedtext = ($row['id'] == $content['template']) ? ' selected="selected"' : '';
748
+                                                $selectedtext = ($row['id'] == $content['template']) ? ' selected="selected"' : '';
749 749
 
750
-												echo "\t\t\t\t\t" . '<option value="' . $row['id'] . '"' . $selectedtext . '>' . $row['templatename'] . "</option>\n";
751
-												$currentCategory = $thisCategory;
752
-											}
753
-											if($thisCategory != '') {
754
-												echo "\t\t\t\t\t</optgroup>\n";
755
-											}
756
-											?>
750
+                                                echo "\t\t\t\t\t" . '<option value="' . $row['id'] . '"' . $selectedtext . '>' . $row['templatename'] . "</option>\n";
751
+                                                $currentCategory = $thisCategory;
752
+                                            }
753
+                                            if($thisCategory != '') {
754
+                                                echo "\t\t\t\t\t</optgroup>\n";
755
+                                            }
756
+                                            ?>
757 757
 										</select>
758 758
 									</td>
759 759
 								</tr>
@@ -793,37 +793,37 @@  discard block
 block discarded – undo
793 793
 									</td>
794 794
 									<td valign="top">
795 795
 										<?php
796
-										$parentlookup = false;
797
-										if(isset ($_REQUEST['id'])) {
798
-											if($content['parent'] == 0) {
799
-												$parentname = $site_name;
800
-											} else {
801
-												$parentlookup = $content['parent'];
802
-											}
803
-										} elseif(isset ($_REQUEST['pid'])) {
804
-											if($_REQUEST['pid'] == 0) {
805
-												$parentname = $site_name;
806
-											} else {
807
-												$parentlookup = $_REQUEST['pid'];
808
-											}
809
-										} elseif(isset($_POST['parent'])) {
810
-											if($_POST['parent'] == 0) {
811
-												$parentname = $site_name;
812
-											} else {
813
-												$parentlookup = $_POST['parent'];
814
-											}
815
-										} else {
816
-											$parentname = $site_name;
817
-											$content['parent'] = 0;
818
-										}
819
-										if($parentlookup !== false && is_numeric($parentlookup)) {
820
-											$rs = $modx->getDatabase()->select('pagetitle', $tbl_site_content, "id='{$parentlookup}'");
821
-											$parentname = $modx->getDatabase()->getValue($rs);
822
-											if(!$parentname) {
823
-												$modx->webAlertAndQuit($_lang["error_no_parent"]);
824
-											}
825
-										}
826
-										?>
796
+                                        $parentlookup = false;
797
+                                        if(isset ($_REQUEST['id'])) {
798
+                                            if($content['parent'] == 0) {
799
+                                                $parentname = $site_name;
800
+                                            } else {
801
+                                                $parentlookup = $content['parent'];
802
+                                            }
803
+                                        } elseif(isset ($_REQUEST['pid'])) {
804
+                                            if($_REQUEST['pid'] == 0) {
805
+                                                $parentname = $site_name;
806
+                                            } else {
807
+                                                $parentlookup = $_REQUEST['pid'];
808
+                                            }
809
+                                        } elseif(isset($_POST['parent'])) {
810
+                                            if($_POST['parent'] == 0) {
811
+                                                $parentname = $site_name;
812
+                                            } else {
813
+                                                $parentlookup = $_POST['parent'];
814
+                                            }
815
+                                        } else {
816
+                                            $parentname = $site_name;
817
+                                            $content['parent'] = 0;
818
+                                        }
819
+                                        if($parentlookup !== false && is_numeric($parentlookup)) {
820
+                                            $rs = $modx->getDatabase()->select('pagetitle', $tbl_site_content, "id='{$parentlookup}'");
821
+                                            $parentname = $modx->getDatabase()->getValue($rs);
822
+                                            if(!$parentname) {
823
+                                                $modx->webAlertAndQuit($_lang["error_no_parent"]);
824
+                                            }
825
+                                        }
826
+                                        ?>
827 827
 										<i id="plock" class="<?= $_style["actions_folder"] ?>" onclick="enableParentSelection(!allowParentSelection);"></i>
828 828
 										<b><span id="parentName"><?= (isset($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']) ?> (<?= $modx->getPhpCompat()->entities($parentname) ?>)</span></b>
829 829
 										<input type="hidden" name="parent" value="<?= (isset($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']) ?>" onchange="documentDirty=true;" />
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 								</tr>
832 832
 								<tr></tr>
833 833
 								<?php
834
-								/*
834
+                                /*
835 835
 								if($content['type'] == 'reference' || $modx->getManagerApi()->action == '72') {
836 836
 									?>
837 837
 									<tr>
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
 									</tr>
860 860
 									<?php
861 861
 								}*/
862
-								?>
862
+                                ?>
863 863
 
864 864
 								<?php if($content['type'] == 'document' || $modx->getManagerApi()->action == '4') { ?>
865 865
 									<tr>
@@ -872,36 +872,36 @@  discard block
 block discarded – undo
872 872
 													<select id="which_editor" class="form-control form-control-sm" size="1" name="which_editor" onchange="changeRTE();">
873 873
 													<option value="none"><?= $_lang['none'] ?></option>
874 874
 														<?php
875
-														// invoke OnRichTextEditorRegister event
876
-														$evtOut = $modx->invokeEvent("OnRichTextEditorRegister");
877
-														if(is_array($evtOut)) {
878
-															for($i = 0; $i < count($evtOut); $i++) {
879
-																$editor = $evtOut[$i];
880
-																echo "\t\t\t", '<option value="', $editor, '"', ($modx->config['which_editor'] == $editor ? ' selected="selected"' : ''), '>', $editor, "</option>\n";
881
-															}
882
-														}
883
-														?>
875
+                                                        // invoke OnRichTextEditorRegister event
876
+                                                        $evtOut = $modx->invokeEvent("OnRichTextEditorRegister");
877
+                                                        if(is_array($evtOut)) {
878
+                                                            for($i = 0; $i < count($evtOut); $i++) {
879
+                                                                $editor = $evtOut[$i];
880
+                                                                echo "\t\t\t", '<option value="', $editor, '"', ($modx->config['which_editor'] == $editor ? ' selected="selected"' : ''), '>', $editor, "</option>\n";
881
+                                                            }
882
+                                                        }
883
+                                                        ?>
884 884
 													</select>
885 885
 												</label>
886 886
 											</div>
887 887
 											<div id="content_body">
888 888
 												<?php
889
-												if(($content['richtext'] == 1 || $modx->getManagerApi()->action == '4') && $use_editor == 1) {
890
-													$htmlContent = $content['content'];
891
-													?>
889
+                                                if(($content['richtext'] == 1 || $modx->getManagerApi()->action == '4') && $use_editor == 1) {
890
+                                                    $htmlContent = $content['content'];
891
+                                                    ?>
892 892
 													<div class="section-editor clearfix">
893 893
 														<textarea id="ta" name="ta" onchange="documentDirty=true;"><?= $modx->getPhpCompat()->htmlspecialchars($htmlContent) ?></textarea>
894 894
 													</div>
895 895
 													<?php
896
-													// Richtext-[*content*]
897
-													$richtexteditorIds = array();
898
-													$richtexteditorOptions = array();
899
-													$richtexteditorIds[$modx->config['which_editor']][] = 'ta';
900
-													$richtexteditorOptions[$modx->config['which_editor']]['ta'] = '';
901
-												} else {
902
-													echo "\t" . '<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->getPhpCompat()->htmlspecialchars($content['content']), '</textarea></div>' . "\n";
903
-												}
904
-												?>
896
+                                                    // Richtext-[*content*]
897
+                                                    $richtexteditorIds = array();
898
+                                                    $richtexteditorOptions = array();
899
+                                                    $richtexteditorIds[$modx->config['which_editor']][] = 'ta';
900
+                                                    $richtexteditorOptions[$modx->config['which_editor']]['ta'] = '';
901
+                                                } else {
902
+                                                    echo "\t" . '<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->getPhpCompat()->htmlspecialchars($content['content']), '</textarea></div>' . "\n";
903
+                                                }
904
+                                                ?>
905 905
 											</div>
906 906
 										</td>
907 907
 									</tr>
@@ -1208,8 +1208,8 @@  discard block
 block discarded – undo
1208 1208
 
1209 1209
 								<?php
1210 1210
 
1211
-								if($_SESSION['mgrRole'] == 1 || $modx->getManagerApi()->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) {
1212
-									?>
1211
+                                if($_SESSION['mgrRole'] == 1 || $modx->getManagerApi()->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) {
1212
+                                    ?>
1213 1213
 									<tr>
1214 1214
 										<td>
1215 1215
 											<span class="warning"><?= $_lang['resource_type'] ?></span>
@@ -1231,15 +1231,15 @@  discard block
 block discarded – undo
1231 1231
 										<td>
1232 1232
 											<select name="contentType" class="inputBox" onchange="documentDirty=true;">
1233 1233
 												<?php
1234
-												if(!$content['contentType']) {
1235
-													$content['contentType'] = 'text/html';
1236
-												}
1237
-												$custom_contenttype = (isset ($custom_contenttype) ? $custom_contenttype : "text/html,text/plain,text/xml");
1238
-												$ct = explode(",", $custom_contenttype);
1239
-												for($i = 0; $i < count($ct); $i++) {
1240
-													echo "\t\t\t\t\t" . '<option value="' . $ct[$i] . '"' . ($content['contentType'] == $ct[$i] ? ' selected="selected"' : '') . '>' . $ct[$i] . "</option>\n";
1241
-												}
1242
-												?>
1234
+                                                if(!$content['contentType']) {
1235
+                                                    $content['contentType'] = 'text/html';
1236
+                                                }
1237
+                                                $custom_contenttype = (isset ($custom_contenttype) ? $custom_contenttype : "text/html,text/plain,text/xml");
1238
+                                                $ct = explode(",", $custom_contenttype);
1239
+                                                for($i = 0; $i < count($ct); $i++) {
1240
+                                                    echo "\t\t\t\t\t" . '<option value="' . $ct[$i] . '"' . ($content['contentType'] == $ct[$i] ? ' selected="selected"' : '') . '>' . $ct[$i] . "</option>\n";
1241
+                                                }
1242
+                                                ?>
1243 1243
 											</select>
1244 1244
 										</td>
1245 1245
 									</tr>
@@ -1262,23 +1262,23 @@  discard block
 block discarded – undo
1262 1262
 										</td>
1263 1263
 									</tr>
1264 1264
 									<?php
1265
-								} else {
1266
-									if($content['type'] != 'reference' && $modx->getManagerApi()->action != '72') {
1267
-										// non-admin managers creating or editing a document resource
1268
-										?>
1265
+                                } else {
1266
+                                    if($content['type'] != 'reference' && $modx->getManagerApi()->action != '72') {
1267
+                                        // non-admin managers creating or editing a document resource
1268
+                                        ?>
1269 1269
 										<input type="hidden" name="contentType" value="<?= (isset($content['contentType']) ? $content['contentType'] : "text/html") ?>" />
1270 1270
 										<input type="hidden" name="type" value="document" />
1271 1271
 										<input type="hidden" name="content_dispo" value="<?= (isset($content['content_dispo']) ? $content['content_dispo'] : '0') ?>" />
1272 1272
 										<?php
1273
-									} else {
1274
-										// non-admin managers creating or editing a reference (weblink) resource
1275
-										?>
1273
+                                    } else {
1274
+                                        // non-admin managers creating or editing a reference (weblink) resource
1275
+                                        ?>
1276 1276
 										<input type="hidden" name="type" value="reference" />
1277 1277
 										<input type="hidden" name="contentType" value="text/html" />
1278 1278
 										<?php
1279
-									}
1280
-								}//if mgrRole
1281
-								?>
1279
+                                    }
1280
+                                }//if mgrRole
1281
+                                ?>
1282 1282
 
1283 1283
 								<tr>
1284 1284
 									<td>
@@ -1361,112 +1361,112 @@  discard block
 block discarded – undo
1361 1361
                     ?>
1362 1362
 
1363 1363
 						<?php
1364
-					/*******************************
1364
+                    /*******************************
1365 1365
 					 * Document Access Permissions */
1366
-					if($use_udperms == 1) {
1367
-						$groupsarray = array();
1368
-						$sql = '';
1369
-
1370
-						$documentId = ($modx->getManagerApi()->action == '27' ? $id : (!empty($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']));
1371
-						if($documentId > 0) {
1372
-							// Load up, the permissions from the parent (if new document) or existing document
1373
-							$rs = $modx->getDatabase()->select('id, document_group', $tbl_document_groups, "document='{$documentId}'");
1374
-							while($currentgroup = $modx->getDatabase()->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id'];
1375
-
1376
-							// Load up the current permissions and names
1377
-							$vs = array(
1378
-								$tbl_document_group_names,
1379
-								$tbl_document_groups,
1380
-								$documentId
1381
-							);
1382
-							$from = vsprintf("%s AS dgn LEFT JOIN %s AS groups ON groups.document_group=dgn.id AND groups.document='%s'", $vs);
1383
-							$rs = $modx->getDatabase()->select('dgn.*, groups.id AS link_id', $from, '', 'name');
1384
-						} else {
1385
-							// Just load up the names, we're starting clean
1386
-							$rs = $modx->getDatabase()->select('*, NULL AS link_id', $tbl_document_group_names, '', 'name');
1387
-						}
1388
-
1389
-						// retain selected doc groups between post
1390
-						if(isset($_POST['docgroups'])) {
1391
-							$groupsarray = array_merge($groupsarray, $_POST['docgroups']);
1392
-						}
1366
+                    if($use_udperms == 1) {
1367
+                        $groupsarray = array();
1368
+                        $sql = '';
1369
+
1370
+                        $documentId = ($modx->getManagerApi()->action == '27' ? $id : (!empty($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']));
1371
+                        if($documentId > 0) {
1372
+                            // Load up, the permissions from the parent (if new document) or existing document
1373
+                            $rs = $modx->getDatabase()->select('id, document_group', $tbl_document_groups, "document='{$documentId}'");
1374
+                            while($currentgroup = $modx->getDatabase()->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id'];
1375
+
1376
+                            // Load up the current permissions and names
1377
+                            $vs = array(
1378
+                                $tbl_document_group_names,
1379
+                                $tbl_document_groups,
1380
+                                $documentId
1381
+                            );
1382
+                            $from = vsprintf("%s AS dgn LEFT JOIN %s AS groups ON groups.document_group=dgn.id AND groups.document='%s'", $vs);
1383
+                            $rs = $modx->getDatabase()->select('dgn.*, groups.id AS link_id', $from, '', 'name');
1384
+                        } else {
1385
+                            // Just load up the names, we're starting clean
1386
+                            $rs = $modx->getDatabase()->select('*, NULL AS link_id', $tbl_document_group_names, '', 'name');
1387
+                        }
1388
+
1389
+                        // retain selected doc groups between post
1390
+                        if(isset($_POST['docgroups'])) {
1391
+                            $groupsarray = array_merge($groupsarray, $_POST['docgroups']);
1392
+                        }
1393
+
1394
+                        $isManager = $modx->hasPermission('access_permissions');
1395
+                        $isWeb = $modx->hasPermission('web_access_permissions');
1396
+
1397
+                        // Setup Basic attributes for each Input box
1398
+                        $inputAttributes = array(
1399
+                            'type' => 'checkbox',
1400
+                            'class' => 'checkbox',
1401
+                            'name' => 'docgroups[]',
1402
+                            'onclick' => 'makePublic(false);',
1403
+                        );
1404
+                        $permissions = array(); // New Permissions array list (this contains the HTML)
1405
+                        $permissions_yes = 0; // count permissions the current mgr user has
1406
+                        $permissions_no = 0; // count permissions the current mgr user doesn't have
1407
+
1408
+                        // Loop through the permissions list
1409
+                        while($row = $modx->getDatabase()->getRow($rs)) {
1410
+
1411
+                            // Create an inputValue pair (group ID and group link (if it exists))
1412
+                            $inputValue = $row['id'] . ',' . ($row['link_id'] ? $row['link_id'] : 'new');
1413
+                            $inputId = 'group-' . $row['id'];
1414
+
1415
+                            $checked = in_array($inputValue, $groupsarray);
1416
+                            if($checked) {
1417
+                                $notPublic = true;
1418
+                            } // Mark as private access (either web or manager)
1419
+
1420
+                            // Skip the access permission if the user doesn't have access...
1421
+                            if((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) {
1422
+                                continue;
1423
+                            }
1393 1424
 
1394
-						$isManager = $modx->hasPermission('access_permissions');
1395
-						$isWeb = $modx->hasPermission('web_access_permissions');
1396
-
1397
-						// Setup Basic attributes for each Input box
1398
-						$inputAttributes = array(
1399
-							'type' => 'checkbox',
1400
-							'class' => 'checkbox',
1401
-							'name' => 'docgroups[]',
1402
-							'onclick' => 'makePublic(false);',
1403
-						);
1404
-						$permissions = array(); // New Permissions array list (this contains the HTML)
1405
-						$permissions_yes = 0; // count permissions the current mgr user has
1406
-						$permissions_no = 0; // count permissions the current mgr user doesn't have
1407
-
1408
-						// Loop through the permissions list
1409
-						while($row = $modx->getDatabase()->getRow($rs)) {
1410
-
1411
-							// Create an inputValue pair (group ID and group link (if it exists))
1412
-							$inputValue = $row['id'] . ',' . ($row['link_id'] ? $row['link_id'] : 'new');
1413
-							$inputId = 'group-' . $row['id'];
1414
-
1415
-							$checked = in_array($inputValue, $groupsarray);
1416
-							if($checked) {
1417
-								$notPublic = true;
1418
-							} // Mark as private access (either web or manager)
1419
-
1420
-							// Skip the access permission if the user doesn't have access...
1421
-							if((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) {
1422
-								continue;
1423
-							}
1424
-
1425
-							// Setup attributes for this Input box
1426
-							$inputAttributes['id'] = $inputId;
1427
-							$inputAttributes['value'] = $inputValue;
1428
-							if($checked) {
1429
-								$inputAttributes['checked'] = 'checked';
1430
-							} else {
1431
-								unset($inputAttributes['checked']);
1432
-							}
1433
-
1434
-							// Create attribute string list
1435
-							$inputString = array();
1436
-							foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"';
1437
-
1438
-							// Make the <input> HTML
1439
-							$inputHTML = '<input ' . implode(' ', $inputString) . ' />';
1440
-
1441
-							// does user have this permission?
1442
-							$from = "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg";
1443
-							$vs = array(
1444
-								$row['id'],
1445
-								$_SESSION['mgrInternalKey']
1446
-							);
1447
-							$where = vsprintf("mga.membergroup=mg.user_group AND mga.documentgroup=%s AND mg.member=%s", $vs);
1448
-							$rsp = $modx->getDatabase()->select('COUNT(mg.id)', $from, $where);
1449
-							$count = $modx->getDatabase()->getValue($rsp);
1450
-							if($count > 0) {
1451
-								++$permissions_yes;
1452
-							} else {
1453
-								++$permissions_no;
1454
-							}
1455
-							$permissions[] = "\t\t" . '<li>' . $inputHTML . '<label for="' . $inputId . '">' . $row['name'] . '</label></li>';
1456
-						}
1457
-						// if mgr user doesn't have access to any of the displayable permissions, forget about them and make doc public
1458
-						if($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) {
1459
-							$permissions = array();
1460
-						}
1425
+                            // Setup attributes for this Input box
1426
+                            $inputAttributes['id'] = $inputId;
1427
+                            $inputAttributes['value'] = $inputValue;
1428
+                            if($checked) {
1429
+                                $inputAttributes['checked'] = 'checked';
1430
+                            } else {
1431
+                                unset($inputAttributes['checked']);
1432
+                            }
1461 1433
 
1462
-						// See if the Access Permissions section is worth displaying...
1463
-						if(!empty($permissions)) {
1464
-							// Add the "All Document Groups" item if we have rights in both contexts
1465
-							if($isManager && $isWeb) {
1466
-								array_unshift($permissions, "\t\t" . '<li><input type="checkbox" class="checkbox" name="chkalldocs" id="groupall"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true);" /><label for="groupall" class="warning">' . $_lang['all_doc_groups'] . '</label></li>');
1467
-							}
1468
-							// Output the permissions list...
1469
-							?>
1434
+                            // Create attribute string list
1435
+                            $inputString = array();
1436
+                            foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"';
1437
+
1438
+                            // Make the <input> HTML
1439
+                            $inputHTML = '<input ' . implode(' ', $inputString) . ' />';
1440
+
1441
+                            // does user have this permission?
1442
+                            $from = "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg";
1443
+                            $vs = array(
1444
+                                $row['id'],
1445
+                                $_SESSION['mgrInternalKey']
1446
+                            );
1447
+                            $where = vsprintf("mga.membergroup=mg.user_group AND mga.documentgroup=%s AND mg.member=%s", $vs);
1448
+                            $rsp = $modx->getDatabase()->select('COUNT(mg.id)', $from, $where);
1449
+                            $count = $modx->getDatabase()->getValue($rsp);
1450
+                            if($count > 0) {
1451
+                                ++$permissions_yes;
1452
+                            } else {
1453
+                                ++$permissions_no;
1454
+                            }
1455
+                            $permissions[] = "\t\t" . '<li>' . $inputHTML . '<label for="' . $inputId . '">' . $row['name'] . '</label></li>';
1456
+                        }
1457
+                        // if mgr user doesn't have access to any of the displayable permissions, forget about them and make doc public
1458
+                        if($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) {
1459
+                            $permissions = array();
1460
+                        }
1461
+
1462
+                        // See if the Access Permissions section is worth displaying...
1463
+                        if(!empty($permissions)) {
1464
+                            // Add the "All Document Groups" item if we have rights in both contexts
1465
+                            if($isManager && $isWeb) {
1466
+                                array_unshift($permissions, "\t\t" . '<li><input type="checkbox" class="checkbox" name="chkalldocs" id="groupall"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true);" /><label for="groupall" class="warning">' . $_lang['all_doc_groups'] . '</label></li>');
1467
+                            }
1468
+                            // Output the permissions list...
1469
+                            ?>
1470 1470
 							<!-- Access Permissions -->
1471 1471
 							<div class="tab-page" id="tabAccess">
1472 1472
 								<h2 class="tab" id="tab_access_header"><?= $_lang['access_permissions'] ?></h2>
@@ -1500,31 +1500,31 @@  discard block
 block discarded – undo
1500 1500
 								</ul>
1501 1501
 							</div><!--div class="tab-page" id="tabAccess"-->
1502 1502
 							<?php
1503
-						} // !empty($permissions)
1504
-						elseif($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) {
1505
-							?>
1503
+                        } // !empty($permissions)
1504
+                        elseif($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) {
1505
+                            ?>
1506 1506
 							<p><?= $_lang["access_permissions_docs_collision"] ?></p>
1507 1507
 							<?php
1508 1508
 
1509
-						}
1510
-					}
1511
-					/* End Document Access Permissions *
1509
+                        }
1510
+                    }
1511
+                    /* End Document Access Permissions *
1512 1512
 					 ***********************************/
1513
-					?>
1513
+                    ?>
1514 1514
 
1515 1515
 					<input type="submit" name="save" style="display:none" />
1516 1516
 					<?php
1517 1517
 
1518
-					// invoke OnDocFormRender event
1519
-					$evtOut = $modx->invokeEvent('OnDocFormRender', array(
1520
-						'id' => $id,
1521
-						'template' => $content['template']
1522
-					));
1518
+                    // invoke OnDocFormRender event
1519
+                    $evtOut = $modx->invokeEvent('OnDocFormRender', array(
1520
+                        'id' => $id,
1521
+                        'template' => $content['template']
1522
+                    ));
1523 1523
 
1524
-					if(is_array($evtOut)) {
1525
-						echo implode('', $evtOut);
1526
-					}
1527
-					?>
1524
+                    if(is_array($evtOut)) {
1525
+                        echo implode('', $evtOut);
1526
+                    }
1527
+                    ?>
1528 1528
 				</div><!--div class="tab-pane" id="documentPane"-->
1529 1529
 			</div><!--div class="sectionBody"-->
1530 1530
 		</fieldset>
@@ -1535,17 +1535,17 @@  discard block
 block discarded – undo
1535 1535
 	</script>
1536 1536
 <?php
1537 1537
 if(($content['richtext'] == 1 || $modx->getManagerApi()->action == '4' || $modx->getManagerApi()->action == '72') && $use_editor == 1) {
1538
-	if(is_array($richtexteditorIds)) {
1539
-		foreach($richtexteditorIds as $editor => $elements) {
1540
-			// invoke OnRichTextEditorInit event
1541
-			$evtOut = $modx->invokeEvent('OnRichTextEditorInit', array(
1542
-				'editor' => $editor,
1543
-				'elements' => $elements,
1544
-				'options' => $richtexteditorOptions[$editor]
1545
-			));
1546
-			if(is_array($evtOut)) {
1547
-				echo implode('', $evtOut);
1548
-			}
1549
-		}
1550
-	}
1538
+    if(is_array($richtexteditorIds)) {
1539
+        foreach($richtexteditorIds as $editor => $elements) {
1540
+            // invoke OnRichTextEditorInit event
1541
+            $evtOut = $modx->invokeEvent('OnRichTextEditorInit', array(
1542
+                'editor' => $editor,
1543
+                'elements' => $elements,
1544
+                'options' => $richtexteditorOptions[$editor]
1545
+            ));
1546
+            if(is_array($evtOut)) {
1547
+                echo implode('', $evtOut);
1548
+            }
1549
+        }
1550
+    }
1551 1551
 }
Please login to merge, or discard this patch.
manager/actions/mutate_templates.dynamic.php 1 patch
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@  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
 
6 6
 switch($modx->getManagerApi()->action) {
7
-	case 16:
8
-		if(!$modx->hasPermission('edit_template')) {
9
-			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
10
-		}
11
-		break;
12
-	case 19:
13
-		if(!$modx->hasPermission('new_template')) {
14
-			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
15
-		}
16
-		break;
17
-	default:
18
-		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7
+    case 16:
8
+        if(!$modx->hasPermission('edit_template')) {
9
+            $modx->webAlertAndQuit($_lang["error_no_privileges"]);
10
+        }
11
+        break;
12
+    case 19:
13
+        if(!$modx->hasPermission('new_template')) {
14
+            $modx->webAlertAndQuit($_lang["error_no_privileges"]);
15
+        }
16
+        break;
17
+    default:
18
+        $modx->webAlertAndQuit($_lang["error_no_privileges"]);
19 19
 }
20 20
 
21 21
 $id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
 // check to see the snippet editor isn't locked
26 26
 if($lockedEl = $modx->elementIsLocked(1, $id)) {
27
-	$modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['template']));
27
+    $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['template']));
28 28
 }
29 29
 // end check for lock
30 30
 
@@ -33,23 +33,23 @@  discard block
 block discarded – undo
33 33
 
34 34
 $content = array();
35 35
 if(!empty($id)) {
36
-	$rs = $modx->getDatabase()->select('*', $tbl_site_templates, "id='{$id}'");
37
-	$content = $modx->getDatabase()->getRow($rs);
38
-	if(!$content) {
39
-		$modx->webAlertAndQuit("No database record has been found for this template.");
40
-	}
41
-
42
-	$_SESSION['itemname'] = $content['templatename'];
43
-	if($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) {
44
-		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
45
-	}
36
+    $rs = $modx->getDatabase()->select('*', $tbl_site_templates, "id='{$id}'");
37
+    $content = $modx->getDatabase()->getRow($rs);
38
+    if(!$content) {
39
+        $modx->webAlertAndQuit("No database record has been found for this template.");
40
+    }
41
+
42
+    $_SESSION['itemname'] = $content['templatename'];
43
+    if($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) {
44
+        $modx->webAlertAndQuit($_lang["error_no_privileges"]);
45
+    }
46 46
 } else {
47
-	$_SESSION['itemname'] = $_lang["new_template"];
48
-	$content['category'] = (int)$_REQUEST['catid'];
47
+    $_SESSION['itemname'] = $_lang["new_template"];
48
+    $content['category'] = (int)$_REQUEST['catid'];
49 49
 }
50 50
 
51 51
 if($modx->getManagerApi()->hasFormValues()) {
52
-	$modx->getManagerApi()->loadFormValues();
52
+    $modx->getManagerApi()->loadFormValues();
53 53
 }
54 54
 
55 55
 $content = array_merge($content, $_POST);
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
 
99 99
 <form name="mutate" method="post" action="index.php">
100 100
 	<?php
101
-	// invoke OnTempFormPrerender event
102
-	$evtOut = $modx->invokeEvent("OnTempFormPrerender", array("id" => $id));
103
-	if(is_array($evtOut)) {
104
-		echo implode("", $evtOut);
105
-	}
106
-	?>
101
+    // invoke OnTempFormPrerender event
102
+    $evtOut = $modx->invokeEvent("OnTempFormPrerender", array("id" => $id));
103
+    if(is_array($evtOut)) {
104
+        echo implode("", $evtOut);
105
+    }
106
+    ?>
107 107
 	<input type="hidden" name="a" value="20">
108 108
 	<input type="hidden" name="id" value="<?= $_REQUEST['id'] ?>">
109 109
 	<input type="hidden" name="mode" value="<?= $modx->getManagerApi()->action ?>">
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 						<label class="col-md-3 col-lg-2">
134 134
 							<?= $_lang['template_name'] ?>
135 135
 							<?php if($id == $modx->config['default_template']) {
136
-								echo '<small class="form-text text-danger">' . mb_strtolower(rtrim($_lang['defaulttemplate_title'], ':'), $modx_manager_charset) . '</small>';
137
-							} ?>
136
+                                echo '<small class="form-text text-danger">' . mb_strtolower(rtrim($_lang['defaulttemplate_title'], ':'), $modx_manager_charset) . '</small>';
137
+                            } ?>
138 138
 						</label>
139 139
 						<div class="col-md-9 col-lg-10">
140 140
 							<div class="form-control-name clearfix">
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
 							<select name="categoryid" class="form-control" onchange="documentDirty=true;">
163 163
 								<option>&nbsp;</option>
164 164
 								<?php
165
-								include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
166
-								foreach(getCategories() as $n => $v) {
167
-									echo "<option value='" . $v['id'] . "'" . ($content["category"] == $v["id"] ? " selected='selected'" : "") . ">" . $modx->getPhpCompat()->htmlspecialchars($v["category"]) . "</option>";
168
-								}
169
-								?>
165
+                                include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
166
+                                foreach(getCategories() as $n => $v) {
167
+                                    echo "<option value='" . $v['id'] . "'" . ($content["category"] == $v["id"] ? " selected='selected'" : "") . ">" . $modx->getPhpCompat()->htmlspecialchars($v["category"]) . "</option>";
168
+                                }
169
+                                ?>
170 170
 							</select>
171 171
 						</div>
172 172
 					</div>
@@ -197,38 +197,38 @@  discard block
 block discarded – undo
197 197
 			<input type="submit" name="save" style="display:none">
198 198
 
199 199
 			<?php
200
-			$selectedTvs = array();
201
-			if(!isset($_POST['assignedTv'])) {
202
-				$rs = $modx->getDatabase()->select(sprintf("tv.name AS tvname, tv.id AS tvid, tr.templateid AS templateid, tv.description AS tvdescription, tv.caption AS tvcaption, tv.locked AS tvlocked, if(isnull(cat.category),'%s',cat.category) AS category", $_lang['no_category']), sprintf("%s tv
200
+            $selectedTvs = array();
201
+            if(!isset($_POST['assignedTv'])) {
202
+                $rs = $modx->getDatabase()->select(sprintf("tv.name AS tvname, tv.id AS tvid, tr.templateid AS templateid, tv.description AS tvdescription, tv.caption AS tvcaption, tv.locked AS tvlocked, if(isnull(cat.category),'%s',cat.category) AS category", $_lang['no_category']), sprintf("%s tv
203 203
                 LEFT JOIN %s tr ON tv.id=tr.tmplvarid
204 204
                 LEFT JOIN %s cat ON tv.category=cat.id", $modx->getDatabase()->getFullTableName('site_tmplvars'), $modx->getDatabase()->getFullTableName('site_tmplvar_templates'), $modx->getDatabase()->getFullTableName('categories')), "templateid='{$id}'", "tr.rank DESC, tv.rank DESC, tvcaption DESC, tvid DESC"     // workaround for correct sort of none-existing ranks
205
-				);
206
-				while($row = $modx->getDatabase()->getRow($rs)) {
207
-					$selectedTvs[$row['tvid']] = $row;
208
-				}
209
-				$selectedTvs = array_reverse($selectedTvs, true);       // reverse ORDERBY DESC
210
-			}
211
-
212
-			$unselectedTvs = array();
213
-			$rs = $modx->getDatabase()->select(sprintf("tv.name AS tvname, tv.id AS tvid, tr.templateid AS templateid, tv.description AS tvdescription, tv.caption AS tvcaption, tv.locked AS tvlocked, if(isnull(cat.category),'%s',cat.category) AS category, cat.id as catid", $_lang['no_category']), sprintf("%s tv
205
+                );
206
+                while($row = $modx->getDatabase()->getRow($rs)) {
207
+                    $selectedTvs[$row['tvid']] = $row;
208
+                }
209
+                $selectedTvs = array_reverse($selectedTvs, true);       // reverse ORDERBY DESC
210
+            }
211
+
212
+            $unselectedTvs = array();
213
+            $rs = $modx->getDatabase()->select(sprintf("tv.name AS tvname, tv.id AS tvid, tr.templateid AS templateid, tv.description AS tvdescription, tv.caption AS tvcaption, tv.locked AS tvlocked, if(isnull(cat.category),'%s',cat.category) AS category, cat.id as catid", $_lang['no_category']), sprintf("%s tv
214 214
 	    LEFT JOIN %s tr ON tv.id=tr.tmplvarid
215 215
 	    LEFT JOIN %s cat ON tv.category=cat.id", $modx->getDatabase()->getFullTableName('site_tmplvars'), $modx->getDatabase()->getFullTableName('site_tmplvar_templates'), $modx->getDatabase()->getFullTableName('categories')), "", "category, tvcaption");
216
-			while($row = $modx->getDatabase()->getRow($rs)) {
217
-				$unselectedTvs[$row['tvid']] = $row;
218
-			}
219
-
220
-			// Catch checkboxes if form not validated
221
-			if(isset($_POST['assignedTv'])) {
222
-				$selectedTvs = array();
223
-				foreach($_POST['assignedTv'] as $tvid) {
224
-					if(isset($unselectedTvs[$tvid])) {
225
-						$selectedTvs[$tvid] = $unselectedTvs[$tvid];
226
-					}
227
-				};
228
-			}
229
-
230
-			$total = count($selectedTvs);
231
-			?>
216
+            while($row = $modx->getDatabase()->getRow($rs)) {
217
+                $unselectedTvs[$row['tvid']] = $row;
218
+            }
219
+
220
+            // Catch checkboxes if form not validated
221
+            if(isset($_POST['assignedTv'])) {
222
+                $selectedTvs = array();
223
+                foreach($_POST['assignedTv'] as $tvid) {
224
+                    if(isset($unselectedTvs[$tvid])) {
225
+                        $selectedTvs[$tvid] = $unselectedTvs[$tvid];
226
+                    }
227
+                };
228
+            }
229
+
230
+            $total = count($selectedTvs);
231
+            ?>
232 232
 		</div>
233 233
 
234 234
 		<div class="tab-page" id="tabAssignedTVs">
@@ -238,65 +238,65 @@  discard block
 block discarded – undo
238 238
 
239 239
 			<div class="container container-body">
240 240
 				<?php
241
-				if($total > 0) {
242
-					echo '<p>' . $_lang['template_tv_msg'] . '</p>';
243
-				}
244
-				if($modx->hasPermission('save_template') && $total > 1 && $id) {
245
-					echo sprintf('<div class="form-group"><a class="btn btn-primary" href="index.php?a=117&amp;id=%s">%s</a></div>', $id, $_lang['template_tv_edit']);
246
-				}
247
-
248
-				// Selected TVs
249
-				$tvList = '';
250
-				if($total > 0) {
251
-					$tvList .= '<ul>';
252
-					foreach($selectedTvs as $row) {
253
-						$desc = !empty($row['tvdescription']) ? '&nbsp;&nbsp;<small>(' . $row['tvdescription'] . ')</small>' : '';
254
-						$locked = $row['tvlocked'] ? ' <em>(' . $_lang['locked'] . ')</em>' : "";
255
-						$tvList .= sprintf('<li><label><input name="assignedTv[]" value="%s" type="checkbox" checked="checked" onchange="documentDirty=true;jQuery(\'#tvsDirty\').val(\'1\');"> %s <small>(%s)</small> - %s%s</label>%s <a href="index.php?id=%s&a=301&or=%s&oid=%s">%s</a></li>', $row['tvid'], $row['tvname'], $row['tvid'], $row['tvcaption'], $desc, $locked, $row['tvid'], $modx->getManagerApi()->action, $id, $_lang['edit']);
256
-					}
257
-					$tvList .= '</ul>';
258
-
259
-				} else {
260
-					echo $_lang['template_no_tv'];
261
-				}
262
-				echo $tvList;
263
-
264
-				// Unselected TVs
265
-				$tvList = '<hr/><p>' . $_lang['template_notassigned_tv'] . '</p><ul>';
266
-				$preCat = '';
267
-				$insideUl = 0;
268
-				while($row = array_shift($unselectedTvs)) {
269
-					if(isset($selectedTvs[$row['tvid']])) {
270
-						continue;
271
-					} // Skip selected
272
-					$row['category'] = stripslashes($row['category']); //pixelchutes
273
-					if($preCat !== $row['category']) {
274
-						$tvList .= $insideUl ? '</ul>' : '';
275
-						$tvList .= '<li><strong>' . $row['category'] . ($row['catid'] != '' ? ' <small>(' . $row['catid'] . ')</small>' : '') . '</strong><ul>';
276
-						$insideUl = 1;
277
-					}
278
-
279
-					$desc = !empty($row['tvdescription']) ? '&nbsp;&nbsp;<small>(' . $row['tvdescription'] . ')</small>' : '';
280
-					$locked = $row['tvlocked'] ? ' <em>(' . $_lang['locked'] . ')</em>' : "";
281
-					$tvList .= sprintf('<li><label><input name="assignedTv[]" value="%s" type="checkbox" onchange="documentDirty=true;jQuery(\'#tvsDirty\').val(\'1\');"> %s <small>(%s)</small> - %s%s</label>%s <a href="index.php?id=%s&a=301&or=%s&oid=%s">%s</a></li>', $row['tvid'], $row['tvname'], $row['tvid'], $row['tvcaption'], $desc, $locked, $row['tvid'], $modx->getManagerApi()->action, $id, $_lang['edit']);
282
-					$tvList .= '</li>';
283
-
284
-					$preCat = $row['category'];
285
-				}
286
-				$tvList .= $insideUl ? '</ul>' : '';
287
-				$tvList .= '</ul>';
288
-				echo $tvList;
289
-
290
-				?>
241
+                if($total > 0) {
242
+                    echo '<p>' . $_lang['template_tv_msg'] . '</p>';
243
+                }
244
+                if($modx->hasPermission('save_template') && $total > 1 && $id) {
245
+                    echo sprintf('<div class="form-group"><a class="btn btn-primary" href="index.php?a=117&amp;id=%s">%s</a></div>', $id, $_lang['template_tv_edit']);
246
+                }
247
+
248
+                // Selected TVs
249
+                $tvList = '';
250
+                if($total > 0) {
251
+                    $tvList .= '<ul>';
252
+                    foreach($selectedTvs as $row) {
253
+                        $desc = !empty($row['tvdescription']) ? '&nbsp;&nbsp;<small>(' . $row['tvdescription'] . ')</small>' : '';
254
+                        $locked = $row['tvlocked'] ? ' <em>(' . $_lang['locked'] . ')</em>' : "";
255
+                        $tvList .= sprintf('<li><label><input name="assignedTv[]" value="%s" type="checkbox" checked="checked" onchange="documentDirty=true;jQuery(\'#tvsDirty\').val(\'1\');"> %s <small>(%s)</small> - %s%s</label>%s <a href="index.php?id=%s&a=301&or=%s&oid=%s">%s</a></li>', $row['tvid'], $row['tvname'], $row['tvid'], $row['tvcaption'], $desc, $locked, $row['tvid'], $modx->getManagerApi()->action, $id, $_lang['edit']);
256
+                    }
257
+                    $tvList .= '</ul>';
258
+
259
+                } else {
260
+                    echo $_lang['template_no_tv'];
261
+                }
262
+                echo $tvList;
263
+
264
+                // Unselected TVs
265
+                $tvList = '<hr/><p>' . $_lang['template_notassigned_tv'] . '</p><ul>';
266
+                $preCat = '';
267
+                $insideUl = 0;
268
+                while($row = array_shift($unselectedTvs)) {
269
+                    if(isset($selectedTvs[$row['tvid']])) {
270
+                        continue;
271
+                    } // Skip selected
272
+                    $row['category'] = stripslashes($row['category']); //pixelchutes
273
+                    if($preCat !== $row['category']) {
274
+                        $tvList .= $insideUl ? '</ul>' : '';
275
+                        $tvList .= '<li><strong>' . $row['category'] . ($row['catid'] != '' ? ' <small>(' . $row['catid'] . ')</small>' : '') . '</strong><ul>';
276
+                        $insideUl = 1;
277
+                    }
278
+
279
+                    $desc = !empty($row['tvdescription']) ? '&nbsp;&nbsp;<small>(' . $row['tvdescription'] . ')</small>' : '';
280
+                    $locked = $row['tvlocked'] ? ' <em>(' . $_lang['locked'] . ')</em>' : "";
281
+                    $tvList .= sprintf('<li><label><input name="assignedTv[]" value="%s" type="checkbox" onchange="documentDirty=true;jQuery(\'#tvsDirty\').val(\'1\');"> %s <small>(%s)</small> - %s%s</label>%s <a href="index.php?id=%s&a=301&or=%s&oid=%s">%s</a></li>', $row['tvid'], $row['tvname'], $row['tvid'], $row['tvcaption'], $desc, $locked, $row['tvid'], $modx->getManagerApi()->action, $id, $_lang['edit']);
282
+                    $tvList .= '</li>';
283
+
284
+                    $preCat = $row['category'];
285
+                }
286
+                $tvList .= $insideUl ? '</ul>' : '';
287
+                $tvList .= '</ul>';
288
+                echo $tvList;
289
+
290
+                ?>
291 291
 			</div>
292 292
 		</div>
293 293
 
294 294
 		<?php
295
-		// invoke OnTempFormRender event
296
-		$evtOut = $modx->invokeEvent("OnTempFormRender", array("id" => $id));
297
-		if(is_array($evtOut)) {
298
-			echo implode("", $evtOut);
299
-		}
300
-		?>
295
+        // invoke OnTempFormRender event
296
+        $evtOut = $modx->invokeEvent("OnTempFormRender", array("id" => $id));
297
+        if(is_array($evtOut)) {
298
+            echo implode("", $evtOut);
299
+        }
300
+        ?>
301 301
 	</div>
302 302
 </form>
Please login to merge, or discard this patch.
manager/actions/mutate_user.dynamic.php 1 patch
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@  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
 
6 6
 switch($modx->getManagerApi()->action) {
7
-	case 12:
8
-		if(!$modx->hasPermission('edit_user')) {
9
-			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
10
-		}
11
-		break;
12
-	case 11:
13
-		if(!$modx->hasPermission('new_user')) {
14
-			$modx->webAlertAndQuit($_lang["error_no_privileges"]);
15
-		}
16
-		break;
17
-	default:
18
-		$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7
+    case 12:
8
+        if(!$modx->hasPermission('edit_user')) {
9
+            $modx->webAlertAndQuit($_lang["error_no_privileges"]);
10
+        }
11
+        break;
12
+    case 11:
13
+        if(!$modx->hasPermission('new_user')) {
14
+            $modx->webAlertAndQuit($_lang["error_no_privileges"]);
15
+        }
16
+        break;
17
+    default:
18
+        $modx->webAlertAndQuit($_lang["error_no_privileges"]);
19 19
 }
20 20
 
21 21
 $user = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
@@ -23,79 +23,79 @@  discard block
 block discarded – undo
23 23
 // check to see the snippet editor isn't locked
24 24
 $rs = $modx->getDatabase()->select('username', $modx->getDatabase()->getFullTableName('active_users'), "action=12 AND id='{$user}' AND internalKey!='" . $modx->getLoginUserID() . "'");
25 25
 if($username = $modx->getDatabase()->getValue($rs)) {
26
-	$modx->webAlertAndQuit(sprintf($_lang["lock_msg"], $username, "user"));
26
+    $modx->webAlertAndQuit(sprintf($_lang["lock_msg"], $username, "user"));
27 27
 }
28 28
 // end check for lock
29 29
 
30 30
 if($modx->getManagerApi()->action == '12') {
31
-	// get user attribute
32
-	$rs = $modx->getDatabase()->select('*', $modx->getDatabase()->getFullTableName('user_attributes'), "internalKey = '{$user}'");
33
-	$userdata = $modx->getDatabase()->getRow($rs);
34
-	if(!$userdata) {
35
-		$modx->webAlertAndQuit("No user returned!");
36
-	}
31
+    // get user attribute
32
+    $rs = $modx->getDatabase()->select('*', $modx->getDatabase()->getFullTableName('user_attributes'), "internalKey = '{$user}'");
33
+    $userdata = $modx->getDatabase()->getRow($rs);
34
+    if(!$userdata) {
35
+        $modx->webAlertAndQuit("No user returned!");
36
+    }
37 37
 
38 38
     if($_SESSION['mgrRole'] != 1 && $userdata['role'] == 1) {
39 39
         $modx->webAlertAndQuit('Illegal attempt to create/modify administrator by non-administrator!');
40 40
     }
41 41
 
42 42
 
43
-	// get user settings
44
-	$rs = $modx->getDatabase()->select('*', $modx->getDatabase()->getFullTableName('user_settings'), "user = '{$user}'");
45
-	$usersettings = array();
46
-	while($row = $modx->getDatabase()->getRow($rs)) $usersettings[$row['setting_name']] = $row['setting_value'];
47
-	// manually extract so that user display settings are not overwritten
48
-	foreach($usersettings as $k => $v) {
49
-		if($k != 'manager_language' && $k != 'manager_theme') {
50
-			${$k} = $v;
51
-		}
52
-	}
43
+    // get user settings
44
+    $rs = $modx->getDatabase()->select('*', $modx->getDatabase()->getFullTableName('user_settings'), "user = '{$user}'");
45
+    $usersettings = array();
46
+    while($row = $modx->getDatabase()->getRow($rs)) $usersettings[$row['setting_name']] = $row['setting_value'];
47
+    // manually extract so that user display settings are not overwritten
48
+    foreach($usersettings as $k => $v) {
49
+        if($k != 'manager_language' && $k != 'manager_theme') {
50
+            ${$k} = $v;
51
+        }
52
+    }
53 53
 
54
-	// get user name
55
-	$rs = $modx->getDatabase()->select('*', $modx->getDatabase()->getFullTableName('manager_users'), "id = '{$user}'");
56
-	$usernamedata = $modx->getDatabase()->getRow($rs);
57
-	if(!$usernamedata) {
58
-		$modx->webAlertAndQuit("No user returned while getting username!");
59
-	}
60
-	$_SESSION['itemname'] = $usernamedata['username'];
54
+    // get user name
55
+    $rs = $modx->getDatabase()->select('*', $modx->getDatabase()->getFullTableName('manager_users'), "id = '{$user}'");
56
+    $usernamedata = $modx->getDatabase()->getRow($rs);
57
+    if(!$usernamedata) {
58
+        $modx->webAlertAndQuit("No user returned while getting username!");
59
+    }
60
+    $_SESSION['itemname'] = $usernamedata['username'];
61 61
 } else {
62
-	$userdata = array();
63
-	$usersettings = array();
64
-	$usernamedata = array();
65
-	$_SESSION['itemname'] = $_lang["new_user"];
62
+    $userdata = array();
63
+    $usersettings = array();
64
+    $usernamedata = array();
65
+    $_SESSION['itemname'] = $_lang["new_user"];
66 66
 }
67 67
 
68 68
 // avoid doubling htmlspecialchars (already encoded in DB)
69 69
 foreach($userdata as $key => $val) {
70
-	$userdata[$key] = html_entity_decode($val, ENT_NOQUOTES, $modx->config['modx_charset']);
70
+    $userdata[$key] = html_entity_decode($val, ENT_NOQUOTES, $modx->config['modx_charset']);
71 71
 };
72 72
 $usernamedata['username'] = html_entity_decode($usernamedata['username'], ENT_NOQUOTES, $modx->config['modx_charset']);
73 73
 
74 74
 // restore saved form
75 75
 $formRestored = false;
76 76
 if($modx->getManagerApi()->hasFormValues()) {
77
-	$modx->getManagerApi()->loadFormValues();
78
-	// restore post values
79
-	$userdata = array_merge($userdata, $_POST);
80
-	$userdata['dob'] = $modx->toTimeStamp($userdata['dob']);
81
-	$usernamedata['username'] = $userdata['newusername'];
82
-	$usernamedata['oldusername'] = $_POST['oldusername'];
83
-	$usersettings = array_merge($usersettings, $userdata);
84
-	$usersettings['allowed_days'] = is_array($_POST['allowed_days']) ? implode(",", $_POST['allowed_days']) : "";
85
-	extract($usersettings, EXTR_OVERWRITE);
77
+    $modx->getManagerApi()->loadFormValues();
78
+    // restore post values
79
+    $userdata = array_merge($userdata, $_POST);
80
+    $userdata['dob'] = $modx->toTimeStamp($userdata['dob']);
81
+    $usernamedata['username'] = $userdata['newusername'];
82
+    $usernamedata['oldusername'] = $_POST['oldusername'];
83
+    $usersettings = array_merge($usersettings, $userdata);
84
+    $usersettings['allowed_days'] = is_array($_POST['allowed_days']) ? implode(",", $_POST['allowed_days']) : "";
85
+    extract($usersettings, EXTR_OVERWRITE);
86 86
 }
87 87
 
88 88
 // include the country list language file
89 89
 $_country_lang = array();
90 90
 include_once "lang/country/english_country.inc.php";
91 91
 if($manager_language != "english" && file_exists($modx->config['site_manager_path'] . "includes/lang/country/" . $manager_language . "_country.inc.php")) {
92
-	include_once "lang/country/" . $manager_language . "_country.inc.php";
92
+    include_once "lang/country/" . $manager_language . "_country.inc.php";
93 93
 }
94 94
 asort($_country_lang);
95 95
 
96 96
 $displayStyle = ($_SESSION['browser'] === 'modern') ? 'table-row' : 'block';
97 97
 if($which_browser == 'default') {
98
-	$which_browser = $modx->configGlobal['which_browser'] ? $modx->configGlobal['which_browser'] : $modx->config['which_browser'];
98
+    $which_browser = $modx->configGlobal['which_browser'] ? $modx->configGlobal['which_browser'] : $modx->config['which_browser'];
99 99
 }
100 100
 ?>
101 101
 <script type="text/javascript">
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
 <form action="index.php?a=32" method="post" name="userform">
206 206
 	<?php
207 207
 
208
-	// invoke OnUserFormPrerender event
209
-	$evtOut = $modx->invokeEvent("OnUserFormPrerender", array(
210
-		"id" => $user
211
-	));
212
-	if(is_array($evtOut)) {
213
-		echo implode("", $evtOut);
214
-	}
215
-	?>
208
+    // invoke OnUserFormPrerender event
209
+    $evtOut = $modx->invokeEvent("OnUserFormPrerender", array(
210
+        "id" => $user
211
+    ));
212
+    if(is_array($evtOut)) {
213
+        echo implode("", $evtOut);
214
+    }
215
+    ?>
216 216
 	<input type="hidden" name="mode" value="<?php echo $modx->getManagerApi()->action; ?>">
217 217
 	<input type="hidden" name="id" value="<?php echo $user ?>">
218 218
 	<input type="hidden" name="blockedmode" value="<?php echo ($userdata['blocked'] == 1 || ($userdata['blockeduntil'] > time() && $userdata['blockeduntil'] != 0) || ($userdata['blockedafter'] < time() && $userdata['blockedafter'] != 0) || $userdata['failedlogins'] > 3) ? "1" : "0" ?>" />
@@ -305,25 +305,25 @@  discard block
 block discarded – undo
305 305
 						<td>&nbsp;</td>
306 306
 						<td><?php
307 307
 
308
-							$rs = $modx->getDatabase()->select(
309
-							        'name, id',
308
+                            $rs = $modx->getDatabase()->select(
309
+                                    'name, id',
310 310
                                     $modx->getDatabase()->getFullTableName('user_roles'),
311 311
                                     ($modx->hasPermission('save_role')) ? '' : 'id != 1'
312 312
                             );
313
-							?>
313
+                            ?>
314 314
 							<select name="role" class="inputBox" onChange='documentDirty=true;' style="width:300px">
315 315
 								<?php
316
-								while($row = $modx->getDatabase()->getRow($rs)) {
317
-									if($modx->getManagerApi()->action == '11') {
318
-										$selectedtext = $row['id'] == '1' ? ' selected="selected"' : '';
319
-									} else {
320
-										$selectedtext = $row['id'] == $userdata['role'] ? "selected='selected'" : '';
321
-									}
322
-									?>
316
+                                while($row = $modx->getDatabase()->getRow($rs)) {
317
+                                    if($modx->getManagerApi()->action == '11') {
318
+                                        $selectedtext = $row['id'] == '1' ? ' selected="selected"' : '';
319
+                                    } else {
320
+                                        $selectedtext = $row['id'] == $userdata['role'] ? "selected='selected'" : '';
321
+                                    }
322
+                                    ?>
323 323
 									<option value="<?php echo $row['id']; ?>"<?php echo $selectedtext; ?>><?php echo $row['name']; ?></option>
324 324
 									<?php
325
-								}
326
-								?>
325
+                                }
326
+                                ?>
327 327
 							</select></td>
328 328
 					</tr>
329 329
 					<tr>
@@ -368,10 +368,10 @@  discard block
 block discarded – undo
368 368
 								<?php $chosenCountry = isset($_POST['country']) ? $_POST['country'] : $userdata['country']; ?>
369 369
 								<option value="" <?php (!isset($chosenCountry) ? ' selected' : '') ?> >&nbsp;</option>
370 370
 								<?php
371
-								foreach($_country_lang as $key => $country) {
372
-									echo "<option value=\"$key\"" . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . ">$country</option>";
373
-								}
374
-								?>
371
+                                foreach($_country_lang as $key => $country) {
372
+                                    echo "<option value=\"$key\"" . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . ">$country</option>";
373
+                                }
374
+                                ?>
375 375
 							</select></td>
376 376
 					</tr>
377 377
 					<tr>
@@ -447,21 +447,21 @@  discard block
 block discarded – undo
447 447
 						<td><select name="manager_language" class="inputBox" onChange="documentDirty=true">
448 448
 								<option value=""></option>
449 449
 								<?php
450
-								$activelang = !empty($usersettings['manager_language']) ? $usersettings['manager_language'] : '';
451
-								$dir = dir("includes/lang");
452
-								while($file = $dir->read()) {
453
-									if(strpos($file, ".inc.php") > 0) {
454
-										$endpos = strpos($file, ".");
455
-										$languagename = substr($file, 0, $endpos);
456
-										$selectedtext = $languagename == $activelang ? "selected='selected'" : "";
457
-										?>
450
+                                $activelang = !empty($usersettings['manager_language']) ? $usersettings['manager_language'] : '';
451
+                                $dir = dir("includes/lang");
452
+                                while($file = $dir->read()) {
453
+                                    if(strpos($file, ".inc.php") > 0) {
454
+                                        $endpos = strpos($file, ".");
455
+                                        $languagename = substr($file, 0, $endpos);
456
+                                        $selectedtext = $languagename == $activelang ? "selected='selected'" : "";
457
+                                        ?>
458 458
 										<option value="<?php echo $languagename; ?>" <?php echo $selectedtext; ?>><?php echo ucwords(str_replace("_", " ", $languagename)); ?></option>
459 459
 										<?php
460 460
 
461
-									}
462
-								}
463
-								$dir->close();
464
-								?>
461
+                                    }
462
+                                }
463
+                                $dir->close();
464
+                                ?>
465 465
 							</select></td>
466 466
 					</tr>
467 467
 					<tr>
@@ -536,22 +536,22 @@  discard block
 block discarded – undo
536 536
 						<td><select name="manager_theme" class="inputBox" onChange="documentDirty=true;document.userform.theme_refresher.value = Date.parse(new Date());">
537 537
 								<option value=""></option>
538 538
 								<?php
539
-								$dir = dir("media/style/");
540
-								while($file = $dir->read()) {
541
-									if($file != "." && $file != ".." && is_dir("media/style/$file") && substr($file, 0, 1) != '.') {
542
-										$themename = $file;
543
-										if($themename === 'common') {
544
-											continue;
545
-										}
546
-										$attr = 'value="' . $themename . '" ';
547
-										if(isset($usersettings['manager_theme']) && $themename == $usersettings['manager_theme']) {
548
-											$attr .= 'selected="selected" ';
549
-										}
550
-										echo "\t\t<option " . rtrim($attr) . '>' . ucwords(str_replace("_", " ", $themename)) . "</option>\n";
551
-									}
552
-								}
553
-								$dir->close();
554
-								?>
539
+                                $dir = dir("media/style/");
540
+                                while($file = $dir->read()) {
541
+                                    if($file != "." && $file != ".." && is_dir("media/style/$file") && substr($file, 0, 1) != '.') {
542
+                                        $themename = $file;
543
+                                        if($themename === 'common') {
544
+                                            continue;
545
+                                        }
546
+                                        $attr = 'value="' . $themename . '" ';
547
+                                        if(isset($usersettings['manager_theme']) && $themename == $usersettings['manager_theme']) {
548
+                                            $attr .= 'selected="selected" ';
549
+                                        }
550
+                                        echo "\t\t<option " . rtrim($attr) . '>' . ucwords(str_replace("_", " ", $themename)) . "</option>\n";
551
+                                    }
552
+                                }
553
+                                $dir->close();
554
+                                ?>
555 555
 							</select>
556 556
 							<input type="hidden" name="theme_refresher" value=""></td>
557 557
 					</tr>
@@ -587,15 +587,15 @@  discard block
 block discarded – undo
587 587
 						<th><?php echo $_lang["which_browser_title"] ?></th>
588 588
 						<td><select name="which_browser" class="inputBox" onChange="documentDirty=true;">
589 589
 								<?php
590
-								$selected = 'default' == $usersettings['which_browser'] || !$usersettings['which_browser'] ? ' selected="selected"' : '';
591
-								echo '<option value="default"' . $selected . '>' . $_lang['option_default'] . "</option>\n";
592
-								foreach(glob("media/browser/*", GLOB_ONLYDIR) as $dir) {
593
-									$dir = str_replace('\\', '/', $dir);
594
-									$browser_name = substr($dir, strrpos($dir, '/') + 1);
595
-									$selected = $browser_name == $usersettings['which_browser'] ? ' selected="selected"' : '';
596
-									echo '<option value="' . $browser_name . '"' . $selected . '>' . "{$browser_name}</option>\n";
597
-								}
598
-								?>
590
+                                $selected = 'default' == $usersettings['which_browser'] || !$usersettings['which_browser'] ? ' selected="selected"' : '';
591
+                                echo '<option value="default"' . $selected . '>' . $_lang['option_default'] . "</option>\n";
592
+                                foreach(glob("media/browser/*", GLOB_ONLYDIR) as $dir) {
593
+                                    $dir = str_replace('\\', '/', $dir);
594
+                                    $browser_name = substr($dir, strrpos($dir, '/') + 1);
595
+                                    $selected = $browser_name == $usersettings['which_browser'] ? ' selected="selected"' : '';
596
+                                    echo '<option value="' . $browser_name . '"' . $selected . '>' . "{$browser_name}</option>\n";
597
+                                }
598
+                                ?>
599 599
 							</select></td>
600 600
 					</tr>
601 601
 					<tr>
@@ -672,17 +672,17 @@  discard block
 block discarded – undo
672 672
 								<option value=""></option>
673 673
 								<?php
674 674
 
675
-								$edt = isset ($usersettings["which_editor"]) ? $usersettings["which_editor"] : '';
676
-								// invoke OnRichTextEditorRegister event
677
-								$evtOut = $modx->invokeEvent("OnRichTextEditorRegister");
678
-								echo "<option value='none'" . ($edt == 'none' ? " selected='selected'" : "") . ">" . $_lang["none"] . "</option>\n";
679
-								if(is_array($evtOut)) {
680
-									for($i = 0; $i < count($evtOut); $i++) {
681
-										$editor = $evtOut[$i];
682
-										echo "<option value='$editor'" . ($edt == $editor ? " selected='selected'" : "") . ">$editor</option>\n";
683
-									}
684
-								}
685
-								?>
675
+                                $edt = isset ($usersettings["which_editor"]) ? $usersettings["which_editor"] : '';
676
+                                // invoke OnRichTextEditorRegister event
677
+                                $evtOut = $modx->invokeEvent("OnRichTextEditorRegister");
678
+                                echo "<option value='none'" . ($edt == 'none' ? " selected='selected'" : "") . ">" . $_lang["none"] . "</option>\n";
679
+                                if(is_array($evtOut)) {
680
+                                    for($i = 0; $i < count($evtOut); $i++) {
681
+                                        $editor = $evtOut[$i];
682
+                                        echo "<option value='$editor'" . ($edt == $editor ? " selected='selected'" : "") . ">$editor</option>\n";
683
+                                    }
684
+                                }
685
+                                ?>
686 686
 							</select></td>
687 687
 					</tr>
688 688
 					<tr id='editorRow1' style="display: <?php echo $use_editor == 1 ? $displayStyle : 'none'; ?>">
@@ -715,12 +715,12 @@  discard block
 block discarded – undo
715 715
 					</tr>
716 716
 				</table>
717 717
 				<?php
718
-				// invoke OnInterfaceSettingsRender event
719
-				$evtOut = $modx->invokeEvent("OnInterfaceSettingsRender");
720
-				if(is_array($evtOut)) {
721
-					echo implode("", $evtOut);
722
-				}
723
-				?>
718
+                // invoke OnInterfaceSettingsRender event
719
+                $evtOut = $modx->invokeEvent("OnInterfaceSettingsRender");
720
+                if(is_array($evtOut)) {
721
+                    echo implode("", $evtOut);
722
+                }
723
+                ?>
724 724
 			</div>
725 725
 
726 726
 			<!-- Photo -->
@@ -769,39 +769,39 @@  discard block
 block discarded – undo
769 769
 			</div>
770 770
 			<?php if($use_udperms == 1) {
771 771
 
772
-			$groupsarray = array();
773
-
774
-			if($modx->getManagerApi()->action == '12') { // only do this bit if the user is being edited
775
-				$rs = $modx->getDatabase()->select('user_group', $modx->getDatabase()->getFullTableName('member_groups'), "member='{$user}'");
776
-				$groupsarray = $modx->getDatabase()->getColumn('user_group', $rs);
777
-			}
778
-			// retain selected doc groups between post
779
-			if(is_array($_POST['user_groups'])) {
780
-				foreach($_POST['user_groups'] as $n => $v) $groupsarray[] = $v;
781
-			}
782
-			?>
772
+            $groupsarray = array();
773
+
774
+            if($modx->getManagerApi()->action == '12') { // only do this bit if the user is being edited
775
+                $rs = $modx->getDatabase()->select('user_group', $modx->getDatabase()->getFullTableName('member_groups'), "member='{$user}'");
776
+                $groupsarray = $modx->getDatabase()->getColumn('user_group', $rs);
777
+            }
778
+            // retain selected doc groups between post
779
+            if(is_array($_POST['user_groups'])) {
780
+                foreach($_POST['user_groups'] as $n => $v) $groupsarray[] = $v;
781
+            }
782
+            ?>
783 783
 			<div class="tab-page" id="tabAccess">
784 784
 				<h2 class="tab"><?php echo $_lang["access_permissions"] ?></h2>
785 785
 				<script type="text/javascript">tpUser.addTabPage(document.getElementById("tabAccess"));</script>
786 786
 				<p><?php echo $_lang['access_permissions_user_message'] ?></p>
787 787
 				<?php
788
-				$rs = $modx->getDatabase()->select('name, id', $modx->getDatabase()->getFullTableName('membergroup_names'), '', 'name');
789
-				while($row = $modx->getDatabase()->getRow($rs)) {
790
-					echo "<label><input type='checkbox' name='user_groups[]' value='" . $row['id'] . "'" . (in_array($row['id'], $groupsarray) ? " checked='checked'" : "") . " />" . $row['name'] . "</label><br />";
791
-				}
792
-				}
793
-				?>
788
+                $rs = $modx->getDatabase()->select('name, id', $modx->getDatabase()->getFullTableName('membergroup_names'), '', 'name');
789
+                while($row = $modx->getDatabase()->getRow($rs)) {
790
+                    echo "<label><input type='checkbox' name='user_groups[]' value='" . $row['id'] . "'" . (in_array($row['id'], $groupsarray) ? " checked='checked'" : "") . " />" . $row['name'] . "</label><br />";
791
+                }
792
+                }
793
+                ?>
794 794
 			</div>
795 795
 		</div>
796 796
 	</div>
797 797
 	<input type="submit" name="save" style="display:none">
798 798
 	<?php
799
-	// invoke OnUserFormRender event
800
-	$evtOut = $modx->invokeEvent("OnUserFormRender", array(
801
-		"id" => $user
802
-	));
803
-	if(is_array($evtOut)) {
804
-		echo implode("", $evtOut);
805
-	}
806
-	?>
799
+    // invoke OnUserFormRender event
800
+    $evtOut = $modx->invokeEvent("OnUserFormRender", array(
801
+        "id" => $user
802
+    ));
803
+    if(is_array($evtOut)) {
804
+        echo implode("", $evtOut);
805
+    }
806
+    ?>
807 807
 </form>
Please login to merge, or discard this patch.
manager/actions/search.static.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -113,31 +113,31 @@
 block discarded – undo
113 113
     // Handle Input "Search in main fields"
114 114
     if ($searchfields != '') {
115 115
 
116
-		/*start search by TV. Added Rising13*/
117
-		$tbl_site_tmplvar_contentvalues = $modx->getDatabase()->getFullTableName('site_tmplvar_contentvalues');
118
-		$articul_query = "SELECT `contentid` FROM {$tbl_site_tmplvar_contentvalues} WHERE `value` LIKE '%{$searchfields}%'";
119
-		$articul_result = $modx->getDatabase()->query($articul_query);
120
-		$articul_id_array = $modx->getDatabase()->makeArray($articul_result);
121
-		if(count($articul_id_array)>0){
122
-			$articul_id = '';
123
-			$i = 1;
124
-			foreach( $articul_id_array as $articul ) {
125
-				$articul_id.=$articul['contentid'];
126
-				if($i !== count($articul_id_array)){
127
-					$articul_id.=',';
128
-				}
129
-				$i++;
130
-			}
131
-		$articul_id_query = " OR sc.id IN ({$articul_id})";
132
-		}else{
133
-			$articul_id_query = '';
134
-		}
135
-		/*end search by TV*/
116
+        /*start search by TV. Added Rising13*/
117
+        $tbl_site_tmplvar_contentvalues = $modx->getDatabase()->getFullTableName('site_tmplvar_contentvalues');
118
+        $articul_query = "SELECT `contentid` FROM {$tbl_site_tmplvar_contentvalues} WHERE `value` LIKE '%{$searchfields}%'";
119
+        $articul_result = $modx->getDatabase()->query($articul_query);
120
+        $articul_id_array = $modx->getDatabase()->makeArray($articul_result);
121
+        if(count($articul_id_array)>0){
122
+            $articul_id = '';
123
+            $i = 1;
124
+            foreach( $articul_id_array as $articul ) {
125
+                $articul_id.=$articul['contentid'];
126
+                if($i !== count($articul_id_array)){
127
+                    $articul_id.=',';
128
+                }
129
+                $i++;
130
+            }
131
+        $articul_id_query = " OR sc.id IN ({$articul_id})";
132
+        }else{
133
+            $articul_id_query = '';
134
+        }
135
+        /*end search by TV*/
136 136
 
137 137
         if (ctype_digit($searchfields)) {
138 138
             $sqladd .= "sc.id='{$searchfields}'";
139 139
             if (strlen($searchfields) > 3) {
140
-				$sqladd .= $articul_id_query;//search by TV
140
+                $sqladd .= $articul_id_query;//search by TV
141 141
                 $sqladd .= " OR sc.pagetitle LIKE '%{$searchfields}%'";
142 142
             }
143 143
         }
Please login to merge, or discard this patch.
manager/actions/user_management.static.php 1 patch
Indentation   +53 added lines, -53 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('edit_user')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 // initialize page view state - the $_PAGE object
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 
12 12
 // get and save search string
13 13
 if($_REQUEST['op'] == 'reset') {
14
-	$query = '';
15
-	$_PAGE['vs']['search'] = '';
14
+    $query = '';
15
+    $_PAGE['vs']['search'] = '';
16 16
 } else {
17
-	$query = isset($_REQUEST['search']) ? $_REQUEST['search'] : $_PAGE['vs']['search'];
18
-	$sqlQuery = $modx->getDatabase()->escape($query);
19
-	$_PAGE['vs']['search'] = $query;
17
+    $query = isset($_REQUEST['search']) ? $_REQUEST['search'] : $_PAGE['vs']['search'];
18
+    $sqlQuery = $modx->getDatabase()->escape($query);
19
+    $_PAGE['vs']['search'] = $query;
20 20
 }
21 21
 
22 22
 // get & save listmode
@@ -119,54 +119,54 @@  discard block
 block discarded – undo
119 119
 			<div class="row">
120 120
 				<div class="table-responsive">
121 121
 					<?php
122
-					$where = "";
123
-					if(!$modx->hasPermission('save_role')) {
124
-						$where .= (empty($where) ? "" : " AND ") . "mua.role != 1";
125
-					}
126
-					if(!empty($sqlQuery)) {
127
-						$where .= (empty($where) ? "" : " AND ") . "((mu.username LIKE '{$sqlQuery}%') OR (mua.fullname LIKE '%{$sqlQuery}%') OR (mua.email LIKE '{$sqlQuery}%'))";
128
-					}
129
-					$ds = $modx->getDatabase()->select("mu.id, mu.username, rname.name AS role, mua.fullname, mua.email, IF(mua.blocked,'{$_lang['yes']}','-') as blocked, mua.thislogin, mua.logincount", $modx->getDatabase()->getFullTableName('manager_users') . " AS mu 
122
+                    $where = "";
123
+                    if(!$modx->hasPermission('save_role')) {
124
+                        $where .= (empty($where) ? "" : " AND ") . "mua.role != 1";
125
+                    }
126
+                    if(!empty($sqlQuery)) {
127
+                        $where .= (empty($where) ? "" : " AND ") . "((mu.username LIKE '{$sqlQuery}%') OR (mua.fullname LIKE '%{$sqlQuery}%') OR (mua.email LIKE '{$sqlQuery}%'))";
128
+                    }
129
+                    $ds = $modx->getDatabase()->select("mu.id, mu.username, rname.name AS role, mua.fullname, mua.email, IF(mua.blocked,'{$_lang['yes']}','-') as blocked, mua.thislogin, mua.logincount", $modx->getDatabase()->getFullTableName('manager_users') . " AS mu 
130 130
 			INNER JOIN " . $modx->getDatabase()->getFullTableName('user_attributes') . " AS mua ON mua.internalKey=mu.id 
131 131
 			LEFT JOIN " . $modx->getDatabase()->getFullTableName('user_roles') . " AS rname ON mua.role=rname.id", $where, 'mua.blocked ASC, mua.thislogin DESC');
132
-					$grd = new \EvolutionCMS\Support\DataGrid('', $ds, $modx->config['number_of_results']); // set page size to 0 t show all items
133
-					$grd->noRecordMsg = $_lang["no_records_found"];
134
-					$grd->cssClass = "table data";
135
-					$grd->columnHeaderClass = "tableHeader";
136
-					$grd->itemClass = "tableItem";
137
-					$grd->altItemClass = "tableAltItem";
138
-					$grd->fields = "id,username,fullname,role,email,thislogin,logincount,blocked";
139
-					$grd->columns = implode(',', array(
140
-						$_lang["icon"],
141
-						$_lang["name"],
142
-						$_lang["user_full_name"],
143
-						$_lang['role'],
144
-						$_lang["email"],
145
-						$_lang["user_prevlogin"],
146
-						$_lang["user_logincount"],
147
-						$_lang["user_block"]
148
-					));
149
-					$grd->colWidths = "1%,,,,,1%,1%,1%";
150
-					$grd->colAligns = "center,,,,,right' nowrap='nowrap,right,center";
151
-					$grd->colTypes = implode('||', array(
152
-						'template:<a class="gridRowIcon" href="javascript:;" onclick="return showContentMenu([+id+],event);" title="' . $_lang['click_to_context'] . '"><i class="' . $_style['icons_user'] . '"></i></a>',
153
-						'template:<a href="index.php?a=12&id=[+id+]" title="' . $_lang['click_to_edit_title'] . '">[+value+]</a>',
154
-						'template:[+fullname+]',
155
-						'template:[+role+]',
156
-						'template:[+email+]',
157
-						'date: ' . $modx->toDateFormat('[+thislogin+]', 'formatOnly') . ' %H:%M',
158
-						'template:[+logincount+]',
159
-						'template:[+blocked+]'
160
-					));
161
-					if($listmode == '1') {
162
-						$grd->pageSize = 0;
163
-					}
164
-					if($_REQUEST['op'] == 'reset') {
165
-						$grd->pageNumber = 1;
166
-					}
167
-					// render grid
168
-					echo $grd->render();
169
-					?>
132
+                    $grd = new \EvolutionCMS\Support\DataGrid('', $ds, $modx->config['number_of_results']); // set page size to 0 t show all items
133
+                    $grd->noRecordMsg = $_lang["no_records_found"];
134
+                    $grd->cssClass = "table data";
135
+                    $grd->columnHeaderClass = "tableHeader";
136
+                    $grd->itemClass = "tableItem";
137
+                    $grd->altItemClass = "tableAltItem";
138
+                    $grd->fields = "id,username,fullname,role,email,thislogin,logincount,blocked";
139
+                    $grd->columns = implode(',', array(
140
+                        $_lang["icon"],
141
+                        $_lang["name"],
142
+                        $_lang["user_full_name"],
143
+                        $_lang['role'],
144
+                        $_lang["email"],
145
+                        $_lang["user_prevlogin"],
146
+                        $_lang["user_logincount"],
147
+                        $_lang["user_block"]
148
+                    ));
149
+                    $grd->colWidths = "1%,,,,,1%,1%,1%";
150
+                    $grd->colAligns = "center,,,,,right' nowrap='nowrap,right,center";
151
+                    $grd->colTypes = implode('||', array(
152
+                        'template:<a class="gridRowIcon" href="javascript:;" onclick="return showContentMenu([+id+],event);" title="' . $_lang['click_to_context'] . '"><i class="' . $_style['icons_user'] . '"></i></a>',
153
+                        'template:<a href="index.php?a=12&id=[+id+]" title="' . $_lang['click_to_edit_title'] . '">[+value+]</a>',
154
+                        'template:[+fullname+]',
155
+                        'template:[+role+]',
156
+                        'template:[+email+]',
157
+                        'date: ' . $modx->toDateFormat('[+thislogin+]', 'formatOnly') . ' %H:%M',
158
+                        'template:[+logincount+]',
159
+                        'template:[+blocked+]'
160
+                    ));
161
+                    if($listmode == '1') {
162
+                        $grd->pageSize = 0;
163
+                    }
164
+                    if($_REQUEST['op'] == 'reset') {
165
+                        $grd->pageNumber = 1;
166
+                    }
167
+                    // render grid
168
+                    echo $grd->render();
169
+                    ?>
170 170
 				</div>
171 171
 			</div>
172 172
 		</div>
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/core/uploader.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc Uploader 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 Uploader 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 uploader {
16 16
 
@@ -18,92 +18,92 @@  discard block
 block discarded – undo
18 18
     const VERSION = "2.54";
19 19
 
20 20
 /** Config session-overrided settings
21
-  * @var array */
21
+ * @var array */
22 22
     protected $config = array();
23 23
 
24 24
 /** Default image driver
25
-  * @var string */
25
+ * @var string */
26 26
     protected $imageDriver = "gd";
27 27
 
28 28
 /** Opener applocation properties
29
-  *   $opener['name']                 Got from $_GET['opener'];
30
-  *   $opener['CKEditor']['funcNum']  CKEditor function number (got from $_GET)
31
-  *   $opener['TinyMCE']              Boolean
32
-  * @var array */
29
+ *   $opener['name']                 Got from $_GET['opener'];
30
+ *   $opener['CKEditor']['funcNum']  CKEditor function number (got from $_GET)
31
+ *   $opener['TinyMCE']              Boolean
32
+ * @var array */
33 33
     protected $opener = array();
34 34
 
35 35
 /** Got from $_GET['type'] or first one $config['types'] array key, if inexistant
36
-  * @var string */
36
+ * @var string */
37 37
     protected $type;
38 38
 
39 39
 /** Helper property. Local filesystem path to the Type Directory
40
-  * Equivalent: $config['uploadDir'] . "/" . $type
41
-  * @var string */
40
+ * Equivalent: $config['uploadDir'] . "/" . $type
41
+ * @var string */
42 42
     protected $typeDir;
43 43
 
44 44
 /** Helper property. Web URL to the Type Directory
45
-  * Equivalent: $config['uploadURL'] . "/" . $type
46
-  * @var string */
45
+ * Equivalent: $config['uploadURL'] . "/" . $type
46
+ * @var string */
47 47
     protected $typeURL;
48 48
 
49 49
 /** Linked to $config['types']
50
-  * @var array */
50
+ * @var array */
51 51
     protected $types = array();
52 52
 
53 53
 /** Settings which can override default settings if exists as keys in $config['types'][$type] array
54
-  * @var array */
54
+ * @var array */
55 55
     protected $typeSettings = array('disabled', 'theme', 'dirPerms', 'filePerms', 'denyZipDownload', 'maxImageWidth', 'maxImageHeight', 'thumbWidth', 'thumbHeight', 'jpegQuality', 'access', 'filenameChangeChars', 'dirnameChangeChars', 'denyExtensionRename', 'deniedExts', 'watermark');
56 56
 
57 57
 /** Got from language file
58
-  * @var string */
58
+ * @var string */
59 59
     protected $charset;
60 60
 
61 61
 /** The language got from $_GET['lng'] or $_GET['lang'] or... Please see next property
62
-  * @var string */
62
+ * @var string */
63 63
     protected $lang = 'en';
64 64
 
65 65
 /** Possible language $_GET keys
66
-  * @var array */
66
+ * @var array */
67 67
     protected $langInputNames = array('lang', 'langCode', 'lng', 'language', 'lang_code');
68 68
 
69 69
 /** Uploaded file(s) info. Linked to first $_FILES element
70
-  * @var array */
70
+ * @var array */
71 71
     protected $file;
72 72
 
73 73
 /** Next three properties are got from the current language file
74
-  * @var string */
74
+ * @var string */
75 75
     protected $dateTimeFull;   // Currently not used
76 76
     protected $dateTimeMid;    // Currently not used
77 77
     protected $dateTimeSmall;
78 78
 
79 79
 /** Contain Specified language labels
80
-  * @var array */
80
+ * @var array */
81 81
     protected $labels = array();
82 82
 
83 83
 /** Contain unprocessed $_GET array. Please use this instead of $_GET
84
-  * @var array */
84
+ * @var array */
85 85
     protected $get;
86 86
 
87 87
 /** Contain unprocessed $_POST array. Please use this instead of $_POST
88
-  * @var array */
88
+ * @var array */
89 89
     protected $post;
90 90
 
91 91
 /** Contain unprocessed $_COOKIE array. Please use this instead of $_COOKIE
92
-  * @var array */
92
+ * @var array */
93 93
     protected $cookie;
94 94
 
95 95
 /** Session array. Please use this property instead of $_SESSION
96
-  * @var array */
96
+ * @var array */
97 97
     protected $session;
98 98
 
99 99
 /** CMS integration attribute (got from $_GET['cms'])
100
-  * @var string */
100
+ * @var string */
101 101
     protected $cms = "";
102 102
 
103 103
     protected $modx = null;
104 104
 /** Magic method which allows read-only access to protected or private class properties
105
-  * @param string $property
106
-  * @return mixed */
105
+     * @param string $property
106
+     * @return mixed */
107 107
     public function __get($property) {
108 108
         return property_exists($this, $property) ? $this->$property : null;
109 109
     }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         )
133 133
             $this->cms = $this->get['cms'];
134 134
 
135
-		// LINKING UPLOADED FILE
135
+        // LINKING UPLOADED FILE
136 136
         if (count($_FILES))
137 137
             $this->file = &$_FILES[key($_FILES)];
138 138
 
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
             $this->config['uploadDir'] = strlen($this->config['uploadDir'])
229 229
                 ? path::normalize($this->config['uploadDir'])
230 230
                 : path::url2fullPath("/$path");
231
-         $this->typeDir = "{$this->config['uploadDir']}/{$this->type}";
232
-         $this->typeURL = "{$this->config['siteURL']}/{$this->config['uploadURL']}/{$this->type}";
231
+            $this->typeDir = "{$this->config['uploadDir']}/{$this->type}";
232
+            $this->typeURL = "{$this->config['siteURL']}/{$this->config['uploadURL']}/{$this->type}";
233 233
 
234 234
         // SITE ROOT
235 235
         } elseif ($this->config['uploadURL'] == "/") {
@@ -365,36 +365,36 @@  discard block
 block discarded – undo
365 365
     }
366 366
 
367 367
 
368
-	protected function getTransaliasSettings() {
369
-		$modx = evolutionCMS();
370
-
371
-		// Cleaning uploaded filename?
372
-		$setting = $modx->getDatabase()->select('count(*)', $modx->getDatabase()->getFullTableName('system_settings'), 'setting_name="clean_uploaded_filename" AND setting_value=1');
373
-		if ($modx->getDatabase()->getValue($setting)>0) {
374
-			// Transalias plugin active?
375
-			$res = $modx->getDatabase()->select('properties', $modx->getDatabase()->getFullTableName('site_plugins'), 'name="TransAlias" AND disabled=0');
376
-			if ($properties = $modx->getDatabase()->getValue($res)) {
377
-				$properties = $modx->parseProperties($properties, 'TransAlias', 'plugin');
378
-			} else {
379
-				$properties = NULL;
380
-			}
381
-		} else {
382
-			$properties = NULL;
383
-		}
384
-		return $properties;
385
-	}
386
-
387
-
388
-	protected function normalizeFilename($filename) {
389
-		if ($this->getTransaliasSettings()) {
390
-        		$format = strrchr($filename, ".");
391
-        		$filename = str_replace($format, "", $filename);
392
-            		$filename = $this->modx->stripAlias($filename).$format;
393
-        	}
394
-        	return $filename;
395
-	}
396
-
397
-	protected function normalizeDirname($dirname) {
368
+    protected function getTransaliasSettings() {
369
+        $modx = evolutionCMS();
370
+
371
+        // Cleaning uploaded filename?
372
+        $setting = $modx->getDatabase()->select('count(*)', $modx->getDatabase()->getFullTableName('system_settings'), 'setting_name="clean_uploaded_filename" AND setting_value=1');
373
+        if ($modx->getDatabase()->getValue($setting)>0) {
374
+            // Transalias plugin active?
375
+            $res = $modx->getDatabase()->select('properties', $modx->getDatabase()->getFullTableName('site_plugins'), 'name="TransAlias" AND disabled=0');
376
+            if ($properties = $modx->getDatabase()->getValue($res)) {
377
+                $properties = $modx->parseProperties($properties, 'TransAlias', 'plugin');
378
+            } else {
379
+                $properties = NULL;
380
+            }
381
+        } else {
382
+            $properties = NULL;
383
+        }
384
+        return $properties;
385
+    }
386
+
387
+
388
+    protected function normalizeFilename($filename) {
389
+        if ($this->getTransaliasSettings()) {
390
+                $format = strrchr($filename, ".");
391
+                $filename = str_replace($format, "", $filename);
392
+                    $filename = $this->modx->stripAlias($filename).$format;
393
+            }
394
+            return $filename;
395
+    }
396
+
397
+    protected function normalizeDirname($dirname) {
398 398
         return $this->modx->stripAlias($dirname);
399 399
     }
400 400
 
@@ -472,10 +472,10 @@  discard block
 block discarded – undo
472 472
             return $this->label("The image is too big and/or cannot be resized.");
473 473
 
474 474
 
475
-	// CHECK FOR MODX MAX FILE SIZE
476
-	$actualfilesize=filesize($file['tmp_name']);
477
-	if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize'])
478
-	    return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)");
475
+    // CHECK FOR MODX MAX FILE SIZE
476
+    $actualfilesize=filesize($file['tmp_name']);
477
+    if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize'])
478
+        return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)");
479 479
 
480 480
         return true;
481 481
     }
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
             $top = isset($this->config['watermark']['top'])
628 628
                 ? $this->config['watermark']['top'] : false;
629 629
             $img->watermark($this->config['watermark']['file'], $left, $top);
630
-		}
630
+        }
631 631
 
632 632
         $options = array( 'file' => $file );
633 633
 
Please login to merge, or discard this patch.