Code Duplication    Length = 15-16 lines in 2 locations

main/inc/lib/agenda.lib.php 2 locations

@@ 2965-2980 (lines=16) @@
2962
            $sql = "SELECT * FROM ".$tbl_global_agenda." WHERE MONTH(start_date) = ".$month." AND YEAR(start_date) = ".$year."  AND access_url_id = $current_access_url_id ORDER BY start_date ASC";
2963
        }
2964
        // 2. creating the SQL statement for getting the personal agenda items in WEEK view
2965
        if ($type == "week_view") { // we are in week view
2966
            $start_end_day_of_week = self::calculate_start_end_of_week($week, $year);
2967
            $start_day = $start_end_day_of_week['start']['day'];
2968
            $start_month = $start_end_day_of_week['start']['month'];
2969
            $start_year = $start_end_day_of_week['start']['year'];
2970
            $end_day = $start_end_day_of_week['end']['day'];
2971
            $end_month = $start_end_day_of_week['end']['month'];
2972
            $end_year = $start_end_day_of_week['end']['year'];
2973
            // in sql statements you have to use year-month-day for date calculations
2974
            $start_filter = $start_year."-".$start_month."-".$start_day." 00:00:00";
2975
            $start_filter = api_get_utc_datetime($start_filter);
2976
2977
            $end_filter = $end_year."-".$end_month."-".$end_day." 23:59:59";
2978
            $end_filter = api_get_utc_datetime($end_filter);
2979
            $sql = " SELECT * FROM ".$tbl_global_agenda." WHERE start_date>='".$start_filter."' AND start_date<='".$end_filter."' AND  access_url_id = $current_access_url_id ";
2980
        }
2981
        // 3. creating the SQL statement for getting the personal agenda items in DAY view
2982
        if ($type == "day_view") { // we are in day view
2983
            // we could use mysql date() function but this is only available from 4.1 and higher
@@ 3090-3104 (lines=15) @@
3087
3088
        // 2. creating the SQL statement for getting the personal agenda items in WEEK view
3089
        // we are in week view
3090
        if ($type == "week_view") {
3091
            $start_end_day_of_week = self::calculate_start_end_of_week($week, $year);
3092
            $start_day = $start_end_day_of_week['start']['day'];
3093
            $start_month = $start_end_day_of_week['start']['month'];
3094
            $start_year = $start_end_day_of_week['start']['year'];
3095
            $end_day = $start_end_day_of_week['end']['day'];
3096
            $end_month = $start_end_day_of_week['end']['month'];
3097
            $end_year = $start_end_day_of_week['end']['year'];
3098
            // in sql statements you have to use year-month-day for date calculations
3099
            $start_filter = $start_year."-".$start_month."-".$start_day." 00:00:00";
3100
            $start_filter  = api_get_utc_datetime($start_filter);
3101
            $end_filter = $end_year."-".$end_month."-".$end_day." 23:59:59";
3102
            $end_filter  = api_get_utc_datetime($end_filter);
3103
            $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'";
3104
        }
3105
        // 3. creating the SQL statement for getting the personal agenda items in DAY view
3106
        if ($type == "day_view") {
3107
            // we are in day view