[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [FIX] ical export - observe rfc formats for datetime metadata and other fixes
"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <69e721a4501da_3818f3bc969d0@gitlab-sidekiq-low-urgency-cpu-bound-v2-55bc4579f-tbdkv.mail> |
Victor Emanouilov pushed to branch 27.x at Tiki Wiki CMS Groupware / Tiki
Commits:
c163811a by Victor Emanouilov at 2026-04-21T10:05:01+03:00
[FIX] ical export - observe rfc formats for datetime metadata and other fixes
---
* [FIX] ical export - observe rfc formats for datetime metadata, fix newlines escaping issue, switch to utf8
See merge request tikiwiki/tiki!10061
- - - - -
1 changed file:
- tiki-calendar_export_ical.php
Changes:
=====================================
tiki-calendar_export_ical.php
=====================================
@@ -143,25 +143,39 @@ if (((is_array($calendarIds) && (count($calendarIds) > 0)) or isset($_REQUEST["c
$vcalendar = new Sabre\VObject\Component\VCalendar();
+ // RFC 5545 §3.8.7.2/§3.8.7.3 require DTSTAMP and LAST-MODIFIED to be UTC.
+ // DTSTART/DTEND are emitted in the calendar owner's display timezone to
+ // stay consistent with the CalDAV export (see Tiki\SabreDav\Utilities::
+ // constructCalendarData). No VTIMEZONE component is emitted - clients are
+ // expected to resolve the TZID name, same as the CalDAV path.
+ $utc = new DateTimeZone('UTC');
+ $tikilib = TikiLib::lib('tiki');
+ $calendar_timezones = [];
+
foreach ($events as $event) {
+ $calendarId = $event['calendarId'];
+ if (! isset($calendar_timezones[$calendarId])) {
+ $calendarOwner = $calendars['data'][$calendarId]['user'] ?? $user;
+ $calendar_timezones[$calendarId] = new DateTimeZone(
+ $tikilib->get_display_timezone($calendarOwner)
+ );
+ }
+ $eventTz = $calendar_timezones[$calendarId];
+
$vevent = [];
$vevent['SUMMARY'] = $event['name'];
- $vevent['DTSTART'] = (new DateTime())->setTimestamp($event['start']);
- $vevent['DTEND'] = (new DateTime())->setTimestamp($event['end']);
-
- $vevent['DESCRIPTION'] = preg_replace(
- '/\n/',
- "\\n",
- strip_tags(
- TikiLib::lib('parser')->parse_data(
- $event['description'],
- ['is_html' => $prefs['calendar_description_is_html'] === 'y']
- )
+ $vevent['DTSTART'] = (new DateTime('@' . $event['start']))->setTimezone($eventTz);
+ $vevent['DTEND'] = (new DateTime('@' . $event['end']))->setTimezone($eventTz);
+
+ $vevent['DESCRIPTION'] = strip_tags(
+ TikiLib::lib('parser')->parse_data(
+ $event['description'],
+ ['is_html' => $prefs['calendar_description_is_html'] === 'y']
)
);
- $vevent['DTSTAMP'] = (new DateTime())->setTimestamp($event['created']);
- $vevent['LAST-MODIFIED'] = (new DateTime())->setTimestamp($event['lastModif']);
+ $vevent['DTSTAMP'] = (new DateTime('@' . $event['created']))->setTimezone($utc);
+ $vevent['LAST-MODIFIED'] = (new DateTime('@' . $event['lastModif']))->setTimezone($utc);
$vevent['CONTACT'] = $event['user']; // Name
@@ -202,16 +216,9 @@ if (((is_array($calendarIds) && (count($calendarIds) > 0)) or isset($_REQUEST["c
// These two lines fix pb with IE and HTTPS
header("Cache-Control: private");
header("Pragma: dummy=bogus");
- // Outlook needs iso8859 encoding
- header("Content-Type:text/calendar; method=REQUEST; charset=iso-8859-15");
+ header('Content-Type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename=tiki-calendar.ics');
- header("Content-Transfer-Encoding:quoted-printable");
- $re_encode = stripos($_SERVER['HTTP_USER_AGENT'], 'windows'); // only re-encode to ISO-8859-15 if client on Windows
- if (function_exists('iconv') && $re_encode !== false) {
- print(iconv("UTF-8", "ISO-8859-15", $calendar_str));
- } else {
- print($calendar_str); // UTF-8 is good for other platforms
- }
+ print($calendar_str);
}
die;
}
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/c163811a4a996acfac7b20a474e666355fc33eb4
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/c163811a4a996acfac7b20a474e666355fc33eb4
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs