Completed
Push — develop ( 868fda...0c1ea9 )
by Dmytro
07:17
created
manager/media/style/default/ajax.php 1 patch
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
 $modx->loadExtension("ManagerAPI");
20 20
 
21 21
 $_lang = array();
22
-include_once MODX_MANAGER_PATH . '/includes/lang/english.inc.php';
22
+include_once MODX_MANAGER_PATH.'/includes/lang/english.inc.php';
23 23
 if ($modx->config['manager_language'] != 'english') {
24
-    include_once MODX_MANAGER_PATH . '/includes/lang/' . $modx->config['manager_language'] . '.inc.php';
24
+    include_once MODX_MANAGER_PATH.'/includes/lang/'.$modx->config['manager_language'].'.inc.php';
25 25
 }
26
-include_once MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/style.php';
26
+include_once MODX_MANAGER_PATH.'/media/style/'.$modx->config['manager_theme'].'/style.php';
27 27
 
28 28
 $action = isset($_REQUEST['a']) ? $_REQUEST['a'] : '';
29 29
 $frame = isset($_REQUEST['f']) ? $_REQUEST['f'] : '';
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
             switch ($frame) {
42 42
                 case 'nodes':
43
-                    include_once MODX_MANAGER_PATH . '/frames/nodes.php';
43
+                    include_once MODX_MANAGER_PATH.'/frames/nodes.php';
44 44
 
45 45
                     break;
46 46
             }
@@ -58,21 +58,21 @@  discard block
 block discarded – undo
58 58
                 $sql = '';
59 59
                 $a = '';
60 60
                 $filter = !empty($_REQUEST['filter']) && is_scalar($_REQUEST['filter']) ? addcslashes(trim($_REQUEST['filter']), '%*_') : '';
61
-                $sqlLike = $filter ? 'WHERE t1.name LIKE "' . $modx->db->escape($filter) . '%"' : '';
62
-                $sqlLimit = $sqlLike ? '' : 'LIMIT ' . $limit;
61
+                $sqlLike = $filter ? 'WHERE t1.name LIKE "'.$modx->db->escape($filter).'%"' : '';
62
+                $sqlLimit = $sqlLike ? '' : 'LIMIT '.$limit;
63 63
 
64 64
                 switch ($elements) {
65 65
                     case 'element_templates':
66 66
                         $a = 16;
67
-                        $sqlLike = $filter ? 'WHERE t1.templatename LIKE "' . $modx->db->escape($filter) . '%"' : '';
67
+                        $sqlLike = $filter ? 'WHERE t1.templatename LIKE "'.$modx->db->escape($filter).'%"' : '';
68 68
                         $sql = $modx->db->query('SELECT t1.*, t1.templatename AS name
69
-                        FROM ' . $modx->getFullTableName('site_templates') . ' AS t1
70
-                        ' . $sqlLike . '
69
+                        FROM ' . $modx->getFullTableName('site_templates').' AS t1
70
+                        ' . $sqlLike.'
71 71
                         ORDER BY t1.templatename ASC
72 72
                         ' . $sqlLimit);
73 73
 
74 74
                         if ($modx->hasPermission('new_template')) {
75
-                            $output .= '<li><a id="a_19" href="index.php?a=19" target="main"><i class="fa fa-plus"></i>' . $_lang['new_template'] . '</a></li>';
75
+                            $output .= '<li><a id="a_19" href="index.php?a=19" target="main"><i class="fa fa-plus"></i>'.$_lang['new_template'].'</a></li>';
76 76
                         }
77 77
 
78 78
                         break;
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
                     case 'element_tplvars':
81 81
                         $a = 301;
82 82
                         $sql = $modx->db->query('SELECT t1.*, IF(t2.templateid,0,1) AS disabled
83
-                        FROM ' . $modx->getFullTableName('site_tmplvars') . ' AS t1
84
-                        LEFT JOIN ' . $modx->getFullTableName('site_tmplvar_templates') . ' AS t2 ON t1.id=t2.tmplvarid
85
-                        ' . $sqlLike . '
83
+                        FROM ' . $modx->getFullTableName('site_tmplvars').' AS t1
84
+                        LEFT JOIN ' . $modx->getFullTableName('site_tmplvar_templates').' AS t2 ON t1.id=t2.tmplvarid
85
+                        ' . $sqlLike.'
86 86
                         ORDER BY t1.name ASC
87 87
                         ' . $sqlLimit);
88 88
 
89 89
                         if ($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
90
-                            $output .= '<li><a id="a_300" href="index.php?a=300" target="main"><i class="fa fa-plus"></i>' . $_lang['new_tmplvars'] . '</a></li>';
90
+                            $output .= '<li><a id="a_300" href="index.php?a=300" target="main"><i class="fa fa-plus"></i>'.$_lang['new_tmplvars'].'</a></li>';
91 91
                         }
92 92
 
93 93
                         break;
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
                     case 'element_htmlsnippets':
96 96
                         $a = 78;
97 97
                         $sql = $modx->db->query('SELECT t1.*
98
-                        FROM ' . $modx->getFullTableName('site_htmlsnippets') . ' AS t1
99
-                        ' . $sqlLike . '
98
+                        FROM ' . $modx->getFullTableName('site_htmlsnippets').' AS t1
99
+                        ' . $sqlLike.'
100 100
                         ORDER BY t1.name ASC
101 101
                         ' . $sqlLimit);
102 102
 
103 103
                         if ($modx->hasPermission('new_chunk')) {
104
-                            $output .= '<li><a id="a_77" href="index.php?a=77" target="main"><i class="fa fa-plus"></i>' . $_lang['new_htmlsnippet'] . '</a></li>';
104
+                            $output .= '<li><a id="a_77" href="index.php?a=77" target="main"><i class="fa fa-plus"></i>'.$_lang['new_htmlsnippet'].'</a></li>';
105 105
                         }
106 106
 
107 107
                         break;
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
                     case 'element_snippets':
110 110
                         $a = 22;
111 111
                         $sql = $modx->db->query('SELECT t1.*
112
-                        FROM ' . $modx->getFullTableName('site_snippets') . ' AS t1
113
-                        ' . $sqlLike . '
112
+                        FROM ' . $modx->getFullTableName('site_snippets').' AS t1
113
+                        ' . $sqlLike.'
114 114
                         ORDER BY t1.name ASC
115 115
                         ' . $sqlLimit);
116 116
 
117 117
                         if ($modx->hasPermission('new_snippet')) {
118
-                            $output .= '<li><a id="a_23" href="index.php?a=23" target="main"><i class="fa fa-plus"></i>' . $_lang['new_snippet'] . '</a></li>';
118
+                            $output .= '<li><a id="a_23" href="index.php?a=23" target="main"><i class="fa fa-plus"></i>'.$_lang['new_snippet'].'</a></li>';
119 119
                         }
120 120
 
121 121
                         break;
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
                     case 'element_plugins':
124 124
                         $a = 102;
125 125
                         $sql = $modx->db->query('SELECT t1.*
126
-                        FROM ' . $modx->getFullTableName('site_plugins') . ' AS t1
127
-                        ' . $sqlLike . '
126
+                        FROM ' . $modx->getFullTableName('site_plugins').' AS t1
127
+                        ' . $sqlLike.'
128 128
                         ORDER BY t1.name ASC
129 129
                         ' . $sqlLimit);
130 130
 
131 131
                         if ($modx->hasPermission('new_plugin')) {
132
-                            $output .= '<li><a id="a_101" href="index.php?a=101" target="main"><i class="fa fa-plus"></i>' . $_lang['new_plugin'] . '</a></li>';
132
+                            $output .= '<li><a id="a_101" href="index.php?a=101" target="main"><i class="fa fa-plus"></i>'.$_lang['new_plugin'].'</a></li>';
133 133
                         }
134 134
 
135 135
                         break;
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                             continue;
145 145
                         }
146 146
 
147
-                        $items .= '<li class="item ' . ($row['disabled'] ? 'disabled' : '') . ($row['locked'] ? ' locked' : '') . '"><a id="a_' . $a . '__id_' . $row['id'] . '" href="index.php?a=' . $a . '&id=' . $row['id'] . '" target="main" data-parent-id="a_76__elements_' . $elements . '">' . $row['name'] . ' <small>(' . $row['id'] . ')</small></a></li>' . "\n";
147
+                        $items .= '<li class="item '.($row['disabled'] ? 'disabled' : '').($row['locked'] ? ' locked' : '').'"><a id="a_'.$a.'__id_'.$row['id'].'" href="index.php?a='.$a.'&id='.$row['id'].'" target="main" data-parent-id="a_76__elements_'.$elements.'">'.$row['name'].' <small>('.$row['id'].')</small></a></li>'."\n";
148 148
                     }
149 149
                 }
150 150
 
@@ -165,18 +165,18 @@  discard block
 block discarded – undo
165 165
             $output = '';
166 166
             $items = '';
167 167
             $filter = !empty($_REQUEST['filter']) && is_scalar($_REQUEST['filter']) ? addcslashes(trim($_REQUEST['filter']), '\%*_') : '';
168
-            $sqlLike = $filter ? 'WHERE t1.username LIKE "' . $modx->db->escape($filter) . '%"' : '';
169
-            $sqlLimit = $sqlLike ? '' : 'LIMIT ' . $limit;
168
+            $sqlLike = $filter ? 'WHERE t1.username LIKE "'.$modx->db->escape($filter).'%"' : '';
169
+            $sqlLimit = $sqlLike ? '' : 'LIMIT '.$limit;
170 170
 
171 171
             $sql = $modx->db->query('SELECT t1.*, t1.username AS name, t2.blocked
172
-				FROM ' . $modx->getFullTableName('manager_users') . ' AS t1
173
-				LEFT JOIN ' . $modx->getFullTableName('user_attributes') . ' AS t2 ON t1.id=t2.internalKey
174
-				' . $sqlLike . '
172
+				FROM ' . $modx->getFullTableName('manager_users').' AS t1
173
+				LEFT JOIN ' . $modx->getFullTableName('user_attributes').' AS t2 ON t1.id=t2.internalKey
174
+				' . $sqlLike.'
175 175
 				ORDER BY t1.username ASC
176 176
 				' . $sqlLimit);
177 177
 
178 178
             if ($modx->hasPermission('new_user')) {
179
-                $output .= '<li><a id="a_11" href="index.php?a=11" target="main"><i class="fa fa-plus"></i>' . $_lang['new_user'] . '</a></li>';
179
+                $output .= '<li><a id="a_11" href="index.php?a=11" target="main"><i class="fa fa-plus"></i>'.$_lang['new_user'].'</a></li>';
180 180
             }
181 181
 
182 182
             if ($count = $modx->db->getRecordCount($sql)) {
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                     $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>';
185 185
                 }
186 186
                 while ($row = $modx->db->getRow($sql)) {
187
-                    $items .= '<li class="item ' . ($row['blocked'] ? 'disabled' : '') . '"><a id="a_' . $a . '__id_' . $row['id'] . '" href="index.php?a=' . $a . '&id=' . $row['id'] . '" target="main">' . $row['name'] . ' <small>(' . $row['id'] . ')</small></a></li>';
187
+                    $items .= '<li class="item '.($row['blocked'] ? 'disabled' : '').'"><a id="a_'.$a.'__id_'.$row['id'].'" href="index.php?a='.$a.'&id='.$row['id'].'" target="main">'.$row['name'].' <small>('.$row['id'].')</small></a></li>';
188 188
                 }
189 189
             }
190 190
 
@@ -204,18 +204,18 @@  discard block
 block discarded – undo
204 204
             $output = '';
205 205
             $items = '';
206 206
             $filter = !empty($_REQUEST['filter']) && is_scalar($_REQUEST['filter']) ? addcslashes(trim($_REQUEST['filter']), '\%*_') : '';
207
-            $sqlLike = $filter ? 'WHERE t1.username LIKE "' . $modx->db->escape($filter) . '%"' : '';
208
-            $sqlLimit = $sqlLike ? '' : 'LIMIT ' . $limit;
207
+            $sqlLike = $filter ? 'WHERE t1.username LIKE "'.$modx->db->escape($filter).'%"' : '';
208
+            $sqlLimit = $sqlLike ? '' : 'LIMIT '.$limit;
209 209
 
210 210
             $sql = $modx->db->query('SELECT t1.*, t1.username AS name, t2.blocked
211
-				FROM ' . $modx->getFullTableName('web_users') . ' AS t1
212
-				LEFT JOIN ' . $modx->getFullTableName('web_user_attributes') . ' AS t2 ON t1.id=t2.internalKey
213
-				' . $sqlLike . '
211
+				FROM ' . $modx->getFullTableName('web_users').' AS t1
212
+				LEFT JOIN ' . $modx->getFullTableName('web_user_attributes').' AS t2 ON t1.id=t2.internalKey
213
+				' . $sqlLike.'
214 214
 				ORDER BY t1.username ASC
215 215
 				' . $sqlLimit);
216 216
 
217 217
             if ($modx->hasPermission('new_web_user')) {
218
-                $output .= '<li><a id="a_87" href="index.php?a=87" target="main"><i class="fa fa-plus"></i>' . $_lang['new_web_user'] . '</a></li>';
218
+                $output .= '<li><a id="a_87" href="index.php?a=87" target="main"><i class="fa fa-plus"></i>'.$_lang['new_web_user'].'</a></li>';
219 219
             }
220 220
 
221 221
             if ($count = $modx->db->getRecordCount($sql)) {
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
                     $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>';
224 224
                 }
225 225
                 while ($row = $modx->db->getRow($sql)) {
226
-                    $items .= '<li class="item ' . ($row['blocked'] ? 'disabled' : '') . '"><a id="a_' . $a . '__id_' . $row['id'] . '" href="index.php?a=' . $a . '&id=' . $row['id'] . '" target="main">' . $row['name'] . ' <small>(' . $row['id'] . ')</small></a></li>';
226
+                    $items .= '<li class="item '.($row['blocked'] ? 'disabled' : '').'"><a id="a_'.$a.'__id_'.$row['id'].'" href="index.php?a='.$a.'&id='.$row['id'].'" target="main">'.$row['name'].' <small>('.$row['id'].')</small></a></li>';
227 227
                 }
228 228
             }
229 229
 
@@ -249,35 +249,35 @@  discard block
 block discarded – undo
249 249
                     case 'SnippetNoCache': {
250 250
 
251 251
                         $sql = $modx->db->query('SELECT *
252
-						FROM ' . $modx->getFullTableName('site_snippets') . '
253
-						WHERE name="' . $name . '"
252
+						FROM ' . $modx->getFullTableName('site_snippets').'
253
+						WHERE name="' . $name.'"
254 254
 						LIMIT 1');
255 255
 
256 256
                         if ($modx->db->getRecordCount($sql)) {
257 257
                             $row = $modx->db->getRow($sql);
258 258
                             $contextmenu = array(
259 259
                                 'header' => array(
260
-                                    'innerHTML' => '<i class="fa fa-code"></i> ' . $row['name']
260
+                                    'innerHTML' => '<i class="fa fa-code"></i> '.$row['name']
261 261
                                 ),
262 262
                                 'item' => array(
263
-                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
264
-                                    'url' => "index.php?a=22&id=" . $row['id']
263
+                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> '.$_lang['edit'],
264
+                                    'url' => "index.php?a=22&id=".$row['id']
265 265
                                 )
266 266
                             );
267 267
                             if (!empty($row['description'])) {
268 268
                                 $contextmenu['seperator'] = '';
269 269
                                 $contextmenu['description'] = array(
270
-                                    'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
270
+                                    'innerHTML' => '<i class="fa fa-info"></i> '.$row['description']
271 271
                                 );
272 272
                             }
273 273
                         } else {
274 274
                             $contextmenu = array(
275 275
                                 'header' => array(
276
-                                    'innerHTML' => '<i class="fa fa-code"></i> ' . $name
276
+                                    'innerHTML' => '<i class="fa fa-code"></i> '.$name
277 277
                                 ),
278 278
                                 'item' => array(
279
-                                    'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_snippet'],
280
-                                    'url' => "index.php?a=23&itemname=" . $name
279
+                                    'innerHTML' => '<i class="fa fa-plus"></i> '.$_lang['new_snippet'],
280
+                                    'url' => "index.php?a=23&itemname=".$name
281 281
                                 )
282 282
                             );
283 283
                         }
@@ -287,35 +287,35 @@  discard block
 block discarded – undo
287 287
                     case 'Chunk' : {
288 288
 
289 289
                         $sql = $modx->db->query('SELECT *
290
-						FROM ' . $modx->getFullTableName('site_htmlsnippets') . '
291
-						WHERE name="' . $name . '"
290
+						FROM ' . $modx->getFullTableName('site_htmlsnippets').'
291
+						WHERE name="' . $name.'"
292 292
 						LIMIT 1');
293 293
 
294 294
                         if ($modx->db->getRecordCount($sql)) {
295 295
                             $row = $modx->db->getRow($sql);
296 296
                             $contextmenu = array(
297 297
                                 'header' => array(
298
-                                    'innerHTML' => '<i class="fa fa-th-large"></i> ' . $row['name']
298
+                                    'innerHTML' => '<i class="fa fa-th-large"></i> '.$row['name']
299 299
                                 ),
300 300
                                 'item' => array(
301
-                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
302
-                                    'url' => "index.php?a=78&id=" . $row['id']
301
+                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> '.$_lang['edit'],
302
+                                    'url' => "index.php?a=78&id=".$row['id']
303 303
                                 )
304 304
                             );
305 305
                             if (!empty($row['description'])) {
306 306
                                 $contextmenu['seperator'] = '';
307 307
                                 $contextmenu['description'] = array(
308
-                                    'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
308
+                                    'innerHTML' => '<i class="fa fa-info"></i> '.$row['description']
309 309
                                 );
310 310
                             }
311 311
                         } else {
312 312
                             $contextmenu = array(
313 313
                                 'header' => array(
314
-                                    'innerHTML' => '<i class="fa fa-th-large"></i> ' . $name
314
+                                    'innerHTML' => '<i class="fa fa-th-large"></i> '.$name
315 315
                                 ),
316 316
                                 'item' => array(
317
-                                    'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_htmlsnippet'],
318
-                                    'url' => "index.php?a=77&itemname=" . $name
317
+                                    'innerHTML' => '<i class="fa fa-plus"></i> '.$_lang['new_htmlsnippet'],
318
+                                    'url' => "index.php?a=77&itemname=".$name
319 319
                                 )
320 320
                             );
321 321
                         }
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
                     }
325 325
                     case 'AttributeValue': {
326 326
                         $sql = $modx->db->query('SELECT *
327
-						FROM ' . $modx->getFullTableName('site_htmlsnippets') . '
328
-						WHERE name="' . $name . '"
327
+						FROM ' . $modx->getFullTableName('site_htmlsnippets').'
328
+						WHERE name="' . $name.'"
329 329
 						LIMIT 1');
330 330
 
331 331
                         if ($modx->db->getRecordCount($sql)) {
@@ -335,52 +335,52 @@  discard block
 block discarded – undo
335 335
                                     'innerText' => $row['name']
336 336
                                 ),
337 337
                                 'item' => array(
338
-                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
339
-                                    'url' => "index.php?a=78&id=" . $row['id']
338
+                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> '.$_lang['edit'],
339
+                                    'url' => "index.php?a=78&id=".$row['id']
340 340
                                 )
341 341
                             );
342 342
                             if (!empty($row['description'])) {
343 343
                                 $contextmenu['seperator'] = '';
344 344
                                 $contextmenu['description'] = array(
345
-                                    'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
345
+                                    'innerHTML' => '<i class="fa fa-info"></i> '.$row['description']
346 346
                                 );
347 347
                             }
348 348
                         } else {
349 349
 
350 350
                             $sql = $modx->db->query('SELECT *
351
-							FROM ' . $modx->getFullTableName('site_snippets') . '
352
-							WHERE name="' . $name . '"
351
+							FROM ' . $modx->getFullTableName('site_snippets').'
352
+							WHERE name="' . $name.'"
353 353
 							LIMIT 1');
354 354
 
355 355
                             if ($modx->db->getRecordCount($sql)) {
356 356
                                 $row = $modx->db->getRow($sql);
357 357
                                 $contextmenu = array(
358 358
                                     'header' => array(
359
-                                        'innerHTML' => '<i class="fa fa-code"></i> ' . $row['name']
359
+                                        'innerHTML' => '<i class="fa fa-code"></i> '.$row['name']
360 360
                                     ),
361 361
                                     'item' => array(
362
-                                        'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
363
-                                        'url' => "index.php?a=22&id=" . $row['id']
362
+                                        'innerHTML' => '<i class="fa fa-pencil-square-o"></i> '.$_lang['edit'],
363
+                                        'url' => "index.php?a=22&id=".$row['id']
364 364
                                     )
365 365
                                 );
366 366
                                 if (!empty($row['description'])) {
367 367
                                     $contextmenu['seperator'] = '';
368 368
                                     $contextmenu['description'] = array(
369
-                                        'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
369
+                                        'innerHTML' => '<i class="fa fa-info"></i> '.$row['description']
370 370
                                     );
371 371
                                 }
372 372
                             } else {
373 373
                                 $contextmenu = array(
374 374
                                     'header' => array(
375
-                                        'innerHTML' => '<i class="fa fa-code"></i> ' . $name
375
+                                        'innerHTML' => '<i class="fa fa-code"></i> '.$name
376 376
                                     ),
377 377
                                     'item' => array(
378
-                                        'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_htmlsnippet'],
379
-                                        'url' => "index.php?a=77&itemname=" . $name
378
+                                        'innerHTML' => '<i class="fa fa-plus"></i> '.$_lang['new_htmlsnippet'],
379
+                                        'url' => "index.php?a=77&itemname=".$name
380 380
                                     ),
381 381
                                     'item2' => array(
382
-                                        'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_snippet'],
383
-                                        'url' => "index.php?a=23&itemname=" . $name
382
+                                        'innerHTML' => '<i class="fa fa-plus"></i> '.$_lang['new_snippet'],
383
+                                        'url' => "index.php?a=23&itemname=".$name
384 384
                                     )
385 385
                                 );
386 386
                             }
@@ -436,35 +436,35 @@  discard block
 block discarded – undo
436 436
                         }
437 437
 
438 438
                         $sql = $modx->db->query('SELECT *
439
-						FROM ' . $modx->getFullTableName('site_tmplvars') . '
440
-						WHERE name="' . $name . '"
439
+						FROM ' . $modx->getFullTableName('site_tmplvars').'
440
+						WHERE name="' . $name.'"
441 441
 						LIMIT 1');
442 442
 
443 443
                         if ($modx->db->getRecordCount($sql)) {
444 444
                             $row = $modx->db->getRow($sql);
445 445
                             $contextmenu = array(
446 446
                                 'header' => array(
447
-                                    'innerHTML' => '<i class="fa fa-list-alt"></i> ' . $row['name']
447
+                                    'innerHTML' => '<i class="fa fa-list-alt"></i> '.$row['name']
448 448
                                 ),
449 449
                                 'item' => array(
450
-                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
451
-                                    'url' => "index.php?a=301&id=" . $row['id']
450
+                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> '.$_lang['edit'],
451
+                                    'url' => "index.php?a=301&id=".$row['id']
452 452
                                 )
453 453
                             );
454 454
                             if (!empty($row['description'])) {
455 455
                                 $contextmenu['seperator'] = '';
456 456
                                 $contextmenu['description'] = array(
457
-                                    'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
457
+                                    'innerHTML' => '<i class="fa fa-info"></i> '.$row['description']
458 458
                                 );
459 459
                             }
460 460
                         } else {
461 461
                             $contextmenu = array(
462 462
                                 'header' => array(
463
-                                    'innerHTML' => '<i class="fa fa-list-alt"></i> ' . $name
463
+                                    'innerHTML' => '<i class="fa fa-list-alt"></i> '.$name
464 464
                                 ),
465 465
                                 'item' => array(
466
-                                    'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_tmplvars'],
467
-                                    'url' => "index.php?a=300&itemname=" . $name
466
+                                    'innerHTML' => '<i class="fa fa-plus"></i> '.$_lang['new_tmplvars'],
467
+                                    'url' => "index.php?a=300&itemname=".$name
468 468
                                 )
469 469
                             );
470 470
                         }
@@ -483,15 +483,15 @@  discard block
 block discarded – undo
483 483
             $json = array();
484 484
 
485 485
             if ($modx->hasPermission('new_document') && $modx->hasPermission('edit_document') && $modx->hasPermission('save_document')) {
486
-                $id = !empty($_REQUEST['id']) ? (int)$_REQUEST['id'] : '';
487
-                $parent = isset($_REQUEST['parent']) ? (int)$_REQUEST['parent'] : 0;
486
+                $id = !empty($_REQUEST['id']) ? (int) $_REQUEST['id'] : '';
487
+                $parent = isset($_REQUEST['parent']) ? (int) $_REQUEST['parent'] : 0;
488 488
                 $menuindex = isset($_REQUEST['menuindex']) && is_scalar($_REQUEST['menuindex']) ? $_REQUEST['menuindex'] : 0;
489 489
 
490 490
                 // set parent
491 491
                 if ($id && $parent >= 0) {
492 492
 
493 493
                     // find older parent
494
-                    $parentOld = $modx->db->getValue($modx->db->select('parent', $modx->getFullTableName('site_content'), 'id=' . $id));
494
+                    $parentOld = $modx->db->getValue($modx->db->select('parent', $modx->getFullTableName('site_content'), 'id='.$id));
495 495
 
496 496
                     $eventOut = $modx->invokeEvent('onBeforeMoveDocument', [
497 497
                         'id_document' => $id,
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
                     if (empty($json['errors'])) {
513 513
                         // check privileges user for move docs
514 514
                         if (!empty($modx->config['tree_show_protected']) && $role != 1) {
515
-                            $sql = $modx->db->select('*', $modx->getFullTableName('document_groups'), 'document IN(' . $id . ',' . $parent . ',' . $parentOld . ')');
515
+                            $sql = $modx->db->select('*', $modx->getFullTableName('document_groups'), 'document IN('.$id.','.$parent.','.$parentOld.')');
516 516
                             if ($modx->db->getRecordCount($sql)) {
517 517
                                 $document_groups = array();
518 518
                                 while ($row = $modx->db->getRow($sql)) {
@@ -537,22 +537,22 @@  discard block
 block discarded – undo
537 537
                             // set new parent
538 538
                             $modx->db->update(array(
539 539
                                 'parent' => $parent
540
-                            ), $modx->getFullTableName('site_content'), 'id=' . $id);
540
+                            ), $modx->getFullTableName('site_content'), 'id='.$id);
541 541
                             // set parent isfolder = 1
542 542
                             $modx->db->update(array(
543 543
                                 'isfolder' => 1
544
-                            ), $modx->getFullTableName('site_content'), 'id=' . $parent);
544
+                            ), $modx->getFullTableName('site_content'), 'id='.$parent);
545 545
 
546 546
                             if ($parent != $parentOld) {
547 547
                                 // check children docs and set parent isfolder
548
-                                if ($modx->db->getRecordCount($modx->db->select('id', $modx->getFullTableName('site_content'), 'parent=' . $parentOld))) {
548
+                                if ($modx->db->getRecordCount($modx->db->select('id', $modx->getFullTableName('site_content'), 'parent='.$parentOld))) {
549 549
                                     $modx->db->update(array(
550 550
                                         'isfolder' => 1
551
-                                    ), $modx->getFullTableName('site_content'), 'id=' . $parentOld);
551
+                                    ), $modx->getFullTableName('site_content'), 'id='.$parentOld);
552 552
                                 } else {
553 553
                                     $modx->db->update(array(
554 554
                                         'isfolder' => 0
555
-                                    ), $modx->getFullTableName('site_content'), 'id=' . $parentOld);
555
+                                    ), $modx->getFullTableName('site_content'), 'id='.$parentOld);
556 556
                                 }
557 557
                             }
558 558
 
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
                             if (!empty($menuindex)) {
561 561
                                 $menuindex = explode(',', $menuindex);
562 562
                                 foreach ($menuindex as $key => $value) {
563
-                                    $modx->db->query('UPDATE ' . $modx->getFullTableName('site_content') . ' SET menuindex=' . $key . ' WHERE id=' . $value);
563
+                                    $modx->db->query('UPDATE '.$modx->getFullTableName('site_content').' SET menuindex='.$key.' WHERE id='.$value);
564 564
                                 }
565 565
                             } else {
566 566
                                 // TODO: max(*) menuindex
@@ -589,19 +589,19 @@  discard block
 block discarded – undo
589 589
         }
590 590
 
591 591
         case 'getLockedElements': {
592
-            $type = isset($_REQUEST['type']) ? (int)$_REQUEST['type'] : 0;
593
-            $id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
592
+            $type = isset($_REQUEST['type']) ? (int) $_REQUEST['type'] : 0;
593
+            $id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
594 594
 
595 595
             $output = !!$modx->elementIsLocked($type, $id, true);
596 596
 
597 597
             if (!$output) {
598 598
                 $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : '';
599
-                $docgrp_cond = $docgrp ? ' OR dg.document_group IN (' . $docgrp . ')' : '';
599
+                $docgrp_cond = $docgrp ? ' OR dg.document_group IN ('.$docgrp.')' : '';
600 600
                 $sql = '
601
-                    SELECT MAX(IF(1=' . $role . ' OR sc.privatemgr=0' . $docgrp_cond . ', 0, 1)) AS locked
602
-                    FROM ' . $modx->getFullTableName('site_content') . ' AS sc 
603
-                    LEFT JOIN ' . $modx->getFullTableName('document_groups') . ' dg ON dg.document=sc.id
604
-                    WHERE sc.id=' . $id . ' GROUP BY sc.id';
601
+                    SELECT MAX(IF(1=' . $role.' OR sc.privatemgr=0'.$docgrp_cond.', 0, 1)) AS locked
602
+                    FROM ' . $modx->getFullTableName('site_content').' AS sc 
603
+                    LEFT JOIN ' . $modx->getFullTableName('document_groups').' dg ON dg.document=sc.id
604
+                    WHERE sc.id=' . $id.' GROUP BY sc.id';
605 605
                 $sql = $modx->db->query($sql);
606 606
                 if ($modx->db->getRecordCount($sql)) {
607 607
                     $row = $modx->db->getRow($sql);
Please login to merge, or discard this patch.