Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
core_calendar

Namespaces

namespace  calendartype_test_example
  
 
namespace  core_calendar
  
 
namespace  core_calendar\external
  
 
namespace  core_calendar\external\export
  
 
namespace  core_calendar\external\subscription
  
 
namespace  core_calendar\local
  
 
namespace  core_calendar\local\event
  
 
namespace  core_calendar\local\event\data_access
  
 
namespace  core_calendar\local\event\entities
  
 
namespace  core_calendar\local\event\exceptions
  
 
namespace  core_calendar\local\event\factories
  
 
namespace  core_calendar\local\event\forms
  
 
namespace  core_calendar\local\event\mappers
  
 
namespace  core_calendar\local\event\proxies
  
 
namespace  core_calendar\local\event\strategies
  
 
namespace  core_calendar\local\event\value_objects
  
 
namespace  core_calendar\output
  
 
namespace  core_calendar\privacy
  
 

Classes

class  action_event_test_factory
 A test factory that will create action events. More...
 
class  behat_calendar
 Contains functions used by behat to test functionality. More...
 
class  behat_calendar_deprecated
 
class  calendar_event
 
class  calendar_information
 Calendar information class. More...
 
class  calendartype_test_example\structure
 
class  core_calendar\action_factory
 Action factory class. More...
 
class  core_calendar\external\calendar_day_exporter
 
class  core_calendar\external\calendar_event_exporter
 Class for displaying a calendar event. More...
 
class  core_calendar\external\calendar_upcoming_exporter
 Class for displaying the day view. More...
 
class  core_calendar\external\date_exporter
 Class for normalising the date data. More...
 
class  core_calendar\external\day_exporter
 
class  core_calendar\external\day_name_exporter
 Class for displaying the day view. More...
 
class  core_calendar\external\event_action_exporter
 Class for displaying a calendar event's action. More...
 
class  core_calendar\external\event_exporter
 Class for displaying a calendar event. More...
 
class  core_calendar\external\event_exporter_base
 Class for displaying a calendar event. More...
 
class  core_calendar\external\event_icon_exporter
 Class for displaying a calendar event's icon. More...
 
class  core_calendar\external\event_subscription_exporter
 Class for displaying a calendar event's subscription. More...
 
class  core_calendar\external\events_exporter
 Class for displaying a list of calendar events. More...
 
class  core_calendar\external\events_grouped_by_course_exporter
 Class for displaying a list of calendar events grouped by course id. More...
 
class  core_calendar\external\events_related_objects_cache
 Class to providing the related objects when exporting a list of calendar events. More...
 
class  core_calendar\external\events_same_course_exporter
 Class for displaying a list of calendar events for a single course. More...
 
class  core_calendar\external\export\token
 This is the external method for exporting a calendar token. More...
 
class  core_calendar\external\footer_options_exporter
 
class  core_calendar\external\month_exporter
 Class for displaying the month view. More...
 
class  core_calendar\external\subscription\delete
 Calendar external API for deleting the subscription. More...
 
class  core_calendar\external\week_day_exporter
 Class for displaying the day on month view. More...
 
class  core_calendar\external\week_exporter
 Class for displaying the week view. More...
 
class  core_calendar\local\api
 Class containing the local calendar API. More...
 
class  core_calendar\local\event\container
 Core container. More...
 
class  core_calendar\local\event\data_access\event_vault
 Event vault class. More...
 
interface  core_calendar\local\event\data_access\event_vault_interface
 Interface for an event vault class. More...
 
class  core_calendar\local\event\entities\action_event
 Class representing an actionable event. More...
 
interface  core_calendar\local\event\entities\action_event_interface
 Interface for an action event class. More...
 
interface  core_calendar\local\event\entities\action_interface
 Interface for a action class. More...
 
class  core_calendar\local\event\entities\event
 Class representing a calendar event. More...
 
interface  core_calendar\local\event\entities\event_collection_interface
 Interface for an event collection class. More...
 
interface  core_calendar\local\event\entities\event_interface
 Interface for an event class. More...
 
class  core_calendar\local\event\entities\repeat_event_collection
 Class representing a collection of repeat events. More...
 
class  core_calendar\local\event\exceptions\invalid_callback_exception
 Invalid callback exception. More...
 
class  core_calendar\local\event\exceptions\invalid_parameter_exception
 General invalid parameter exception. More...
 
class  core_calendar\local\event\exceptions\limit_invalid_parameter_exception
 Invalid limit parameter exception. More...
 
class  core_calendar\local\event\exceptions\member_does_not_exist_exception
 Member does not exist exception. More...
 
class  core_calendar\local\event\exceptions\timesort_invalid_parameter_exception
 Invalid timesort parameter exception. More...
 
interface  core_calendar\local\event\factories\action_factory_interface
 
class  core_calendar\local\event\factories\event_abstract_factory
 Abstract factory for creating calendar events. More...
 
class  core_calendar\local\event\factories\event_factory
 Event factory class. More...
 
interface  core_calendar\local\event\factories\event_factory_interface
 Interface for an event factory class. More...
 
class  core_calendar\local\event\forms\create
 The mform class for creating a calendar event. More...
 
class  core_calendar\local\event\forms\update
 The mform class for updating a calendar event. More...
 
class  core_calendar\local\event\mappers\create_update_form_mapper
 Event create form and update form mapper class. More...
 
interface  core_calendar\local\event\mappers\create_update_form_mapper_interface
 Interface for a create_update_form_mapper class. More...
 
class  core_calendar\local\event\mappers\event_mapper
 Event mapper class. More...
 
interface  core_calendar\local\event\mappers\event_mapper_interface
 Interface for an event mapper class. More...
 
class  core_calendar\local\event\proxies\cm_info_proxy
 Course module stdClass proxy. More...
 
class  core_calendar\local\event\proxies\coursecat_proxy
 Course category proxy. More...
 
interface  core_calendar\local\event\proxies\proxy_interface
 Interface for a proxy class. More...
 
class  core_calendar\local\event\proxies\std_proxy
 stdClass proxy. More...
 
class  core_calendar\local\event\strategies\raw_event_retrieval_strategy
 Raw event retrieval strategy. More...
 
interface  core_calendar\local\event\strategies\raw_event_retrieval_strategy_interface
 Interface for an raw event retrival strategy class. More...
 
class  core_calendar\local\event\value_objects\action
 Class representing an action a user should take. More...
 
interface  core_calendar\local\event\value_objects\description_interface
 Interface for a description value object. More...
 
class  core_calendar\local\event\value_objects\event_description
 Class representing a description value object. More...
 
class  core_calendar\local\event\value_objects\event_times
 Class representing event times. More...
 
interface  core_calendar\local\event\value_objects\times_interface
 Interface for various times. More...
 
class  core_calendar\output\refreshintervalcollection
 
class  core_calendar\privacy\provider
 Privacy Subsystem for core_calendar implementing metadata, plugin, and user_preference providers. More...
 
class  core_calendar\rrule_manager
 Defines calendar class to manage recurrence rule (rrule) during ical imports. More...
 
class  core_calendar\type_base
 
class  core_calendar\type_factory
 
class  core_calendar_export_form
 The mform class for creating and editing a calendar. More...
 
class  core_calendar_external
 Calendar external functions. More...
 

Functions

 calendar_add_event_allowed ($event)
 Check wether the current user is permitted to add events.
 
 calendar_add_event_metadata ($event)
 Add calendar event metadata.
 
 calendar_add_icalendar_event ($event, $unused, $subscriptionid, $timezone='UTC')
 Add an iCalendar event to the Moodle calendar.
 
 calendar_add_month ($month, $year)
 Get the next following month.
 
 calendar_add_subscription ($sub)
 Add an iCalendar subscription to the database.
 
 calendar_can_edit_subscription ($subscriptionorid)
 Checks to see if the user can edit a given subscription feed.
 
 calendar_can_manage_non_user_event_in_system ($event)
 Can current user manage a non user event in system context.
 
 calendar_can_manage_user_event ($event)
 Can current user edit/delete/add an user event?
 
 calendar_day_representation ($tstamp, $now=false, $usecommonwords=true)
 Return the representation day.
 
 calendar_days_in_month ($month, $year)
 Return the number of days in month.
 
 calendar_delete_event_allowed ($event)
 Return the capability for deleting a calendar event.
 
 calendar_delete_subscription ($subscription)
 Delete subscription and all related events.
 
 calendar_edit_event_allowed ($event, $manualedit=false)
 Return the capability for editing calendar event.
 
 calendar_events_by_day ($events, $month, $year, &$eventsbyday, &$durationbyday, &$typesbyday, &$courses)
 Get per-day basis events.
 
 calendar_format_event_location (calendar_event $event)
 Format event location property.
 
 calendar_format_event_time ($event, $now, $linkparams=null, $usecommonwords=true, $showtime=0)
 Get event format time.
 
 calendar_get_allowed_event_types (int $courseid=null)
 Get event types the user can create event based on categories, courses and groups the logged in user belongs to.
 
 calendar_get_allowed_types (&$allowed, $course=null, $groups=null, $category=null)
 Get calendar's allowed types.
 
 calendar_get_calendar_context ($subscription)
 Helper function to determine the context of a calendar subscription.
 
 calendar_get_course_cached (&$coursecache, $courseid)
 Get current course cache.
 
 calendar_get_courselink ($course)
 Get a HTML link to a course.
 
 calendar_get_days ()
 Return the days of the week.
 
 calendar_get_default_courses ($courseid=null, $fields=' *', $canmanage=false, int $userid=null)
 Returns the default courses to display on the calendar when there isn't a specific course to display.
 
 calendar_get_events ($tstart, $tend, $users, $groups, $courses, $withduration=true, $ignorehidden=true, $categories=[])
 Get calendar events.
 
 calendar_get_events_by_id ($eventids)
 Get calendar events by id.
 
 calendar_get_eventtype_choices ($courseid)
 Returns option list of available options for the calendar event type, given the current user and course.
 
 calendar_get_export_import_link_params ()
 Get the list of URL parameters for calendar expport and import links.
 
 calendar_get_export_token (stdClass $user)
 Get the auth token for exporting the given user calendar.
 
 calendar_get_filter_types ()
 Get the list of potential calendar filter types as a type => name combination.
 
 calendar_get_footer_options ($calendar, array $options=[])
 Get the calendar footer options.
 
 calendar_get_group_cached ($groupid)
 Get group from groupid for calendar display.
 
 calendar_get_icalendar ($url)
 From a URL, fetch the calendar and return an iCalendar object.
 
 calendar_get_legacy_events ($tstart, $tend, $users, $groups, $courses, $withduration=true, $ignorehidden=true, $categories=[], $limitnum=0)
 Get legacy calendar events.
 
 calendar_get_link_href ($linkbase, $d, $m, $y, $time=0)
 Adds day, month, year arguments to a URL and returns a moodle_url object.
 
 calendar_get_link_next ($text, $linkbase, $d, $m, $y, $accesshide=false, $time=0)
 Build and return a next month HTML link, with an arrow.
 
 calendar_get_link_previous ($text, $linkbase, $d, $m, $y, $accesshide=false, $time=0)
 Build and return a previous month HTML link, with an arrow.
 
 calendar_get_module_cached (&$modulecache, $modulename, $instance)
 Get current module cache.
 
 calendar_get_pollinterval_choices ()
 Returns option list for the poll interval setting.
 
 calendar_get_starting_weekday ()
 Gets the first day of the week.
 
 calendar_get_subscription ($id)
 Get the subscription from a given id.
 
 calendar_get_timestamp ($d, $m, $y, $time=0)
 Calculate the timestamp from the supplied Gregorian Year, Month, and Day.
 
 calendar_get_view (\calendar_information $calendar, $view, $includenavigation=true, bool $skipevents=false, ?int $lookahead=null)
 Get the calendar view output.
 
 calendar_import_events_from_ical (iCalendar $ical, int $subscriptionid=null)
 Import events from an iCalendar object into a course calendar.
 
 calendar_inplace_editable (string $itemtype, int $itemid, int $newvalue)
 Implements the inplace editable feature.
 
 calendar_internal_update_course_and_group_permission (int $courseid, context $context, array &$types)
 Given a course id, and context, updates the permission types array to add the 'course' or 'group' permission if it is relevant for that course.
 
 calendar_is_valid_eventtype ($type)
 Check whether the specified event type is valid.
 
 calendar_output_fragment_event_form ($args)
 Request and render event form fragment.
 
 calendar_set_event_type_display ($type, $display=null, $user=null)
 Sets the display of the event type given $display.
 
 calendar_set_filters (array $courseeventsfrom, $ignorefilters=false, stdClass $user=null)
 Returns the courses to load events for.
 
 calendar_show_event_type ($type, $user=null)
 Checks to see if the requested type of event should be shown for the given user.
 
 calendar_sub_month ($month, $year)
 Get the previous month.
 
 calendar_time_representation ($time)
 return the formatted representation time.
 
 calendar_top_controls ($type, $data)
 Get control options for calendar.
 
 calendar_update_subscription ($subscription)
 Update a calendar subscription.
 
 calendar_update_subscription_events ($subscriptionid)
 Fetch a calendar subscription and update the events in the calendar.
 
 calendar_user_can_add_event ($course)
 See if user can add calendar entries at all used to print the "New Event" button.
 
 calendar_view_event_allowed (calendar_event $event)
 Return the capability for viewing a calendar event.
 
 core_calendar_user_preferences ()
 Implements callback user_preferences, lists preferences that users are allowed to update directly.
 
 create_action_event (array $data)
 Helper function to create an action event.
 
 create_event ($properties)
 Create a calendar event with the given properties.
 
 create_group_override_event (string $modulename, int $instanceid, int $courseid, int $groupid)
 Helper function to create an group override calendar event.
 
 create_standard_events (int $quantity)
 Helper function to create a x number of events for each event type.
 
 create_user_override_event (string $modulename, int $instanceid, int $userid)
 Helper function to create an user override calendar event.
 

Variables

global $CFG
 
global core_calendar\external\export::$CFG
 
const CALENDAR_DEFAULT_STARTING_WEEKDAY 1
 CALENDAR_DEFAULT_STARTING_WEEKDAY - default value to display the starting weekday.
 
const CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD (!defined('MOODLE_INTERNAL')) 21
 These are read by the administration component to provide default values.
 
const CALENDAR_DEFAULT_UPCOMING_MAXEVENTS 10
 CALENDAR_DEFAULT_UPCOMING_MAXEVENTS - default value to display the maximum number of upcoming event.
 
const CALENDAR_DEFAULT_WEEKEND 65
 CALENDAR_DEFAULT_WEEKEND - default value for weekend (Saturday & Sunday)
 
const CALENDAR_EVENT_COURSE 2
 CALENDAR_EVENT_COURSE - Course calendar event types.
 
const CALENDAR_EVENT_COURSECAT 16
 CALENDAR_EVENT_COURSECAT - Course category calendar event types.
 
const CALENDAR_EVENT_GROUP 4
 CALENDAR_EVENT_GROUP - group calendar event types.
 
const CALENDAR_EVENT_SITE 1
 CALENDAR_EVENT_SITE - Site calendar event types.
 
const CALENDAR_EVENT_TYPE_ACTION 1
 CALENDAR_EVENT_TYPE_ACTION - Action events.
 
const CALENDAR_EVENT_TYPE_STANDARD 0
 CALENDAR_EVENT_TYPE_STANDARD - Standard events.
 
const CALENDAR_EVENT_USER 8
 CALENDAR_EVENT_USER - user calendar event types.
 
const CALENDAR_EVENT_USER_OVERRIDE_PRIORITY 0
 CALENDAR_EVENT_USER_OVERRIDE_PRIORITY - Constant for the user override priority.
 
const CALENDAR_IMPORT_EVENT_INSERTED 2
 CALENDAR_IMPORT_EVENT_INSERTED - imported event was added by insert.
 
const CALENDAR_IMPORT_EVENT_SKIPPED -1
 CALENDAR_IMPORT_EVENT_UPDATED_SKIPPED - imported event was skipped.
 
const CALENDAR_IMPORT_EVENT_UPDATED 1
 CALENDAR_IMPORT_EVENT_UPDATED - imported event was updated.
 
const CALENDAR_IMPORT_FROM_FILE 0
 CALENDAR_IMPORT_FROM_FILE - import the calendar from a file.
 
const CALENDAR_IMPORT_FROM_URL 1
 CALENDAR_IMPORT_FROM_URL - import the calendar from a URL.
 
const CALENDAR_SUBSCRIPTION_REMOVE 2
 CALENDAR_SUBSCRIPTION_REMOVE - Used to represent remove action for subscriptions in various forms.
 
const CALENDAR_SUBSCRIPTION_UPDATE 1
 CALENDAR_SUBSCRIPTION_UPDATE - Used to represent update action for subscriptions in various forms.
 
const CALENDAR_TF_12 '%I:%M %p'
 CALENDAR_TF_12 - Calendar time in 12 hours format.
 
const CALENDAR_TF_24 '%H:%M'
 CALENDAR_TF_24 - Calendar time in 24 hours format.
 
const CALENDAR_URL $CFG->wwwroot.'/calendar/'
 CALENDAR_URL - path to calendar's folder.
 
 if (!defined( 'MOODLE_INTERNAL'))
 

Detailed Description

Function Documentation

◆ calendar_add_event_allowed()

calendar_add_event_allowed ( $event)

Check wether the current user is permitted to add events.

Parameters
stdClass$eventobject of event
Return values
boolhas the capability to add event

◆ calendar_add_event_metadata()

calendar_add_event_metadata ( $event)

Add calendar event metadata.

Deprecated
since 3.9
Parameters
stdClass$eventevent info
Return values
stdClass\$eventmetadata

◆ calendar_add_icalendar_event()

calendar_add_icalendar_event ( $event,
$unused,
$subscriptionid,
$timezone = 'UTC' )

Add an iCalendar event to the Moodle calendar.

Parameters
stdClass$eventThe RFC-2445 iCalendar event
int$unusedDeprecated
int$subscriptionidThe iCalendar subscription ID
string$timezoneThe X-WR-TIMEZONE iCalendar property if provided
Exceptions
dml_exceptionA DML specific exception is thrown for invalid subscriptionids.
Return values
intCode: CALENDAR_IMPORT_EVENT_UPDATED = updated, CALENDAR_IMPORT_EVENT_INSERTED = inserted, 0 = error

◆ calendar_add_month()

calendar_add_month ( $month,
$year )

Get the next following month.

Parameters
int$monththe number of the month.
int$yearthe number of the year.
Return values
arraythe following month

◆ calendar_add_subscription()

calendar_add_subscription ( $sub)

Add an iCalendar subscription to the database.

Parameters
stdClass$subThe subscription object (e.g. from the form)
Return values
intThe insert ID, if any.

◆ calendar_can_edit_subscription()

calendar_can_edit_subscription ( $subscriptionorid)

Checks to see if the user can edit a given subscription feed.

Parameters
mixed$subscriptionoridSubscription object or id
Return values
booltrue if current user can edit the subscription else false

◆ calendar_can_manage_non_user_event_in_system()

calendar_can_manage_non_user_event_in_system ( $event)

Can current user manage a non user event in system context.

Parameters
calendar_event | stdClass$eventevent object
Return values
boolean

◆ calendar_can_manage_user_event()

calendar_can_manage_user_event ( $event)

Can current user edit/delete/add an user event?

Parameters
calendar_event | stdClass$eventevent object
Return values
bool

◆ calendar_day_representation()

calendar_day_representation ( $tstamp,
$now = false,
$usecommonwords = true )

Return the representation day.

Parameters
int$tstampTimestamp in GMT
int | bool$nowcurrent Unix timestamp
bool$usecommonwords
Return values
stringthe formatted date/time

◆ calendar_days_in_month()

calendar_days_in_month ( $month,
$year )

Return the number of days in month.

Parameters
int$monththe number of the month.
int$yearthe number of the year
Return values
int

◆ calendar_delete_event_allowed()

calendar_delete_event_allowed ( $event)

Return the capability for deleting a calendar event.

Parameters
calendar_event$eventThe event object
Return values
boolWhether the user has permission to delete the event or not.

◆ calendar_delete_subscription()

calendar_delete_subscription ( $subscription)

Delete subscription and all related events.

Parameters
int | stdClass$subscriptionsubscription or it's id, which needs to be deleted.

◆ calendar_edit_event_allowed()

calendar_edit_event_allowed ( $event,
$manualedit = false )

Return the capability for editing calendar event.

Parameters
calendar_event$eventevent object
bool$manualeditis the event being edited manually by the user
Return values
boolcapability to edit event

◆ calendar_events_by_day()

calendar_events_by_day ( $events,
$month,
$year,
& $eventsbyday,
& $durationbyday,
& $typesbyday,
& $courses )

Get per-day basis events.

Parameters
array$eventslist of events
int$monththe number of the month
int$yearthe number of the year
array$eventsbydayevent on specific day
array$durationbydayduration of the event in days
array$typesbydayevent type (eg: site, course, user, or group)
array$courseslist of courses
Return values
void

◆ calendar_format_event_location()

calendar_format_event_location ( calendar_event $event)

Format event location property.

Parameters
calendar_event$event
Return values
string

◆ calendar_format_event_time()

calendar_format_event_time ( $event,
$now,
$linkparams = null,
$usecommonwords = true,
$showtime = 0 )

Get event format time.

Parameters
calendar_event$eventevent object
int$nowcurrent time in gmt
array$linkparamslist of params for event link
bool$usecommonwordsthe words as formatted date/time.
int$showtimedetermine the show time GMT timestamp
Return values
string\$eventtimelink/string for event time

◆ calendar_get_allowed_event_types()

calendar_get_allowed_event_types ( int $courseid = null)

Get event types the user can create event based on categories, courses and groups the logged in user belongs to.

Parameters
int | null$courseidThe course id.
Return values
arrayThe array of allowed types.

◆ calendar_get_allowed_types()

calendar_get_allowed_types ( & $allowed,
$course = null,
$groups = null,
$category = null )

Get calendar's allowed types.

Parameters
stdClass$allowedlist of allowed edit for event type
stdClass | int$courseobject of a course or course id
array$groupsarray of groups for the given course
stdClass | int$categoryobject of a category

◆ calendar_get_calendar_context()

calendar_get_calendar_context ( $subscription)

Helper function to determine the context of a calendar subscription.

Subscriptions can be created in two contexts COURSE, or USER.

Parameters
stdClass$subscription
Return values
contextinstance

◆ calendar_get_course_cached()

calendar_get_course_cached ( & $coursecache,
$courseid )

Get current course cache.

Parameters
array$coursecachelist of course cache
int$courseidid of the course
Return values
stdClass\$coursecache,[$courseid]return the specific course cache

◆ calendar_get_courselink()

calendar_get_courselink ( $course)

Get a HTML link to a course.

Parameters
int | stdClass$coursethe course id or course object
Return values
stringa link to the course (as HTML); empty if the course id is invalid

◆ calendar_get_days()

calendar_get_days ( )

Return the days of the week.

Return values
arrayarray of days

◆ calendar_get_default_courses()

calendar_get_default_courses ( $courseid = null,
$fields = '*',
$canmanage = false,
int $userid = null )

Returns the default courses to display on the calendar when there isn't a specific course to display.

Parameters
int$courseid(optional) If passed, an additional course can be returned for admins (the current course).
string$fieldsComma separated list of course fields to return.
bool$canmanageIf true, this will return the list of courses the user can create events in, rather than the list of courses they see events from (an admin can always add events in a course calendar, even if they are not enrolled in the course).
int$userid(optional) The user which this function returns the default courses for. By default the current user.
Return values
array\$coursesArray of courses to display

◆ calendar_get_events()

calendar_get_events ( $tstart,
$tend,
$users,
$groups,
$courses,
$withduration = true,
$ignorehidden = true,
$categories = [] )

Get calendar events.

Parameters
int$tstartStart time of time range for events
int$tendEnd time of time range for events
array | int | boolean$usersarray of users, user id or boolean for all/no user events
array | int | boolean$groupsarray of groups, group id or boolean for all/no group events
array | int | boolean$coursesarray of courses, course id or boolean for all/no course events
boolean$withdurationwhether only events starting within time range selected or events in progress/already started selected as well
boolean$ignorehiddenwhether to select only visible events or all events
array | int | boolean$categoriesarray of categories, category id or boolean for all/no course events
Return values
array\$eventsof selected events or an empty array if there aren't any (or there was an error)

◆ calendar_get_events_by_id()

calendar_get_events_by_id ( $eventids)

Get calendar events by id.

Since
Moodle 2.5
Parameters
array$eventidslist of event ids
Return values
arrayArray of event entries, empty array if nothing found

◆ calendar_get_eventtype_choices()

calendar_get_eventtype_choices ( $courseid)

Returns option list of available options for the calendar event type, given the current user and course.

Parameters
int$courseidThe id of the course
Return values
arrayAn array containing the event types the user can create.

◆ calendar_get_export_import_link_params()

calendar_get_export_import_link_params ( )

Get the list of URL parameters for calendar expport and import links.

Return values
array

◆ calendar_get_export_token()

calendar_get_export_token ( stdClass $user)

Get the auth token for exporting the given user calendar.

Parameters
stdClass$userThe user to export the calendar for
Return values
stringThe export token.

◆ calendar_get_filter_types()

calendar_get_filter_types ( )

Get the list of potential calendar filter types as a type => name combination.

Return values
array

◆ calendar_get_footer_options()

calendar_get_footer_options ( $calendar,
array $options = [] )

Get the calendar footer options.

Parameters
calendar_information$calendarThe calendar information object.
array$optionsDisplay options for the footer. If an option is not set, a default value will be provided. It consists of:
  • showfullcalendarlink - bool - Whether to show the full calendar link or not. Defaults to false.
Return values
arrayThe data for template and template name.

◆ calendar_get_group_cached()

calendar_get_group_cached ( $groupid)

Get group from groupid for calendar display.

Parameters
int$groupid
Return values
stdClassgroup object with fields 'id', 'name' and 'courseid'

◆ calendar_get_icalendar()

calendar_get_icalendar ( $url)

From a URL, fetch the calendar and return an iCalendar object.

Parameters
string$urlThe iCalendar URL
Return values
iCalendarThe iCalendar object

◆ calendar_get_legacy_events()

calendar_get_legacy_events ( $tstart,
$tend,
$users,
$groups,
$courses,
$withduration = true,
$ignorehidden = true,
$categories = [],
$limitnum = 0 )

Get legacy calendar events.

Parameters
int$tstartStart time of time range for events
int$tendEnd time of time range for events
array | int | boolean$usersarray of users, user id or boolean for all/no user events
array | int | boolean$groupsarray of groups, group id or boolean for all/no group events
array | int | boolean$coursesarray of courses, course id or boolean for all/no course events
boolean$withdurationwhether only events starting within time range selected or events in progress/already started selected as well
boolean$ignorehiddenwhether to select only visible events or all events
array$categoriesarray of category ids and/or objects.
int$limitnumNumber of events to fetch or zero to fetch all.
Return values
array\$eventsof selected events or an empty array if there aren't any (or there was an error)

◆ calendar_get_link_href()

calendar_get_link_href ( $linkbase,
$d,
$m,
$y,
$time = 0 )

Adds day, month, year arguments to a URL and returns a moodle_url object.

Parameters
string | moodle_url$linkbase
int$dThe number of the day.
int$mThe number of the month.
int$yThe number of the year.
int$timethe unixtime, used for multiple calendar support. The values $d, $m and $y are kept for backwards compatibility.
Return values
moodle_url|null\$linkbase

◆ calendar_get_link_next()

calendar_get_link_next ( $text,
$linkbase,
$d,
$m,
$y,
$accesshide = false,
$time = 0 )

Build and return a next month HTML link, with an arrow.

Deprecated
since Moodle 4.3
Parameters
string$textThe text label.
string | moodle_url$linkbaseThe URL stub.
int$dthe number of the Day
int$mThe number of the month.
int$yThe number of the year.
bool$accesshideDefault visible, or hide from all except screenreaders.
int$timethe unixtime, used for multiple calendar support. The values $d, $m and $y are kept for backwards compatibility.
Return values
stringHTML string.

◆ calendar_get_link_previous()

calendar_get_link_previous ( $text,
$linkbase,
$d,
$m,
$y,
$accesshide = false,
$time = 0 )

Build and return a previous month HTML link, with an arrow.

Deprecated
since Moodle 4.3
Parameters
string$textThe text label.
string | moodle_url$linkbaseThe URL stub.
int$dThe number of the date.
int$mThe number of the month.
int$yyear The number of the year.
bool$accesshideDefault visible, or hide from all except screenreaders.
int$timethe unixtime, used for multiple calendar support. The values $d, $m and $y are kept for backwards compatibility.
Return values
stringHTML string.

◆ calendar_get_module_cached()

calendar_get_module_cached ( & $modulecache,
$modulename,
$instance )

Get current module cache.

Only use this method if you do not know courseid. Otherwise use: get_fast_modinfo($courseid)->instances[$modulename][$instance]

Parameters
array$modulecachein memory module cache
string$modulenamename of the module
int$instancemodule instance number
Return values
stdClass|bool\$moduleinformation

◆ calendar_get_pollinterval_choices()

calendar_get_pollinterval_choices ( )

Returns option list for the poll interval setting.

Return values
arrayAn array of poll interval options. Interval => description.

◆ calendar_get_starting_weekday()

calendar_get_starting_weekday ( )

Gets the first day of the week.

Used to be define('CALENDAR_STARTING_WEEKDAY', blah);

Return values
int

◆ calendar_get_subscription()

calendar_get_subscription ( $id)

Get the subscription from a given id.

Since
Moodle 2.5
Parameters
int$idid of the subscription
Return values
stdClassSubscription record from DB
Exceptions
moodle_exceptionfor an invalid id

◆ calendar_get_timestamp()

calendar_get_timestamp ( $d,
$m,
$y,
$time = 0 )

Calculate the timestamp from the supplied Gregorian Year, Month, and Day.

Parameters
int$dThe day
int$mThe month
int$yThe year
int$timeThe timestamp to use instead of a separate y/m/d.
Return values
intThe timestamp

◆ calendar_get_view()

calendar_get_view ( \calendar_information $calendar,
$view,
$includenavigation = true,
bool $skipevents = false,
?int $lookahead = null )

Get the calendar view output.

Parameters
calendar_information$calendarThe calendar being represented
string$viewThe type of calendar to have displayed
bool$includenavigationWhether to include navigation
bool$skipeventsWhether to load the events or not
int$lookaheadOverwrites site and users's lookahead setting.
Return values
array[array,string]

◆ calendar_import_events_from_ical()

calendar_import_events_from_ical ( iCalendar $ical,
int $subscriptionid = null )

Import events from an iCalendar object into a course calendar.

Parameters
iCalendar$icalThe iCalendar object.
int | null$subscriptionidThe subscription ID.
Return values
arrayA log of the import progress, including errors.

◆ calendar_inplace_editable()

calendar_inplace_editable ( string $itemtype,
int $itemid,
int $newvalue )

Implements the inplace editable feature.

Parameters
string$itemtypeType of the inplace editable element
int$itemidId of the item to edit
int$newvalueNew value of the item
Return values
core\output\inplace_editable

◆ calendar_internal_update_course_and_group_permission()

calendar_internal_update_course_and_group_permission ( int $courseid,
context $context,
array & $types )

Given a course id, and context, updates the permission types array to add the 'course' or 'group' permission if it is relevant for that course.

For efficiency, if they already have 'course' or 'group' then it skips checks.

Do not call this function directly, it is only for use by calendar_get_allowed_event_types().

Parameters
int$courseidCourse id
context$contextContext for that course
array$typesCurrent permissions

◆ calendar_is_valid_eventtype()

calendar_is_valid_eventtype ( $type)

Check whether the specified event type is valid.

Parameters
string$type
Return values
bool

◆ calendar_output_fragment_event_form()

calendar_output_fragment_event_form ( $args)

Request and render event form fragment.

Parameters
array$argsThe fragment arguments.
Return values
stringThe rendered mform fragment.

◆ calendar_set_event_type_display()

calendar_set_event_type_display ( $type,
$display = null,
$user = null )

Sets the display of the event type given $display.

If $display = true the event type will be shown. If $display = false the event type will NOT be shown. If $display = null the current value will be toggled and saved.

Parameters
int$typeobject of CALENDAR_EVENT_XXX
bool$displayoption to display event type
stdClass | int$usermoodle user object or id, null means current user

◆ calendar_set_filters()

calendar_set_filters ( array $courseeventsfrom,
$ignorefilters = false,
stdClass $user = null )

Returns the courses to load events for.

Parameters
array$courseeventsfromAn array of courses to load calendar events for
bool$ignorefiltersspecify the use of filters, false is set as default
stdClass$userThe user object. This defaults to the global $USER object.
Return values
arrayAn array of courses, groups, and user to load calendar events for based upon filters

◆ calendar_show_event_type()

calendar_show_event_type ( $type,
$user = null )

Checks to see if the requested type of event should be shown for the given user.

Parameters
int$typeThe type to check the display for (default is to display all)
stdClass | int | null$userThe user to check for - by default the current user
Return values
boolTrue if the tyep should be displayed false otherwise

◆ calendar_sub_month()

calendar_sub_month ( $month,
$year )

Get the previous month.

Parameters
int$monththe number of the month.
int$yearthe number of the year.
Return values
arrayprevious month

◆ calendar_time_representation()

calendar_time_representation ( $time)

return the formatted representation time.

Parameters
int$timethe timestamp in UTC, as obtained from the database
Return values
stringthe formatted date/time

◆ calendar_top_controls()

calendar_top_controls ( $type,
$data )

Get control options for calendar.

Deprecated
since Moodle 4.3
Parameters
string$typeof calendar
array$datacalendar information
Return values
string\$contentreturn available control for the calendar in html

◆ calendar_update_subscription()

calendar_update_subscription ( $subscription)

Update a calendar subscription.

Also updates the associated cache.

Parameters
stdClass | array$subscriptionSubscription record.
Exceptions
coding_exceptionIf something goes wrong
Since
Moodle 2.5

◆ calendar_update_subscription_events()

calendar_update_subscription_events ( $subscriptionid)

Fetch a calendar subscription and update the events in the calendar.

Parameters
int$subscriptionidThe course ID for the calendar.
Return values
arrayA log of the import progress, including errors.

◆ calendar_user_can_add_event()

calendar_user_can_add_event ( $course)

See if user can add calendar entries at all used to print the "New Event" button.

Parameters
stdClass$courseobject of a course or course id
Return values
boolhas the capability to add at least one event type

◆ calendar_view_event_allowed()

calendar_view_event_allowed ( calendar_event $event)

Return the capability for viewing a calendar event.

Parameters
calendar_event$eventevent object
Return values
boolean

◆ core_calendar_user_preferences()

core_calendar_user_preferences ( )

Implements callback user_preferences, lists preferences that users are allowed to update directly.

Used in {

See also
core_user\fill_preferences_cache()}, see also {
useredit_update_user_preference()}
Return values
array

◆ create_action_event()

create_action_event ( array $data)

Helper function to create an action event.

Parameters
array$dataThe event data.
Return values
bool|calendar_event

◆ create_event()

create_event ( $properties)

Create a calendar event with the given properties.

Parameters
array$propertiesThe properties to set on the event
Return values
calendar_event

◆ create_group_override_event()

create_group_override_event ( string $modulename,
int $instanceid,
int $courseid,
int $groupid )

Helper function to create an group override calendar event.

Parameters
string$modulenameThe modulename.
int$instanceidThe instance id.
int$courseidThe course id.
int$groupidThe group id.
Return values
calendar_event|false

◆ create_standard_events()

create_standard_events ( int $quantity)

Helper function to create a x number of events for each event type.

Parameters
int$quantityThe quantity of events to be created.
Return values
arrayList of created events.

◆ create_user_override_event()

create_user_override_event ( string $modulename,
int $instanceid,
int $userid )

Helper function to create an user override calendar event.

Parameters
string$modulenameThe modulename.
int$instanceidThe instance id.
int$useridThe user id.
Return values
calendar_event|false

Variable Documentation

◆ CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD

const CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD(!defined( 'MOODLE_INTERNAL')) ( ! defined 'MOODLE_INTERNAL') 21

These are read by the administration component to provide default values.

CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD - default value of upcoming event preference