diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php
index b58428d3..1c7a6d0d 100644
--- a/inc/CalDAVRequest.php
+++ b/inc/CalDAVRequest.php
@@ -77,12 +77,33 @@ class CalDAVRequest
*/
var $collection_type;
+ /**
+ * A static structure of supported privileges.
+ */
+ var $supported_privileges;
+
/**
* Create a new CalDAVRequest object.
*/
function CalDAVRequest( $options = array() ) {
global $session, $c, $debugging;
+ $this->supported_privileges = array(
+ 'all' => array(
+ 'read' => 'Read the content of a resource or collection',
+ 'write' => array(
+ 'bind' => 'Create a resource or collection',
+ 'unbind' => 'Delete a resource or collection',
+ 'write-content' => 'Write content',
+ 'write-properties' => 'Write properties'
+ ),
+ 'urn:ietf:params:xml:ns:caldav:read-free-busy' => 'Read the free/busy information for a calendar collection',
+ 'read-acl' => 'Read ACLs for a resource or collection',
+ 'write-acl' => 'Write ACLs for a resource or collection',
+ 'unlock' => 'Remove a lock'
+ )
+ );
+
$this->options = $options;
if ( !isset($this->options['allow_by_email']) ) $this->options['allow_by_email'] = false;
$this->principal = (object) array( 'username' => $session->username, 'user_no' => $session->user_no );
@@ -727,27 +748,46 @@ EOSQL;
}
+ /**
+ * Returns the array of supported privileges converted into XMLElements
+ */
+ function RenderSupportedPrivileges( $privs = null ) {
+ global $reply;
+ $privileges = array();
+ if ( $privs === null ) $privs = $this->supported_privileges;
+ foreach( $privs AS $k => $v ) {
+ dbg_error_log( 'caldav', 'Adding privilege "%s" which is "%s".', $k, $v );
+ $privilege = new XMLElement('privilege');
+ $reply->NSElement($privilege,$k);
+ $privset = array($privilege);
+ if ( is_array($v) ) {
+ dbg_error_log( 'caldav', '"%s" is a container of sub-privileges.', $k );
+ $privset = array_merge($privset, $this->RenderSupportedPrivileges($v));
+ }
+ else if ( $v == 'abstract' ) {
+ dbg_error_log( 'caldav', '"%s" is an abstract privilege.', $v );
+ $privset[] = new XMLElement('abstract');
+ }
+ else if ( strlen($v) > 1 ) {
+ $privset[] = new XMLElement('description', $v);
+ }
+ $privileges[] = new XMLElement('supported-privilege',$privset);
+ }
+ return $privileges;
+ }
+
+
/**
* Returns the array of privilege names converted into XMLElements
*/
- function RenderPrivileges($privilege_names, $container=null) {
+ function RenderPrivileges($privilege_names) {
global $reply;
$privileges = array();
foreach( $privilege_names AS $k => $v ) {
dbg_error_log( 'caldav', 'Adding privilege "%s" which is "%s".', $k, $v );
$privilege = new XMLElement('privilege');
$reply->NSElement($privilege,$k);
- if ( isset($container) ) {
- $privset = array($privilege);
- if ( $v == 'abstract' ) {
- dbg_error_log( 'caldav', '"%s" is an abstract privilege.', $v );
- $privset[] = new XMLElement('abstract');
- }
- $privileges[] = new XMLElement($container,$privset);
- }
- else {
- $privileges[] = $privilege;
- }
+ $privileges[] = $privilege;
}
return $privileges;
}
@@ -801,7 +841,7 @@ EOSQL;
case 'DAV::supported-privilege-set':
dbg_error_log( 'caldav', 'Processing "%s" on "%s".', $tag, $this->path );
- $prop->NewElement('supported-privilege-set', $this->RenderPrivileges( $this->SupportedPrivileges(), 'supported-privilege') );
+ $prop->NewElement('supported-privilege-set', $this->RenderSupportedPrivileges() );
break;
default:
diff --git a/testing/tests/regression-suite/874-PROPFIND.result b/testing/tests/regression-suite/874-PROPFIND.result
index 77c84fec..93ae782f 100644
--- a/testing/tests/regression-suite/874-PROPFIND.result
+++ b/testing/tests/regression-suite/874-PROPFIND.result
@@ -1,8 +1,8 @@
HTTP/1.1 207 Multi-Status
Date: Dow, 01 Jan 2000 00:00:00 GMT
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
-ETag: "e3119e4ec64afd062ae2634ebd232f0f"
-Content-Length: 1235
+ETag: "e01e87a334e05b0efb2deedc5fa7ae50"
+Content-Length: 2219
Content-Type: text/xml; charset="utf-8"
@@ -16,42 +16,65 @@ Content-Type: text/xml; charset="utf-8"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ Read the content of a resource or collection
+
+
+
+
+
+
+
+
+
+ Create a resource or collection
+
+
+
+
+
+ Delete a resource or collection
+
+
+
+
+
+ Write content
+
+
+
+
+
+ Write properties
+
+
+
+
+
+
+ Read the free/busy information for a calendar collection
+
+
+
+
+
+ Read ACLs for a resource or collection
+
+
+
+
+
+ Write ACLs for a resource or collection
+
+
+
+
+
+ Remove a lock
+