From c59097ce7b7903d715c453eab38f06fa1cbc54d2 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Thu, 26 Oct 2006 00:31:01 +1300 Subject: [PATCH] Rudimentary support for DAV:ACL and DAV:SUPPORTED-PRIVILEGE-SET. --- inc/caldav-PROPFIND.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/inc/caldav-PROPFIND.php b/inc/caldav-PROPFIND.php index 92dfb70a..62a76e62 100644 --- a/inc/caldav-PROPFIND.php +++ b/inc/caldav-PROPFIND.php @@ -27,6 +27,7 @@ foreach( $xml_tags AS $k => $v ) { break; case 'HTTP://APACHE.ORG/DAV/PROPS/:EXECUTABLE': + case 'DAV::ACL': case 'DAV::CHECKED-OUT': case 'DAV::CHECKED-IN': case 'DAV::GETLASTMODIFIED': @@ -35,6 +36,7 @@ foreach( $xml_tags AS $k => $v ) { case 'DAV::GETCONTENTLENGTH': case 'DAV::GETCONTENTTYPE': case 'DAV::RESOURCETYPE': + case 'DAV::SUPPORTED-PRIVILEGE-SET': case 'DAV::CURRENT-USER-PRIVILEGE-SET': $attribute = substr($v['tag'],5); $attribute_list[$attribute] = 1; @@ -60,10 +62,10 @@ foreach( $xml_tags AS $k => $v ) { /** * Returns the array of privilege names converted into XMLElements */ -function privileges($privilege_names) { +function privileges($privilege_names, $container="privilege") { $privileges = array(); foreach( $privilege_names AS $k => $v ) { - $privileges[] = new XMLElement("privilege", new XMLElement($v)); + $privileges[] = new XMLElement($container, new XMLElement($v)); } return $privileges; } @@ -110,6 +112,22 @@ function collection_to_xml( $collection ) { if ( isset($attribute_list['CURRENT-USER-PRIVILEGE-SET']) ) { $prop->NewElement("current-user-privilege-set", privileges($GLOBALS['permissions']) ); } + if ( isset($attribute_list['ACL']) ) { + /** + * FIXME: This information is semantically valid but presents an incorrect picture. + */ + $principal = new XMLElement("principal"); + $principal->NewElement("authenticated"); + $grant = new XMLElement( "grant", array(privileges($GLOBALS['permissions'])) ); + $prop->NewElement("acl", new XMLElement( "ace", array( $principal, $grant ) ) ); + } + if ( isset($attribute_list['SUPPORTED-PRIVILEGE-SET']) ) { + /** + * FIXME: This information is semantically valid and is correct, but could be extended + * if we allow clients such as Mulberry to manipulate these values. + */ + $prop->NewElement("supported-privilege-set", privileges(array("read","write"), "supported-privilege") ); + } $status = new XMLElement("status", "HTTP/1.1 200 OK" ); $propstat = new XMLElement( "propstat", array( $prop, $status) );