Code Duplication    Length = 15-16 lines in 2 locations

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

@@ 2898-2913 (lines=16) @@
2895
            $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";
2896
        }
2897
        // 2. creating the SQL statement for getting the personal agenda items in WEEK view
2898
        if ($type == "week_view") { // we are in week view
2899
            $start_end_day_of_week = self::calculate_start_end_of_week($week, $year);
2900
            $start_day = $start_end_day_of_week['start']['day'];
2901
            $start_month = $start_end_day_of_week['start']['month'];
2902
            $start_year = $start_end_day_of_week['start']['year'];
2903
            $end_day = $start_end_day_of_week['end']['day'];
2904
            $end_month = $start_end_day_of_week['end']['month'];
2905
            $end_year = $start_end_day_of_week['end']['year'];
2906
            // in sql statements you have to use year-month-day for date calculations
2907
            $start_filter = $start_year."-".$start_month."-".$start_day." 00:00:00";
2908
            $start_filter = api_get_utc_datetime($start_filter);
2909
2910
            $end_filter = $end_year."-".$end_month."-".$end_day." 23:59:59";
2911
            $end_filter = api_get_utc_datetime($end_filter);
2912
            $sql = " SELECT * FROM ".$tbl_global_agenda." WHERE start_date>='".$start_filter."' AND start_date<='".$end_filter."' AND  access_url_id = $current_access_url_id ";
2913
        }
2914
        // 3. creating the SQL statement for getting the personal agenda items in DAY view
2915
        if ($type == "day_view") { // we are in day view
2916
            // we could use mysql date() function but this is only available from 4.1 and higher
@@ 3023-3037 (lines=15) @@
3020
3021
        // 2. creating the SQL statement for getting the personal agenda items in WEEK view
3022
        // we are in week view
3023
        if ($type == "week_view") {
3024
            $start_end_day_of_week = self::calculate_start_end_of_week($week, $year);
3025
            $start_day = $start_end_day_of_week['start']['day'];
3026
            $start_month = $start_end_day_of_week['start']['month'];
3027
            $start_year = $start_end_day_of_week['start']['year'];
3028
            $end_day = $start_end_day_of_week['end']['day'];
3029
            $end_month = $start_end_day_of_week['end']['month'];
3030
            $end_year = $start_end_day_of_week['end']['year'];
3031
            // in sql statements you have to use year-month-day for date calculations
3032
            $start_filter = $start_year."-".$start_month."-".$start_day." 00:00:00";
3033
            $start_filter  = api_get_utc_datetime($start_filter);
3034
            $end_filter = $end_year."-".$end_month."-".$end_day." 23:59:59";
3035
            $end_filter  = api_get_utc_datetime($end_filter);
3036
            $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'";
3037
        }
3038
        // 3. creating the SQL statement for getting the personal agenda items in DAY view
3039
        if ($type == "day_view") {
3040
            // we are in day view