]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/lib/Sabre/DAVACL/Property/CurrentUserPrivilegeSet.php
Initial Release of the calendar plugin
[friendica-addons.git] / dav / SabreDAV / lib / Sabre / DAVACL / Property / CurrentUserPrivilegeSet.php
1 <?php
2
3 /**
4  * CurrentUserPrivilegeSet
5  *
6  * This class represents the current-user-privilege-set property. When
7  * requested, it contain all the privileges a user has on a specific node.
8  *
9  * @package Sabre
10  * @subpackage DAVACL
11  * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
12  * @author Evert Pot (http://www.rooftopsolutions.nl/)
13  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
14  */
15 class Sabre_DAVACL_Property_CurrentUserPrivilegeSet extends Sabre_DAV_Property {
16
17     /**
18      * List of privileges
19      *
20      * @var array
21      */
22     private $privileges;
23
24     /**
25      * Creates the object
26      *
27      * Pass the privileges in clark-notation
28      *
29      * @param array $privileges
30      */
31     public function __construct(array $privileges) {
32
33         $this->privileges = $privileges;
34
35     }
36
37     /**
38      * Serializes the property in the DOM
39      *
40      * @param Sabre_DAV_Server $server
41      * @param DOMElement $node
42      * @return void
43      */
44     public function serialize(Sabre_DAV_Server $server,DOMElement $node) {
45
46         $doc = $node->ownerDocument;
47         foreach($this->privileges as $privName) {
48
49             $this->serializePriv($doc,$node,$privName);
50
51         }
52
53     }
54
55     /**
56      * Serializes one privilege
57      *
58      * @param DOMDocument $doc
59      * @param DOMElement $node
60      * @param string $privName
61      * @return void
62      */
63     protected function serializePriv($doc,$node,$privName) {
64
65         $xp  = $doc->createElementNS('DAV:','d:privilege');
66         $node->appendChild($xp);
67
68         $privParts = null;
69         preg_match('/^{([^}]*)}(.*)$/',$privName,$privParts);
70
71         $xp->appendChild($doc->createElementNS($privParts[1],'d:'.$privParts[2]));
72
73     }
74
75 }