Completed
Push — develop ( 614386...4063f2 )
by
unknown
15s
created
manager/includes/tmplvars.inc.php 1 patch
Indentation   +250 added lines, -250 removed lines patch added patch discarded remove patch
@@ -13,159 +13,159 @@  discard block
 block discarded – undo
13 13
  * @return string
14 14
  */
15 15
 function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()) {
16
-	global $modx;
17
-	global $_style;
18
-	global $_lang;
19
-	global $content;
20
-	global $which_browser;
16
+    global $modx;
17
+    global $_style;
18
+    global $_lang;
19
+    global $content;
20
+    global $which_browser;
21 21
 
22
-	if(substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) {
23
-		$eval_str = trim(substr($default_text, 7));
24
-		$default_text = eval($eval_str);
25
-		$field_value = $default_text;
26
-	}
22
+    if(substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) {
23
+        $eval_str = trim(substr($default_text, 7));
24
+        $default_text = eval($eval_str);
25
+        $field_value = $default_text;
26
+    }
27 27
 
28
-	$field_html = '';
29
-	$cimode = strpos($field_type, ':');
30
-	if($cimode === false) {
31
-		switch($field_type) {
28
+    $field_html = '';
29
+    $cimode = strpos($field_type, ':');
30
+    if($cimode === false) {
31
+        switch($field_type) {
32 32
 
33
-			case "text": // handler for regular text boxes
34
-			case "rawtext"; // non-htmlentity converted text boxes
35
-				$field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" />';
36
-				break;
37
-			case "email": // handles email input fields
38
-				$field_html .= '<input type="email" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%"/>';
39
-				break;
40
-			case "number": // handles the input of numbers
41
-				$field_html .= '<input type="number" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>';
42
-				break;
43
-			case "textareamini": // handler for textarea mini boxes
44
-				$field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>';
45
-				break;
46
-			case "textarea": // handler for textarea boxes
47
-			case "rawtextarea": // non-htmlentity convertex textarea boxes
48
-			case "htmlarea": // handler for textarea boxes (deprecated)
49
-			case "richtext": // handler for textarea boxes
50
-				$field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>';
51
-				break;
52
-			case "date":
53
-				$field_id = str_replace(array(
54
-					'-',
55
-					'.'
56
-				), '_', urldecode($field_id));
57
-				if($field_value == '') {
58
-					$field_value = 0;
59
-				}
60
-				$field_html .= '<input id="tv' . $field_id . '" name="tv' . $field_id . '" class="DatePicker" type="text" value="' . ($field_value == 0 || !isset($field_value) ? "" : $field_value) . '" onblur="documentDirty=true;" />';
61
-				$field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].value=\'\';document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="' . $_style["actions_calendar_delete"] . '"></i></a>';
33
+            case "text": // handler for regular text boxes
34
+            case "rawtext"; // non-htmlentity converted text boxes
35
+                $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" />';
36
+                break;
37
+            case "email": // handles email input fields
38
+                $field_html .= '<input type="email" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%"/>';
39
+                break;
40
+            case "number": // handles the input of numbers
41
+                $field_html .= '<input type="number" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>';
42
+                break;
43
+            case "textareamini": // handler for textarea mini boxes
44
+                $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>';
45
+                break;
46
+            case "textarea": // handler for textarea boxes
47
+            case "rawtextarea": // non-htmlentity convertex textarea boxes
48
+            case "htmlarea": // handler for textarea boxes (deprecated)
49
+            case "richtext": // handler for textarea boxes
50
+                $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>';
51
+                break;
52
+            case "date":
53
+                $field_id = str_replace(array(
54
+                    '-',
55
+                    '.'
56
+                ), '_', urldecode($field_id));
57
+                if($field_value == '') {
58
+                    $field_value = 0;
59
+                }
60
+                $field_html .= '<input id="tv' . $field_id . '" name="tv' . $field_id . '" class="DatePicker" type="text" value="' . ($field_value == 0 || !isset($field_value) ? "" : $field_value) . '" onblur="documentDirty=true;" />';
61
+                $field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].value=\'\';document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="' . $_style["actions_calendar_delete"] . '"></i></a>';
62 62
 
63
-				break;
64
-			case "dropdown": // handler for select boxes
65
-				$field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" size="1" onchange="documentDirty=true;">';
66
-				$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
67
-				while(list($item, $itemvalue) = each($index_list)) {
68
-					list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
69
-					if(strlen($itemvalue) == 0) {
70
-						$itemvalue = $item;
71
-					}
72
-					$field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
73
-				}
74
-				$field_html .= "</select>";
75
-				break;
76
-			case "listbox": // handler for select boxes
77
-				$field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" onchange="documentDirty=true;" size="8">';
78
-				$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
79
-				while(list($item, $itemvalue) = each($index_list)) {
80
-					list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
81
-					if(strlen($itemvalue) == 0) {
82
-						$itemvalue = $item;
83
-					}
84
-					$field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
85
-				}
86
-				$field_html .= "</select>";
87
-				break;
88
-			case "listbox-multiple": // handler for select boxes where you can choose multiple items
89
-				$field_value = explode("||", $field_value);
90
-				$field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '[]" multiple="multiple" onchange="documentDirty=true;" size="8">';
91
-				$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
92
-				while(list($item, $itemvalue) = each($index_list)) {
93
-					list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
94
-					if(strlen($itemvalue) == 0) {
95
-						$itemvalue = $item;
96
-					}
97
-					$field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . (in_array($itemvalue, $field_value) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
98
-				}
99
-				$field_html .= "</select>";
100
-				break;
101
-			case "url": // handles url input fields
102
-				$urls = array(
103
-					'' => '--',
104
-					'http://' => 'http://',
105
-					'https://' => 'https://',
106
-					'ftp://' => 'ftp://',
107
-					'mailto:' => 'mailto:'
108
-				);
109
-				$field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv' . $field_id . '_prefix" name="tv' . $field_id . '_prefix" onchange="documentDirty=true;">';
110
-				foreach($urls as $k => $v) {
111
-					if(strpos($field_value, $v) === false) {
112
-						$field_html .= '<option value="' . $v . '">' . $k . '</option>';
113
-					} else {
114
-						$field_value = str_replace($v, '', $field_value);
115
-						$field_html .= '<option value="' . $v . '" selected="selected">' . $k . '</option>';
116
-					}
117
-				}
118
-				$field_html .= '</select></td><td>';
119
-				$field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" width="100" ' . $field_style . ' onchange="documentDirty=true;" /></td></tr></table>';
120
-				break;
121
-			case 'checkbox': // handles check boxes
122
-				$values = !is_array($field_value) ? explode('||', $field_value) : $field_value;
123
-				$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
124
-				$tpl = '<label class="checkbox"><input type="checkbox" value="%s" id="tv_%s" name="tv%s[]" %s onchange="documentDirty=true;" />%s</label><br />';
125
-				static $i = 0;
126
-				$_ = array();
127
-				foreach($index_list as $c => $item) {
128
-					if(is_array($item)) {
129
-						$name = trim($item[0]);
130
-						$value = isset($item[1]) ? $item[1] : $name;
131
-					} else {
132
-						$item = trim($item);
133
-						list($name, $value) = (strpos($item, '==') !== false) ? explode('==', $item, 2) : array(
134
-							$item,
135
-							$item
136
-						);
137
-					}
138
-					$checked = in_array($value, $values) ? ' checked="checked"' : '';
139
-					$param = array(
140
-						$modx->htmlspecialchars($value),
141
-						$i,
142
-						$field_id,
143
-						$checked,
144
-						$name
145
-					);
146
-					$_[] = vsprintf($tpl, $param);
147
-					$i++;
148
-				}
149
-				$field_html = implode("\n", $_);
150
-				break;
151
-			case "option": // handles radio buttons
152
-				$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
153
-				static $i = 0;
154
-				while(list($item, $itemvalue) = each($index_list)) {
155
-					list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
156
-					if(strlen($itemvalue) == 0) {
157
-						$itemvalue = $item;
158
-					}
159
-					$field_html .= '<input type="radio" value="' . $modx->htmlspecialchars($itemvalue) . '" id="tv_' . $i . '" name="tv' . $field_id . '" ' . ($itemvalue == $field_value ? 'checked="checked"' : '') . ' onchange="documentDirty=true;" /><label for="tv_' . $i . '" class="radio">' . $item . '</label><br />';
160
-					$i++;
161
-				}
162
-				break;
163
-			case "image": // handles image fields using htmlarea image manager
164
-				global $_lang;
165
-				global $ResourceManagerLoaded;
166
-				global $content, $use_editor, $which_editor;
167
-				if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) {
168
-					$field_html .= "
63
+                break;
64
+            case "dropdown": // handler for select boxes
65
+                $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" size="1" onchange="documentDirty=true;">';
66
+                $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
67
+                while(list($item, $itemvalue) = each($index_list)) {
68
+                    list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
69
+                    if(strlen($itemvalue) == 0) {
70
+                        $itemvalue = $item;
71
+                    }
72
+                    $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
73
+                }
74
+                $field_html .= "</select>";
75
+                break;
76
+            case "listbox": // handler for select boxes
77
+                $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" onchange="documentDirty=true;" size="8">';
78
+                $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
79
+                while(list($item, $itemvalue) = each($index_list)) {
80
+                    list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
81
+                    if(strlen($itemvalue) == 0) {
82
+                        $itemvalue = $item;
83
+                    }
84
+                    $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
85
+                }
86
+                $field_html .= "</select>";
87
+                break;
88
+            case "listbox-multiple": // handler for select boxes where you can choose multiple items
89
+                $field_value = explode("||", $field_value);
90
+                $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '[]" multiple="multiple" onchange="documentDirty=true;" size="8">';
91
+                $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
92
+                while(list($item, $itemvalue) = each($index_list)) {
93
+                    list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
94
+                    if(strlen($itemvalue) == 0) {
95
+                        $itemvalue = $item;
96
+                    }
97
+                    $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . (in_array($itemvalue, $field_value) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
98
+                }
99
+                $field_html .= "</select>";
100
+                break;
101
+            case "url": // handles url input fields
102
+                $urls = array(
103
+                    '' => '--',
104
+                    'http://' => 'http://',
105
+                    'https://' => 'https://',
106
+                    'ftp://' => 'ftp://',
107
+                    'mailto:' => 'mailto:'
108
+                );
109
+                $field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv' . $field_id . '_prefix" name="tv' . $field_id . '_prefix" onchange="documentDirty=true;">';
110
+                foreach($urls as $k => $v) {
111
+                    if(strpos($field_value, $v) === false) {
112
+                        $field_html .= '<option value="' . $v . '">' . $k . '</option>';
113
+                    } else {
114
+                        $field_value = str_replace($v, '', $field_value);
115
+                        $field_html .= '<option value="' . $v . '" selected="selected">' . $k . '</option>';
116
+                    }
117
+                }
118
+                $field_html .= '</select></td><td>';
119
+                $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" width="100" ' . $field_style . ' onchange="documentDirty=true;" /></td></tr></table>';
120
+                break;
121
+            case 'checkbox': // handles check boxes
122
+                $values = !is_array($field_value) ? explode('||', $field_value) : $field_value;
123
+                $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
124
+                $tpl = '<label class="checkbox"><input type="checkbox" value="%s" id="tv_%s" name="tv%s[]" %s onchange="documentDirty=true;" />%s</label><br />';
125
+                static $i = 0;
126
+                $_ = array();
127
+                foreach($index_list as $c => $item) {
128
+                    if(is_array($item)) {
129
+                        $name = trim($item[0]);
130
+                        $value = isset($item[1]) ? $item[1] : $name;
131
+                    } else {
132
+                        $item = trim($item);
133
+                        list($name, $value) = (strpos($item, '==') !== false) ? explode('==', $item, 2) : array(
134
+                            $item,
135
+                            $item
136
+                        );
137
+                    }
138
+                    $checked = in_array($value, $values) ? ' checked="checked"' : '';
139
+                    $param = array(
140
+                        $modx->htmlspecialchars($value),
141
+                        $i,
142
+                        $field_id,
143
+                        $checked,
144
+                        $name
145
+                    );
146
+                    $_[] = vsprintf($tpl, $param);
147
+                    $i++;
148
+                }
149
+                $field_html = implode("\n", $_);
150
+                break;
151
+            case "option": // handles radio buttons
152
+                $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
153
+                static $i = 0;
154
+                while(list($item, $itemvalue) = each($index_list)) {
155
+                    list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
156
+                    if(strlen($itemvalue) == 0) {
157
+                        $itemvalue = $item;
158
+                    }
159
+                    $field_html .= '<input type="radio" value="' . $modx->htmlspecialchars($itemvalue) . '" id="tv_' . $i . '" name="tv' . $field_id . '" ' . ($itemvalue == $field_value ? 'checked="checked"' : '') . ' onchange="documentDirty=true;" /><label for="tv_' . $i . '" class="radio">' . $item . '</label><br />';
160
+                    $i++;
161
+                }
162
+                break;
163
+            case "image": // handles image fields using htmlarea image manager
164
+                global $_lang;
165
+                global $ResourceManagerLoaded;
166
+                global $content, $use_editor, $which_editor;
167
+                if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) {
168
+                    $field_html .= "
169 169
 						<script type=\"text/javascript\">
170 170
 							/* <![CDATA[ */
171 171
 								var lastImageCtrl;
@@ -224,18 +224,18 @@  discard block
 block discarded – undo
224 224
 								}
225 225
 							/* ]]> */
226 226
 						</script>";
227
-					$ResourceManagerLoaded = true;
228
-				}
229
-				$field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '"  value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseServer(\'tv' . $field_id . '\')" />';
230
-				break;
231
-			case "file": // handles the input of file uploads
232
-				/* Modified by Timon for use with resource browser */
233
-				global $_lang;
234
-				global $ResourceManagerLoaded;
235
-				global $content, $use_editor, $which_editor;
236
-				if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) {
237
-					/* I didn't understand the meaning of the condition above, so I left it untouched ;-) */
238
-					$field_html .= "
227
+                    $ResourceManagerLoaded = true;
228
+                }
229
+                $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '"  value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseServer(\'tv' . $field_id . '\')" />';
230
+                break;
231
+            case "file": // handles the input of file uploads
232
+                /* Modified by Timon for use with resource browser */
233
+                global $_lang;
234
+                global $ResourceManagerLoaded;
235
+                global $content, $use_editor, $which_editor;
236
+                if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) {
237
+                    /* I didn't understand the meaning of the condition above, so I left it untouched ;-) */
238
+                    $field_html .= "
239 239
 						<script type=\"text/javascript\">
240 240
 							/* <![CDATA[ */
241 241
 								var lastImageCtrl;
@@ -294,90 +294,90 @@  discard block
 block discarded – undo
294 294
 								}
295 295
 							/* ]]> */
296 296
 						</script>";
297
-					$ResourceManagerLoaded = true;
298
-				}
299
-				$field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '"  value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseFileServer(\'tv' . $field_id . '\')" />';
297
+                    $ResourceManagerLoaded = true;
298
+                }
299
+                $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '"  value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseFileServer(\'tv' . $field_id . '\')" />';
300 300
 
301
-				break;
301
+                break;
302 302
 
303
-			case 'custom_tv':
304
-				$custom_output = '';
305
-				/* If we are loading a file */
306
-				if(substr($field_elements, 0, 5) == "@FILE") {
307
-					$file_name = MODX_BASE_PATH . trim(substr($field_elements, 6));
308
-					if(!file_exists($file_name)) {
309
-						$custom_output = $file_name . ' does not exist';
310
-					} else {
311
-						$custom_output = file_get_contents($file_name);
312
-					}
313
-				} elseif(substr($field_elements, 0, 8) == '@INCLUDE') {
314
-					$file_name = MODX_BASE_PATH . trim(substr($field_elements, 9));
315
-					if(!file_exists($file_name)) {
316
-						$custom_output = $file_name . ' does not exist';
317
-					} else {
318
-						ob_start();
319
-						include $file_name;
320
-						$custom_output = ob_get_contents();
321
-						ob_end_clean();
322
-					}
323
-				} elseif(substr($field_elements, 0, 6) == "@CHUNK") {
324
-					$chunk_name = trim(substr($field_elements, 7));
325
-					$chunk_body = $modx->getChunk($chunk_name);
326
-					if($chunk_body == false) {
327
-						$custom_output = $_lang['chunk_no_exist'] . '(' . $_lang['htmlsnippet_name'] . ':' . $chunk_name . ')';
328
-					} else {
329
-						$custom_output = $chunk_body;
330
-					}
331
-				} elseif(substr($field_elements, 0, 5) == "@EVAL") {
332
-					$eval_str = trim(substr($field_elements, 6));
333
-					$custom_output = eval($eval_str);
334
-				} else {
335
-					$custom_output = $field_elements;
336
-				}
337
-				$replacements = array(
338
-					'[+field_type+]' => $field_type,
339
-					'[+field_id+]' => $field_id,
340
-					'[+default_text+]' => $default_text,
341
-					'[+field_value+]' => $modx->htmlspecialchars($field_value),
342
-					'[+field_style+]' => $field_style,
343
-				);
344
-				$custom_output = str_replace(array_keys($replacements), $replacements, $custom_output);
345
-				$modx->documentObject = $content;
346
-				$modx->documentIdentifier = $content['id'];
347
-				$custom_output = $modx->parseDocumentSource($custom_output);
348
-				$field_html .= $custom_output;
349
-				break;
303
+            case 'custom_tv':
304
+                $custom_output = '';
305
+                /* If we are loading a file */
306
+                if(substr($field_elements, 0, 5) == "@FILE") {
307
+                    $file_name = MODX_BASE_PATH . trim(substr($field_elements, 6));
308
+                    if(!file_exists($file_name)) {
309
+                        $custom_output = $file_name . ' does not exist';
310
+                    } else {
311
+                        $custom_output = file_get_contents($file_name);
312
+                    }
313
+                } elseif(substr($field_elements, 0, 8) == '@INCLUDE') {
314
+                    $file_name = MODX_BASE_PATH . trim(substr($field_elements, 9));
315
+                    if(!file_exists($file_name)) {
316
+                        $custom_output = $file_name . ' does not exist';
317
+                    } else {
318
+                        ob_start();
319
+                        include $file_name;
320
+                        $custom_output = ob_get_contents();
321
+                        ob_end_clean();
322
+                    }
323
+                } elseif(substr($field_elements, 0, 6) == "@CHUNK") {
324
+                    $chunk_name = trim(substr($field_elements, 7));
325
+                    $chunk_body = $modx->getChunk($chunk_name);
326
+                    if($chunk_body == false) {
327
+                        $custom_output = $_lang['chunk_no_exist'] . '(' . $_lang['htmlsnippet_name'] . ':' . $chunk_name . ')';
328
+                    } else {
329
+                        $custom_output = $chunk_body;
330
+                    }
331
+                } elseif(substr($field_elements, 0, 5) == "@EVAL") {
332
+                    $eval_str = trim(substr($field_elements, 6));
333
+                    $custom_output = eval($eval_str);
334
+                } else {
335
+                    $custom_output = $field_elements;
336
+                }
337
+                $replacements = array(
338
+                    '[+field_type+]' => $field_type,
339
+                    '[+field_id+]' => $field_id,
340
+                    '[+default_text+]' => $default_text,
341
+                    '[+field_value+]' => $modx->htmlspecialchars($field_value),
342
+                    '[+field_style+]' => $field_style,
343
+                );
344
+                $custom_output = str_replace(array_keys($replacements), $replacements, $custom_output);
345
+                $modx->documentObject = $content;
346
+                $modx->documentIdentifier = $content['id'];
347
+                $custom_output = $modx->parseDocumentSource($custom_output);
348
+                $field_html .= $custom_output;
349
+                break;
350 350
 
351
-			default: // the default handler -- for errors, mostly
352
-				$field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' onchange="documentDirty=true;" />';
351
+            default: // the default handler -- for errors, mostly
352
+                $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' onchange="documentDirty=true;" />';
353 353
 
354
-		} // end switch statement
355
-	} else {
356
-		$custom = explode(":", $field_type);
357
-		$custom_output = '';
358
-		$file_name = MODX_BASE_PATH . 'assets/tvs/' . $custom['1'] . '/' . $custom['1'] . '.customtv.php';
359
-		if(!file_exists($file_name)) {
360
-			$custom_output = $file_name . ' does not exist';
361
-		} else {
362
-			ob_start();
363
-			include $file_name;
364
-			$custom_output = ob_get_contents();
365
-			ob_end_clean();
366
-		}
367
-		$replacements = array(
368
-			'[+field_type+]' => $field_type,
369
-			'[+field_id+]' => $field_id,
370
-			'[+default_text+]' => $default_text,
371
-			'[+field_value+]' => $modx->htmlspecialchars($field_value),
372
-			'[+field_style+]' => $field_style,
373
-		);
374
-		$custom_output = str_replace(array_keys($replacements), $replacements, $custom_output);
375
-		$modx->documentObject = $content;
376
-		$custom_output = $modx->parseDocumentSource($custom_output);
377
-		$field_html .= $custom_output;
378
-	}
354
+        } // end switch statement
355
+    } else {
356
+        $custom = explode(":", $field_type);
357
+        $custom_output = '';
358
+        $file_name = MODX_BASE_PATH . 'assets/tvs/' . $custom['1'] . '/' . $custom['1'] . '.customtv.php';
359
+        if(!file_exists($file_name)) {
360
+            $custom_output = $file_name . ' does not exist';
361
+        } else {
362
+            ob_start();
363
+            include $file_name;
364
+            $custom_output = ob_get_contents();
365
+            ob_end_clean();
366
+        }
367
+        $replacements = array(
368
+            '[+field_type+]' => $field_type,
369
+            '[+field_id+]' => $field_id,
370
+            '[+default_text+]' => $default_text,
371
+            '[+field_value+]' => $modx->htmlspecialchars($field_value),
372
+            '[+field_style+]' => $field_style,
373
+        );
374
+        $custom_output = str_replace(array_keys($replacements), $replacements, $custom_output);
375
+        $modx->documentObject = $content;
376
+        $custom_output = $modx->parseDocumentSource($custom_output);
377
+        $field_html .= $custom_output;
378
+    }
379 379
 
380
-	return $field_html;
380
+    return $field_html;
381 381
 } // end renderFormElement function
382 382
 
383 383
 /**
@@ -385,14 +385,14 @@  discard block
 block discarded – undo
385 385
  * @return array
386 386
  */
387 387
 function ParseIntputOptions($v) {
388
-	global $modx;
389
-	$a = array();
390
-	if(is_array($v)) {
391
-		return $v;
392
-	} else if($modx->db->isResult($v)) {
393
-		while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols;
394
-	} else {
395
-		$a = explode("||", $v);
396
-	}
397
-	return $a;
388
+    global $modx;
389
+    $a = array();
390
+    if(is_array($v)) {
391
+        return $v;
392
+    } else if($modx->db->isResult($v)) {
393
+        while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols;
394
+    } else {
395
+        $a = explode("||", $v);
396
+    }
397
+    return $a;
398 398
 }
Please login to merge, or discard this patch.
install/cli-install.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
         echo $_lang['failed'] . ' ' . $_lang['table_prefix_not_exist'] . PHP_EOL;
340 340
         $errors++;
341 341
 
342
-  } else {
342
+    } else {
343 343
         echo $_lang['ok'] . PHP_EOL;
344
-  }
344
+    }
345 345
 }
346 346
 
347 347
 // check mysql version
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
                         $tRow = mysqli_fetch_assoc($ts);
1163 1163
                         $templateId = $tRow['id'];
1164 1164
                         mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)");
1165
-                   }
1165
+                    }
1166 1166
                 }
1167 1167
             }
1168 1168
         }
@@ -1527,9 +1527,9 @@  discard block
 block discarded – undo
1527 1527
 echo PHP_EOL . $_lang['installation_successful'] . PHP_EOL . PHP_EOL;
1528 1528
 //echo "<p>" . $_lang['to_log_into_content_manager'] . "</p>";
1529 1529
 if ($installMode == 0) {
1530
-   echo strip_tags($_lang['installation_note']) . PHP_EOL;
1530
+    echo strip_tags($_lang['installation_note']) . PHP_EOL;
1531 1531
 } else {
1532
-   echo strip_tags($_lang['upgrade_note']) . PHP_EOL;
1532
+    echo strip_tags($_lang['upgrade_note']) . PHP_EOL;
1533 1533
 }
1534 1534
 
1535 1535
 
Please login to merge, or discard this patch.
manager/processors/save_web_user.processor.php 1 patch
Indentation   +281 added lines, -281 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3
-	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3
+    die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('save_web_user')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $tbl_web_users = $modx->getFullTableName('web_users');
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 $input = $_POST;
14 14
 foreach($input as $k => $v) {
15
-	if($k !== 'comment') {
16
-		$v = sanitize($v);
17
-	}
18
-	$input[$k] = $v;
15
+    if($k !== 'comment') {
16
+        $v = sanitize($v);
17
+    }
18
+    $input[$k] = $v;
19 19
 }
20 20
 
21 21
 $id = (int)$input['id'];
@@ -51,82 +51,82 @@  discard block
 block discarded – undo
51 51
 
52 52
 // verify password
53 53
 if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
54
-	webAlertAndQuit("Password typed is mismatched");
54
+    webAlertAndQuit("Password typed is mismatched");
55 55
 }
56 56
 
57 57
 // verify email
58 58
 if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
59
-	webAlertAndQuit("E-mail address doesn't seem to be valid!");
59
+    webAlertAndQuit("E-mail address doesn't seem to be valid!");
60 60
 }
61 61
 
62 62
 switch($input['mode']) {
63
-	case '87' : // new user
64
-		// check if this user name already exist
65
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
-		$limit = $modx->db->getValue($rs);
67
-		if($limit > 0) {
68
-			webAlertAndQuit("User name is already in use!");
69
-		}
70
-
71
-		// check if the email address already exist
72
-		if ($modx->config['allow_multiple_emails'] != 1) {
73
-			$rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
74
-			$limit = $modx->db->getValue($rs);
75
-			if($limit > 0) {
76
-				webAlertAndQuit("Email is already in use!");
77
-			}
78
-		}
79
-
80
-		// generate a new password for this user
81
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
82
-			if(strlen($specifiedpassword) < 6) {
83
-				webAlertAndQuit("Password is too short!");
84
-			} else {
85
-				$newpassword = $specifiedpassword;
86
-			}
87
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
88
-			webAlertAndQuit("You didn't specify a password for this user!");
89
-		} elseif($passwordgenmethod == 'g') {
90
-			$newpassword = generate_password(8);
91
-		} else {
92
-			webAlertAndQuit("No password generation method specified!");
93
-		}
94
-
95
-		// invoke OnBeforeWUsrFormSave event
96
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
97
-			"mode" => "new",
98
-		));
99
-
100
-		// create the user account
101
-		$field = array();
102
-		$field['username'] = $esc_newusername;
103
-		$field['password'] = md5($newpassword);
104
-		$internalKey = $modx->db->insert($field, $tbl_web_users);
105
-
106
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
107
-		$field = $modx->db->escape($field);
108
-		$modx->db->insert($field, $tbl_web_user_attributes);
109
-
110
-		// Save User Settings
111
-		saveUserSettings($internalKey);
112
-
113
-		// Set the item name for logger
114
-		$_SESSION['itemname'] = $newusername;
115
-
116
-		/*******************************************************************************/
117
-		// put the user in the user_groups he/ she should be in
118
-		// first, check that up_perms are switched on!
119
-		if($use_udperms == 1) {
120
-			if(!empty($user_groups)) {
121
-				for($i = 0; $i < count($user_groups); $i++) {
122
-					$f = array();
123
-					$f['webgroup'] = (int)$user_groups[$i];
124
-					$f['webuser'] = $internalKey;
125
-					$modx->db->insert($f, $tbl_web_groups);
126
-				}
127
-			}
128
-		}
129
-		// end of user_groups stuff!
63
+    case '87' : // new user
64
+        // check if this user name already exist
65
+        $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
+        $limit = $modx->db->getValue($rs);
67
+        if($limit > 0) {
68
+            webAlertAndQuit("User name is already in use!");
69
+        }
70
+
71
+        // check if the email address already exist
72
+        if ($modx->config['allow_multiple_emails'] != 1) {
73
+            $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
74
+            $limit = $modx->db->getValue($rs);
75
+            if($limit > 0) {
76
+                webAlertAndQuit("Email is already in use!");
77
+            }
78
+        }
79
+
80
+        // generate a new password for this user
81
+        if($specifiedpassword != "" && $passwordgenmethod == "spec") {
82
+            if(strlen($specifiedpassword) < 6) {
83
+                webAlertAndQuit("Password is too short!");
84
+            } else {
85
+                $newpassword = $specifiedpassword;
86
+            }
87
+        } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
88
+            webAlertAndQuit("You didn't specify a password for this user!");
89
+        } elseif($passwordgenmethod == 'g') {
90
+            $newpassword = generate_password(8);
91
+        } else {
92
+            webAlertAndQuit("No password generation method specified!");
93
+        }
94
+
95
+        // invoke OnBeforeWUsrFormSave event
96
+        $modx->invokeEvent("OnBeforeWUsrFormSave", array(
97
+            "mode" => "new",
98
+        ));
99
+
100
+        // create the user account
101
+        $field = array();
102
+        $field['username'] = $esc_newusername;
103
+        $field['password'] = md5($newpassword);
104
+        $internalKey = $modx->db->insert($field, $tbl_web_users);
105
+
106
+        $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
107
+        $field = $modx->db->escape($field);
108
+        $modx->db->insert($field, $tbl_web_user_attributes);
109
+
110
+        // Save User Settings
111
+        saveUserSettings($internalKey);
112
+
113
+        // Set the item name for logger
114
+        $_SESSION['itemname'] = $newusername;
115
+
116
+        /*******************************************************************************/
117
+        // put the user in the user_groups he/ she should be in
118
+        // first, check that up_perms are switched on!
119
+        if($use_udperms == 1) {
120
+            if(!empty($user_groups)) {
121
+                for($i = 0; $i < count($user_groups); $i++) {
122
+                    $f = array();
123
+                    $f['webgroup'] = (int)$user_groups[$i];
124
+                    $f['webuser'] = $internalKey;
125
+                    $modx->db->insert($f, $tbl_web_groups);
126
+                }
127
+            }
128
+        }
129
+        // end of user_groups stuff!
130 130
 
131 131
         // invoke OnWebSaveUser event
132 132
         $modx->invokeEvent("OnWebSaveUser", array(
@@ -144,26 +144,26 @@  discard block
 block discarded – undo
144 144
             "id" => $internalKey
145 145
         ));
146 146
 
147
-		if($passwordnotifymethod == 'e') {
148
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
149
-			if($input['stay'] != '') {
150
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
151
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
152
-				header($header);
153
-			} else {
154
-				$header = "Location: index.php?a=99&r=2";
155
-				header($header);
156
-			}
157
-		} else {
158
-			if($input['stay'] != '') {
159
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
160
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
161
-			} else {
162
-				$stayUrl = "index.php?a=99&r=2";
163
-			}
164
-
165
-			include_once "header.inc.php";
166
-			?>
147
+        if($passwordnotifymethod == 'e') {
148
+            sendMailMessage($email, $newusername, $newpassword, $fullname);
149
+            if($input['stay'] != '') {
150
+                $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
151
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
152
+                header($header);
153
+            } else {
154
+                $header = "Location: index.php?a=99&r=2";
155
+                header($header);
156
+            }
157
+        } else {
158
+            if($input['stay'] != '') {
159
+                $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
160
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
161
+            } else {
162
+                $stayUrl = "index.php?a=99&r=2";
163
+            }
164
+
165
+            include_once "header.inc.php";
166
+            ?>
167 167
 
168 168
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
169 169
 
@@ -185,86 +185,86 @@  discard block
 block discarded – undo
185 185
 			</div>
186 186
 			<?php
187 187
 
188
-			include_once "footer.inc.php";
189
-		}
190
-		break;
191
-	case '88' : // edit user
192
-		// generate a new password for this user
193
-		if($genpassword == 1) {
194
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
195
-				if(strlen($specifiedpassword) < 6) {
196
-					webAlertAndQuit("Password is too short!");
197
-				} else {
198
-					$newpassword = $specifiedpassword;
199
-				}
200
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
201
-				webAlertAndQuit("You didn't specify a password for this user!");
202
-			} elseif($passwordgenmethod == 'g') {
203
-				$newpassword = generate_password(8);
204
-			} else {
205
-				webAlertAndQuit("No password generation method specified!");
206
-			}
207
-		}
208
-		if($passwordnotifymethod == 'e') {
209
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
210
-		}
211
-
212
-		// check if the username already exist
213
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
214
-		$limit = $modx->db->getValue($rs);
215
-		if($limit > 0) {
216
-			webAlertAndQuit("User name is already in use!");
217
-		}
218
-
219
-		// check if the email address already exists
220
-		if ($modx->config['allow_multiple_emails'] != 1) {
221
-			$rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
222
-			$limit = $modx->db->getValue($rs);
223
-			if($limit > 0) {
224
-				webAlertAndQuit("Email is already in use!");
225
-			}
226
-		}
227
-
228
-		// invoke OnBeforeWUsrFormSave event
229
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
230
-			"mode" => "upd",
231
-			"id" => $id
232
-		));
233
-
234
-		// update user name and password
235
-		$field = array();
236
-		$field['username'] = $esc_newusername;
237
-		if($genpassword == 1) {
238
-			$field['password'] = md5($newpassword);
239
-		}
240
-		$modx->db->update($field, $tbl_web_users, "id='{$id}'");
241
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
242
-		$field = $modx->db->escape($field);
243
-		$modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
244
-
245
-		// Save User Settings
246
-		saveUserSettings($id);
247
-
248
-		// Set the item name for logger
249
-		$_SESSION['itemname'] = $newusername;
250
-
251
-		/*******************************************************************************/
252
-		// put the user in the user_groups he/ she should be in
253
-		// first, check that up_perms are switched on!
254
-		if($use_udperms == 1) {
255
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
256
-			$modx->db->delete($tbl_web_groups, "webuser='{$id}'");
257
-			if(!empty($user_groups)) {
258
-				for($i = 0; $i < count($user_groups); $i++) {
259
-					$field = array();
260
-					$field['webgroup'] = (int)$user_groups[$i];
261
-					$field['webuser'] = $id;
262
-					$modx->db->insert($field, $tbl_web_groups);
263
-				}
264
-			}
265
-		}
266
-		// end of user_groups stuff!
267
-		/*******************************************************************************/
188
+            include_once "footer.inc.php";
189
+        }
190
+        break;
191
+    case '88' : // edit user
192
+        // generate a new password for this user
193
+        if($genpassword == 1) {
194
+            if($specifiedpassword != "" && $passwordgenmethod == "spec") {
195
+                if(strlen($specifiedpassword) < 6) {
196
+                    webAlertAndQuit("Password is too short!");
197
+                } else {
198
+                    $newpassword = $specifiedpassword;
199
+                }
200
+            } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
201
+                webAlertAndQuit("You didn't specify a password for this user!");
202
+            } elseif($passwordgenmethod == 'g') {
203
+                $newpassword = generate_password(8);
204
+            } else {
205
+                webAlertAndQuit("No password generation method specified!");
206
+            }
207
+        }
208
+        if($passwordnotifymethod == 'e') {
209
+            sendMailMessage($email, $newusername, $newpassword, $fullname);
210
+        }
211
+
212
+        // check if the username already exist
213
+        $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
214
+        $limit = $modx->db->getValue($rs);
215
+        if($limit > 0) {
216
+            webAlertAndQuit("User name is already in use!");
217
+        }
218
+
219
+        // check if the email address already exists
220
+        if ($modx->config['allow_multiple_emails'] != 1) {
221
+            $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
222
+            $limit = $modx->db->getValue($rs);
223
+            if($limit > 0) {
224
+                webAlertAndQuit("Email is already in use!");
225
+            }
226
+        }
227
+
228
+        // invoke OnBeforeWUsrFormSave event
229
+        $modx->invokeEvent("OnBeforeWUsrFormSave", array(
230
+            "mode" => "upd",
231
+            "id" => $id
232
+        ));
233
+
234
+        // update user name and password
235
+        $field = array();
236
+        $field['username'] = $esc_newusername;
237
+        if($genpassword == 1) {
238
+            $field['password'] = md5($newpassword);
239
+        }
240
+        $modx->db->update($field, $tbl_web_users, "id='{$id}'");
241
+        $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
242
+        $field = $modx->db->escape($field);
243
+        $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
244
+
245
+        // Save User Settings
246
+        saveUserSettings($id);
247
+
248
+        // Set the item name for logger
249
+        $_SESSION['itemname'] = $newusername;
250
+
251
+        /*******************************************************************************/
252
+        // put the user in the user_groups he/ she should be in
253
+        // first, check that up_perms are switched on!
254
+        if($use_udperms == 1) {
255
+            // as this is an existing user, delete his/ her entries in the groups before saving the new groups
256
+            $modx->db->delete($tbl_web_groups, "webuser='{$id}'");
257
+            if(!empty($user_groups)) {
258
+                for($i = 0; $i < count($user_groups); $i++) {
259
+                    $field = array();
260
+                    $field['webgroup'] = (int)$user_groups[$i];
261
+                    $field['webuser'] = $id;
262
+                    $modx->db->insert($field, $tbl_web_groups);
263
+                }
264
+            }
265
+        }
266
+        // end of user_groups stuff!
267
+        /*******************************************************************************/
268 268
 
269 269
         // invoke OnWebSaveUser event
270 270
         $modx->invokeEvent("OnWebSaveUser", array(
@@ -293,16 +293,16 @@  discard block
 block discarded – undo
293 293
             "id" => $id
294 294
         ));
295 295
 
296
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
297
-			if($input['stay'] != '') {
298
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
299
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
300
-			} else {
301
-				$stayUrl = "index.php?a=99&r=2";
302
-			}
296
+        if($genpassword == 1 && $passwordnotifymethod == 's') {
297
+            if($input['stay'] != '') {
298
+                $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
299
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
300
+            } else {
301
+                $stayUrl = "index.php?a=99&r=2";
302
+            }
303 303
 
304
-			include_once "header.inc.php";
305
-			?>
304
+            include_once "header.inc.php";
305
+            ?>
306 306
 
307 307
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
308 308
 
@@ -322,20 +322,20 @@  discard block
 block discarded – undo
322 322
 			</div>
323 323
 			<?php
324 324
 
325
-			include_once "footer.inc.php";
326
-		} else {
327
-			if($input['stay'] != '') {
328
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
329
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
330
-				header($header);
331
-			} else {
332
-				$header = "Location: index.php?a=99&r=2";
333
-				header($header);
334
-			}
335
-		}
336
-		break;
337
-	default :
338
-		webAlertAndQuit("No operation set in request.");
325
+            include_once "footer.inc.php";
326
+        } else {
327
+            if($input['stay'] != '') {
328
+                $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
329
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
330
+                header($header);
331
+            } else {
332
+                $header = "Location: index.php?a=99&r=2";
333
+                header($header);
334
+            }
335
+        }
336
+        break;
337
+    default :
338
+        webAlertAndQuit("No operation set in request.");
339 339
 }
340 340
 
341 341
 /**
@@ -345,14 +345,14 @@  discard block
 block discarded – undo
345 345
  * @return string
346 346
  */
347 347
 function save_user_quoted_printable($string) {
348
-	$crlf = "\n";
349
-	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
350
-	$f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
351
-	$r[] = "'=' . sprintf('%02X', ord('\\1'))";
352
-	$f[] = '/([\011\040])' . $crlf . '/e';
353
-	$r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'";
354
-	$string = preg_replace($f, $r, $string);
355
-	return trim(wordwrap($string, 70, ' =' . $crlf));
348
+    $crlf = "\n";
349
+    $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
350
+    $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
351
+    $r[] = "'=' . sprintf('%02X', ord('\\1'))";
352
+    $f[] = '/([\011\040])' . $crlf . '/e';
353
+    $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'";
354
+    $string = preg_replace($f, $r, $string);
355
+    return trim(wordwrap($string, 70, ' =' . $crlf));
356 356
 }
357 357
 
358 358
 /**
@@ -364,94 +364,94 @@  discard block
 block discarded – undo
364 364
  * @param string $ufn
365 365
  */
366 366
 function sendMailMessage($email, $uid, $pwd, $ufn) {
367
-	global $modx, $_lang, $websignupemail_message;
368
-	global $emailsubject, $emailsender;
369
-	global $site_name, $site_url;
370
-	$message = sprintf($websignupemail_message, $uid, $pwd); // use old method
371
-	// replace placeholders
372
-	$message = str_replace("[+uid+]", $uid, $message);
373
-	$message = str_replace("[+pwd+]", $pwd, $message);
374
-	$message = str_replace("[+ufn+]", $ufn, $message);
375
-	$message = str_replace("[+sname+]", $site_name, $message);
376
-	$message = str_replace("[+saddr+]", $emailsender, $message);
377
-	$message = str_replace("[+semail+]", $emailsender, $message);
378
-	$message = str_replace("[+surl+]", $site_url, $message);
379
-
380
-	$param = array();
381
-	$param['from'] = "{$site_name}<{$emailsender}>";
382
-	$param['subject'] = $emailsubject;
383
-	$param['body'] = $message;
384
-	$param['to'] = $email;
385
-	$param['type'] = 'text';
386
-	$rs = $modx->sendmail($param);
387
-	if(!$rs) {
388
-		$modx->manager->saveFormValues();
389
-		$modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
390
-	}
367
+    global $modx, $_lang, $websignupemail_message;
368
+    global $emailsubject, $emailsender;
369
+    global $site_name, $site_url;
370
+    $message = sprintf($websignupemail_message, $uid, $pwd); // use old method
371
+    // replace placeholders
372
+    $message = str_replace("[+uid+]", $uid, $message);
373
+    $message = str_replace("[+pwd+]", $pwd, $message);
374
+    $message = str_replace("[+ufn+]", $ufn, $message);
375
+    $message = str_replace("[+sname+]", $site_name, $message);
376
+    $message = str_replace("[+saddr+]", $emailsender, $message);
377
+    $message = str_replace("[+semail+]", $emailsender, $message);
378
+    $message = str_replace("[+surl+]", $site_url, $message);
379
+
380
+    $param = array();
381
+    $param['from'] = "{$site_name}<{$emailsender}>";
382
+    $param['subject'] = $emailsubject;
383
+    $param['body'] = $message;
384
+    $param['to'] = $email;
385
+    $param['type'] = 'text';
386
+    $rs = $modx->sendmail($param);
387
+    if(!$rs) {
388
+        $modx->manager->saveFormValues();
389
+        $modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
390
+    }
391 391
 }
392 392
 
393 393
 // Save User Settings
394 394
 function saveUserSettings($id) {
395
-	global $modx;
396
-	$tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
397
-
398
-	$settings = array(
399
-		"login_home",
400
-		"allowed_ip",
401
-		"allowed_days"
402
-	);
403
-
404
-	$modx->db->delete($tbl_web_user_settings, "webuser='{$id}'");
405
-
406
-	foreach($settings as $n) {
407
-		$vl = $_POST[$n];
408
-		if(is_array($vl)) {
409
-			$vl = implode(",", $vl);
410
-		}
411
-		if($vl != '') {
412
-			$f = array();
413
-			$f['webuser'] = $id;
414
-			$f['setting_name'] = $n;
415
-			$f['setting_value'] = $vl;
416
-			$f = $modx->db->escape($f);
417
-			$modx->db->insert($f, $tbl_web_user_settings);
418
-		}
419
-	}
395
+    global $modx;
396
+    $tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
397
+
398
+    $settings = array(
399
+        "login_home",
400
+        "allowed_ip",
401
+        "allowed_days"
402
+    );
403
+
404
+    $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'");
405
+
406
+    foreach($settings as $n) {
407
+        $vl = $_POST[$n];
408
+        if(is_array($vl)) {
409
+            $vl = implode(",", $vl);
410
+        }
411
+        if($vl != '') {
412
+            $f = array();
413
+            $f['webuser'] = $id;
414
+            $f['setting_name'] = $n;
415
+            $f['setting_value'] = $vl;
416
+            $f = $modx->db->escape($f);
417
+            $modx->db->insert($f, $tbl_web_user_settings);
418
+        }
419
+    }
420 420
 }
421 421
 
422 422
 // Web alert -  sends an alert to web browser
423 423
 function webAlertAndQuit($msg) {
424
-	global $id, $modx;
425
-	$mode = $_POST['mode'];
426
-	$modx->manager->saveFormValues($mode);
427
-	$modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : ''));
424
+    global $id, $modx;
425
+    $mode = $_POST['mode'];
426
+    $modx->manager->saveFormValues($mode);
427
+    $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : ''));
428 428
 }
429 429
 
430 430
 // Generate password
431 431
 function generate_password($length = 10) {
432
-	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
433
-	$ps_len = strlen($allowable_characters);
434
-	mt_srand((double) microtime() * 1000000);
435
-	$pass = "";
436
-	for($i = 0; $i < $length; $i++) {
437
-		$pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
438
-	}
439
-	return $pass;
432
+    $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
433
+    $ps_len = strlen($allowable_characters);
434
+    mt_srand((double) microtime() * 1000000);
435
+    $pass = "";
436
+    for($i = 0; $i < $length; $i++) {
437
+        $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
438
+    }
439
+    return $pass;
440 440
 }
441 441
 
442 442
 function sanitize($str = '', $safecount = 0) {
443
-	global $modx;
444
-	$safecount++;
445
-	if(1000 < $safecount) {
446
-		exit("error too many loops '{$safecount}'");
447
-	}
448
-	if(is_array($str)) {
449
-		foreach($str as $i => $v) {
450
-			$str[$i] = sanitize($v, $safecount);
451
-		}
452
-	} else {
453
-		// $str = strip_tags($str); // LEAVE < and > intact
454
-		$str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']);
455
-	}
456
-	return $str;
443
+    global $modx;
444
+    $safecount++;
445
+    if(1000 < $safecount) {
446
+        exit("error too many loops '{$safecount}'");
447
+    }
448
+    if(is_array($str)) {
449
+        foreach($str as $i => $v) {
450
+            $str[$i] = sanitize($v, $safecount);
451
+        }
452
+    } else {
453
+        // $str = strip_tags($str); // LEAVE < and > intact
454
+        $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']);
455
+    }
456
+    return $str;
457 457
 }
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->getFullTableName('site_tmplvar_contentvalues');
118
-		$articul_query = "SELECT `contentid` FROM {$tbl_site_tmplvar_contentvalues} WHERE `value` LIKE '%{$searchfields}%'";
119
-		$articul_result = $modx->db->query($articul_query);
120
-		$articul_id_array = $modx->db->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->getFullTableName('site_tmplvar_contentvalues');
118
+        $articul_query = "SELECT `contentid` FROM {$tbl_site_tmplvar_contentvalues} WHERE `value` LIKE '%{$searchfields}%'";
119
+        $articul_result = $modx->db->query($articul_query);
120
+        $articul_id_array = $modx->db->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/mutate_settings/tab1_site_settings.inc.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-  $site_unavailable_message_view = isset($site_unavailable_message) ? $site_unavailable_message : $_lang['siteunavailable_message_default'];
2
+    $site_unavailable_message_view = isset($site_unavailable_message) ? $site_unavailable_message : $_lang['siteunavailable_message_default'];
3 3
 ?>
4 4
 <style>
5 5
 table.sysSettings > tbody td, table.sysSettings > tbody th {border-bottom:1px dotted #ccc;padding:10px;}
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
         <?php
136 136
             // Check if PHX is enabled
137 137
             $count = $modx->db->getRecordCount(
138
-              $modx->db->select('id', '[+prefix+]site_plugins', 
139
-              "plugincode LIKE '%phx.parser.class.inc.php%OnParseDocument();%' AND disabled != 1")
138
+                $modx->db->select('id', '[+prefix+]site_plugins', 
139
+                "plugincode LIKE '%phx.parser.class.inc.php%OnParseDocument();%' AND disabled != 1")
140 140
             );
141 141
             if($count) {
142 142
                 $disabledFilters = 1;
@@ -259,14 +259,14 @@  discard block
 block discarded – undo
259 259
       <th><?php echo $_lang['serveroffset_title'] ?><br><small>[(server_offset_time)]</small></th>
260 260
       <td> <select name="server_offset_time" size="1" class="inputBox">
261 261
           <?php
262
-      for($i=-24; $i<25; $i++) {
263
-          $seconds = $i*60*60;
264
-          $selectedtext = $seconds==$server_offset_time ? "selected='selected'" : "" ;
265
-      ?>
262
+        for($i=-24; $i<25; $i++) {
263
+            $seconds = $i*60*60;
264
+            $selectedtext = $seconds==$server_offset_time ? "selected='selected'" : "" ;
265
+        ?>
266 266
           <option value="<?php echo $seconds; ?>" <?php echo $selectedtext; ?>><?php echo $i; ?></option>
267 267
           <?php
268
-      }
269
-      ?>
268
+        }
269
+        ?>
270 270
         </select>
271 271
         <div class="comment"><?php printf($_lang['serveroffset_message'], strftime('%H:%M:%S', time()), strftime('%H:%M:%S', time()+$server_offset_time)); ?></div>
272 272
         </td>
Please login to merge, or discard this patch.
manager/includes/accesscontrol.inc.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -102,19 +102,19 @@
 block discarded – undo
102 102
     $modx->setPlaceholder('login_form_position_class', 'loginbox-' . $modx->config['login_form_position']);
103 103
     
104 104
     switch ($modx->config['manager_theme_mode']) {
105
-      case '1':
105
+        case '1':
106 106
         $modx->setPlaceholder('manager_theme_style', 'lightness');
107 107
         break;
108
-      case '2':
108
+        case '2':
109 109
         $modx->setPlaceholder('manager_theme_style', 'light');
110 110
         break;
111
-      case '3':
111
+        case '3':
112 112
         $modx->setPlaceholder('manager_theme_style', 'dark');
113 113
         break;
114
-      case '4':
114
+        case '4':
115 115
         $modx->setPlaceholder('manager_theme_style', 'darkness');
116 116
         break;
117
-	}
117
+    }
118 118
 
119 119
     // andrazk 20070416 - notify user of install/update
120 120
     if (isset($_GET['installGoingOn'])) {
Please login to merge, or discard this patch.
manager/actions/welcome.static.php 1 patch
Indentation   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  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
 unset($_SESSION['itemname']); // clear this, because it's only set for logging purposes
7 7
 
8 8
 if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
9
-	// seems to be a new install - send the user to the configuration page
10
-	exit('<script type="text/javascript">document.location.href="index.php?a=17";</script>');
9
+    // seems to be a new install - send the user to the configuration page
10
+    exit('<script type="text/javascript">document.location.href="index.php?a=17";</script>');
11 11
 }
12 12
 
13 13
 // set placeholders
@@ -17,92 +17,92 @@  discard block
 block discarded – undo
17 17
 
18 18
 // setup message info
19 19
 if($modx->hasPermission('messages')) {
20
-	include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php');
21
-	$_SESSION['nrtotalmessages'] = $nrtotalmessages;
22
-	$_SESSION['nrnewmessages'] = $nrnewmessages;
23
-
24
-	$msg = array();
25
-	$msg[] = sprintf('<a href="index.php?a=10" target="main"><img src="%s" /></a>', $_style['icons_mail_large']);
26
-	$nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? ' (<span style="color:red">' . $_SESSION['nrnewmessages'] . '</span>)' : '';
27
-	$msg[] = sprintf('<span style="color:#909090;font-size:15px;font-weight:bold">&nbsp;<a class="wm_messages_inbox_link" href="index.php?a=10" target="main">[%%inbox%%]</a>%s</span><br />', $nrnewmessages);
28
-	$nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? '<span style="color:red;">' . $_SESSION['nrnewmessages'] . '</span>' : '0';
29
-	$welcome_messages = sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages);
30
-	$msg[] = sprintf('<span class="comment">%s</span>', $welcome_messages);
31
-	$ph['MessageInfo'] = implode("\n", $msg);
20
+    include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php');
21
+    $_SESSION['nrtotalmessages'] = $nrtotalmessages;
22
+    $_SESSION['nrnewmessages'] = $nrnewmessages;
23
+
24
+    $msg = array();
25
+    $msg[] = sprintf('<a href="index.php?a=10" target="main"><img src="%s" /></a>', $_style['icons_mail_large']);
26
+    $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? ' (<span style="color:red">' . $_SESSION['nrnewmessages'] . '</span>)' : '';
27
+    $msg[] = sprintf('<span style="color:#909090;font-size:15px;font-weight:bold">&nbsp;<a class="wm_messages_inbox_link" href="index.php?a=10" target="main">[%%inbox%%]</a>%s</span><br />', $nrnewmessages);
28
+    $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? '<span style="color:red;">' . $_SESSION['nrnewmessages'] . '</span>' : '0';
29
+    $welcome_messages = sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages);
30
+    $msg[] = sprintf('<span class="comment">%s</span>', $welcome_messages);
31
+    $ph['MessageInfo'] = implode("\n", $msg);
32 32
 }
33 33
 
34 34
 // setup icons
35 35
 if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
36
-	$icon = '<i class="[&icons_security_large&]" alt="[%user_management_title%]"> </i>[%user_management_title%]';
37
-	$ph['SecurityIcon'] = wrapIcon($icon, 75);
36
+    $icon = '<i class="[&icons_security_large&]" alt="[%user_management_title%]"> </i>[%user_management_title%]';
37
+    $ph['SecurityIcon'] = wrapIcon($icon, 75);
38 38
 }
39 39
 if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
40
-	$icon = '<i class="[&icons_webusers_large&]" alt="[%web_user_management_title%]"> </i>[%web_user_management_title%]';
41
-	$ph['WebUserIcon'] = wrapIcon($icon, 99);
40
+    $icon = '<i class="[&icons_webusers_large&]" alt="[%web_user_management_title%]"> </i>[%web_user_management_title%]';
41
+    $ph['WebUserIcon'] = wrapIcon($icon, 99);
42 42
 }
43 43
 if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
44
-	$icon = '<i class="[&icons_modules_large&]" alt="[%manage_modules%]"> </i>[%modules%]';
45
-	$ph['ModulesIcon'] = wrapIcon($icon, 106);
44
+    $icon = '<i class="[&icons_modules_large&]" alt="[%manage_modules%]"> </i>[%modules%]';
45
+    $ph['ModulesIcon'] = wrapIcon($icon, 106);
46 46
 }
47 47
 if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
48
-	$icon = '<i class="[&icons_resources_large&]" alt="[%element_management%]"> </i>[%elements%]';
49
-	$ph['ResourcesIcon'] = wrapIcon($icon, 76);
48
+    $icon = '<i class="[&icons_resources_large&]" alt="[%element_management%]"> </i>[%elements%]';
49
+    $ph['ResourcesIcon'] = wrapIcon($icon, 76);
50 50
 }
51 51
 if($modx->hasPermission('bk_manager')) {
52
-	$icon = '<i class="[&icons_backup_large&]" alt="[%bk_manager%]"> </i>[%backup%]';
53
-	$ph['BackupIcon'] = wrapIcon($icon, 93);
52
+    $icon = '<i class="[&icons_backup_large&]" alt="[%bk_manager%]"> </i>[%backup%]';
53
+    $ph['BackupIcon'] = wrapIcon($icon, 93);
54 54
 }
55 55
 if($modx->hasPermission('help')) {
56
-	$icon = '<i class="[&icons_help_large&]" alt="[%help%]" /> </i>[%help%]';
57
-	$ph['HelpIcon'] = wrapIcon($icon, 9);
56
+    $icon = '<i class="[&icons_help_large&]" alt="[%help%]" /> </i>[%help%]';
57
+    $ph['HelpIcon'] = wrapIcon($icon, 9);
58 58
 }
59 59
 
60 60
 if($modx->hasPermission('new_document')) {
61
-	$icon = '<i class="[&icons_resource_large&]"></i>[%add_resource%]';
62
-	$ph['ResourceIcon'] = wrapIcon($icon, 4);
63
-	$icon = '<i class="[&icons_weblink_large&]"></i>[%add_weblink%]';
64
-	$ph['WeblinkIcon'] = wrapIcon($icon, 72);
61
+    $icon = '<i class="[&icons_resource_large&]"></i>[%add_resource%]';
62
+    $ph['ResourceIcon'] = wrapIcon($icon, 4);
63
+    $icon = '<i class="[&icons_weblink_large&]"></i>[%add_weblink%]';
64
+    $ph['WeblinkIcon'] = wrapIcon($icon, 72);
65 65
 }
66 66
 if($modx->hasPermission('assets_images')) {
67
-	$icon = '<i class="[&icons_images_large&]"></i>[%images_management%]';
68
-	$ph['ImagesIcon'] = wrapIcon($icon, 72);
67
+    $icon = '<i class="[&icons_images_large&]"></i>[%images_management%]';
68
+    $ph['ImagesIcon'] = wrapIcon($icon, 72);
69 69
 }
70 70
 if($modx->hasPermission('assets_files')) {
71
-	$icon = '<i class="[&icons_files_large&]"></i>[%files_management%]';
72
-	$ph['FilesIcon'] = wrapIcon($icon, 72);
71
+    $icon = '<i class="[&icons_files_large&]"></i>[%files_management%]';
72
+    $ph['FilesIcon'] = wrapIcon($icon, 72);
73 73
 }
74 74
 if($modx->hasPermission('change_password')) {
75
-	$icon = '<i class="[&icons_password_large&]"></i>[%change_password%]';
76
-	$ph['PasswordIcon'] = wrapIcon($icon, 28);
75
+    $icon = '<i class="[&icons_password_large&]"></i>[%change_password%]';
76
+    $ph['PasswordIcon'] = wrapIcon($icon, 28);
77 77
 }
78 78
 $icon = '<i class="[&icons_logout_large&]"></i>[%logout%]';
79 79
 $ph['LogoutIcon'] = wrapIcon($icon, 8);
80 80
 
81 81
 // do some config checks
82 82
 if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
83
-	include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php');
84
-	if($config_check_results != $_lang['configcheck_ok']) {
85
-		$ph['config_check_results'] = $config_check_results;
86
-		$ph['config_display'] = 'block';
87
-	} else {
88
-		$ph['config_display'] = 'none';
89
-	}
83
+    include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php');
84
+    if($config_check_results != $_lang['configcheck_ok']) {
85
+        $ph['config_check_results'] = $config_check_results;
86
+        $ph['config_display'] = 'block';
87
+    } else {
88
+        $ph['config_display'] = 'none';
89
+    }
90 90
 } else {
91
-	$ph['config_display'] = 'none';
91
+    $ph['config_display'] = 'none';
92 92
 }
93 93
 
94 94
 // Check logout-reminder
95 95
 if(isset($_SESSION['show_logout_reminder'])) {
96
-	switch($_SESSION['show_logout_reminder']['type']) {
97
-		case 'logout_reminder':
98
-			$date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly');
99
-			$ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']);
100
-			break;
101
-	}
102
-	$ph['show_logout_reminder'] = 'block';
103
-	unset($_SESSION['show_logout_reminder']);
96
+    switch($_SESSION['show_logout_reminder']['type']) {
97
+        case 'logout_reminder':
98
+            $date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly');
99
+            $ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']);
100
+            break;
101
+    }
102
+    $ph['show_logout_reminder'] = 'block';
103
+    unset($_SESSION['show_logout_reminder']);
104 104
 } else {
105
-	$ph['show_logout_reminder'] = 'none';
105
+    $ph['show_logout_reminder'] = 'none';
106 106
 }
107 107
 
108 108
 // Check multiple sessions
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
 $nrnewmessages = '<span class="text-danger">' . $_SESSION['nrnewmessages'] . '</span>';
151 151
 
152 152
 $ph['UserInfo'] = $modx->parseText($tpl, array(
153
-	'username' => $modx->getLoginUserName(),
154
-	'role' => $_SESSION['mgrPermissions']['name'],
155
-	'lastlogin' => $modx->toDateFormat($_SESSION['mgrLastlogin'] + $server_offset_time),
156
-	'logincount' => $_SESSION['mgrLogincount'] + 1,
157
-	'msginfo' => sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages)
153
+    'username' => $modx->getLoginUserName(),
154
+    'role' => $_SESSION['mgrPermissions']['name'],
155
+    'lastlogin' => $modx->toDateFormat($_SESSION['mgrLastlogin'] + $server_offset_time),
156
+    'logincount' => $_SESSION['mgrLogincount'] + 1,
157
+    'msginfo' => sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages)
158 158
 ));
159 159
 
160 160
 $from = array();
@@ -163,13 +163,13 @@  discard block
 block discarded – undo
163 163
 $rs = $modx->db->select('*', $from, '', 'username ASC, au.sid ASC');
164 164
 
165 165
 if($modx->db->getRecordCount($rs) < 1) {
166
-	$html = '<p>[%no_active_users_found%]</p>';
166
+    $html = '<p>[%no_active_users_found%]</p>';
167 167
 } else {
168
-	include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php');
169
-	$now = $_SERVER['REQUEST_TIME'] + $server_offset_time;
170
-	$ph['now'] = strftime('%H:%M:%S', $now);
171
-	$timetocheck = ($now - (60 * 20)); //+$server_offset_time;
172
-	$html = '
168
+    include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php');
169
+    $now = $_SERVER['REQUEST_TIME'] + $server_offset_time;
170
+    $ph['now'] = strftime('%H:%M:%S', $now);
171
+    $timetocheck = ($now - (60 * 20)); //+$server_offset_time;
172
+    $html = '
173 173
 	<div class="card-body">
174 174
 		[%onlineusers_message%] 
175 175
 		<b>[+now+]</b>):
@@ -187,33 +187,33 @@  discard block
 block discarded – undo
187 187
 	</thead>
188 188
 	<tbody>';
189 189
 
190
-	$userList = array();
191
-	$userCount = array();
192
-	// Create userlist with session-count first before output
193
-	while($activeusers = $modx->db->getRow($rs)) {
194
-		$userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1;
195
-
196
-		$idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : '';
197
-		$webicon = $activeusers['internalKey'] < 0 ? '<img src="[&tree_globe&]" alt="Web user" />&nbsp;' : '';
198
-		$ip = $activeusers['ip'] === '::1' ? '127.0.0.1' : $activeusers['ip'];
199
-		$currentaction = getAction($activeusers['action'], $activeusers['id']);
200
-		$userList[] = array(
201
-			$idle,
202
-			'',
203
-			$activeusers['username'],
204
-			$webicon,
205
-			abs($activeusers['internalKey']),
206
-			$ip,
207
-			strftime('%H:%M:%S', $activeusers['lasthit'] + $server_offset_time),
208
-			$currentaction
209
-		);
210
-	}
211
-	foreach($userList as $params) {
212
-		$params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : '';
213
-		$html .= "\n\t\t" . vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params);
214
-	}
215
-
216
-	$html .= '
190
+    $userList = array();
191
+    $userCount = array();
192
+    // Create userlist with session-count first before output
193
+    while($activeusers = $modx->db->getRow($rs)) {
194
+        $userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1;
195
+
196
+        $idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : '';
197
+        $webicon = $activeusers['internalKey'] < 0 ? '<img src="[&tree_globe&]" alt="Web user" />&nbsp;' : '';
198
+        $ip = $activeusers['ip'] === '::1' ? '127.0.0.1' : $activeusers['ip'];
199
+        $currentaction = getAction($activeusers['action'], $activeusers['id']);
200
+        $userList[] = array(
201
+            $idle,
202
+            '',
203
+            $activeusers['username'],
204
+            $webicon,
205
+            abs($activeusers['internalKey']),
206
+            $ip,
207
+            strftime('%H:%M:%S', $activeusers['lasthit'] + $server_offset_time),
208
+            $currentaction
209
+        );
210
+    }
211
+    foreach($userList as $params) {
212
+        $params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : '';
213
+        $html .= "\n\t\t" . vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params);
214
+    }
215
+
216
+    $html .= '
217 217
 	</tbody>
218 218
 	</table>
219 219
 </div>
@@ -254,17 +254,17 @@  discard block
 block discarded – undo
254 254
 // invoke event OnManagerWelcomePrerender
255 255
 $evtOut = $modx->invokeEvent('OnManagerWelcomePrerender');
256 256
 if(is_array($evtOut)) {
257
-	$output = implode('', $evtOut);
258
-	$ph['OnManagerWelcomePrerender'] = $output;
257
+    $output = implode('', $evtOut);
258
+    $ph['OnManagerWelcomePrerender'] = $output;
259 259
 }
260 260
 
261 261
 $widgets['welcome'] = array(
262
-	'menuindex' => '10',
263
-	'id' => 'welcome',
264
-	'cols' => 'col-lg-6',
265
-	'icon' => 'fa-home',
266
-	'title' => '[%welcome_title%]',
267
-	'body' => '
262
+    'menuindex' => '10',
263
+    'id' => 'welcome',
264
+    'cols' => 'col-lg-6',
265
+    'icon' => 'fa-home',
266
+    'title' => '[%welcome_title%]',
267
+    'body' => '
268 268
 				<div class="wm_buttons card-body"> 
269 269
 					<!--@IF:[[#hasPermission?key=new_document]]--> 
270 270
 					<span class="wm_button">
@@ -338,25 +338,25 @@  discard block
 block discarded – undo
338 338
 					</table>
339 339
 				</div>
340 340
 		',
341
-	'hide'=>'0'
341
+    'hide'=>'0'
342 342
 );
343 343
 $widgets['onlineinfo'] = array(
344
-	'menuindex' => '20',
345
-	'id' => 'onlineinfo',
346
-	'cols' => 'col-lg-6',
347
-	'icon' => 'fa-user',
348
-	'title' => '[%onlineusers_title%]',
349
-	'body' => '<div class="userstable">[+OnlineInfo+]</div>',
350
-	'hide'=>'0'
344
+    'menuindex' => '20',
345
+    'id' => 'onlineinfo',
346
+    'cols' => 'col-lg-6',
347
+    'icon' => 'fa-user',
348
+    'title' => '[%onlineusers_title%]',
349
+    'body' => '<div class="userstable">[+OnlineInfo+]</div>',
350
+    'hide'=>'0'
351 351
 );
352 352
 $widgets['recentinfo'] = array(
353
-	'menuindex' => '30',
354
-	'id' => 'modxrecent_widget',
355
-	'cols' => 'col-sm-12',
356
-	'icon' => 'fa-pencil-square-o',
357
-	'title' => '[%activity_title%]',
358
-	'body' => '<div class="widget-stage">[+RecentInfo+]</div>',
359
-	'hide'=>'0'
353
+    'menuindex' => '30',
354
+    'id' => 'modxrecent_widget',
355
+    'cols' => 'col-sm-12',
356
+    'icon' => 'fa-pencil-square-o',
357
+    'title' => '[%activity_title%]',
358
+    'body' => '<div class="widget-stage">[+RecentInfo+]</div>',
359
+    'hide'=>'0'
360 360
 );
361 361
 if ($modx->config['rss_url_news']) {
362 362
     $widgets['news'] = array(
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 // invoke OnManagerWelcomeHome event
385 385
 $sitewidgets = $modx->invokeEvent("OnManagerWelcomeHome", array('widgets' => $widgets));
386 386
 if(is_array($sitewidgets)) {
387
-	$newwidgets = array();
387
+    $newwidgets = array();
388 388
     foreach($sitewidgets as $widget){
389 389
         $newwidgets = array_merge($newwidgets, unserialize($widget));
390 390
     }
@@ -392,21 +392,21 @@  discard block
 block discarded – undo
392 392
 }
393 393
 
394 394
 usort($widgets, function ($a, $b) {
395
-	return $a['menuindex'] - $b['menuindex'];
395
+    return $a['menuindex'] - $b['menuindex'];
396 396
 });
397 397
 
398 398
 $tpl = getTplWidget();
399 399
 $output = '';
400 400
 foreach($widgets as $widget) {
401
-	if ($widget['hide'] != '1'){
402
-		$output .= $modx->parseText($tpl, $widget);
403
-	}
401
+    if ($widget['hide'] != '1'){
402
+        $output .= $modx->parseText($tpl, $widget);
403
+    }
404 404
 }
405 405
 $ph['widgets'] = $output;
406 406
 
407 407
 // load template
408 408
 if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
409
-	$modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl';
409
+    $modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl';
410 410
 }
411 411
 
412 412
 $target = $modx->config['manager_welcome_tpl'];
@@ -414,27 +414,27 @@  discard block
 block discarded – undo
414 414
 $target = $modx->mergeSettingsContent($target);
415 415
 
416 416
 if(substr($target, 0, 1) === '@') {
417
-	if(substr($target, 0, 6) === '@CHUNK') {
418
-		$content = $modx->getChunk(trim(substr($target, 7)));
419
-	} elseif(substr($target, 0, 5) === '@FILE') {
420
-		$content = file_get_contents(trim(substr($target, 6)));
421
-	} else {
422
-		$content = '';
423
-	}
417
+    if(substr($target, 0, 6) === '@CHUNK') {
418
+        $content = $modx->getChunk(trim(substr($target, 7)));
419
+    } elseif(substr($target, 0, 5) === '@FILE') {
420
+        $content = file_get_contents(trim(substr($target, 6)));
421
+    } else {
422
+        $content = '';
423
+    }
424 424
 } else {
425
-	$chunk = $modx->getChunk($target);
426
-	if($chunk !== false && !empty($chunk)) {
427
-		$content = $chunk;
428
-	} elseif(is_file(MODX_BASE_PATH . $target)) {
429
-		$content = file_get_contents(MODX_BASE_PATH . $target);
430
-	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
431
-		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl');
432
-	} elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible
433
-	{
434
-		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html');
435
-	} else {
436
-		$content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl');
437
-	}
425
+    $chunk = $modx->getChunk($target);
426
+    if($chunk !== false && !empty($chunk)) {
427
+        $content = $chunk;
428
+    } elseif(is_file(MODX_BASE_PATH . $target)) {
429
+        $content = file_get_contents(MODX_BASE_PATH . $target);
430
+    } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
431
+        $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl');
432
+    } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible
433
+    {
434
+        $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html');
435
+    } else {
436
+        $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl');
437
+    }
438 438
 }
439 439
 
440 440
 // merge placeholders
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 $content = $modx->mergeSettingsContent($content);
443 443
 $content = $modx->parseText($content, $ph);
444 444
 if(strpos($content, '[+') !== false) {
445
-	$modx->toPlaceholders($ph);
446
-	$content = $modx->mergePlaceholderContent($content);
445
+    $modx->toPlaceholders($ph);
446
+    $content = $modx->mergePlaceholderContent($content);
447 447
 }
448 448
 $content = $modx->parseDocumentSource($content);
449 449
 $content = $modx->parseText($content, $_lang, '[%', '%]');
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 $content = $modx->cleanUpMODXTags($content); //cleanup
452 452
 
453 453
 if($js = $modx->getRegisteredClientScripts()) {
454
-	$content .= $js;
454
+    $content .= $js;
455 455
 }
456 456
 
457 457
 echo $content;
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 //  <a href="javascript:;" class="closed"><i class="fa fa-close"></i></a>
462 462
 //</span>
463 463
 function getTplWidget() { // recent document info
464
-	return '
464
+    return '
465 465
 		<div class="[+cols+]" id="[+id+]">
466 466
 			<div class="card"[+cardAttr+]>
467 467
 				<div class="card-header"[+headAttr+]> <i class="fa [+icon+]"></i> [+title+] </div>
@@ -472,11 +472,11 @@  discard block
 block discarded – undo
472 472
 }
473 473
 
474 474
 function getRecentInfo() { // recent document info
475
-	global $modx;
475
+    global $modx;
476 476
 
477
-	$modx->addSnippet('recentInfoList', 'getRecentInfoList');
477
+    $modx->addSnippet('recentInfoList', 'getRecentInfoList');
478 478
 
479
-	$html = '
479
+    $html = '
480 480
 			<div class="table-responsive">
481 481
 				<table class="table data">
482 482
 					<thead>
@@ -494,96 +494,96 @@  discard block
 block discarded – undo
494 494
 				</table>
495 495
 			</div>
496 496
 ';
497
-	return $html;
497
+    return $html;
498 498
 }
499 499
 
500 500
 function getRecentInfoList() {
501
-	global $modx;
502
-
503
-	$rs = $modx->db->select('*', '[+prefix+]site_content', '', 'editedon DESC', 10);
504
-
505
-	if($modx->db->getRecordCount($rs) < 1) {
506
-		return '<tr><td>[%no_activity_message%]</td></tr>';
507
-	}
508
-
509
-	$tpl = getRecentInfoRowTpl();
510
-
511
-	$btntpl['edit'] = '<a title="[%edit_resource%]" href="index.php?a=27&amp;id=[+id+]" target="main"><i class="fa fa-edit fa-fw"></i></a> ';
512
-	$btntpl['preview_btn'] = '<a [+preview_disabled+]" title="[%preview_resource%]" target="_blank" href="../index.php?&amp;id=[+id+]"><i class="fa fa-eye fa-fw"></i></a> ';
513
-
514
-	$output = array();
515
-	while($ph = $modx->db->getRow($rs)) {
516
-		$docid = $ph['id'];
517
-		$_ = $modx->getUserInfo($ph['editedby']);
518
-		$ph['username'] = $_['username'];
519
-
520
-		if($ph['deleted'] == 1) {
521
-			$ph['status'] = 'deleted text-danger';
522
-		} elseif($ph['published'] == 0) {
523
-			$ph['status'] = 'unpublished font-italic text-muted';
524
-		} else {
525
-			$ph['status'] = 'published';
526
-		}
527
-
528
-		if($modx->hasPermission('edit_document')) {
529
-			$ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']);
530
-		} else {
531
-			$ph['edit_btn'] = '';
532
-		}
533
-
534
-		$preview_disabled = ($ph['deleted'] == 1) ? 'disabled' : '';
535
-		$ph['preview_btn'] = str_replace(array(
536
-			'[+id+]',
537
-			'[+preview_disabled+]'
538
-		), array(
539
-			$docid,
540
-			$preview_disabled
541
-		), $btntpl['preview_btn']);
542
-
543
-		if($modx->hasPermission('delete_document')) {
544
-			if($ph['deleted'] == 0) {
545
-				$delete_btn = '<a onclick="return confirm(\'[%confirm_delete_record%]\')" title="[%delete_resource%]" href="index.php?a=6&amp;id=[+id+]" target="main"><i class="fa fa-trash fa-fw"></i></a> ';
546
-			} else {
547
-				$delete_btn = '<a onclick="return confirm(\'[%confirm_undelete%]\')" title="[%undelete_resource%]" href="index.php?a=63&amp;id=[+id+]" target="main"><i class="fa fa-arrow-circle-o-up fa-fw"></i></a> ';
548
-			}
549
-			$ph['delete_btn'] = str_replace('[+id+]', $docid, $delete_btn);
550
-		} else {
551
-			$ph['delete_btn'] = '';
552
-		}
553
-
554
-		if($ph['deleted'] == 1 && $ph['published'] == 0) {
555
-			$publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> ';
556
-		} elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
557
-			$publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> ';
558
-		} elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
559
-			$publish_btn = '<a title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> ';
560
-		} else {
561
-			$publish_btn = '<a title="[%unpublish_resource%]" href="index.php?a=62&amp;id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> ';
562
-		}
563
-		$ph['publish_btn'] = str_replace('[+id+]', $docid, $publish_btn);
564
-
565
-		$ph['info_btn'] = str_replace('[+id+]', $docid, '<a title="[%resource_overview%]" data-toggle="collapse" data-target=".collapse[+id+]"><i class="fa fa-info fa-fw"></i></a>');
566
-
567
-		if($ph['longtitle'] == '') {
568
-			$ph['longtitle'] = '(<i>[%not_set%]</i>)';
569
-		}
570
-		if($ph['description'] == '') {
571
-			$ph['description'] = '(<i>[%not_set%]</i>)';
572
-		}
573
-		if($ph['introtext'] == '') {
574
-			$ph['introtext'] = '(<i>[%not_set%]</i>)';
575
-		}
576
-		if($ph['alias'] == '') {
577
-			$ph['alias'] = '(<i>[%not_set%]</i>)';
578
-		}
579
-
580
-		$output[] = $modx->parseText($tpl, $ph);
581
-	}
582
-	return implode("\n", $output);
501
+    global $modx;
502
+
503
+    $rs = $modx->db->select('*', '[+prefix+]site_content', '', 'editedon DESC', 10);
504
+
505
+    if($modx->db->getRecordCount($rs) < 1) {
506
+        return '<tr><td>[%no_activity_message%]</td></tr>';
507
+    }
508
+
509
+    $tpl = getRecentInfoRowTpl();
510
+
511
+    $btntpl['edit'] = '<a title="[%edit_resource%]" href="index.php?a=27&amp;id=[+id+]" target="main"><i class="fa fa-edit fa-fw"></i></a> ';
512
+    $btntpl['preview_btn'] = '<a [+preview_disabled+]" title="[%preview_resource%]" target="_blank" href="../index.php?&amp;id=[+id+]"><i class="fa fa-eye fa-fw"></i></a> ';
513
+
514
+    $output = array();
515
+    while($ph = $modx->db->getRow($rs)) {
516
+        $docid = $ph['id'];
517
+        $_ = $modx->getUserInfo($ph['editedby']);
518
+        $ph['username'] = $_['username'];
519
+
520
+        if($ph['deleted'] == 1) {
521
+            $ph['status'] = 'deleted text-danger';
522
+        } elseif($ph['published'] == 0) {
523
+            $ph['status'] = 'unpublished font-italic text-muted';
524
+        } else {
525
+            $ph['status'] = 'published';
526
+        }
527
+
528
+        if($modx->hasPermission('edit_document')) {
529
+            $ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']);
530
+        } else {
531
+            $ph['edit_btn'] = '';
532
+        }
533
+
534
+        $preview_disabled = ($ph['deleted'] == 1) ? 'disabled' : '';
535
+        $ph['preview_btn'] = str_replace(array(
536
+            '[+id+]',
537
+            '[+preview_disabled+]'
538
+        ), array(
539
+            $docid,
540
+            $preview_disabled
541
+        ), $btntpl['preview_btn']);
542
+
543
+        if($modx->hasPermission('delete_document')) {
544
+            if($ph['deleted'] == 0) {
545
+                $delete_btn = '<a onclick="return confirm(\'[%confirm_delete_record%]\')" title="[%delete_resource%]" href="index.php?a=6&amp;id=[+id+]" target="main"><i class="fa fa-trash fa-fw"></i></a> ';
546
+            } else {
547
+                $delete_btn = '<a onclick="return confirm(\'[%confirm_undelete%]\')" title="[%undelete_resource%]" href="index.php?a=63&amp;id=[+id+]" target="main"><i class="fa fa-arrow-circle-o-up fa-fw"></i></a> ';
548
+            }
549
+            $ph['delete_btn'] = str_replace('[+id+]', $docid, $delete_btn);
550
+        } else {
551
+            $ph['delete_btn'] = '';
552
+        }
553
+
554
+        if($ph['deleted'] == 1 && $ph['published'] == 0) {
555
+            $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> ';
556
+        } elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
557
+            $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> ';
558
+        } elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
559
+            $publish_btn = '<a title="[%publish_resource%]" href="index.php?a=61&amp;id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> ';
560
+        } else {
561
+            $publish_btn = '<a title="[%unpublish_resource%]" href="index.php?a=62&amp;id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> ';
562
+        }
563
+        $ph['publish_btn'] = str_replace('[+id+]', $docid, $publish_btn);
564
+
565
+        $ph['info_btn'] = str_replace('[+id+]', $docid, '<a title="[%resource_overview%]" data-toggle="collapse" data-target=".collapse[+id+]"><i class="fa fa-info fa-fw"></i></a>');
566
+
567
+        if($ph['longtitle'] == '') {
568
+            $ph['longtitle'] = '(<i>[%not_set%]</i>)';
569
+        }
570
+        if($ph['description'] == '') {
571
+            $ph['description'] = '(<i>[%not_set%]</i>)';
572
+        }
573
+        if($ph['introtext'] == '') {
574
+            $ph['introtext'] = '(<i>[%not_set%]</i>)';
575
+        }
576
+        if($ph['alias'] == '') {
577
+            $ph['alias'] = '(<i>[%not_set%]</i>)';
578
+        }
579
+
580
+        $output[] = $modx->parseText($tpl, $ph);
581
+    }
582
+    return implode("\n", $output);
583 583
 }
584 584
 
585 585
 function getRecentInfoRowTpl() {
586
-	$tpl = '
586
+    $tpl = '
587 587
 						<tr>
588 588
 							<td data-toggle="collapse" data-target=".collapse[+id+]" class="text-right"><span class="label label-info">[+id+]</span></td>
589 589
 							<td data-toggle="collapse" data-target=".collapse[+id+]"><a class="[+status+]" title="[%edit_resource%]" href="index.php?a=3&amp;id=[+id+]" target="main">[+pagetitle+]</a></td>
@@ -607,16 +607,16 @@  discard block
 block discarded – undo
607 607
 								</div>
608 608
 							</td>
609 609
 						</tr>';
610
-	return $tpl;
610
+    return $tpl;
611 611
 }
612 612
 
613 613
 // setup icons
614 614
 function wrapIcon($i, $action) {
615
-	return sprintf('<a href="index.php?a=%s" target="main"><span class="wm_button" style="border:0">%s</span></a>', $action, $i);
615
+    return sprintf('<a href="index.php?a=%s" target="main"><span class="wm_button" style="border:0">%s</span></a>', $action, $i);
616 616
 }
617 617
 
618 618
 function getStartUpScript() {
619
-	$script = '
619
+    $script = '
620 620
         <script type="text/javascript">
621 621
         function hideConfigCheckWarning(key) {
622 622
         	var xhr = new XMLHttpRequest();
@@ -640,5 +640,5 @@  discard block
 block discarded – undo
640 640
 		})(jQuery);        
641 641
         </script>
642 642
 ';
643
-	return $script;
643
+    return $script;
644 644
 }
Please login to merge, or discard this patch.