Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
|
Defines calendar class to manage recurrence rule (rrule) during ical imports. More...
Public Member Functions | |
__construct ($rrule) | |
Constructor for the class. | |
create_events ($passedevent) | |
Create events for specified rrule. | |
parse_rrule () | |
Parse the recurrence rule and setup all properties. | |
Public Attributes | |
const | DAY_FRIDAY = 'Friday' |
const string Day constant | |
const | DAY_MONDAY = 'Monday' |
const string Day constant | |
const | DAY_SATURDAY = 'Saturday' |
const string Day constant | |
const | DAY_SUNDAY = 'Sunday' |
const string Day constant | |
const | DAY_THURSDAY = 'Thursday' |
const string Day constant | |
const | DAY_TUESDAY = 'Tuesday' |
const string Day constant | |
const | DAY_WEDNESDAY = 'Wednesday' |
const string Day constant | |
const | DAYS_OF_WEEK |
const array Array of days in a week. | |
const | FREQ_DAILY = 'daily' |
const string Frequency constant | |
const | FREQ_HOURLY = 'hourly' |
const string Frequency constant | |
const | FREQ_MINUTELY = 'everyminute' |
const string Frequency constant | |
const | FREQ_MONTHLY = 'monthly' |
const string Frequency constant | |
const | FREQ_SECONDLY = 'everysecond' |
const string Frequency constant | |
const | FREQ_WEEKLY = 'weekly' |
const string Frequency constant | |
const | FREQ_YEARLY = 'yearly' |
const string Frequency constant | |
const | TIME_UNLIMITED_YEARS = 10 |
const int For forever repeating events, repeat for this many years | |
Protected Member Functions | |
apply_hour_minute_second_rules (DateTime $eventdatetime, $eventdates) | |
Applies BYHOUR, BYMINUTE and BYSECOND rules to the calculated event dates. | |
create_recurring_events ($event, $eventtimes) | |
Creates calendar events for the recurring events. | |
filter_by_day ($event, $eventdates, $until) | |
Filter event times based on the BYDAY rule. | |
filter_by_month ($eventdates) | |
Filter event times based on the BYMONTH rule. | |
filter_by_monthday ($eventdates) | |
Filter event times based on the BYMONTHDAY rule. | |
filter_by_setpos ($event, $eventtimes, $until) | |
Filter event times based on the BYSETPOS rule. | |
filter_by_weekno ($eventdates) | |
Filter event times based on the BYWEEKNO rule. | |
filter_by_yearday ($eventdates) | |
Filter event times based on the BYYEARDAY rule. | |
generate_recurring_event_times ($event) | |
Generates recurring events based on the parent event and the RRULE set. | |
get_day ($daystring) | |
Gets the day from day string. | |
get_interval () | |
Generates a DateInterval object based on the FREQ and INTERVAL rules. | |
get_period_boundaries ($eventtime) | |
Determines the start and end DateTime objects that serve as references to determine whether a calculated event timestamp falls on the period defined by these DateTimes objects. | |
get_period_bounds_list ($eventtime, $until) | |
Gets the list of period boundaries covered by the recurring events. | |
has_by_rules () | |
Determines whether the RRULE has BYxxx rules or not. | |
in_bounds ($time, $bounds) | |
Determine whether the date-time in question is within the bounds of the periods that are covered by the RRULE. | |
parse_rrule_property ($prop) | |
Parse a property of the recurrence rule. | |
set_byday ($byday) | |
Sets the BYDAY rule. | |
set_byhour ($byhour) | |
Sets the BYHOUR rule. | |
set_byminute ($byminute) | |
Sets the BYMINUTE rule. | |
set_bymonth ($bymonth) | |
Sets the BYMONTH rule. | |
set_bymonthday ($bymonthday) | |
Sets the BYMONTHDAY rule. | |
set_bysecond ($bysecond) | |
Sets the BYSECOND rule. | |
set_bysetpos ($bysetpos) | |
Sets the BYSETPOS rule. | |
set_byweekno ($byweekno) | |
Sets the BYWEEKNO rule. | |
set_byyearday ($byyearday) | |
Sets the BYYEARDAY rule. | |
set_count ($count) | |
Sets the COUNT rule. | |
set_frequency ($freq) | |
Sets Frequency property. | |
set_interval ($intervalstr) | |
Sets the INTERVAL rule. | |
set_until ($until) | |
Sets the UNTIL rule. | |
validate_rules () | |
Validate the rules as a whole. | |
Protected Attributes | |
array | $byday = array() |
List of day rules. | |
array | $byhour = array() |
List of hour rules. | |
array | $byminute = array() |
List of Minute rules. | |
array | $bymonth = array() |
List of month rules. | |
array | $bymonthday = array() |
List of monthday rules. | |
array | $bysecond = array() |
List of second rules. | |
array | $bysetpos = array() |
List of setpos rules. | |
array | $byweekno = array() |
List of weekno rules. | |
array | $byyearday = array() |
List of yearday rules. | |
int | $count = 0 |
Defines the number of occurrences at which to range-bound the recurrence. | |
string | $freq |
Frequency of event. | |
int | $interval = 1 |
This rule part contains a positive integer representing how often the recurrence rule repeats. | |
string | $rrule |
string representing the recurrence rule | |
int | $until = 0 |
defines a timestamp value which bounds the recurrence rule in an inclusive manner. | |
string | $wkst = self::DAY_MONDAY |
Week start rule. | |
Defines calendar class to manage recurrence rule (rrule) during ical imports.
Please refer to RFC 2445 for detail explanation of the logic. Here is a basic extract from it to explain various params:- recur = "FREQ"=freq *( ; either UNTIL or COUNT may appear in a 'recur', ; but UNTIL and COUNT MUST NOT occur in the same 'recur' ( ";" "UNTIL" "=" enddate ) / ( ";" "COUNT" "=" 1*DIGIT ) / ; the rest of these keywords are optional, ; but MUST NOT occur more than once ( ";" "INTERVAL" "=" 1*DIGIT ) / ( ";" "BYSECOND" "=" byseclist ) / ( ";" "BYMINUTE" "=" byminlist ) / ( ";" "BYHOUR" "=" byhrlist ) / ( ";" "BYDAY" "=" bywdaylist ) / ( ";" "BYMONTHDAY" "=" bymodaylist ) / ( ";" "BYYEARDAY" "=" byyrdaylist ) / ( ";" "BYWEEKNO" "=" bywknolist ) / ( ";" "BYMONTH" "=" bymolist ) / ( ";" "BYSETPOS" "=" bysplist ) / ( ";" "WKST" "=" weekday ) / ( ";" x-name "=" text ) )
freq = "SECONDLY" / "MINUTELY" / "HOURLY" / "DAILY" / "WEEKLY" / "MONTHLY" / "YEARLY" enddate = date enddate =/ date-time ;An UTC value byseclist = seconds / ( seconds *("," seconds) ) seconds = 1DIGIT / 2DIGIT ;0 to 59 byminlist = minutes / ( minutes *("," minutes) ) minutes = 1DIGIT / 2DIGIT ;0 to 59 byhrlist = hour / ( hour *("," hour) ) hour = 1DIGIT / 2DIGIT ;0 to 23 bywdaylist = weekdaynum / ( weekdaynum *("," weekdaynum) ) weekdaynum = [([plus] ordwk / minus ordwk)] weekday plus = "+" minus = "-" ordwk = 1DIGIT / 2DIGIT ;1 to 53 weekday = "SU" / "MO" / "TU" / "WE" / "TH" / "FR" / "SA" ;Corresponding to SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, ;FRIDAY, SATURDAY and SUNDAY days of the week. bymodaylist = monthdaynum / ( monthdaynum *("," monthdaynum) ) monthdaynum = ([plus] ordmoday) / (minus ordmoday) ordmoday = 1DIGIT / 2DIGIT ;1 to 31 byyrdaylist = yeardaynum / ( yeardaynum *("," yeardaynum) ) yeardaynum = ([plus] ordyrday) / (minus ordyrday) ordyrday = 1DIGIT / 2DIGIT / 3DIGIT ;1 to 366 bywknolist = weeknum / ( weeknum *("," weeknum) ) weeknum = ([plus] ordwk) / (minus ordwk) bymolist = monthnum / ( monthnum *("," monthnum) ) monthnum = 1DIGIT / 2DIGIT ;1 to 12 bysplist = setposday / ( setposday *("," setposday) ) setposday = yeardaynum
core_calendar\rrule_manager::__construct | ( | $rrule | ) |
Constructor for the class.
string | $rrule | Recurrence rule |
|
protected |
Applies BYHOUR, BYMINUTE and BYSECOND rules to the calculated event dates.
Defaults to the DTSTART's hour/minute/second component when not defined.
DateTime | $eventdatetime | The parent event DateTime object pertaining to the DTSTART. |
int[] | $eventdates | Array of candidate event date timestamps. |
array | List of updated event timestamps that contain the time component of the event times. |
core_calendar\rrule_manager::create_events | ( | $passedevent | ) |
Create events for specified rrule.
calendar_event | $passedevent | Properties of event to create. |
moodle_exception |
|
protected |
Creates calendar events for the recurring events.
stdClass | $event | The parent event. |
int[] | $eventtimes | The timestamps of the recurring events. |
|
protected |
Filter event times based on the BYDAY rule.
stdClass | $event | The parent event. |
int[] | $eventdates | The event times to be filtered. |
int | $until | Event times generation limit date. |
int[] | Array of filtered timestamps. |
|
protected |
Filter event times based on the BYMONTH rule.
int[] | $eventdates | Timestamps of event times to be filtered. |
int[] | Array of filtered timestamps. |
|
protected |
Filter event times based on the BYMONTHDAY rule.
int[] | $eventdates | The event times to be filtered. |
int[] | Array of filtered timestamps. |
|
protected |
Filter event times based on the BYSETPOS rule.
stdClass | $event | The parent event. |
int[] | $eventtimes | The event times to be filtered. |
int | $until | Event times generation limit date. |
int[] | Array of filtered timestamps. |
|
protected |
Filter event times based on the BYWEEKNO rule.
int[] | $eventdates | Timestamps of event times to be filtered. |
int[] | Array of filtered timestamps. |
|
protected |
Filter event times based on the BYYEARDAY rule.
int[] | $eventdates | Timestamps of event times to be filtered. |
int[] | Array of filtered timestamps. |
|
protected |
Generates recurring events based on the parent event and the RRULE set.
If multiple BYxxx rule parts are specified, then after evaluating the specified FREQ and INTERVAL rule parts, the BYxxx rule parts are applied to the current set of evaluated occurrences in the following order: BYMONTH, BYWEEKNO, BYYEARDAY, BYMONTHDAY, BYDAY, BYHOUR, BYMINUTE, BYSECOND and BYSETPOS; then COUNT and UNTIL are evaluated.
stdClass | $event | The event object. |
array | The list of timestamps that obey the given RRULE. |
|
protected |
Gets the day from day string.
string | $daystring | Day string (MO, TU, etc) |
moodle_exception |
string | Day represented by the parameter. |
|
protected |
Generates a DateInterval object based on the FREQ and INTERVAL rules.
DateInterval |
moodle_exception |
|
protected |
Determines the start and end DateTime objects that serve as references to determine whether a calculated event timestamp falls on the period defined by these DateTimes objects.
int | $eventtime | Unix timestamp of the event time. |
DateTime[] |
moodle_exception |
|
protected |
Gets the list of period boundaries covered by the recurring events.
int | $eventtime | The event timestamp. |
int | $until | The end timestamp. |
array | List of period bounds, with start and next properties. |
|
protected |
Determines whether the RRULE has BYxxx rules or not.
bool | True if there is one or more BYxxx rules to process. False, otherwise. |
|
protected |
Determine whether the date-time in question is within the bounds of the periods that are covered by the RRULE.
int | $time | The timestamp to be evaluated. |
array | $bounds | Array of period boundaries covered by the RRULE. |
bool |
|
protected |
Parse a property of the recurrence rule.
string | $prop | property string with type-value pair |
moodle_exception |
|
protected |
Sets the BYDAY rule.
The BYDAY rule part specifies a comma-separated list of days of the week;
Each BYDAY value can also be preceded by a positive (+n) or negative (-n) integer. If present, this indicates the nth occurrence of the specific day within the MONTHLY or YEARLY RRULE. For example, within a MONTHLY rule, +1MO (or simply 1MO) represents the first Monday within the month, whereas -1MO represents the last Monday of the month. If an integer modifier is not present, it means all days of this type within the specified frequency. For example, within a MONTHLY rule, MO represents all Mondays within the month.
string | $byday | Comma-separated list of days of the week. |
moodle_exception |
|
protected |
Sets the BYHOUR rule.
The BYHOUR rule part specifies a comma-separated list of hours of the day. Valid values are 0 to 23.
string | $byhour | Comma-separated list of hours of the day. |
moodle_exception |
|
protected |
Sets the BYMINUTE rule.
The BYMINUTE rule part specifies a comma-separated list of seconds within an hour. Valid values are 0 to 59.
string | $byminute | Comma-separated list of minutes within an hour. |
moodle_exception |
|
protected |
Sets the BYMONTH rule.
The BYMONTH rule part specifies a comma-separated list of months of the year. Valid values are 1 to 12.
string | $bymonth | Comma-separated list of months of the year. |
moodle_exception |
|
protected |
Sets the BYMONTHDAY rule.
The BYMONTHDAY rule part specifies a comma-separated list of days of the month. Valid values are 1 to 31 or -31 to -1. For example, -10 represents the tenth to the last day of the month.
string | $bymonthday | Comma-separated list of days of the month. |
moodle_exception |
|
protected |
Sets the BYSECOND rule.
The BYSECOND rule part specifies a comma-separated list of seconds within a minute. Valid values are 0 to 59.
string | $bysecond | Comma-separated list of seconds within a minute. |
moodle_exception |
|
protected |
Sets the BYSETPOS rule.
The BYSETPOS rule part specifies a comma-separated list of values which corresponds to the nth occurrence within the set of events specified by the rule. Valid values are 1 to 366 or -366 to -1. It MUST only be used in conjunction with another BYxxx rule part.
For example "the last work day of the month" could be represented as: RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1
string | $bysetpos | Comma-separated list of values. |
moodle_exception |
|
protected |
Sets the BYWEEKNO rule.
The BYWEEKNO rule part specifies a comma-separated list of ordinals specifying weeks of the year. Valid values are 1 to 53 or -53 to -1. This corresponds to weeks according to week numbering as defined in [ISO 8601]. A week is defined as a seven day period, starting on the day of the week defined to be the week start (see WKST). Week number one of the calendar year is the first week which contains at least four (4) days in that calendar year. This rule part is only valid for YEARLY rules. For example, 3 represents the third week of the year.
Note: Assuming a Monday week start, week 53 can only occur when Thursday is January 1 or if it is a leap year and Wednesday is January 1.
string | $byweekno | Comma-separated list of number of weeks. |
moodle_exception |
|
protected |
Sets the BYYEARDAY rule.
The BYYEARDAY rule part specifies a comma-separated list of days of the year. Valid values are 1 to 366 or -366 to -1. For example, -1 represents the last day of the year (December 31st) and -306 represents the 306th to the last day of the year (March 1st).
string | $byyearday | Comma-separated list of days of the year. |
moodle_exception |
|
protected |
|
protected |
|
protected |
Sets the INTERVAL rule.
The INTERVAL rule part contains a positive integer representing how often the recurrence rule repeats. The default value is "1", meaning:
string | $intervalstr | The value for the interval rule. |
moodle_exception |
|
protected |
Sets the UNTIL rule.
string | $until | The date string representation of the UNTIL rule. |
moodle_exception |
|
protected |
Validate the rules as a whole.
moodle_exception |
|
protected |
Week start rule.
Default is Monday.
const core_calendar\rrule_manager::DAYS_OF_WEEK |
const array Array of days in a week.