Code Duplication    Length = 16-17 lines in 2 locations

main/admin/add_users_to_group.php 2 locations

@@ 247-262 (lines=16) @@
244
if ($ajax_search) {
245
246
    // data for destination list
247
    if (isset($_POST['id']) && isset($_POST['relation'])) {
248
        // data for destination user list
249
        $id = intval($_POST['id']);
250
        $relation_type = intval($_POST['relation']);
251
        $condition_relation = " AND groups.relation_type = '$relation_type' ";
252
        $sql = "SELECT user.user_id, user.username, user.lastname, user.firstname
253
                FROM $tbl_group_rel_user groups
254
                INNER JOIN  $tbl_user user ON user.user_id = groups.user_id
255
                WHERE groups.group_id = '$id' $condition_relation ";
256
        $rs_destination = Database::query($sql);
257
        if (Database::num_rows($rs_destination) > 0) {
258
            while ($row_destination_list = Database::fetch_array($rs_destination)) {
259
                $sessionUsersList[$row_destination_list['user_id']] = $row_destination_list ;
260
            }
261
        }
262
    }
263
} else {
264
265
    $many_users = false;
@@ 330-346 (lines=17) @@
327
    }
328
329
    // data for destination list
330
    if (isset($_POST['id']) && isset($_POST['relation'])) {
331
        // data for destination user list
332
        $id = intval($_POST['id']);
333
        $relation_type = intval($_POST['relation']);
334
        $condition_relation = " AND groups.relation_type = '$relation_type' ";
335
336
        $sql = "SELECT user.user_id, user.username, user.lastname, user.firstname
337
                FROM $tbl_group_rel_user groups
338
                INNER JOIN  $tbl_user user ON user.user_id = groups.user_id
339
                WHERE groups.group_id = '$id' $condition_relation ";
340
        $rs_destination = Database::query($sql);
341
        if (Database::num_rows($rs_destination) > 0) {
342
            while ($row_destination_list = Database::fetch_array($rs_destination)) {
343
                $sessionUsersList[$row_destination_list['user_id']] = $row_destination_list ;
344
            }
345
        }
346
    }
347
}
348
349
if ($add_type == 'multiple') {