From e099259a46fecd4222d2bb90282227db4ec748dd Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Tue, 21 May 2019 09:59:39 +0800 Subject: [PATCH 1/2] MDL-59650 core_calendar: remove limit from event exporter --- calendar/classes/local/event/data_access/event_vault.php | 9 +++++---- calendar/export_execute.php | 4 ++-- calendar/lib.php | 6 ++++-- 3 files changed, 11 insertions(+), 8 deletions(-) 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 02c2d971392..8e634806a80 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -3237,10 +3237,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. @@ -3277,7 +3279,7 @@ function calendar_get_legacy_events($tstart, $tend, $users, $groups, $courses, null, null, null, - 40, + $limitnum, null, $userparam, $groupparam, From 2b815157c949dd959a1c6ed24348e9805aff842f Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Tue, 21 May 2019 10:46:47 +0800 Subject: [PATCH 2/2] MDL-59650 core_calendar: remove limit from calendar UI --- calendar/lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/calendar/lib.php b/calendar/lib.php index 8e634806a80..be383703c3e 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -3316,7 +3316,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']);