From 175197d7c0c804d98120fda8acb35d21bd6ccd3f Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 3 Oct 2011 12:53:28 +0000 Subject: [PATCH] * CalDAV: no METHOD:PUBLISH for CalDAV outside the inbox --- calendar/inc/class.calendar_groupdav.inc.php | 9 +++++---- calendar/inc/class.calendar_ical.inc.php | 2 +- infolog/inc/class.infolog_groupdav.inc.php | 4 ++-- infolog/inc/class.infolog_ical.inc.php | 2 +- phpgwapi/inc/horde/Horde/iCalendar.php | 3 ++- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/calendar/inc/class.calendar_groupdav.inc.php b/calendar/inc/class.calendar_groupdav.inc.php index 2bd9eb6e5b..a68ab974ea 100644 --- a/calendar/inc/class.calendar_groupdav.inc.php +++ b/calendar/inc/class.calendar_groupdav.inc.php @@ -243,7 +243,7 @@ class calendar_groupdav extends groupdav_handler //error_log(__FILE__ . __METHOD__ . "Calendar Data : $calendar_data"); if ($calendar_data) { - $content = $this->iCal($event,$filter['users']); + $content = $this->iCal($event, $filter['users'], strpos($path, '/inbox/') !== false ? 'PUBLISH' : null); $props['getcontentlength'] = bytes($content); $props[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data',$content); } @@ -386,7 +386,7 @@ class calendar_groupdav extends groupdav_handler { return $event; } - $options['data'] = $this->iCal($event,$user); + $options['data'] = $this->iCal($event, $user, strpos($options['path'], '/inbox/') !== false ? 'PUBLISH' : null); $options['mimetype'] = 'text/calendar; charset=utf-8'; header('Content-Encoding: identity'); header('ETag: '.$this->get_etag($event)); @@ -400,9 +400,10 @@ class calendar_groupdav extends groupdav_handler * * @param array $event * @param int $user=null account_id of calendar to display + * @param string $method=null eg. 'PUBLISH' for inbox, nothing anywhere else * @return string */ - private function iCal(array $event,$user=null) + private function iCal(array $event,$user=null, $method=null) { static $handler = null; if (is_null($handler)) $handler = $this->_get_handler(); @@ -427,7 +428,7 @@ class calendar_groupdav extends groupdav_handler { $events[0]['uid'] .= '-'.$event['id']; // force a different uid } - return $handler->exportVCal($events,'2.0','PUBLISH'); + return $handler->exportVCal($events, '2.0', $method); } /** diff --git a/calendar/inc/class.calendar_ical.inc.php b/calendar/inc/class.calendar_ical.inc.php index 44a38bb3c5..d9a1a7d5dc 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -231,7 +231,7 @@ class calendar_ical extends calendar_boupdate $vcal->setAttribute('PRODID','-//eGroupWare//NONSGML eGroupWare Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); $vcal->setAttribute('VERSION', $version); - $vcal->setAttribute('METHOD', $method); + if ($method) $vcal->setAttribute('METHOD', $method); $events_exported = false; if (!is_array($events)) $events = array($events); diff --git a/infolog/inc/class.infolog_groupdav.inc.php b/infolog/inc/class.infolog_groupdav.inc.php index 29a8a894fc..3460dee2f4 100644 --- a/infolog/inc/class.infolog_groupdav.inc.php +++ b/infolog/inc/class.infolog_groupdav.inc.php @@ -233,7 +233,7 @@ class infolog_groupdav extends groupdav_handler ); if ($calendar_data) { - $content = $handler->exportVTODO($task,'2.0','PUBLISH'); + $content = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV $props['getcontentlength'] = bytes($content); $props[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data',$content); } @@ -354,7 +354,7 @@ class infolog_groupdav extends groupdav_handler return $task; } $handler = $this->_get_handler(); - $options['data'] = $handler->exportVTODO($task,'2.0','PUBLISH'); + $options['data'] = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV $options['mimetype'] = 'text/calendar; charset=utf-8'; header('Content-Encoding: identity'); header('ETag: '.$this->get_etag($task)); diff --git a/infolog/inc/class.infolog_ical.inc.php b/infolog/inc/class.infolog_ical.inc.php index 58cf94dd04..f2961fd1a0 100644 --- a/infolog/inc/class.infolog_ical.inc.php +++ b/infolog/inc/class.infolog_ical.inc.php @@ -168,7 +168,7 @@ class infolog_ical extends infolog_bo $vcal = new Horde_iCalendar; $vcal->setAttribute('VERSION',$_version); - $vcal->setAttribute('METHOD',$_method); + if ($_method) $vcal->setAttribute('METHOD',$_method); $tzid = $this->tzid; diff --git a/phpgwapi/inc/horde/Horde/iCalendar.php b/phpgwapi/inc/horde/Horde/iCalendar.php index 4c05e8f9ab..50577221af 100644 --- a/phpgwapi/inc/horde/Horde/iCalendar.php +++ b/phpgwapi/inc/horde/Horde/iCalendar.php @@ -470,7 +470,8 @@ class Horde_iCalendar { { // Default values. $requiredAttributes['PRODID'] = '-//The Horde Project//Horde_iCalendar Library' . (defined('HORDE_VERSION') ? ', Horde ' . constant('HORDE_VERSION') : '') . '//EN'; - $requiredAttributes['METHOD'] = 'PUBLISH'; + // METHOD is only required for iTip, but not for CalDAV, therefore removing it here calendar_ical sets it anyway by default + //$requiredAttributes['METHOD'] = 'PUBLISH'; foreach ($requiredAttributes as $name => $default_value) { if (is_a($this->getattribute($name), 'PEAR_Error')) {