Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]

Contains class containing the internal calendar API.

Copyright: 2017 Ryan Wyllie <ryan@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 338 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: api  - X-Ref

Class containing the local calendar API.

This should not be used outside of core_calendar.

get_events($timestartfrom = null,$timestartto = null,$timesortfrom = null,$timesortto = null,$timestartaftereventid = null,$timesortaftereventid = null,$limitnum = 20,$type = null,array $usersfilter = null,array $groupsfilter = null,array $coursesfilter = null,array $categoriesfilter = null,$withduration = true,$ignorehidden = true,callable $filter = null)   X-Ref
Get all events restricted by various parameters, taking in to account user and group overrides.

param: int|null      $timestartfrom         Events with timestart from this value (inclusive).
param: int|null      $timestartto           Events with timestart until this value (inclusive).
param: int|null      $timesortfrom          Events with timesort from this value (inclusive).
param: int|null      $timesortto            Events with timesort until this value (inclusive).
param: int|null      $timestartaftereventid Restrict the events in the timestart range to ones after this ID.
param: int|null      $timesortaftereventid  Restrict the events in the timesort range to ones after this ID.
param: int           $limitnum              Return at most this number of events.
param: int|null      $type                  Return only events of this type.
param: array|null    $usersfilter           Return only events for these users.
param: array|null    $groupsfilter          Return only events for these groups.
param: array|null    $coursesfilter         Return only events for these courses.
param: bool          $withduration          If true return only events starting within specified
param: bool          $ignorehidden          If true don't return hidden events.
return: \core_calendar\local\event\entities\event_interface[] Array of event_interfaces.

get_action_events_by_timesort($timesortfrom = null,$timesortto = null,$aftereventid = null,$limitnum = 20,$limittononsuspendedevents = false,?\stdClass $user = null,?string $searchvalue = null)   X-Ref
Get a list of action events for the logged in user by the given
timesort values.

param: int|null $timesortfrom The start timesort value (inclusive)
param: int|null $timesortto The end timesort value (inclusive)
param: int|null $aftereventid Only return events after this one
param: int $limitnum Limit results to this amount (between 1 and 50)
param: bool $lmittononsuspendedevents Limit course events to courses the user is active in (not suspended).
param: \stdClass|null $user The user id or false for $USER
param: string|null $searchvalue The value a user wishes to search against
return: array A list of action_event_interface objects

get_action_events_by_course($course,$timesortfrom = null,$timesortto = null,$aftereventid = null,$limitnum = 20,?string $searchvalue = null)   X-Ref
Get a list of action events for the logged in user by the given
course and timesort values.

param: \stdClass $course The course the events must belong to
param: int|null $timesortfrom The start timesort value (inclusive)
param: int|null $timesortto The end timesort value (inclusive)
param: int|null $aftereventid Only return events after this one
param: int $limitnum Limit results to this amount (between 1 and 50)
param: string|null $searchvalue The value a user wishes to search against
return: array A list of action_event_interface objects

get_action_events_by_courses($courses = [],$timesortfrom = null,$timesortto = null,$limitnum = 20,?string $searchvalue = null)   X-Ref
Get a list of action events for the logged in user by the given
courses and timesort values.

The limit number applies per course, not for the result set as a whole.
E.g. Requesting 3 courses with a limit of 10 will result in up to 30
events being returned (up to 10 per course).

param: array $courses The courses the events must belong to
param: int|null $timesortfrom The start timesort value (inclusive)
param: int|null $timesortto The end timesort value (inclusive)
param: int $limitnum Limit results per course to this amount (between 1 and 50)
param: string|null $searchvalue The value a user wishes to search against
return: array A list of action_event_interface objects indexed by course id

update_event_start_day(event_interface $event,\DateTimeInterface $startdate)   X-Ref
Change the start day for an event. Only the date will be
modified, the time of day for the event will be left as is.

param: event_interface $event The existing event to modify
param: DateTimeInterface $startdate The new date to use for the start day
return: event_interface The new event with updated start date