Merge branch 'MDL-59650-master' of git://github.com/lameze/moodle

This commit is contained in:
Andrew Nicols 2019-05-23 10:19:55 +08:00
commit a37fa5c443
3 changed files with 12 additions and 9 deletions

View File

@ -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;

View File

@ -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');

View File

@ -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,
@ -3314,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']);