From c8b9bf7e68308af7f23daae660efeaa5f9dfe90b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Lehrke?= Date: Sun, 15 Aug 2010 06:37:34 +0000 Subject: [PATCH] Improve iPhone iCal support --- calendar/inc/class.calendar_groupdav.inc.php | 13 +++++++++++-- calendar/inc/class.calendar_hooks.inc.php | 10 ++++++++++ calendar/inc/class.calendar_ical.inc.php | 15 +++++++++++++-- phpgwapi/inc/class.groupdav_handler.inc.php | 4 ++++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/calendar/inc/class.calendar_groupdav.inc.php b/calendar/inc/class.calendar_groupdav.inc.php index f2658e6acd..e4da86a4ff 100644 --- a/calendar/inc/class.calendar_groupdav.inc.php +++ b/calendar/inc/class.calendar_groupdav.inc.php @@ -867,6 +867,15 @@ error_log(__METHOD__."($path,,".array2string($start).") filter=".array2string($f */ static function extra_properties(array $props=array(), $displayname, $base_uri=null) { + if (strlen($GLOBALS['egw_info']['user']['preferences']['calendar']['display_color']) == 9 && + $GLOBALS['egw_info']['user']['preferences']['calendar']['display_color'][0] == '#') + { + $display_color = $GLOBALS['egw_info']['user']['preferences']['calendar']['display_color']; + } + else + { + $display_color = '#0040A0FF'; + } // calendar description $props[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-description',$displayname); /* @@ -903,7 +912,7 @@ error_log(__METHOD__."($path,,".array2string($start).") filter=".array2string($f $props[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'supported-calendar-data',array( HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')), HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0')))); - $props[] = HTTP_WebDAV_Server::mkprop(groupdav::ICAL,'calendar-color','#0040A0FF'); // TODO: make it configurable + $props[] = HTTP_WebDAV_Server::mkprop(groupdav::ICAL,'calendar-color',$display_color); //$props[] = HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'publish-url',array( // HTTP_WebDAV_Server::mkprop('href',$base_uri.'/calendar/'))); @@ -920,7 +929,7 @@ error_log(__METHOD__."($path,,".array2string($start).") filter=".array2string($f { $handler = new calendar_ical(); $handler->setSupportedFields('GroupDAV',$this->agent); - if ($this->debug > 1) error_log("ical Handler called:" . $this->agent); + if ($this->debug > 1) error_log("ical Handler called: " . $this->agent); return $handler; } } diff --git a/calendar/inc/class.calendar_hooks.inc.php b/calendar/inc/class.calendar_hooks.inc.php index 83970b3aa1..3b43983f11 100644 --- a/calendar/inc/class.calendar_hooks.inc.php +++ b/calendar/inc/class.calendar_hooks.inc.php @@ -409,6 +409,16 @@ class calendar_hooks 'xmlrpc' => True, 'admin' => False ), + 'display_color' => array( + 'type' => 'input', + 'size' => 9, + 'label' => 'Select a color for this calendar', + 'name' => 'display_color', + 'help' => 'The Apple iCal Apps use this color to display events from this calendar.', + 'forced' => '#0040A0FF', + 'xmlrpc' => True, + 'admin' => False + ), 'default_private' => array( 'type' => 'check', 'label' => 'Set new events to private', diff --git a/calendar/inc/class.calendar_ical.inc.php b/calendar/inc/class.calendar_ical.inc.php index 968a818c12..2cbc9b9e6c 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -619,8 +619,19 @@ class calendar_ical extends calendar_boupdate $rrule = $rriter->generate_rrule($version); if ($event['recur_enddate']) { - $length = ($event['end'] - $event['start']) / 2; - $rrule['UNTIL']->modify($length . ' second'); + if ($this->productManufacturer == 'groupdav' && $this->productName == 'iphone') + { + // Fix iPhone issue + $length = ($event['end'] - $event['start']); + $rrule['UNTIL']->modify($length . ' second'); + $rrule['UNTIL']->setTime(23, 59, 59); + } + else + { + $length = ($event['end'] - $event['start']) / 2; + $rrule['UNTIL']->modify($length . ' second'); + } + if (!$tzid || $version != '1.0') { if (!isset(self::$tz_cache['UTC'])) diff --git a/phpgwapi/inc/class.groupdav_handler.inc.php b/phpgwapi/inc/class.groupdav_handler.inc.php index 473398e5e5..b797699ab2 100644 --- a/phpgwapi/inc/class.groupdav_handler.inc.php +++ b/phpgwapi/inc/class.groupdav_handler.inc.php @@ -341,6 +341,7 @@ abstract class groupdav_handler // identify the agent (GroupDAV client) from the HTTP_USER_AGENT header $user_agent = strtolower($_SERVER['HTTP_USER_AGENT']); foreach(array( + 'iphone' => 'iphone', // Apple iPhone iCal 'davkit' => 'davkit', // Apple iCal 'cfnetwork' => 'cfnetwork', // Apple Addressbook 'bionicmessage.net' => 'funambol', // funambol GroupDAV connector from bionicmessage.net @@ -372,6 +373,9 @@ abstract class groupdav_handler } } } + + if ($debug) error_log(__METHOD__."GroupDAV client: $agent"); + return $agent; } }