Completed
Push — develop ( b0abe3...be20f3 )
by Serg
13:48
created
manager/media/style/default/ajax.php 1 patch
Spacing   +99 added lines, -99 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.id, t1.templatename AS name, t1.locked, 0 AS disabled
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,15 +80,15 @@  discard block
 block discarded – undo
80 80
                     case 'element_tplvars':
81 81
                         $a = 301;
82 82
                         $sql = $modx->db->query('SELECT t1.id, t1.name, t1.locked, IF(MIN(t2.tmplvarid),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
                         GROUP BY t1.id
87 87
                         ORDER BY t1.name ASC
88 88
                         ' . $sqlLimit);
89 89
 
90 90
                         if ($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
91
-                            $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
+                            $output .= '<li><a id="a_300" href="index.php?a=300" target="main"><i class="fa fa-plus"></i>'.$_lang['new_tmplvars'].'</a></li>';
92 92
                         }
93 93
 
94 94
                         break;
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
                     case 'element_htmlsnippets':
97 97
                         $a = 78;
98 98
                         $sql = $modx->db->query('SELECT t1.id, t1.name, t1.locked, t1.disabled
99
-                        FROM ' . $modx->getFullTableName('site_htmlsnippets') . ' AS t1
100
-                        ' . $sqlLike . '
99
+                        FROM ' . $modx->getFullTableName('site_htmlsnippets').' AS t1
100
+                        ' . $sqlLike.'
101 101
                         ORDER BY t1.name ASC
102 102
                         ' . $sqlLimit);
103 103
 
104 104
                         if ($modx->hasPermission('new_chunk')) {
105
-                            $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
+                            $output .= '<li><a id="a_77" href="index.php?a=77" target="main"><i class="fa fa-plus"></i>'.$_lang['new_htmlsnippet'].'</a></li>';
106 106
                         }
107 107
 
108 108
                         break;
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
                     case 'element_snippets':
111 111
                         $a = 22;
112 112
                         $sql = $modx->db->query('SELECT t1.id, t1.name, t1.locked, t1.disabled
113
-                        FROM ' . $modx->getFullTableName('site_snippets') . ' AS t1
114
-                        ' . $sqlLike . '
113
+                        FROM ' . $modx->getFullTableName('site_snippets').' AS t1
114
+                        ' . $sqlLike.'
115 115
                         ORDER BY t1.name ASC
116 116
                         ' . $sqlLimit);
117 117
 
118 118
                         if ($modx->hasPermission('new_snippet')) {
119
-                            $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
+                            $output .= '<li><a id="a_23" href="index.php?a=23" target="main"><i class="fa fa-plus"></i>'.$_lang['new_snippet'].'</a></li>';
120 120
                         }
121 121
 
122 122
                         break;
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
                     case 'element_plugins':
125 125
                         $a = 102;
126 126
                         $sql = $modx->db->query('SELECT t1.id, t1.name, t1.locked, t1.disabled
127
-                        FROM ' . $modx->getFullTableName('site_plugins') . ' AS t1
128
-                        ' . $sqlLike . '
127
+                        FROM ' . $modx->getFullTableName('site_plugins').' AS t1
128
+                        ' . $sqlLike.'
129 129
                         ORDER BY t1.name ASC
130 130
                         ' . $sqlLimit);
131 131
 
132 132
                         if ($modx->hasPermission('new_plugin')) {
133
-                            $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
+                            $output .= '<li><a id="a_101" href="index.php?a=101" target="main"><i class="fa fa-plus"></i>'.$_lang['new_plugin'].'</a></li>';
134 134
                         }
135 135
 
136 136
                         break;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                             continue;
146 146
                         }
147 147
 
148
-                        $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
+                        $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";
149 149
                     }
150 150
                 }
151 151
 
@@ -166,23 +166,23 @@  discard block
 block discarded – undo
166 166
             $output = '';
167 167
             $items = '';
168 168
             $filter = !empty($_REQUEST['filter']) && is_scalar($_REQUEST['filter']) ? addcslashes(trim($_REQUEST['filter']), '\%*_') : '';
169
-            $sqlLike = $filter ? 'WHERE t1.username LIKE "' . $modx->db->escape($filter) . '%"' : '';
170
-            $sqlLimit = $sqlLike ? '' : 'LIMIT ' . $limit;
169
+            $sqlLike = $filter ? 'WHERE t1.username LIKE "'.$modx->db->escape($filter).'%"' : '';
170
+            $sqlLimit = $sqlLike ? '' : 'LIMIT '.$limit;
171 171
 
172
-            if(!$modx->hasPermission('save_role')) {
172
+            if (!$modx->hasPermission('save_role')) {
173 173
                 $sqlLike .= $sqlLike ? ' AND ' : 'WHERE ';
174 174
                 $sqlLike .= 't2.role != 1';
175 175
             }
176 176
 
177 177
             $sql = $modx->db->query('SELECT t1.*, t1.username AS name, t2.blocked
178
-				FROM ' . $modx->getFullTableName('manager_users') . ' AS t1
179
-				LEFT JOIN ' . $modx->getFullTableName('user_attributes') . ' AS t2 ON t1.id=t2.internalKey
180
-				' . $sqlLike . '
178
+				FROM ' . $modx->getFullTableName('manager_users').' AS t1
179
+				LEFT JOIN ' . $modx->getFullTableName('user_attributes').' AS t2 ON t1.id=t2.internalKey
180
+				' . $sqlLike.'
181 181
 				ORDER BY t1.username ASC
182 182
 				' . $sqlLimit);
183 183
 
184 184
             if ($modx->hasPermission('new_user')) {
185
-                $output .= '<li><a id="a_11" href="index.php?a=11" target="main"><i class="fa fa-plus"></i>' . $_lang['new_user'] . '</a></li>';
185
+                $output .= '<li><a id="a_11" href="index.php?a=11" target="main"><i class="fa fa-plus"></i>'.$_lang['new_user'].'</a></li>';
186 186
             }
187 187
 
188 188
             if ($count = $modx->db->getRecordCount($sql)) {
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
                     $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>';
191 191
                 }
192 192
                 while ($row = $modx->db->getRow($sql)) {
193
-                    $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>';
193
+                    $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>';
194 194
                 }
195 195
             }
196 196
 
@@ -210,18 +210,18 @@  discard block
 block discarded – undo
210 210
             $output = '';
211 211
             $items = '';
212 212
             $filter = !empty($_REQUEST['filter']) && is_scalar($_REQUEST['filter']) ? addcslashes(trim($_REQUEST['filter']), '\%*_') : '';
213
-            $sqlLike = $filter ? 'WHERE t1.username LIKE "' . $modx->db->escape($filter) . '%"' : '';
214
-            $sqlLimit = $sqlLike ? '' : 'LIMIT ' . $limit;
213
+            $sqlLike = $filter ? 'WHERE t1.username LIKE "'.$modx->db->escape($filter).'%"' : '';
214
+            $sqlLimit = $sqlLike ? '' : 'LIMIT '.$limit;
215 215
 
216 216
             $sql = $modx->db->query('SELECT t1.*, t1.username AS name, t2.blocked
217
-				FROM ' . $modx->getFullTableName('web_users') . ' AS t1
218
-				LEFT JOIN ' . $modx->getFullTableName('web_user_attributes') . ' AS t2 ON t1.id=t2.internalKey
219
-				' . $sqlLike . '
217
+				FROM ' . $modx->getFullTableName('web_users').' AS t1
218
+				LEFT JOIN ' . $modx->getFullTableName('web_user_attributes').' AS t2 ON t1.id=t2.internalKey
219
+				' . $sqlLike.'
220 220
 				ORDER BY t1.username ASC
221 221
 				' . $sqlLimit);
222 222
 
223 223
             if ($modx->hasPermission('new_web_user')) {
224
-                $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>';
224
+                $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>';
225 225
             }
226 226
 
227 227
             if ($count = $modx->db->getRecordCount($sql)) {
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
                     $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>';
230 230
                 }
231 231
                 while ($row = $modx->db->getRow($sql)) {
232
-                    $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>';
232
+                    $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>';
233 233
                 }
234 234
             }
235 235
 
@@ -255,35 +255,35 @@  discard block
 block discarded – undo
255 255
                     case 'SnippetNoCache': {
256 256
 
257 257
                         $sql = $modx->db->query('SELECT *
258
-						FROM ' . $modx->getFullTableName('site_snippets') . '
259
-						WHERE name="' . $name . '"
258
+						FROM ' . $modx->getFullTableName('site_snippets').'
259
+						WHERE name="' . $name.'"
260 260
 						LIMIT 1');
261 261
 
262 262
                         if ($modx->db->getRecordCount($sql)) {
263 263
                             $row = $modx->db->getRow($sql);
264 264
                             $contextmenu = array(
265 265
                                 'header' => array(
266
-                                    'innerHTML' => '<i class="fa fa-code"></i> ' . $row['name']
266
+                                    'innerHTML' => '<i class="fa fa-code"></i> '.$row['name']
267 267
                                 ),
268 268
                                 'item' => array(
269
-                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
270
-                                    'url' => "index.php?a=22&id=" . $row['id']
269
+                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> '.$_lang['edit'],
270
+                                    'url' => "index.php?a=22&id=".$row['id']
271 271
                                 )
272 272
                             );
273 273
                             if (!empty($row['description'])) {
274 274
                                 $contextmenu['seperator'] = '';
275 275
                                 $contextmenu['description'] = array(
276
-                                    'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
276
+                                    'innerHTML' => '<i class="fa fa-info"></i> '.$row['description']
277 277
                                 );
278 278
                             }
279 279
                         } else {
280 280
                             $contextmenu = array(
281 281
                                 'header' => array(
282
-                                    'innerHTML' => '<i class="fa fa-code"></i> ' . $name
282
+                                    'innerHTML' => '<i class="fa fa-code"></i> '.$name
283 283
                                 ),
284 284
                                 'item' => array(
285
-                                    'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_snippet'],
286
-                                    'url' => "index.php?a=23&itemname=" . $name
285
+                                    'innerHTML' => '<i class="fa fa-plus"></i> '.$_lang['new_snippet'],
286
+                                    'url' => "index.php?a=23&itemname=".$name
287 287
                                 )
288 288
                             );
289 289
                         }
@@ -293,35 +293,35 @@  discard block
 block discarded – undo
293 293
                     case 'Chunk' : {
294 294
 
295 295
                         $sql = $modx->db->query('SELECT *
296
-						FROM ' . $modx->getFullTableName('site_htmlsnippets') . '
297
-						WHERE name="' . $name . '"
296
+						FROM ' . $modx->getFullTableName('site_htmlsnippets').'
297
+						WHERE name="' . $name.'"
298 298
 						LIMIT 1');
299 299
 
300 300
                         if ($modx->db->getRecordCount($sql)) {
301 301
                             $row = $modx->db->getRow($sql);
302 302
                             $contextmenu = array(
303 303
                                 'header' => array(
304
-                                    'innerHTML' => '<i class="fa fa-th-large"></i> ' . $row['name']
304
+                                    'innerHTML' => '<i class="fa fa-th-large"></i> '.$row['name']
305 305
                                 ),
306 306
                                 'item' => array(
307
-                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
308
-                                    'url' => "index.php?a=78&id=" . $row['id']
307
+                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> '.$_lang['edit'],
308
+                                    'url' => "index.php?a=78&id=".$row['id']
309 309
                                 )
310 310
                             );
311 311
                             if (!empty($row['description'])) {
312 312
                                 $contextmenu['seperator'] = '';
313 313
                                 $contextmenu['description'] = array(
314
-                                    'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
314
+                                    'innerHTML' => '<i class="fa fa-info"></i> '.$row['description']
315 315
                                 );
316 316
                             }
317 317
                         } else {
318 318
                             $contextmenu = array(
319 319
                                 'header' => array(
320
-                                    'innerHTML' => '<i class="fa fa-th-large"></i> ' . $name
320
+                                    'innerHTML' => '<i class="fa fa-th-large"></i> '.$name
321 321
                                 ),
322 322
                                 'item' => array(
323
-                                    'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_htmlsnippet'],
324
-                                    'url' => "index.php?a=77&itemname=" . $name
323
+                                    'innerHTML' => '<i class="fa fa-plus"></i> '.$_lang['new_htmlsnippet'],
324
+                                    'url' => "index.php?a=77&itemname=".$name
325 325
                                 )
326 326
                             );
327 327
                         }
@@ -330,8 +330,8 @@  discard block
 block discarded – undo
330 330
                     }
331 331
                     case 'AttributeValue': {
332 332
                         $sql = $modx->db->query('SELECT *
333
-						FROM ' . $modx->getFullTableName('site_htmlsnippets') . '
334
-						WHERE name="' . $name . '"
333
+						FROM ' . $modx->getFullTableName('site_htmlsnippets').'
334
+						WHERE name="' . $name.'"
335 335
 						LIMIT 1');
336 336
 
337 337
                         if ($modx->db->getRecordCount($sql)) {
@@ -341,52 +341,52 @@  discard block
 block discarded – undo
341 341
                                     'innerText' => $row['name']
342 342
                                 ),
343 343
                                 'item' => array(
344
-                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
345
-                                    'url' => "index.php?a=78&id=" . $row['id']
344
+                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> '.$_lang['edit'],
345
+                                    'url' => "index.php?a=78&id=".$row['id']
346 346
                                 )
347 347
                             );
348 348
                             if (!empty($row['description'])) {
349 349
                                 $contextmenu['seperator'] = '';
350 350
                                 $contextmenu['description'] = array(
351
-                                    'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
351
+                                    'innerHTML' => '<i class="fa fa-info"></i> '.$row['description']
352 352
                                 );
353 353
                             }
354 354
                         } else {
355 355
 
356 356
                             $sql = $modx->db->query('SELECT *
357
-							FROM ' . $modx->getFullTableName('site_snippets') . '
358
-							WHERE name="' . $name . '"
357
+							FROM ' . $modx->getFullTableName('site_snippets').'
358
+							WHERE name="' . $name.'"
359 359
 							LIMIT 1');
360 360
 
361 361
                             if ($modx->db->getRecordCount($sql)) {
362 362
                                 $row = $modx->db->getRow($sql);
363 363
                                 $contextmenu = array(
364 364
                                     'header' => array(
365
-                                        'innerHTML' => '<i class="fa fa-code"></i> ' . $row['name']
365
+                                        'innerHTML' => '<i class="fa fa-code"></i> '.$row['name']
366 366
                                     ),
367 367
                                     'item' => array(
368
-                                        'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
369
-                                        'url' => "index.php?a=22&id=" . $row['id']
368
+                                        'innerHTML' => '<i class="fa fa-pencil-square-o"></i> '.$_lang['edit'],
369
+                                        'url' => "index.php?a=22&id=".$row['id']
370 370
                                     )
371 371
                                 );
372 372
                                 if (!empty($row['description'])) {
373 373
                                     $contextmenu['seperator'] = '';
374 374
                                     $contextmenu['description'] = array(
375
-                                        'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
375
+                                        'innerHTML' => '<i class="fa fa-info"></i> '.$row['description']
376 376
                                     );
377 377
                                 }
378 378
                             } else {
379 379
                                 $contextmenu = array(
380 380
                                     'header' => array(
381
-                                        'innerHTML' => '<i class="fa fa-code"></i> ' . $name
381
+                                        'innerHTML' => '<i class="fa fa-code"></i> '.$name
382 382
                                     ),
383 383
                                     'item' => array(
384
-                                        'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_htmlsnippet'],
385
-                                        'url' => "index.php?a=77&itemname=" . $name
384
+                                        'innerHTML' => '<i class="fa fa-plus"></i> '.$_lang['new_htmlsnippet'],
385
+                                        'url' => "index.php?a=77&itemname=".$name
386 386
                                     ),
387 387
                                     'item2' => array(
388
-                                        'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_snippet'],
389
-                                        'url' => "index.php?a=23&itemname=" . $name
388
+                                        'innerHTML' => '<i class="fa fa-plus"></i> '.$_lang['new_snippet'],
389
+                                        'url' => "index.php?a=23&itemname=".$name
390 390
                                     )
391 391
                                 );
392 392
                             }
@@ -442,35 +442,35 @@  discard block
 block discarded – undo
442 442
                         }
443 443
 
444 444
                         $sql = $modx->db->query('SELECT *
445
-						FROM ' . $modx->getFullTableName('site_tmplvars') . '
446
-						WHERE name="' . $name . '"
445
+						FROM ' . $modx->getFullTableName('site_tmplvars').'
446
+						WHERE name="' . $name.'"
447 447
 						LIMIT 1');
448 448
 
449 449
                         if ($modx->db->getRecordCount($sql)) {
450 450
                             $row = $modx->db->getRow($sql);
451 451
                             $contextmenu = array(
452 452
                                 'header' => array(
453
-                                    'innerHTML' => '<i class="fa fa-list-alt"></i> ' . $row['name']
453
+                                    'innerHTML' => '<i class="fa fa-list-alt"></i> '.$row['name']
454 454
                                 ),
455 455
                                 'item' => array(
456
-                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
457
-                                    'url' => "index.php?a=301&id=" . $row['id']
456
+                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> '.$_lang['edit'],
457
+                                    'url' => "index.php?a=301&id=".$row['id']
458 458
                                 )
459 459
                             );
460 460
                             if (!empty($row['description'])) {
461 461
                                 $contextmenu['seperator'] = '';
462 462
                                 $contextmenu['description'] = array(
463
-                                    'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
463
+                                    'innerHTML' => '<i class="fa fa-info"></i> '.$row['description']
464 464
                                 );
465 465
                             }
466 466
                         } else {
467 467
                             $contextmenu = array(
468 468
                                 'header' => array(
469
-                                    'innerHTML' => '<i class="fa fa-list-alt"></i> ' . $name
469
+                                    'innerHTML' => '<i class="fa fa-list-alt"></i> '.$name
470 470
                                 ),
471 471
                                 'item' => array(
472
-                                    'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_tmplvars'],
473
-                                    'url' => "index.php?a=300&itemname=" . $name
472
+                                    'innerHTML' => '<i class="fa fa-plus"></i> '.$_lang['new_tmplvars'],
473
+                                    'url' => "index.php?a=300&itemname=".$name
474 474
                                 )
475 475
                             );
476 476
                         }
@@ -489,15 +489,15 @@  discard block
 block discarded – undo
489 489
             $json = array();
490 490
 
491 491
             if ($modx->hasPermission('new_document') && $modx->hasPermission('edit_document') && $modx->hasPermission('save_document')) {
492
-                $id = !empty($_REQUEST['id']) ? (int)$_REQUEST['id'] : '';
493
-                $parent = isset($_REQUEST['parent']) ? (int)$_REQUEST['parent'] : 0;
492
+                $id = !empty($_REQUEST['id']) ? (int) $_REQUEST['id'] : '';
493
+                $parent = isset($_REQUEST['parent']) ? (int) $_REQUEST['parent'] : 0;
494 494
                 $menuindex = isset($_REQUEST['menuindex']) && is_scalar($_REQUEST['menuindex']) ? $_REQUEST['menuindex'] : 0;
495 495
 
496 496
                 // set parent
497 497
                 if ($id && $parent >= 0) {
498 498
 
499 499
                     // find older parent
500
-                    $parentOld = $modx->db->getValue($modx->db->select('parent', $modx->getFullTableName('site_content'), 'id=' . $id));
500
+                    $parentOld = $modx->db->getValue($modx->db->select('parent', $modx->getFullTableName('site_content'), 'id='.$id));
501 501
 
502 502
                     $eventOut = $modx->invokeEvent('onBeforeMoveDocument', [
503 503
                         'id_document' => $id,
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
                     if (empty($json['errors'])) {
519 519
                         // check privileges user for move docs
520 520
                         if (!empty($modx->config['tree_show_protected']) && $role != 1) {
521
-                            $sql = $modx->db->select('*', $modx->getFullTableName('document_groups'), 'document IN(' . $id . ',' . $parent . ',' . $parentOld . ')');
521
+                            $sql = $modx->db->select('*', $modx->getFullTableName('document_groups'), 'document IN('.$id.','.$parent.','.$parentOld.')');
522 522
                             if ($modx->db->getRecordCount($sql)) {
523 523
                                 $document_groups = array();
524 524
                                 while ($row = $modx->db->getRow($sql)) {
@@ -543,22 +543,22 @@  discard block
 block discarded – undo
543 543
                             // set new parent
544 544
                             $modx->db->update(array(
545 545
                                 'parent' => $parent
546
-                            ), $modx->getFullTableName('site_content'), 'id=' . $id);
546
+                            ), $modx->getFullTableName('site_content'), 'id='.$id);
547 547
                             // set parent isfolder = 1
548 548
                             $modx->db->update(array(
549 549
                                 'isfolder' => 1
550
-                            ), $modx->getFullTableName('site_content'), 'id=' . $parent);
550
+                            ), $modx->getFullTableName('site_content'), 'id='.$parent);
551 551
 
552 552
                             if ($parent != $parentOld) {
553 553
                                 // check children docs and set parent isfolder
554
-                                if ($modx->db->getRecordCount($modx->db->select('id', $modx->getFullTableName('site_content'), 'parent=' . $parentOld))) {
554
+                                if ($modx->db->getRecordCount($modx->db->select('id', $modx->getFullTableName('site_content'), 'parent='.$parentOld))) {
555 555
                                     $modx->db->update(array(
556 556
                                         'isfolder' => 1
557
-                                    ), $modx->getFullTableName('site_content'), 'id=' . $parentOld);
557
+                                    ), $modx->getFullTableName('site_content'), 'id='.$parentOld);
558 558
                                 } else {
559 559
                                     $modx->db->update(array(
560 560
                                         'isfolder' => 0
561
-                                    ), $modx->getFullTableName('site_content'), 'id=' . $parentOld);
561
+                                    ), $modx->getFullTableName('site_content'), 'id='.$parentOld);
562 562
                                 }
563 563
                             }
564 564
 
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
                             if (!empty($menuindex)) {
567 567
                                 $menuindex = explode(',', $menuindex);
568 568
                                 foreach ($menuindex as $key => $value) {
569
-                                    $modx->db->query('UPDATE ' . $modx->getFullTableName('site_content') . ' SET menuindex=' . $key . ' WHERE id=' . $value);
569
+                                    $modx->db->query('UPDATE '.$modx->getFullTableName('site_content').' SET menuindex='.$key.' WHERE id='.$value);
570 570
                                 }
571 571
                             } else {
572 572
                                 // TODO: max(*) menuindex
@@ -595,19 +595,19 @@  discard block
 block discarded – undo
595 595
         }
596 596
 
597 597
         case 'getLockedElements': {
598
-            $type = isset($_REQUEST['type']) ? (int)$_REQUEST['type'] : 0;
599
-            $id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
598
+            $type = isset($_REQUEST['type']) ? (int) $_REQUEST['type'] : 0;
599
+            $id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
600 600
 
601 601
             $output = !!$modx->elementIsLocked($type, $id, true);
602 602
 
603 603
             if (!$output) {
604 604
                 $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : '';
605
-                $docgrp_cond = $docgrp ? ' OR dg.document_group IN (' . $docgrp . ')' : '';
605
+                $docgrp_cond = $docgrp ? ' OR dg.document_group IN ('.$docgrp.')' : '';
606 606
                 $sql = '
607
-                    SELECT MAX(IF(1=' . $role . ' OR sc.privatemgr=0' . $docgrp_cond . ', 0, 1)) AS locked
608
-                    FROM ' . $modx->getFullTableName('site_content') . ' AS sc 
609
-                    LEFT JOIN ' . $modx->getFullTableName('document_groups') . ' dg ON dg.document=sc.id
610
-                    WHERE sc.id=' . $id . ' GROUP BY sc.id';
607
+                    SELECT MAX(IF(1=' . $role.' OR sc.privatemgr=0'.$docgrp_cond.', 0, 1)) AS locked
608
+                    FROM ' . $modx->getFullTableName('site_content').' AS sc 
609
+                    LEFT JOIN ' . $modx->getFullTableName('document_groups').' dg ON dg.document=sc.id
610
+                    WHERE sc.id=' . $id.' GROUP BY sc.id';
611 611
                 $sql = $modx->db->query($sql);
612 612
                 if ($modx->db->getRecordCount($sql)) {
613 613
                     $row = $modx->db->getRow($sql);
Please login to merge, or discard this patch.