Code Duplication    Length = 38-38 lines in 2 locations

manager/media/style/default/ajax.php 2 locations

@@ 167-204 (lines=38) @@
164
            break;
165
        }
166
167
        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
        case '99': {
207
            $a = 88;
@@ 206-243 (lines=38) @@
203
            break;
204
        }
205
206
        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;