Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250620) (7d9030acd6e)
|
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 |
| |
Functions | |
calendar_add_event_allowed ($event) | |
Check wether the current user is permitted to add events. | |
calendar_add_icalendar_event ($event, $unused, $subscriptionid, $timezone='UTC') | |
Add an iCalendar event to the Moodle calendar. | |
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_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_format_event_location (calendar_event $event) | |
Format event location property. | |
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_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_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_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 |
replacement | $now = false |
replacement | __pad0__ |
Return the representation day. | |
const | CALENDAR_DEFAULT_STARTING_WEEKDAY 1 |
CALENDAR_DEFAULT_STARTING_WEEKDAY - default value to display the starting weekday. | |
const | CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD 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. | |
Use | core_calendar\output::DateTimeInterface |
if (!defined( 'MOODLE_INTERNAL')) | |
if (!defined( 'MOODLE_INTERNAL')) | |
replacement | mdl |
replacement | since |
calendar_add_event_allowed | ( | $event | ) |
Check wether the current user is permitted to add events.
stdClass | $event | object of event |
bool | has the capability to add event |
calendar_add_icalendar_event | ( | $event, | |
$unused, | |||
$subscriptionid, | |||
$timezone = 'UTC' ) |
Add an iCalendar event to the Moodle calendar.
stdClass | $event | The RFC-2445 iCalendar event |
int | $unused | Deprecated |
int | $subscriptionid | The iCalendar subscription ID |
string | $timezone | The X-WR-TIMEZONE iCalendar property if provided |
dml_exception | A DML specific exception is thrown for invalid subscriptionids. |
int | Code: CALENDAR_IMPORT_EVENT_UPDATED = updated, CALENDAR_IMPORT_EVENT_INSERTED = inserted, 0 = error |
calendar_add_subscription | ( | $sub | ) |
Add an iCalendar subscription to the database.
stdClass | $sub | The subscription object (e.g. from the form) |
int | The insert ID, if any. |
calendar_can_edit_subscription | ( | $subscriptionorid | ) |
Checks to see if the user can edit a given subscription feed.
mixed | $subscriptionorid | Subscription object or id |
bool | true if current user can edit the subscription else false |
calendar_can_manage_non_user_event_in_system | ( | $event | ) |
Can current user manage a non user event in system context.
calendar_event | stdClass | $event | event object |
boolean |
calendar_can_manage_user_event | ( | $event | ) |
Can current user edit/delete/add an user event?
calendar_event | stdClass | $event | event object |
bool |
calendar_days_in_month | ( | $month, | |
$year ) |
Return the number of days in month.
int | $month | the number of the month. |
int | $year | the number of the year |
int |
calendar_delete_event_allowed | ( | $event | ) |
Return the capability for deleting a calendar event.
calendar_event | $event | The event object |
bool | Whether the user has permission to delete the event or not. |
calendar_delete_subscription | ( | $subscription | ) |
Delete subscription and all related events.
int | stdClass | $subscription | subscription or it's id, which needs to be deleted. |
calendar_edit_event_allowed | ( | $event, | |
$manualedit = false ) |
Return the capability for editing calendar event.
calendar_event | $event | event object |
bool | $manualedit | is the event being edited manually by the user |
bool | capability to edit event |
calendar_format_event_location | ( | calendar_event | $event | ) |
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.
int | null | $courseid | The course id. |
array | The array of allowed types. |
calendar_get_allowed_types | ( | & | $allowed, |
$course = null, | |||
$groups = null, | |||
$category = null ) |
Get calendar's allowed types.
stdClass | $allowed | list of allowed edit for event type |
stdClass | int | $course | object of a course or course id |
array | $groups | array of groups for the given course |
stdClass | int | $category | object of a category |
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.
stdClass | $subscription |
context | instance |
calendar_get_course_cached | ( | & | $coursecache, |
$courseid ) |
Get current course cache.
array | $coursecache | list of course cache |
int | $courseid | id of the course |
stdClass#$coursecache,[$courseid] | return the specific course cache |
calendar_get_days | ( | ) |
Return the days of the week.
array | array of days |
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.
int | $courseid | (optional) If passed, an additional course can be returned for admins (the current course). |
string | $fields | Comma separated list of course fields to return. |
bool | $canmanage | If 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. |
array#$courses | Array of courses to display |
calendar_get_events | ( | $tstart, | |
$tend, | |||
$users, | |||
$groups, | |||
$courses, | |||
$withduration = true, | |||
$ignorehidden = true, | |||
$categories = [] ) |
Get calendar events.
int | $tstart | Start time of time range for events |
int | $tend | End time of time range for events |
array | int | boolean | $users | array of users, user id or boolean for all/no user events |
array | int | boolean | $groups | array of groups, group id or boolean for all/no group events |
array | int | boolean | $courses | array of courses, course id or boolean for all/no course events |
boolean | $withduration | whether only events starting within time range selected or events in progress/already started selected as well |
boolean | $ignorehidden | whether to select only visible events or all events |
array | int | boolean | $categories | array of categories, category id or boolean for all/no course events |
array#$events | of selected events or an empty array if there aren't any (or there was an error) |
calendar_get_events_by_id | ( | $eventids | ) |
Get calendar events by id.
array | $eventids | list of event ids |
array | Array of event entries, empty array if nothing found |
calendar_get_eventtype_choices | ( | $courseid | ) |
Returns option list of available options for the calendar event type, given the current user and course.
int | $courseid | The id of the course |
array | An array containing the event types the user can create. |
calendar_get_export_import_link_params | ( | ) |
Get the list of URL parameters for calendar expport and import links.
array |
calendar_get_export_token | ( | stdClass | $user | ) |
Get the auth token for exporting the given user calendar.
stdClass | $user | The user to export the calendar for |
string | The export token. |
calendar_get_filter_types | ( | ) |
Get the list of potential calendar filter types as a type => name combination.
array |
calendar_get_footer_options | ( | $calendar, | |
array | $options = [] ) |
Get the calendar footer options.
calendar_information | $calendar | The calendar information object. |
array | $options | Display options for the footer. If an option is not set, a default value will be provided. It consists of:
|
array | The data for template and template name. |
calendar_get_group_cached | ( | $groupid | ) |
Get group from groupid for calendar display.
int | $groupid |
stdClass | group object with fields 'id', 'name' and 'courseid' |
calendar_get_icalendar | ( | $url | ) |
calendar_get_legacy_events | ( | $tstart, | |
$tend, | |||
$users, | |||
$groups, | |||
$courses, | |||
$withduration = true, | |||
$ignorehidden = true, | |||
$categories = [], | |||
$limitnum = 0 ) |
Get legacy calendar events.
int | $tstart | Start time of time range for events |
int | $tend | End time of time range for events |
array | int | boolean | $users | array of users, user id or boolean for all/no user events |
array | int | boolean | $groups | array of groups, group id or boolean for all/no group events |
array | int | boolean | $courses | array of courses, course id or boolean for all/no course events |
boolean | $withduration | whether only events starting within time range selected or events in progress/already started selected as well |
boolean | $ignorehidden | whether to select only visible events or all events |
array | $categories | array of category ids and/or objects. |
int | $limitnum | Number of events to fetch or zero to fetch all. |
array#$events | of selected events or an empty array if there aren't any (or there was an error) |
calendar_get_link_href | ( | $linkbase, | |
$d, | |||
$m, | |||
$y, | |||
$time = 0 ) |
Adds day, month, year arguments to a URL and returns a moodle_url object.
string | moodle_url | $linkbase | |
int | $d | The number of the day. |
int | $m | The number of the month. |
int | $y | The number of the year. |
int | $time | the unixtime, used for multiple calendar support. The values $d, $m and $y are kept for backwards compatibility. |
moodle_url|null#$linkbase |
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]
array | $modulecache | in memory module cache |
string | $modulename | name of the module |
int | $instance | module instance number |
stdClass|bool#$module | information |
calendar_get_pollinterval_choices | ( | ) |
Returns option list for the poll interval setting.
array | An array of poll interval options. Interval => description. |
calendar_get_starting_weekday | ( | ) |
Gets the first day of the week.
Used to be define('CALENDAR_STARTING_WEEKDAY', blah);
int |
calendar_get_subscription | ( | $id | ) |
calendar_get_timestamp | ( | $d, | |
$m, | |||
$y, | |||
$time = 0 ) |
Calculate the timestamp from the supplied Gregorian Year, Month, and Day.
int | $d | The day |
int | $m | The month |
int | $y | The year |
int | $time | The timestamp to use instead of a separate y/m/d. |
int | The timestamp |
calendar_get_view | ( | \calendar_information | $calendar, |
$view, | |||
$includenavigation = true, | |||
bool | $skipevents = false, | ||
?int | $lookahead = null ) |
Get the calendar view output.
calendar_information | $calendar | The calendar being represented |
string | $view | The type of calendar to have displayed |
bool | $includenavigation | Whether to include navigation |
bool | $skipevents | Whether to load the events or not |
int | $lookahead | Overwrites site and users's lookahead setting. |
array[array,string] |
calendar_import_events_from_ical | ( | iCalendar | $ical, |
?int | $subscriptionid = null ) |
calendar_inplace_editable | ( | string | $itemtype, |
int | $itemid, | ||
int | $newvalue ) |
Implements the inplace editable feature.
string | $itemtype | Type of the inplace editable element |
int | $itemid | Id of the item to edit |
int | $newvalue | New value of the item |
core\output\inplace_editable |
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().
int | $courseid | Course id |
context | $context | Context for that course |
array | $types | Current permissions |
calendar_is_valid_eventtype | ( | $type | ) |
Check whether the specified event type is valid.
string | $type |
bool |
calendar_output_fragment_event_form | ( | $args | ) |
Request and render event form fragment.
array | $args | The fragment arguments. |
string | The rendered mform fragment. |
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.
int | $type | object of CALENDAR_EVENT_XXX |
bool | $display | option to display event type |
stdClass | int | $user | moodle user object or id, null means current user |
calendar_set_filters | ( | array | $courseeventsfrom, |
$ignorefilters = false, | |||
?stdClass | $user = null ) |
Returns the courses to load events for.
array | $courseeventsfrom | An array of courses to load calendar events for |
bool | $ignorefilters | specify the use of filters, false is set as default |
stdClass | $user | The user object. This defaults to the global $USER object. |
array | An array of courses, groups, and user to load calendar events for based upon filters |
calendar_show_event_type | ( | $type, | |
$user = null ) |
Checks to see if the requested type of event should be shown for the given user.
int | $type | The type to check the display for (default is to display all) |
stdClass | int | null | $user | The user to check for - by default the current user |
bool | True if the tyep should be displayed false otherwise |
calendar_update_subscription | ( | $subscription | ) |
Update a calendar subscription.
Also updates the associated cache.
stdClass | array | $subscription | Subscription record. |
coding_exception | If something goes wrong |
calendar_update_subscription_events | ( | $subscriptionid | ) |
Fetch a calendar subscription and update the events in the calendar.
int | $subscriptionid | The course ID for the calendar. |
array | A log of the import progress, including errors. |
calendar_user_can_add_event | ( | $course | ) |
See if user can add calendar entries at all used to print the "New Event" button.
stdClass | $course | object of a course or course id |
bool | has the capability to add at least one event type |
calendar_view_event_allowed | ( | calendar_event | $event | ) |
Return the capability for viewing a calendar event.
calendar_event | $event | event object |
boolean |
core_calendar_user_preferences | ( | ) |
Implements callback user_preferences, lists preferences that users are allowed to update directly.
Used in {
array |
create_action_event | ( | array | $data | ) |
Helper function to create an action event.
array | $data | The event data. |
bool|calendar_event |
create_event | ( | $properties | ) |
Create a calendar event with the given properties.
array | $properties | The properties to set on the event |
calendar_event |
create_group_override_event | ( | string | $modulename, |
int | $instanceid, | ||
int | $courseid, | ||
int | $groupid ) |
Helper function to create an group override calendar event.
string | $modulename | The modulename. |
int | $instanceid | The instance id. |
int | $courseid | The course id. |
int | $groupid | The group id. |
calendar_event|false |
create_standard_events | ( | int | $quantity | ) |
Helper function to create a x number of events for each event type.
int | $quantity | The quantity of events to be created. |
array | List of created events. |
create_user_override_event | ( | string | $modulename, |
int | $instanceid, | ||
int | $userid ) |
Helper function to create an user override calendar event.
string | $modulename | The modulename. |
int | $instanceid | The instance id. |
int | $userid | The user id. |
calendar_event|false |
replacement __pad0__ |
Return the representation day.
int | $tstamp | Timestamp in GMT |
int | bool | $now | current Unix timestamp |
bool | $usecommonwords |
string | the formatted date/time |
const CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD 21 |
These are read by the administration component to provide default values.
CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD - default value of upcoming event preference