Code Duplication    Length = 12-20 lines in 2 locations

main/inc/lib/userportal.lib.php 1 location

@@ 299-318 (lines=20) @@
296
            $courseCategoryCondition = " INNER JOIN $table a ON (t1.id = a.course_category_id)";
297
298
            $url_access_id = api_get_current_access_url_id();
299
            if ($url_access_id != -1) {
300
                $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
301
                $sqlGetSubCatList = "
302
                    SELECT t1.name,
303
                            t1.code,
304
                            t1.parent_id,
305
                            t1.children_count,
306
                            COUNT(DISTINCT t3.code) AS nbCourse
307
                    FROM $main_category_table t1
308
                    $courseCategoryCondition
309
                    LEFT JOIN $main_category_table t2 ON t1.code = t2.parent_id
310
                    LEFT JOIN $main_course_table t3 ON (t3.category_code = t1.code $platform_visible_courses)
311
                    INNER JOIN $tbl_url_rel_course as url_rel_course
312
                    ON (url_rel_course.c_id = t3.id)
313
                    WHERE
314
                        url_rel_course.access_url_id = $url_access_id AND
315
                        t1.parent_id ".(empty($category) ? "IS NULL" : "='$category'")."
316
                    GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count
317
                    ORDER BY t1.tree_pos, t1.name";
318
            }
319
        }
320
321
        $resCats = Database::query($sqlGetSubCatList);

src/Chamilo/CoreBundle/Framework/PageController.php 1 location

@@ 399-410 (lines=12) @@
396
        // Showing only the category of courses of the current access_url_id
397
        if (api_is_multiple_url_enabled()) {
398
            $url_access_id = api_get_current_access_url_id();
399
            if ($url_access_id != -1) {
400
                $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
401
                $sqlGetSubCatList   = "
402
                    SELECT t1.name,t1.code,t1.parent_id,t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse
403
                    FROM $main_category_table t1
404
                    LEFT JOIN $main_category_table t2 ON t1.code=t2.parent_id
405
                    LEFT JOIN $main_course_table t3 ON (t3.category_code=t1.code $platform_visible_courses)
406
                    INNER JOIN $tbl_url_rel_course as url_rel_course
407
                        ON (url_rel_course.c_id = t3.id)
408
                    WHERE access_url_id = $url_access_id AND t1.parent_id ".(empty($category) ? "IS NULL" : "='$category'")."
409
                    GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name";
410
            }
411
        }
412
413
        $resCats       = Database::query($sqlGetSubCatList);