diff --git a/calendar/classes/local/event/data_access/event_vault.php b/calendar/classes/local/event/data_access/event_vault.php index 3d592088d58..8a8c20d2f3b 100644 --- a/calendar/classes/local/event/data_access/event_vault.php +++ b/calendar/classes/local/event/data_access/event_vault.php @@ -100,9 +100,6 @@ class event_vault implements event_vault_interface { $ignorehidden = true, callable $filter = null ) { - if ($limitnum < 1 || $limitnum > 200) { - throw new limit_invalid_parameter_exception("Limit must be between 1 and 200 (inclusive)"); - } $fromquery = function($field, $timefrom, $lastseenmethod, $afterevent, $withduration) { if (!$timefrom) { @@ -186,7 +183,11 @@ class event_vault implements event_vault_interface { } } - $offset += $limitnum; + if (!$limitnum) { + break; + } else { + $offset += $limitnum; + } } return $events; diff --git a/calendar/export_execute.php b/calendar/export_execute.php index f87e439e632..17b55010e8e 100644 --- a/calendar/export_execute.php +++ b/calendar/export_execute.php @@ -186,9 +186,9 @@ if(!empty($what) && !empty($time)) { die(); } } - +$limitnum = 0; $events = calendar_get_legacy_events($timestart, $timeend, $users, $groups, array_keys($paramcourses), false, true, - $paramcategory); + $paramcategory, $limitnum); $ical = new iCalendar; $ical->add_property('method', 'PUBLISH'); diff --git a/calendar/lib.php b/calendar/lib.php index 272805313d1..8577aedd586 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -3234,10 +3234,12 @@ function core_calendar_user_preferences() { * or events in progress/already started selected as well * @param boolean $ignorehidden whether to select only visible events or all events * @param array $categories array of category ids and/or objects. + * @param int $limitnum Number of events to fetch or zero to fetch all. + * * @return array $events of selected events or an empty array if there aren't any (or there was an error) */ function calendar_get_legacy_events($tstart, $tend, $users, $groups, $courses, - $withduration = true, $ignorehidden = true, $categories = []) { + $withduration = true, $ignorehidden = true, $categories = [], $limitnum = 0) { // Normalise the users, groups and courses parameters so that they are compliant with \core_calendar\local\api::get_events(). // Existing functions that were using the old calendar_get_events() were passing a mixture of array, int, boolean for these // parameters, but with the new API method, only null and arrays are accepted. @@ -3274,7 +3276,7 @@ function calendar_get_legacy_events($tstart, $tend, $users, $groups, $courses, null, null, null, - 40, + $limitnum, null, $userparam, $groupparam, @@ -3309,7 +3311,7 @@ function calendar_get_view(\calendar_information $calendar, $view, $includenavig $calendardate = $type->timestamp_to_date_array($calendar->time); $date = new \DateTime('now', core_date::get_user_timezone_object(99)); - $eventlimit = 200; + $eventlimit = 0; if ($view === 'day') { $tstart = $type->convert_to_timestamp($calendardate['year'], $calendardate['mon'], $calendardate['mday']);