4 * SupportedPrivilegeSet property
6 * This property encodes the {DAV:}supported-privilege-set property, as defined
7 * in rfc3744. Please consult the rfc for details about it's structure.
9 * This class expects a structure like the one given from
10 * Sabre_DAVACL_Plugin::getSupportedPrivilegeSet as the argument in its
15 * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
16 * @author Evert Pot (http://www.rooftopsolutions.nl/)
17 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
19 class Sabre_DAVACL_Property_SupportedPrivilegeSet extends Sabre_DAV_Property {
31 * @param array $privileges
33 public function __construct(array $privileges) {
35 $this->privileges = $privileges;
40 * Serializes the property into a domdocument.
42 * @param Sabre_DAV_Server $server
43 * @param DOMElement $node
46 public function serialize(Sabre_DAV_Server $server,DOMElement $node) {
48 $doc = $node->ownerDocument;
49 $this->serializePriv($doc, $node, $this->privileges);
54 * Serializes a property
56 * This is a recursive function.
58 * @param DOMDocument $doc
59 * @param DOMElement $node
60 * @param array $privilege
63 private function serializePriv($doc,$node,$privilege) {
65 $xsp = $doc->createElementNS('DAV:','d:supported-privilege');
66 $node->appendChild($xsp);
68 $xp = $doc->createElementNS('DAV:','d:privilege');
69 $xsp->appendChild($xp);
72 preg_match('/^{([^}]*)}(.*)$/',$privilege['privilege'],$privParts);
74 $xp->appendChild($doc->createElementNS($privParts[1],'d:'.$privParts[2]));
76 if (isset($privilege['abstract']) && $privilege['abstract']) {
77 $xsp->appendChild($doc->createElementNS('DAV:','d:abstract'));
80 if (isset($privilege['description'])) {
81 $xsp->appendChild($doc->createElementNS('DAV:','d:description',$privilege['description']));
84 if (isset($privilege['aggregates'])) {
85 foreach($privilege['aggregates'] as $subPrivilege) {
86 $this->serializePriv($doc,$xsp,$subPrivilege);