| 1 |  |  | <?php
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | define('MODX_API_MODE', true);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | define('IN_MANAGER_MODE', true);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | include_once("./../../../../index.php");
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | $modx->db->connect();
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | if (empty ($modx->config)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     $modx->getSettings();
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | if (!isset($_SESSION['mgrValidated']) || !isset($_SERVER['HTTP_X_REQUESTED_WITH']) || (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') || ($_SERVER['REQUEST_METHOD'] != 'POST')) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     $modx->sendErrorPage();
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | $modx->sid = session_id();
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | $modx->loadExtension("ManagerAPI");
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | extract($modx->config, EXTR_OVERWRITE); // For correct function of native processors
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | $_lang = array();
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | include_once MODX_MANAGER_PATH . '/includes/lang/english.inc.php';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | if ($modx->config['manager_language'] != 'english') {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     include_once MODX_MANAGER_PATH . '/includes/lang/' . $modx->config['manager_language'] . '.inc.php';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | include_once MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/style.php';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | $action = isset($_REQUEST['a']) ? $_REQUEST['a'] : '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | $frame = isset($_REQUEST['f']) ? $_REQUEST['f'] : '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | $role = isset($_SESSION['mgrRole']) && $_SESSION['mgrRole'] == 1 ? 1 : 0;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | $docGroups = isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups']) ? implode(',', $_SESSION['mgrDocgroups']) : '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | // set limit sql query
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | $limit = !empty($modx->config['number_of_results']) ? (int) $modx->config['number_of_results'] : 100;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | $json = array();
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | if (isset($action)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     switch ($action) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         case '1': {
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |             switch ($frame) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |                 case 'nodes':
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |                     include_once MODX_MANAGER_PATH . '/frames/nodes.php';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |                     break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         case '76': {
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             $elements = isset($_REQUEST['elements']) && is_scalar($_REQUEST['elements']) ? htmlentities($_REQUEST['elements']) : '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             if ($elements) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |                 $output = '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |                 $items = '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |                 $sql = '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |                 $a = '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |                 $filter = !empty($_REQUEST['filter']) && is_scalar($_REQUEST['filter']) ? addcslashes(trim($_REQUEST['filter']), '%*_') : '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |                 $sqlLike = $filter ? 'WHERE t1.name LIKE "' . $modx->db->escape($filter) . '%"' : '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |                 $sqlLimit = $sqlLike ? '' : 'LIMIT ' . $limit;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |                 switch ($elements) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |                     case 'element_templates':
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |                         $a = 16;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |                         $sqlLike = $filter ? 'WHERE t1.templatename LIKE "' . $modx->db->escape($filter) . '%"' : '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |                         $sql = $modx->db->query('SELECT t1.*, t1.templatename AS name
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |                         FROM ' . $modx->getFullTableName('site_templates') . ' AS t1
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |                         ' . $sqlLike . '
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                         ORDER BY t1.templatename ASC
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |                         ' . $sqlLimit);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |                         if ($modx->hasPermission('new_template')) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |                             $output .= '<li><a id="a_19" href="index.php?a=19" target="main"><i class="fa fa-plus"></i>' . $_lang['new_template'] . '</a></li>';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |                         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |                         break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |                     case 'element_tplvars':
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |                         $a = 301;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |                         $sql = $modx->db->query('SELECT t1.*, IF(t2.templateid,0,1) AS disabled
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |                         FROM ' . $modx->getFullTableName('site_tmplvars') . ' AS t1
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |                         LEFT JOIN ' . $modx->getFullTableName('site_tmplvar_templates') . ' AS t2 ON t1.id=t2.tmplvarid
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |                         ' . $sqlLike . '
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |                         GROUP BY t1.id
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |                         ORDER BY t1.name ASC
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |                         ' . $sqlLimit);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |                         if ($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |                             $output .= '<li><a id="a_300" href="index.php?a=300" target="main"><i class="fa fa-plus"></i>' . $_lang['new_tmplvars'] . '</a></li>';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |                         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |                         break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 
 | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 99 |  | View Code Duplication |                     case 'element_htmlsnippets':
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |                         $a = 78;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |                         $sql = $modx->db->query('SELECT t1.*
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |                         FROM ' . $modx->getFullTableName('site_htmlsnippets') . ' AS t1
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |                         ' . $sqlLike . '
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |                         ORDER BY t1.name ASC
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |                         ' . $sqlLimit);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |                         if ($modx->hasPermission('new_chunk')) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |                             $output .= '<li><a id="a_77" href="index.php?a=77" target="main"><i class="fa fa-plus"></i>' . $_lang['new_htmlsnippet'] . '</a></li>';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |                         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |                         break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 
 | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 113 |  | View Code Duplication |                     case 'element_snippets':
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |                         $a = 22;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |                         $sql = $modx->db->query('SELECT t1.*
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |                         FROM ' . $modx->getFullTableName('site_snippets') . ' AS t1
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |                         ' . $sqlLike . '
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |                         ORDER BY t1.name ASC
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |                         ' . $sqlLimit);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |                         if ($modx->hasPermission('new_snippet')) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |                             $output .= '<li><a id="a_23" href="index.php?a=23" target="main"><i class="fa fa-plus"></i>' . $_lang['new_snippet'] . '</a></li>';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |                         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |                         break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 
 | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 127 |  | View Code Duplication |                     case 'element_plugins':
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |                         $a = 102;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |                         $sql = $modx->db->query('SELECT t1.*
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |                         FROM ' . $modx->getFullTableName('site_plugins') . ' AS t1
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |                         ' . $sqlLike . '
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |                         ORDER BY t1.name ASC
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |                         ' . $sqlLimit);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |                         if ($modx->hasPermission('new_plugin')) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |                             $output .= '<li><a id="a_101" href="index.php?a=101" target="main"><i class="fa fa-plus"></i>' . $_lang['new_plugin'] . '</a></li>';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |                         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |                         break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |                 }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |                 if ($count = $modx->db->getRecordCount($sql)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |                     if ($count == $limit) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |                         $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |                     }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |                     while ($row = $modx->db->getRow($sql)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |                         if (($row['disabled'] || $row['locked']) && $role != 1) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |                             continue;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |                         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |                         $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";
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |                     }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |                 }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |                 if (isset($_REQUEST['filter'])) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |                     $output = $items;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |                 } else {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |                     $output .= $items;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |                 }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |                 echo $output;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |             break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 
 | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 167 |  | View Code Duplication |         case '75': {
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |             $a = 12;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |             $output = '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |             $items = '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |             $filter = !empty($_REQUEST['filter']) && is_scalar($_REQUEST['filter']) ? addcslashes(trim($_REQUEST['filter']), '\%*_') : '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |             $sqlLike = $filter ? 'WHERE t1.username LIKE "' . $modx->db->escape($filter) . '%"' : '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |             $sqlLimit = $sqlLike ? '' : 'LIMIT ' . $limit;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |             $sql = $modx->db->query('SELECT t1.*, t1.username AS name, t2.blocked
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 				FROM ' . $modx->getFullTableName('manager_users') . ' AS t1
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 				LEFT JOIN ' . $modx->getFullTableName('user_attributes') . ' AS t2 ON t1.id=t2.internalKey
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 				' . $sqlLike . '
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 				ORDER BY t1.username ASC
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 				' . $sqlLimit);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |             if ($modx->hasPermission('new_user')) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |                 $output .= '<li><a id="a_11" href="index.php?a=11" target="main"><i class="fa fa-plus"></i>' . $_lang['new_user'] . '</a></li>';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |             if ($count = $modx->db->getRecordCount($sql)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |                 if ($count == $limit) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |                     $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |                 }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |                 while ($row = $modx->db->getRow($sql)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |                     $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>';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |                 }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |             if (isset($_REQUEST['filter'])) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |                 $output = $items;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             } else {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |                 $output .= $items;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |             echo $output;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |             break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 
 | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 206 |  | View Code Duplication |         case '99': {
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |             $a = 88;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |             $output = '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |             $items = '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |             $filter = !empty($_REQUEST['filter']) && is_scalar($_REQUEST['filter']) ? addcslashes(trim($_REQUEST['filter']), '\%*_') : '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |             $sqlLike = $filter ? 'WHERE t1.username LIKE "' . $modx->db->escape($filter) . '%"' : '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |             $sqlLimit = $sqlLike ? '' : 'LIMIT ' . $limit;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |             $sql = $modx->db->query('SELECT t1.*, t1.username AS name, t2.blocked
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  | 				FROM ' . $modx->getFullTableName('web_users') . ' AS t1
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 				LEFT JOIN ' . $modx->getFullTableName('web_user_attributes') . ' AS t2 ON t1.id=t2.internalKey
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 				' . $sqlLike . '
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 				ORDER BY t1.username ASC
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 				' . $sqlLimit);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |             if ($modx->hasPermission('new_web_user')) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |                 $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>';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |             if ($count = $modx->db->getRecordCount($sql)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |                 if ($count == $limit) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |                     $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |                 }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |                 while ($row = $modx->db->getRow($sql)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |                     $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>';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |                 }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |             if (isset($_REQUEST['filter'])) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |                 $output = $items;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |             } else {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |                 $output .= $items;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |             echo $output;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |             break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |         case 'modxTagHelper': {
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |             $name = isset($_REQUEST['name']) && is_scalar($_REQUEST['name']) ? $modx->db->escape($_REQUEST['name']) : false;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |             $type = isset($_REQUEST['type']) && is_scalar($_REQUEST['type']) ? $modx->db->escape($_REQUEST['type']) : false;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |             $contextmenu = '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |             if ($role && $name && $type) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |                 switch ($type) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |                     case 'Snippet':
 | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 253 |  | View Code Duplication |                     case 'SnippetNoCache': {
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |                         $sql = $modx->db->query('SELECT *
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  | 						FROM ' . $modx->getFullTableName('site_snippets') . '
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 						WHERE name="' . $name . '"
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 						LIMIT 1');
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |                         if ($modx->db->getRecordCount($sql)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |                             $row = $modx->db->getRow($sql);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |                             $contextmenu = array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |                                 'header' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |                                     'innerHTML' => '<i class="fa fa-code"></i> ' . $row['name']
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |                                 ),
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |                                 'item' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |                                     'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |                                     'url' => "index.php?a=22&id=" . $row['id']
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |                                 )
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |                             );
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |                             if (!empty($row['description'])) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |                                 $contextmenu['seperator'] = '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |                                 $contextmenu['description'] = array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |                                     'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |                                 );
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |                             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |                         } else {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |                             $contextmenu = array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |                                 'header' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |                                     'innerHTML' => '<i class="fa fa-code"></i> ' . $name
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |                                 ),
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |                                 'item' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |                                     'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_snippet'],
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |                                     'url' => "index.php?a=23&itemname=" . $name
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |                                 )
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |                             );
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |                         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |                         break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |                     }
 | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 291 |  | View Code Duplication |                     case 'Chunk' : {
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |                         $sql = $modx->db->query('SELECT *
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 						FROM ' . $modx->getFullTableName('site_htmlsnippets') . '
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 						WHERE name="' . $name . '"
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 						LIMIT 1');
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |                         if ($modx->db->getRecordCount($sql)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |                             $row = $modx->db->getRow($sql);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |                             $contextmenu = array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |                                 'header' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |                                     'innerHTML' => '<i class="fa fa-th-large"></i> ' . $row['name']
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |                                 ),
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |                                 'item' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |                                     'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |                                     'url' => "index.php?a=78&id=" . $row['id']
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |                                 )
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |                             );
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |                             if (!empty($row['description'])) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |                                 $contextmenu['seperator'] = '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |                                 $contextmenu['description'] = array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |                                     'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |                                 );
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |                             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |                         } else {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |                             $contextmenu = array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |                                 'header' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |                                     'innerHTML' => '<i class="fa fa-th-large"></i> ' . $name
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |                                 ),
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |                                 'item' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |                                     'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_htmlsnippet'],
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |                                     'url' => "index.php?a=77&itemname=" . $name
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |                                 )
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |                             );
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |                         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |                         break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |                     }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |                     case 'AttributeValue': {
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |                         $sql = $modx->db->query('SELECT *
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | 						FROM ' . $modx->getFullTableName('site_htmlsnippets') . '
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 						WHERE name="' . $name . '"
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 						LIMIT 1');
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |                         if ($modx->db->getRecordCount($sql)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |                             $row = $modx->db->getRow($sql);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |                             $contextmenu = array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |                                 'header' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |                                     'innerText' => $row['name']
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |                                 ),
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |                                 'item' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |                                     'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |                                     'url' => "index.php?a=78&id=" . $row['id']
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |                                 )
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |                             );
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |                             if (!empty($row['description'])) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |                                 $contextmenu['seperator'] = '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |                                 $contextmenu['description'] = array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |                                     'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |                                 );
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |                             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |                         } else {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |                             $sql = $modx->db->query('SELECT *
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  | 							FROM ' . $modx->getFullTableName('site_snippets') . '
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  | 							WHERE name="' . $name . '"
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  | 							LIMIT 1');
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |                             if ($modx->db->getRecordCount($sql)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |                                 $row = $modx->db->getRow($sql);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |                                 $contextmenu = array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |                                     'header' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |                                         'innerHTML' => '<i class="fa fa-code"></i> ' . $row['name']
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |                                     ),
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |                                     'item' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |                                         'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |                                         'url' => "index.php?a=22&id=" . $row['id']
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |                                     )
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |                                 );
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |                                 if (!empty($row['description'])) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |                                     $contextmenu['seperator'] = '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |                                     $contextmenu['description'] = array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |                                         'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |                                     );
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |                                 }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |                             } else {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |                                 $contextmenu = array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |                                     'header' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |                                         'innerHTML' => '<i class="fa fa-code"></i> ' . $name
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |                                     ),
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |                                     'item' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |                                         'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_htmlsnippet'],
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |                                         'url' => "index.php?a=77&itemname=" . $name
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |                                     ),
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |                                     'item2' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |                                         'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_snippet'],
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |                                         'url' => "index.php?a=23&itemname=" . $name
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |                                     )
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |                                 );
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |                             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |                         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |                         break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |                     }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |                     case 'Placeholder' :
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |                     case 'Tv' : {
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |                         $default_field = array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |                             'id',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |                             'type',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |                             'contentType',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |                             'pagetitle',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |                             'longtitle',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |                             'description',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |                             'alias',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |                             'link_attributes',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |                             'published',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |                             'pub_date',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |                             'unpub_date',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |                             'parent',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |                             'isfolder',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |                             'introtext',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |                             'content',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |                             'richtext',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |                             'template',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |                             'menuindex',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |                             'searchable',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |                             'cacheable',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |                             'createdon',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |                             'createdby',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |                             'editedon',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |                             'editedby',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |                             'deleted',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |                             'deletedon',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |                             'deletedby',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |                             'publishedon',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |                             'publishedby',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |                             'menutitle',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |                             'donthit',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |                             'haskeywords',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |                             'hasmetatags',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |                             'privateweb',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |                             'privatemgr',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |                             'content_dispo',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |                             'hidemenu',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |                             'alias_visible'
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |                         );
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |                         if (in_array($name, $default_field)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |                             return;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |                         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |                         $sql = $modx->db->query('SELECT *
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | 						FROM ' . $modx->getFullTableName('site_tmplvars') . '
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 						WHERE name="' . $name . '"
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | 						LIMIT 1');
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |                         if ($modx->db->getRecordCount($sql)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |                             $row = $modx->db->getRow($sql);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |                             $contextmenu = array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |                                 'header' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |                                     'innerHTML' => '<i class="fa fa-list-alt"></i> ' . $row['name']
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |                                 ),
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |                                 'item' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |                                     'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |                                     'url' => "index.php?a=301&id=" . $row['id']
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |                                 )
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |                             );
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |                             if (!empty($row['description'])) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |                                 $contextmenu['seperator'] = '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |                                 $contextmenu['description'] = array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |                                     'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |                                 );
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |                             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |                         } else {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |                             $contextmenu = array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |                                 'header' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |                                     'innerHTML' => '<i class="fa fa-list-alt"></i> ' . $name
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |                                 ),
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |                                 'item' => array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |                                     'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_tmplvars'],
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |                                     'url' => "index.php?a=300&itemname=" . $name
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |                                 )
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |                             );
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |                         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |                         break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |                     }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |                 }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |                 echo json_encode($contextmenu, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE);
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |                 break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |             break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |         case 'movedocument' : {
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |             if ($modx->hasPermission('new_document') && $modx->hasPermission('edit_document') && $modx->hasPermission('save_document')) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |                 $id = !empty($_REQUEST['id']) ? (int)$_REQUEST['id'] : '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |                 $parent = isset($_REQUEST['parent']) ? (int)$_REQUEST['parent'] : 0;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |                 $menuindex = isset($_REQUEST['menuindex']) && is_scalar($_REQUEST['menuindex']) ? $_REQUEST['menuindex'] : 0;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |                 // set parent
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |                 if ($id && $parent >= 0) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |                     // find older parent
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |                     $parentOld = $modx->db->getValue($modx->db->select('parent', $modx->getFullTableName('site_content'), 'id=' . $id));
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |                     $eventOut = $modx->invokeEvent('onBeforeMoveDocument', [
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |                         'id_document' => $id,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |                         'old_parent'  => $parentOld,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |                         'new_parent'  => $parent,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |                     ]);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |                     if (is_array($eventOut) && count($eventOut) > 0) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |                         $eventParent = array_pop($eventOut);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |                         if ($eventParent == $parentOld) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |                             $json['errors'] = $_lang['error_movedocument2'];
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |                         } else {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |                             $parent = $eventParent;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |                         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |                     }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |                     if (empty($json['errors'])) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |                         // check privileges user for move docs
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |                         if (!empty($modx->config['tree_show_protected']) && $role != 1) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |                             $sql = $modx->db->select('*', $modx->getFullTableName('document_groups'), 'document IN(' . $id . ',' . $parent . ',' . $parentOld . ')');
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |                             if ($modx->db->getRecordCount($sql)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |                                 $document_groups = array();
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |                                 while ($row = $modx->db->getRow($sql)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |                                     $document_groups[$row['document']]['groups'][] = $row['document_group'];
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |                                 }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |                                 foreach ($document_groups as $key => $value) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |                                     if (($key == $parent || $key == $parentOld || $key == $id) && !in_array($role, $value['groups'])) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |                                         $json['errors'] = $_lang["error_no_privileges"];
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |                                     }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |                                 }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |                                 if ($json['errors']) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |                                     header('content-type: application/json');
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |                                     echo json_encode($json, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE);
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |                                     break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |                                 }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |                             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |                         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |                         if ($parent == 0 && $parent != $parentOld && !$modx->config['udperms_allowroot'] && $role != 1) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |                             $json['errors'] = $_lang["error_no_privileges"];
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |                         } else {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |                             // set new parent
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |                             $modx->db->update(array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |                                 'parent' => $parent
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |                             ), $modx->getFullTableName('site_content'), 'id=' . $id);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |                             // set parent isfolder = 1
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |                             $modx->db->update(array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |                                 'isfolder' => 1
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |                             ), $modx->getFullTableName('site_content'), 'id=' . $parent);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |                             if ($parent != $parentOld) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |                                 // check children docs and set parent isfolder
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |                                 if ($modx->db->getRecordCount($modx->db->select('id', $modx->getFullTableName('site_content'), 'parent=' . $parentOld))) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  |                                     $modx->db->update(array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  |                                         'isfolder' => 1
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |                                     ), $modx->getFullTableName('site_content'), 'id=' . $parentOld);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  |                                 } else {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  |                                     $modx->db->update(array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  |                                         'isfolder' => 0
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  |                                     ), $modx->getFullTableName('site_content'), 'id=' . $parentOld);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  |                                 }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  |                             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  |                             // set menuindex
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |                             if (!empty($menuindex)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |                                 $menuindex = explode(',', $menuindex);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |                                 foreach ($menuindex as $key => $value) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |                                     $modx->db->query('UPDATE ' . $modx->getFullTableName('site_content') . ' SET menuindex=' . $key . ' WHERE id=' . $value);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  |                                 }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |                             } else {
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  |                                 // TODO: max(*) menuindex
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  |                             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  |                             if (!$json['errors']) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |                                 $json['success'] = $_lang["actioncomplete"];
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |                                 $modx->invokeEvent('onAfterMoveDocument', [
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |                                     'id_document' => $id,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  |                                     'old_parent'  => $parentOld,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  |                                     'new_parent'  => $parent,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |                                 ]);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |                             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |                         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |                     }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |                 }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |             } else {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |                 $json['errors'] = $_lang["error_no_privileges"];
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  |             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  |             $modx->jsonResponse($json);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  |             break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  |         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  |         case 'getLockedElements': {
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |             $type = isset($_REQUEST['type']) ? (int)$_REQUEST['type'] : 0;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  |             $id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |             $output = !!$modx->elementIsLocked($type, $id, true);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |             if (!$output) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |                 $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |                 $docgrp_cond = $docgrp ? ' OR dg.document_group IN (' . $docgrp . ')' : '';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  |                 $sql = '
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |                     SELECT MAX(IF(1=' . $role . ' OR sc.privatemgr=0' . $docgrp_cond . ', 0, 1)) AS locked
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |                     FROM ' . $modx->getFullTableName('site_content') . ' AS sc 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  |                     LEFT JOIN ' . $modx->getFullTableName('document_groups') . ' dg ON dg.document=sc.id
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |                     WHERE sc.id=' . $id . ' GROUP BY sc.id';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  |                 $sql = $modx->db->query($sql);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  |                 if ($modx->db->getRecordCount($sql)) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  |                     $row = $modx->db->getRow($sql);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  |                     $output = !!$row['locked'];
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  |                 }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  |             }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  |             
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  |             echo $output;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  |             break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  |         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  |         
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  |         /* Ajax-Button Actions */
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  | 	    case 'publish.res': {
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  | 		    $published = getDocumentTv('published');
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  | 		    $state = $published == 0 ? 1 : 0;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  | 		    if($state) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  | 			    require_once('../../../processors/publish_content.processor.php');
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  | 		    } else {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  | 			    require_once('../../../processors/unpublish_content.processor.php');
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  | 		    }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  | 		    $json['result'] = $state == 1 ? 'publish' : 'unpublish';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  | 			break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  | 		}
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  | 	    case 'delete.res': {
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  | 		    $deleted = getDocumentTv('deleted');
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  | 		    $state = $deleted == 0 ? 1 : 0;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  | 		    if($state) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  | 			    require_once('../../../processors/delete_content.processor.php');
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  | 		    } else {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  | 			    require_once('../../../processors/undelete_content.processor.php');
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  | 		    }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  | 		    $json['result'] = $state == 1 ? 'delete' : 'undelete';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  | 			break;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  | 		}
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  |     }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  |     if(!empty($json)) $modx->jsonResponse($json);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  | }
 | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 644 |  |  | 
 | 
            
                                                        
            
                                    
            
            
                | 645 |  |  | function getDocumentTv($tv) {
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 646 |  |  | 	global $modx, $_lang;
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 647 |  |  | 	$modx->setAjaxMode(true);
 | 
            
                                                        
            
                                    
            
            
                | 648 |  |  | 	$id = isset($_REQUEST['id'])? intval($_REQUEST['id']) : 0;
 | 
            
                                                        
            
                                    
            
            
                | 649 |  |  | 	if($id==0) $modx->webAlertAndQuit($_lang["error_no_id"]);
 | 
            
                                                        
            
                                    
            
            
                | 650 |  |  | 	return $modx->db->getValue($modx->db->select($tv, $modx->getFullTableName('site_content'), 'id=' . $id));
 | 
            
                                                        
            
                                    
            
            
                | 651 |  |  | } | 
            
                        
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.