From 6d2ab6a7d68ac8bb474344eeb1a3baa4cb7c3b99 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 3 Jun 2019 11:48:30 +0200 Subject: [PATCH 1/5] update changelog --- CHANGELOG | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 534d52320..47abe631c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,7 +7,7 @@ Hubzilla 4.2 (2019-??-??) - Do not try to oembed URLs without embed tags - Optimise pdf oembed processing - Add form security token to mod register - - Replace photo URL for gallery on clonned channel post sync + - Replace URLs for mod gallery, mod photos and mod photo on cloned channel post sync - Update justified gallery library - Update bootstrap libraries - Use "cache" flag for bbcode() on content destined for zot6 @@ -29,6 +29,8 @@ Hubzilla 4.2 (2019-??-??) - Implement option to store photo thumbnails in filesystem instead of DB Bugfixes + - Fix category widget when using articles + - Fix live update not triggering in mod search - Fix encoded URLs in code blocks - Fix wiki headers not escaped - Fix possible xchan protocol confusion in new_contact() From 66c6c6c7d1c87aa50ac0fe701505802110b8eecb Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 3 Jun 2019 11:25:48 +0000 Subject: [PATCH 2/5] regard timezones in calendar import/export (cherry picked from commit 5b4aa1afc2d3811aae93706299dfb5d5c703198f) --- Zotlabs/Module/Channel_calendar.php | 4 +++- include/event.php | 27 +++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php index 13f879d84..4f08eb27c 100644 --- a/Zotlabs/Module/Channel_calendar.php +++ b/Zotlabs/Module/Channel_calendar.php @@ -304,7 +304,9 @@ class Channel_calendar extends \Zotlabs\Web\Controller { ); } elseif($export) { - $r = q("SELECT * from event where uid = %d and dtstart > '%s' and dtend > dtstart", + $r = q("SELECT event.*, item.id as item_id + from event left join item on item.resource_id = event.event_hash + where event.uid = %d and event.dtstart > '%s' and event.dtend > event.dtstart", intval(local_channel()), dbesc(NULL_DATE) ); diff --git a/include/event.php b/include/event.php index de4e692b8..b1da2de8e 100644 --- a/include/event.php +++ b/include/event.php @@ -144,6 +144,12 @@ function format_event_ical($ev) { if($ev['etype'] === 'task') return format_todo_ical($ev); + $tz = get_iconfig($ev['item_id'], 'event', 'timezone'); + if(! $tz) + $tz = 'UTC'; + + $tzid = ';TZID=' . $tz; + $o = ''; $o .= "\r\nBEGIN:VEVENT"; @@ -151,10 +157,19 @@ function format_event_ical($ev) { $o .= "\r\nCREATED:" . datetime_convert('UTC','UTC', $ev['created'],'Ymd\\THis\\Z'); $o .= "\r\nLAST-MODIFIED:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z'); $o .= "\r\nDTSTAMP:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z'); - if($ev['dtstart']) - $o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['dtstart'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : '')); - if($ev['dtend'] && ! $ev['nofinish']) - $o .= "\r\nDTEND:" . datetime_convert('UTC','UTC', $ev['dtend'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : '')); + + if($ev['adjust']) { + if($ev['dtstart']) + $o .= "\r\nDTSTART$tzid:" . datetime_convert($tz,'UTC', $ev['dtstart'],'Ymd\\THis\\Z'); + if($ev['dtend'] && ! $ev['nofinish']) + $o .= "\r\nDTEND$tzid:" . datetime_convert($tz,'UTC', $ev['dtend'],'Ymd\\THis\\Z'); + } + else { + if($ev['dtstart']) + $o .= "\r\nDTSTART;VALUE=DATE:" . datetime_convert('UTC','UTC', $ev['dtstart'],'Ymd'); + if($ev['dtend'] && ! $ev['nofinish']) + $o .= "\r\nDTEND;VALUE=DATE:" . datetime_convert('UTC','UTC', $ev['dtend'],'Ymd'); + } if($ev['summary']) { $o .= "\r\nSUMMARY:" . format_ical_text($ev['summary']); $o .= "\r\nX-ZOT-SUMMARY:" . format_ical_sourcetext($ev['summary']); @@ -856,6 +871,10 @@ function event_import_ical($ical, $uid) { $ev['external_id'] = $evuid; } + $ev['timezone'] = 'UTC'; + if(isset($ical->DTSTART['TZID'])) + $ev['timezone'] = $ical->DTSTART['TZID']; + if($ev['summary'] && $ev['dtstart']) { $ev['event_xchan'] = $channel['channel_hash']; $ev['uid'] = $channel['channel_id']; From 2b452ea3e8dca9324ebea6031b3060e6c27d5526 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 3 Jun 2019 21:03:43 +0200 Subject: [PATCH 3/5] fix timezone issue when importing adjusted events --- include/event.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/include/event.php b/include/event.php index b1da2de8e..f1a095d1d 100644 --- a/include/event.php +++ b/include/event.php @@ -757,7 +757,6 @@ function parse_vobject($ical, $type) { function parse_ical_file($f,$uid) { - require_once('vendor/autoload.php'); $s = @file_get_contents($f); @@ -816,12 +815,23 @@ function event_import_ical($ical, $uid) { // logger('dtstart: ' . var_export($dtstart,true)); - $ev['dtstart'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $ev['timezone'] = 'UTC'; + + // Try to get an usable olson format timezone + if($ev['adjust']) { + //TODO: we should pass the vcalendar to getTimeZone() to be more accurate + // we do not have it here since parse_ical_file() is passing the vevent only. + $timezone_obj = \Sabre\VObject\TimeZoneUtil::getTimeZone($ical->DTSTART['TZID']); + $timezone = $timezone_obj->getName(); + $ev['timezone'] = $timezone; + } + + $ev['dtstart'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),$ev['timezone'], $dtstart->format(\DateTime::W3C)); if(isset($ical->DTEND)) { $dtend = $ical->DTEND->getDateTime(); - $ev['dtend'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $ev['dtend'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),$ev['timezone'], $dtend->format(\DateTime::W3C)); } else { @@ -871,10 +881,6 @@ function event_import_ical($ical, $uid) { $ev['external_id'] = $evuid; } - $ev['timezone'] = 'UTC'; - if(isset($ical->DTSTART['TZID'])) - $ev['timezone'] = $ical->DTSTART['TZID']; - if($ev['summary'] && $ev['dtstart']) { $ev['event_xchan'] = $channel['channel_hash']; $ev['uid'] = $channel['channel_id']; From f1b54cf0a49afcaa7b5a8d5f8fb35a4da72b6b85 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 3 Jun 2019 22:37:03 +0200 Subject: [PATCH 4/5] do not change default timezone in parse_ical_file() --- include/event.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/include/event.php b/include/event.php index f1a095d1d..6689919cf 100644 --- a/include/event.php +++ b/include/event.php @@ -760,13 +760,6 @@ function parse_ical_file($f,$uid) { $s = @file_get_contents($f); - // Change the current timezone to something besides UTC. - // Doesn't matter what it is, as long as it isn't UTC. - // Save the current timezone so we can reset it when we're done processing. - - $saved_timezone = date_default_timezone_get(); - date_default_timezone_set('Australia/Sydney'); - $ical = VObject\Reader::read($s); if($ical) { @@ -782,8 +775,6 @@ function parse_ical_file($f,$uid) { } } - date_default_timezone_set($saved_timezone); - if($ical) return true; From 5d6128b25ce4cb37f406c9bb5bd7ff16b09c0bde Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 4 Jun 2019 10:13:25 +0200 Subject: [PATCH 5/5] update changelog --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 47abe631c..d38144670 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -Hubzilla 4.2 (2019-??-??) +Hubzilla 4.2 (2019-06-04) - Introduce Calendar app which deprecates Events and CalDAV apps and streamlines the featuresets - Update mod cal to reflect changes in the calendar app - Improve timezone detection for CalDAV calendars