MDL-75627 Calendar: Fix calendar imports from Office 365

This commit is contained in:
Stephen Bourget 2022-09-06 22:18:53 -04:00
parent a7514f231d
commit 32f170c4b2

View File

@ -3091,11 +3091,21 @@ function calendar_import_events_from_ical(iCalendar $ical, int $subscriptionid =
\core_php_time_limit::raise(300);
}
// Start with a safe default timezone.
$timezone = 'UTC';
// Grab the timezone from the iCalendar file to be used later.
if (isset($ical->properties['X-WR-TIMEZONE'][0]->value)) {
$timezone = $ical->properties['X-WR-TIMEZONE'][0]->value;
} else {
$timezone = 'UTC';
} else if (isset($ical->properties['PRODID'][0]->value)) {
// If the timezone was not found, check to se if this is MS exchange / Office 365 which uses Windows timezones.
if (strncmp($ical->properties['PRODID'][0]->value, 'Microsoft', 9) == 0) {
if (isset($ical->components['VTIMEZONE'][0]->properties['TZID'][0]->value)) {
$tzname = $ical->components['VTIMEZONE'][0]->properties['TZID'][0]->value;
$timezone = IntlTimeZone::getIDForWindowsID($tzname);
}
}
}
$icaluuids = [];