Code Duplication    Length = 7-8 lines in 6 locations

main/inc/lib/course_category.lib.php 6 locations

@@ 70-77 (lines=8) @@
67
        $conditions = null;
68
        $whereCondition = '';
69
70
        if (self::isMultipleUrlSupport()) {
71
            $table = Database::get_main_table(
72
                TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY
73
            );
74
            $conditions = " INNER JOIN $table a ON (t1.id = a.course_category_id)";
75
            $whereCondition = " AND a.access_url_id = ".api_get_current_access_url_id(
76
                );
77
        }
78
79
        $parentIdCondition = " AND (t1.parent_id IS NULL OR t1.parent_id = '' )";
80
        if (!empty($category)) {
@@ 560-566 (lines=7) @@
557
    {
558
        $conditions = null;
559
        $whereCondition = null;
560
        if (self::isMultipleUrlSupport()) {
561
            $table = Database::get_main_table(
562
                TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY
563
            );
564
            $conditions = " INNER JOIN $table a ON (c.id = a.course_category_id)";
565
            $whereCondition = " AND a.access_url_id = ".api_get_current_access_url_id();
566
        }
567
568
        $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
569
        $sql = "SELECT code, name
@@ 597-604 (lines=8) @@
594
        $conditions = null;
595
        $whereCondition = null;
596
597
        if (self::isMultipleUrlSupport()) {
598
            $table = Database::get_main_table(
599
                TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY
600
            );
601
            $conditions = " INNER JOIN $table a ON (c.id = a.course_category_id)";
602
            $whereCondition = " WHERE a.access_url_id = ".api_get_current_access_url_id(
603
                );
604
        }
605
        $sql = "SELECT c.* FROM $tbl_category c
606
                $conditions
607
                $whereCondition
@@ 919-926 (lines=8) @@
916
        $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
917
        $conditions = null;
918
        $whereCondition = null;
919
        if (self::isMultipleUrlSupport()) {
920
            $table = Database::get_main_table(
921
                TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY
922
            );
923
            $conditions = " INNER JOIN $table a ON (c.id = a.course_category_id)";
924
            $whereCondition = " AND a.access_url_id = ".api_get_current_access_url_id(
925
                );
926
        }
927
928
        $sql = "SELECT code, name, auth_course_child, auth_cat_child
929
                FROM ".$tbl_category." c
@@ 989-996 (lines=8) @@
986
        $tableCategory = Database::get_main_table(TABLE_MAIN_CATEGORY);
987
        $conditions = null;
988
        $whereCondition = null;
989
        if (self::isMultipleUrlSupport()) {
990
            $table = Database::get_main_table(
991
                TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY
992
            );
993
            $conditions = " INNER JOIN $table a ON (c.id = a.course_category_id)";
994
            $whereCondition = " AND a.access_url_id = ".api_get_current_access_url_id(
995
                );
996
        }
997
998
        $keyword = Database::escape_string($keyword);
999
@@ 1029-1036 (lines=8) @@
1026
        $tableCategory = Database::get_main_table(TABLE_MAIN_CATEGORY);
1027
        $conditions = null;
1028
        $whereCondition = null;
1029
        if (self::isMultipleUrlSupport()) {
1030
            $table = Database::get_main_table(
1031
                TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY
1032
            );
1033
            $conditions = " INNER JOIN $table a ON (c.id = a.course_category_id)";
1034
            $whereCondition = " AND a.access_url_id = ".api_get_current_access_url_id(
1035
                );
1036
        }
1037
1038
        $sql = "SELECT c.*, c.name as text FROM $tableCategory c $conditions
1039
                WHERE c.id IN $list $whereCondition";