* CalDAV: no METHOD:PUBLISH for CalDAV outside the inbox

This commit is contained in:
Ralf Becker 2011-10-03 12:53:28 +00:00
parent 0837c263ff
commit 175197d7c0
5 changed files with 11 additions and 9 deletions

View File

@ -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);
}
/**

View File

@ -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);

View File

@ -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));

View File

@ -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;

View File

@ -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')) {