aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-05-21 12:29:00 +0200
committerMario Vavti <mario@mariovavti.com>2019-05-21 12:29:00 +0200
commitf96958adf84f7f2a45aa7860e52198f3de74f9e0 (patch)
treefed75c73887eb13dcf9eca1c93c6654ecaf8703c /Zotlabs/Module
parentc9d64d75f3acab6b44d28cd7bcc6e7e5dd042e77 (diff)
downloadvolse-hubzilla-f96958adf84f7f2a45aa7860e52198f3de74f9e0.tar.gz
volse-hubzilla-f96958adf84f7f2a45aa7860e52198f3de74f9e0.tar.bz2
volse-hubzilla-f96958adf84f7f2a45aa7860e52198f3de74f9e0.zip
fix all day events for caldav calendars
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Cdav.php60
1 files changed, 45 insertions, 15 deletions
diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php
index 275873db5..0c3450c70 100644
--- a/Zotlabs/Module/Cdav.php
+++ b/Zotlabs/Module/Cdav.php
@@ -274,9 +274,12 @@ class Cdav extends Controller {
$timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
$tz = (($timezone) ? $timezone : date_default_timezone_get());
+ $allday = $_REQUEST['allday'];
+
$title = $_REQUEST['title'];
$start = datetime_convert($tz, 'UTC', $_REQUEST['dtstart']);
$dtstart = new \DateTime($start);
+
if($_REQUEST['dtend']) {
$end = datetime_convert($tz, 'UTC', $_REQUEST['dtend']);
$dtend = new \DateTime($end);
@@ -304,16 +307,23 @@ class Cdav extends Controller {
'DTSTART' => $dtstart
]
]);
+
if($dtend) {
$vcalendar->VEVENT->add('DTEND', $dtend);
- $vcalendar->VEVENT->DTEND['TZID'] = $tz;
+ if($allday)
+ $vcalendar->VEVENT->DTEND['VALUE'] = 'DATE';
+ else
+ $vcalendar->VEVENT->DTEND['TZID'] = $tz;
}
if($description)
$vcalendar->VEVENT->add('DESCRIPTION', $description);
if($location)
$vcalendar->VEVENT->add('LOCATION', $location);
- $vcalendar->VEVENT->DTSTART['TZID'] = $tz;
+ if($allday)
+ $vcalendar->VEVENT->DTSTART['VALUE'] = 'DATE';
+ else
+ $vcalendar->VEVENT->DTSTART['TZID'] = $tz;
$calendarData = $vcalendar->serialize();
@@ -354,6 +364,8 @@ class Cdav extends Controller {
$timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
$tz = (($timezone) ? $timezone : date_default_timezone_get());
+ $allday = $_REQUEST['allday'];
+
$uri = $_REQUEST['uri'];
$title = $_REQUEST['title'];
$start = datetime_convert($tz, 'UTC', $_REQUEST['dtstart']);
@@ -371,12 +383,23 @@ class Cdav extends Controller {
if($title)
$vcalendar->VEVENT->SUMMARY = $title;
- if($dtstart)
+ if($dtstart) {
$vcalendar->VEVENT->DTSTART = $dtstart;
- if($dtend)
+ if($allday)
+ $vcalendar->VEVENT->DTSTART['VALUE'] = 'DATE';
+ else
+ $vcalendar->VEVENT->DTSTART['TZID'] = $tz;
+ }
+ if($dtend) {
$vcalendar->VEVENT->DTEND = $dtend;
+ if($allday)
+ $vcalendar->VEVENT->DTEND['VALUE'] = 'DATE';
+ else
+ $vcalendar->VEVENT->DTEND['TZID'] = $tz;
+ }
else
unset($vcalendar->VEVENT->DTEND);
+
if($description)
$vcalendar->VEVENT->DESCRIPTION = $description;
if($location)
@@ -415,6 +438,8 @@ class Cdav extends Controller {
$timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
$tz = (($timezone) ? $timezone : date_default_timezone_get());
+ $allday = $_REQUEST['allday'];
+
$uri = $_REQUEST['uri'];
$start = datetime_convert($tz, 'UTC', $_REQUEST['dtstart']);
$dtstart = new \DateTime($start);
@@ -429,13 +454,20 @@ class Cdav extends Controller {
if($dtstart) {
$vcalendar->VEVENT->DTSTART = $dtstart;
+ if($allday)
+ $vcalendar->VEVENT->DTSTART['VALUE'] = 'DATE';
+ else
+ $vcalendar->VEVENT->DTSTART['TZID'] = $tz;
}
if($dtend) {
$vcalendar->VEVENT->DTEND = $dtend;
+ if($allday)
+ $vcalendar->VEVENT->DTEND['VALUE'] = 'DATE';
+ else
+ $vcalendar->VEVENT->DTEND['TZID'] = $tz;
}
- else {
+ else
unset($vcalendar->VEVENT->DTEND);
- }
$calendarData = $vcalendar->serialize();
@@ -1001,6 +1033,9 @@ class Cdav extends Controller {
$title = ['title', t('Event title') ];
$dtstart = ['dtstart', t('Start date and time')];
$dtend = ['dtend', t('End date and time')];
+ $timezone_select = ['timezone_select' , t('Timezone:'), date_default_timezone_get(), '', get_timezones()];
+ $allday = ['allday', t('All day event'), '', '', [t('No'), t('Yes')]];
+
$description = ['description', t('Description')];
$location = ['location', t('Location')];
@@ -1061,7 +1096,8 @@ class Cdav extends Controller {
'$resource' => json_encode($resource),
'$categories' => $categories,
- '$timezone_select' => ((feature_enabled(local_channel(),'event_tz_select')) ? ['timezone_select' , t('Timezone:'), date_default_timezone_get(), '', get_timezones()] : [])
+ '$timezone_select' => ((feature_enabled(local_channel(),'event_tz_select')) ? $timezone_select : ''),
+ '$allday' => $allday
]);
@@ -1091,8 +1127,8 @@ class Cdav extends Controller {
$filters['comp-filters'][0]['time-range']['end'] = $end;
$uris = $caldavBackend->calendarQuery($id, $filters);
-
if($uris) {
+
$objects = $caldavBackend->getMultipleCalendarObjects($id, $uris);
foreach($objects as $object) {
@@ -1121,13 +1157,7 @@ class Cdav extends Controller {
$timezone = $recurrent_timezone;
}
- $allDay = false;
-
- // allDay event rules
- if(!strpos($dtstart, 'T') && !strpos($dtend, 'T'))
- $allDay = true;
- if(strpos($dtstart, 'T000000') && strpos($dtend, 'T000000'))
- $allDay = true;
+ $allDay = (((string)$vevent->DTSTART['VALUE'] == 'DATE') ? true : false);
$events[] = [
'calendar_id' => $id,