Fix CalDAV issues

This commit is contained in:
Jörg Lehrke 2010-06-29 09:19:25 +00:00
parent 5cb14e716e
commit affd4b1885
2 changed files with 44 additions and 4 deletions

View File

@ -482,7 +482,7 @@ error_log(__METHOD__."($path,,".array2string($start).") filter=".array2string($f
$oldEvent = $this->_common_get_put_delete('PUT',$options,$id,$return_no_access);
if (!is_null($oldEvent) && !is_array($oldEvent))
{
if ($this->debug) error_log(__METHOD__.print_r($oldEvent,true).function_backtrace());
if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace());
return $oldEvent;
}
@ -591,10 +591,44 @@ error_log(__METHOD__."($path,,".array2string($start).") filter=".array2string($f
*/
function post(&$options,$id,$user=null)
{
if (preg_match('/^METHOD:PUBLISH(\r\n|\r|\n)/im', $options['content']))
if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
if (preg_match('/^METHOD:(PUBLISH|REQUEST)(\r\n|\r|\n)(.*)^BEGIN:VEVENT/ism', $options['content']))
{
$status = $this->put($options,$id,$user);
// error_log("CalDAV POST: $status" . print_r($options, true));
$handler = $this->_get_handler();
$vCalendar = htmlspecialchars_decode($options['content']);
$charset = null;
if (!empty($options['content_type']))
{
$content_type = explode(';', $options['content_type']);
if (count($content_type) > 1)
{
array_shift($content_type);
foreach ($content_type as $attribute)
{
trim($attribute);
list($key, $value) = explode('=', $attribute);
switch (strtolower($key))
{
case 'charset':
$charset = strtoupper(substr($value,1,-1));
}
}
}
}
if (($foundEvents = $handler->search($vCalendar, null, false, $charset)))
{
$eventId = array_shift($foundEvents);
list($eventId) = explode(':', $eventId);
if (!($cal_id = $handler->importVCal($vCalendar, $eventId, null,
false, 0, $this->principalURL, $user, $charset)))
{
if ($this->debug) error_log(__METHOD__."() importVCal($eventId) returned false");
}
header('ETag: '.$this->get_etag($eventId));
}
}
return true;
}

View File

@ -264,6 +264,10 @@ class groupdav_principals extends groupdav_handler
HTTP_WebDAV_Server::mkprop(groupdav::DAV,'href',$this->base_uri.'/calendar/'))),
HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'email-address-set',array(
HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'email-address',$account['account_email']))),
HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'last-name',$account['account_lastname']),
HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'first-name',$account['account_firstname']),
HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'record-type','user'),
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-user-type','INDIVIDUAL'),
HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'addressbook-home-set',array(
HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/'))),
HTTP_WebDAV_Server::mkprop('group-member-ship', $memberships),
@ -308,6 +312,8 @@ class groupdav_principals extends groupdav_handler
HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/'))),
HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'addressbook-home-set',array(
HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/'))),
HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'record-type','group'),
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-user-type','GROUP'),
HTTP_WebDAV_Server::mkprop('group-member-set', $members),
//HTTP_WebDAV_Server::mkprop('principal-URL',array(self::mkprop('href',$this->principalURL))),
);