merged iPhone CalDAV fixes to 1.6

This commit is contained in:
Ralf Becker 2009-07-16 16:38:33 +00:00
parent e841d31273
commit 907da227e6
2 changed files with 50 additions and 1 deletions

View File

@ -125,6 +125,7 @@ class calendar_groupdav extends groupdav_handler
'text/calendar; charset=utf-8; component=VEVENT' : 'text/calendar'), 'text/calendar; charset=utf-8; component=VEVENT' : 'text/calendar'),
// getlastmodified and getcontentlength are required by WebDAV and Cadaver eg. reports 404 Not found if not set // getlastmodified and getcontentlength are required by WebDAV and Cadaver eg. reports 404 Not found if not set
HTTP_WebDAV_Server::mkprop('getlastmodified', $event['modified']), HTTP_WebDAV_Server::mkprop('getlastmodified', $event['modified']),
HTTP_WebDAV_Server::mkprop('resourcetype',''), // iPhone requires that attribute!
); );
if ($calendar_data) if ($calendar_data)
{ {
@ -395,6 +396,11 @@ class calendar_groupdav extends groupdav_handler
$props[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-home-set',$_SERVER['SCRIPT_NAME'].'/'); $props[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-home-set',$_SERVER['SCRIPT_NAME'].'/');
// email of the current user, see caldav-sheduling draft // email of the current user, see caldav-sheduling draft
$props[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-user-address-set','MAILTO:'.$GLOBALS['egw_info']['user']['email']); $props[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-user-address-set','MAILTO:'.$GLOBALS['egw_info']['user']['email']);
// supported components, currently only VEVENT
$props[] = $sc = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'supported-calendar-component-set',array(
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VEVENT')),
// HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VTODO')), // not yet supported
));
return $props; return $props;
} }
@ -411,4 +417,4 @@ class calendar_groupdav extends groupdav_handler
return $handler; return $handler;
} }
} }

View File

@ -791,6 +791,49 @@ class HTTP_WebDAV_Server
break; break;
} }
} else { } else {
// allow multiple values and attributes, required eg. for caldav:supported-calendar-component-set
if ($prop['ns'] && is_array($prop['val'])) {
if (!isset($ns_hash[$prop['ns']])) {
$ns_name = "ns".(count($ns_hash) + 1);
$ns_hash[$prop['ns']] = $ns_name;
}
$vals = $extra_ns = '';
foreach($prop['val'] as $subprop)
{
if ($subprop['ns'] && $subprop['ns'] != 'DAV:') {
// register property namespace if not known yet
if (!isset($ns_hash[$subprop['ns']])) {
$ns_name = "ns".(count($ns_hash) + 1);
$ns_hash[$subprop['ns']] = $ns_name;
} else {
$ns_name = $ns_hash[$subprop['ns']];
}
if (strchr($extra_ns,$extra=' xmlns:'.$ns_name.'="'.$subprop['ns'].'"') === false) {
$extra_ns .= $extra;
}
$ns_name .= ':';
} elseif ($subprop['ns'] == 'DAV:') {
$ns_name = 'D:';
} else {
$ns_name = '';
}
$vals .= "<$ns_name$subprop[name]";
if (is_array($subprop['val'])) // val contains only attributes, no value
{
foreach($subprop['val'] as $attr => $val)
{
$vals .= ' '.$attr.'="'.htmlspecialchars($val).'"';
}
$vals .= '/>';
}
else
{
$vals .= '>'.htmlspecialchars($subprop['val'])."</$ns_name$subprop[name]>";
}
}
echo " <".$ns_hash[$prop['ns']].":$prop[name]$extra_ns>$vals</".$ns_hash[$prop['ns']].":$prop[name]>\n";
}
else
// properties from namespaces != "DAV:" or without any namespace // properties from namespaces != "DAV:" or without any namespace
if ($prop["ns"]) { if ($prop["ns"]) {
echo " <" . $ns_hash[$prop["ns"]] . ":$prop[name]>" echo " <" . $ns_hash[$prop["ns"]] . ":$prop[name]>"