@@ -22,165 +22,165 @@ |
||
22 | 22 | */ |
23 | 23 | class Principal extends DAV\Xml\Property\Href |
24 | 24 | { |
25 | - /** |
|
26 | - * To specify a not-logged-in user, use the UNAUTHENTICATED principal. |
|
27 | - */ |
|
28 | - const UNAUTHENTICATED = 1; |
|
25 | + /** |
|
26 | + * To specify a not-logged-in user, use the UNAUTHENTICATED principal. |
|
27 | + */ |
|
28 | + const UNAUTHENTICATED = 1; |
|
29 | 29 | |
30 | - /** |
|
31 | - * To specify any principal that is logged in, use AUTHENTICATED. |
|
32 | - */ |
|
33 | - const AUTHENTICATED = 2; |
|
30 | + /** |
|
31 | + * To specify any principal that is logged in, use AUTHENTICATED. |
|
32 | + */ |
|
33 | + const AUTHENTICATED = 2; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Specific principals can be specified with the HREF. |
|
37 | - */ |
|
38 | - const HREF = 3; |
|
35 | + /** |
|
36 | + * Specific principals can be specified with the HREF. |
|
37 | + */ |
|
38 | + const HREF = 3; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Everybody, basically. |
|
42 | - */ |
|
43 | - const ALL = 4; |
|
40 | + /** |
|
41 | + * Everybody, basically. |
|
42 | + */ |
|
43 | + const ALL = 4; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Principal-type. |
|
47 | - * |
|
48 | - * Must be one of the UNAUTHENTICATED, AUTHENTICATED or HREF constants. |
|
49 | - * |
|
50 | - * @var int |
|
51 | - */ |
|
52 | - protected $type; |
|
45 | + /** |
|
46 | + * Principal-type. |
|
47 | + * |
|
48 | + * Must be one of the UNAUTHENTICATED, AUTHENTICATED or HREF constants. |
|
49 | + * |
|
50 | + * @var int |
|
51 | + */ |
|
52 | + protected $type; |
|
53 | 53 | |
54 | - /** |
|
55 | - * Creates the property. |
|
56 | - * |
|
57 | - * The 'type' argument must be one of the type constants defined in this class. |
|
58 | - * |
|
59 | - * 'href' is only required for the HREF type. |
|
60 | - * |
|
61 | - * @param int $type |
|
62 | - * @param string|null $href |
|
63 | - */ |
|
64 | - public function __construct($type, $href = null) |
|
65 | - { |
|
66 | - $this->type = $type; |
|
67 | - if (self::HREF === $type && is_null($href)) { |
|
68 | - throw new DAV\Exception('The href argument must be specified for the HREF principal type.'); |
|
69 | - } |
|
70 | - if ($href) { |
|
71 | - $href = rtrim($href, '/').'/'; |
|
72 | - parent::__construct($href); |
|
73 | - } |
|
74 | - } |
|
54 | + /** |
|
55 | + * Creates the property. |
|
56 | + * |
|
57 | + * The 'type' argument must be one of the type constants defined in this class. |
|
58 | + * |
|
59 | + * 'href' is only required for the HREF type. |
|
60 | + * |
|
61 | + * @param int $type |
|
62 | + * @param string|null $href |
|
63 | + */ |
|
64 | + public function __construct($type, $href = null) |
|
65 | + { |
|
66 | + $this->type = $type; |
|
67 | + if (self::HREF === $type && is_null($href)) { |
|
68 | + throw new DAV\Exception('The href argument must be specified for the HREF principal type.'); |
|
69 | + } |
|
70 | + if ($href) { |
|
71 | + $href = rtrim($href, '/').'/'; |
|
72 | + parent::__construct($href); |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Returns the principal type. |
|
78 | - * |
|
79 | - * @return int |
|
80 | - */ |
|
81 | - public function getType() |
|
82 | - { |
|
83 | - return $this->type; |
|
84 | - } |
|
76 | + /** |
|
77 | + * Returns the principal type. |
|
78 | + * |
|
79 | + * @return int |
|
80 | + */ |
|
81 | + public function getType() |
|
82 | + { |
|
83 | + return $this->type; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * The xmlSerialize method is called during xml writing. |
|
88 | - * |
|
89 | - * Use the $writer argument to write its own xml serialization. |
|
90 | - * |
|
91 | - * An important note: do _not_ create a parent element. Any element |
|
92 | - * implementing XmlSerializable should only ever write what's considered |
|
93 | - * its 'inner xml'. |
|
94 | - * |
|
95 | - * The parent of the current element is responsible for writing a |
|
96 | - * containing element. |
|
97 | - * |
|
98 | - * This allows serializers to be re-used for different element names. |
|
99 | - * |
|
100 | - * If you are opening new elements, you must also close them again. |
|
101 | - */ |
|
102 | - public function xmlSerialize(Writer $writer) |
|
103 | - { |
|
104 | - switch ($this->type) { |
|
105 | - case self::UNAUTHENTICATED: |
|
106 | - $writer->writeElement('{DAV:}unauthenticated'); |
|
107 | - break; |
|
108 | - case self::AUTHENTICATED: |
|
109 | - $writer->writeElement('{DAV:}authenticated'); |
|
110 | - break; |
|
111 | - case self::HREF: |
|
112 | - parent::xmlSerialize($writer); |
|
113 | - break; |
|
114 | - case self::ALL: |
|
115 | - $writer->writeElement('{DAV:}all'); |
|
116 | - break; |
|
117 | - } |
|
118 | - } |
|
86 | + /** |
|
87 | + * The xmlSerialize method is called during xml writing. |
|
88 | + * |
|
89 | + * Use the $writer argument to write its own xml serialization. |
|
90 | + * |
|
91 | + * An important note: do _not_ create a parent element. Any element |
|
92 | + * implementing XmlSerializable should only ever write what's considered |
|
93 | + * its 'inner xml'. |
|
94 | + * |
|
95 | + * The parent of the current element is responsible for writing a |
|
96 | + * containing element. |
|
97 | + * |
|
98 | + * This allows serializers to be re-used for different element names. |
|
99 | + * |
|
100 | + * If you are opening new elements, you must also close them again. |
|
101 | + */ |
|
102 | + public function xmlSerialize(Writer $writer) |
|
103 | + { |
|
104 | + switch ($this->type) { |
|
105 | + case self::UNAUTHENTICATED: |
|
106 | + $writer->writeElement('{DAV:}unauthenticated'); |
|
107 | + break; |
|
108 | + case self::AUTHENTICATED: |
|
109 | + $writer->writeElement('{DAV:}authenticated'); |
|
110 | + break; |
|
111 | + case self::HREF: |
|
112 | + parent::xmlSerialize($writer); |
|
113 | + break; |
|
114 | + case self::ALL: |
|
115 | + $writer->writeElement('{DAV:}all'); |
|
116 | + break; |
|
117 | + } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Generate html representation for this value. |
|
122 | - * |
|
123 | - * The html output is 100% trusted, and no effort is being made to sanitize |
|
124 | - * it. It's up to the implementor to sanitize user provided values. |
|
125 | - * |
|
126 | - * The output must be in UTF-8. |
|
127 | - * |
|
128 | - * The baseUri parameter is a url to the root of the application, and can |
|
129 | - * be used to construct local links. |
|
130 | - * |
|
131 | - * @return string |
|
132 | - */ |
|
133 | - public function toHtml(HtmlOutputHelper $html) |
|
134 | - { |
|
135 | - switch ($this->type) { |
|
136 | - case self::UNAUTHENTICATED: |
|
137 | - return '<em>unauthenticated</em>'; |
|
138 | - case self::AUTHENTICATED: |
|
139 | - return '<em>authenticated</em>'; |
|
140 | - case self::HREF: |
|
141 | - return parent::toHtml($html); |
|
142 | - case self::ALL: |
|
143 | - return '<em>all</em>'; |
|
144 | - } |
|
120 | + /** |
|
121 | + * Generate html representation for this value. |
|
122 | + * |
|
123 | + * The html output is 100% trusted, and no effort is being made to sanitize |
|
124 | + * it. It's up to the implementor to sanitize user provided values. |
|
125 | + * |
|
126 | + * The output must be in UTF-8. |
|
127 | + * |
|
128 | + * The baseUri parameter is a url to the root of the application, and can |
|
129 | + * be used to construct local links. |
|
130 | + * |
|
131 | + * @return string |
|
132 | + */ |
|
133 | + public function toHtml(HtmlOutputHelper $html) |
|
134 | + { |
|
135 | + switch ($this->type) { |
|
136 | + case self::UNAUTHENTICATED: |
|
137 | + return '<em>unauthenticated</em>'; |
|
138 | + case self::AUTHENTICATED: |
|
139 | + return '<em>authenticated</em>'; |
|
140 | + case self::HREF: |
|
141 | + return parent::toHtml($html); |
|
142 | + case self::ALL: |
|
143 | + return '<em>all</em>'; |
|
144 | + } |
|
145 | 145 | |
146 | - return '<em>unknown</em>'; |
|
147 | - } |
|
146 | + return '<em>unknown</em>'; |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * The deserialize method is called during xml parsing. |
|
151 | - * |
|
152 | - * This method is called staticly, this is because in theory this method |
|
153 | - * may be used as a type of constructor, or factory method. |
|
154 | - * |
|
155 | - * Often you want to return an instance of the current class, but you are |
|
156 | - * free to return other data as well. |
|
157 | - * |
|
158 | - * Important note 2: You are responsible for advancing the reader to the |
|
159 | - * next element. Not doing anything will result in a never-ending loop. |
|
160 | - * |
|
161 | - * If you just want to skip parsing for this element altogether, you can |
|
162 | - * just call $reader->next(); |
|
163 | - * |
|
164 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
165 | - * the next element. |
|
166 | - * |
|
167 | - * @return mixed |
|
168 | - */ |
|
169 | - public static function xmlDeserialize(Reader $reader) |
|
170 | - { |
|
171 | - $tree = $reader->parseInnerTree()[0]; |
|
149 | + /** |
|
150 | + * The deserialize method is called during xml parsing. |
|
151 | + * |
|
152 | + * This method is called staticly, this is because in theory this method |
|
153 | + * may be used as a type of constructor, or factory method. |
|
154 | + * |
|
155 | + * Often you want to return an instance of the current class, but you are |
|
156 | + * free to return other data as well. |
|
157 | + * |
|
158 | + * Important note 2: You are responsible for advancing the reader to the |
|
159 | + * next element. Not doing anything will result in a never-ending loop. |
|
160 | + * |
|
161 | + * If you just want to skip parsing for this element altogether, you can |
|
162 | + * just call $reader->next(); |
|
163 | + * |
|
164 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
165 | + * the next element. |
|
166 | + * |
|
167 | + * @return mixed |
|
168 | + */ |
|
169 | + public static function xmlDeserialize(Reader $reader) |
|
170 | + { |
|
171 | + $tree = $reader->parseInnerTree()[0]; |
|
172 | 172 | |
173 | - switch ($tree['name']) { |
|
174 | - case '{DAV:}unauthenticated': |
|
175 | - return new self(self::UNAUTHENTICATED); |
|
176 | - case '{DAV:}authenticated': |
|
177 | - return new self(self::AUTHENTICATED); |
|
178 | - case '{DAV:}href': |
|
179 | - return new self(self::HREF, $tree['value']); |
|
180 | - case '{DAV:}all': |
|
181 | - return new self(self::ALL); |
|
182 | - default: |
|
183 | - throw new BadRequest('Unknown or unsupported principal type: '.$tree['name']); |
|
184 | - } |
|
185 | - } |
|
173 | + switch ($tree['name']) { |
|
174 | + case '{DAV:}unauthenticated': |
|
175 | + return new self(self::UNAUTHENTICATED); |
|
176 | + case '{DAV:}authenticated': |
|
177 | + return new self(self::AUTHENTICATED); |
|
178 | + case '{DAV:}href': |
|
179 | + return new self(self::HREF, $tree['value']); |
|
180 | + case '{DAV:}all': |
|
181 | + return new self(self::ALL); |
|
182 | + default: |
|
183 | + throw new BadRequest('Unknown or unsupported principal type: '.$tree['name']); |
|
184 | + } |
|
185 | + } |
|
186 | 186 | } |
@@ -25,122 +25,122 @@ |
||
25 | 25 | */ |
26 | 26 | class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput |
27 | 27 | { |
28 | - /** |
|
29 | - * privileges. |
|
30 | - * |
|
31 | - * @var array |
|
32 | - */ |
|
33 | - protected $privileges; |
|
28 | + /** |
|
29 | + * privileges. |
|
30 | + * |
|
31 | + * @var array |
|
32 | + */ |
|
33 | + protected $privileges; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Constructor. |
|
37 | - */ |
|
38 | - public function __construct(array $privileges) |
|
39 | - { |
|
40 | - $this->privileges = $privileges; |
|
41 | - } |
|
35 | + /** |
|
36 | + * Constructor. |
|
37 | + */ |
|
38 | + public function __construct(array $privileges) |
|
39 | + { |
|
40 | + $this->privileges = $privileges; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Returns the privilege value. |
|
45 | - * |
|
46 | - * @return array |
|
47 | - */ |
|
48 | - public function getValue() |
|
49 | - { |
|
50 | - return $this->privileges; |
|
51 | - } |
|
43 | + /** |
|
44 | + * Returns the privilege value. |
|
45 | + * |
|
46 | + * @return array |
|
47 | + */ |
|
48 | + public function getValue() |
|
49 | + { |
|
50 | + return $this->privileges; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * The xmlSerialize method is called during xml writing. |
|
55 | - * |
|
56 | - * Use the $writer argument to write its own xml serialization. |
|
57 | - * |
|
58 | - * An important note: do _not_ create a parent element. Any element |
|
59 | - * implementing XmlSerializable should only ever write what's considered |
|
60 | - * its 'inner xml'. |
|
61 | - * |
|
62 | - * The parent of the current element is responsible for writing a |
|
63 | - * containing element. |
|
64 | - * |
|
65 | - * This allows serializers to be re-used for different element names. |
|
66 | - * |
|
67 | - * If you are opening new elements, you must also close them again. |
|
68 | - */ |
|
69 | - public function xmlSerialize(Writer $writer) |
|
70 | - { |
|
71 | - $this->serializePriv($writer, '{DAV:}all', ['aggregates' => $this->privileges]); |
|
72 | - } |
|
53 | + /** |
|
54 | + * The xmlSerialize method is called during xml writing. |
|
55 | + * |
|
56 | + * Use the $writer argument to write its own xml serialization. |
|
57 | + * |
|
58 | + * An important note: do _not_ create a parent element. Any element |
|
59 | + * implementing XmlSerializable should only ever write what's considered |
|
60 | + * its 'inner xml'. |
|
61 | + * |
|
62 | + * The parent of the current element is responsible for writing a |
|
63 | + * containing element. |
|
64 | + * |
|
65 | + * This allows serializers to be re-used for different element names. |
|
66 | + * |
|
67 | + * If you are opening new elements, you must also close them again. |
|
68 | + */ |
|
69 | + public function xmlSerialize(Writer $writer) |
|
70 | + { |
|
71 | + $this->serializePriv($writer, '{DAV:}all', ['aggregates' => $this->privileges]); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Generate html representation for this value. |
|
76 | - * |
|
77 | - * The html output is 100% trusted, and no effort is being made to sanitize |
|
78 | - * it. It's up to the implementor to sanitize user provided values. |
|
79 | - * |
|
80 | - * The output must be in UTF-8. |
|
81 | - * |
|
82 | - * The baseUri parameter is a url to the root of the application, and can |
|
83 | - * be used to construct local links. |
|
84 | - * |
|
85 | - * @return string |
|
86 | - */ |
|
87 | - public function toHtml(HtmlOutputHelper $html) |
|
88 | - { |
|
89 | - $traverse = function ($privName, $priv) use (&$traverse, $html) { |
|
90 | - echo '<li>'; |
|
91 | - echo $html->xmlName($privName); |
|
92 | - if (isset($priv['abstract']) && $priv['abstract']) { |
|
93 | - echo ' <i>(abstract)</i>'; |
|
94 | - } |
|
95 | - if (isset($priv['description'])) { |
|
96 | - echo ' '.$html->h($priv['description']); |
|
97 | - } |
|
98 | - if (isset($priv['aggregates'])) { |
|
99 | - echo "\n<ul>\n"; |
|
100 | - foreach ($priv['aggregates'] as $subPrivName => $subPriv) { |
|
101 | - $traverse($subPrivName, $subPriv); |
|
102 | - } |
|
103 | - echo '</ul>'; |
|
104 | - } |
|
105 | - echo "</li>\n"; |
|
106 | - }; |
|
74 | + /** |
|
75 | + * Generate html representation for this value. |
|
76 | + * |
|
77 | + * The html output is 100% trusted, and no effort is being made to sanitize |
|
78 | + * it. It's up to the implementor to sanitize user provided values. |
|
79 | + * |
|
80 | + * The output must be in UTF-8. |
|
81 | + * |
|
82 | + * The baseUri parameter is a url to the root of the application, and can |
|
83 | + * be used to construct local links. |
|
84 | + * |
|
85 | + * @return string |
|
86 | + */ |
|
87 | + public function toHtml(HtmlOutputHelper $html) |
|
88 | + { |
|
89 | + $traverse = function ($privName, $priv) use (&$traverse, $html) { |
|
90 | + echo '<li>'; |
|
91 | + echo $html->xmlName($privName); |
|
92 | + if (isset($priv['abstract']) && $priv['abstract']) { |
|
93 | + echo ' <i>(abstract)</i>'; |
|
94 | + } |
|
95 | + if (isset($priv['description'])) { |
|
96 | + echo ' '.$html->h($priv['description']); |
|
97 | + } |
|
98 | + if (isset($priv['aggregates'])) { |
|
99 | + echo "\n<ul>\n"; |
|
100 | + foreach ($priv['aggregates'] as $subPrivName => $subPriv) { |
|
101 | + $traverse($subPrivName, $subPriv); |
|
102 | + } |
|
103 | + echo '</ul>'; |
|
104 | + } |
|
105 | + echo "</li>\n"; |
|
106 | + }; |
|
107 | 107 | |
108 | - ob_start(); |
|
109 | - echo '<ul class="tree">'; |
|
110 | - $traverse('{DAV:}all', ['aggregates' => $this->getValue()]); |
|
111 | - echo "</ul>\n"; |
|
108 | + ob_start(); |
|
109 | + echo '<ul class="tree">'; |
|
110 | + $traverse('{DAV:}all', ['aggregates' => $this->getValue()]); |
|
111 | + echo "</ul>\n"; |
|
112 | 112 | |
113 | - return ob_get_clean(); |
|
114 | - } |
|
113 | + return ob_get_clean(); |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * Serializes a property. |
|
118 | - * |
|
119 | - * This is a recursive function. |
|
120 | - * |
|
121 | - * @param string $privName |
|
122 | - * @param array $privilege |
|
123 | - */ |
|
124 | - private function serializePriv(Writer $writer, $privName, $privilege) |
|
125 | - { |
|
126 | - $writer->startElement('{DAV:}supported-privilege'); |
|
116 | + /** |
|
117 | + * Serializes a property. |
|
118 | + * |
|
119 | + * This is a recursive function. |
|
120 | + * |
|
121 | + * @param string $privName |
|
122 | + * @param array $privilege |
|
123 | + */ |
|
124 | + private function serializePriv(Writer $writer, $privName, $privilege) |
|
125 | + { |
|
126 | + $writer->startElement('{DAV:}supported-privilege'); |
|
127 | 127 | |
128 | - $writer->startElement('{DAV:}privilege'); |
|
129 | - $writer->writeElement($privName); |
|
130 | - $writer->endElement(); // privilege |
|
128 | + $writer->startElement('{DAV:}privilege'); |
|
129 | + $writer->writeElement($privName); |
|
130 | + $writer->endElement(); // privilege |
|
131 | 131 | |
132 | - if (!empty($privilege['abstract'])) { |
|
133 | - $writer->writeElement('{DAV:}abstract'); |
|
134 | - } |
|
135 | - if (!empty($privilege['description'])) { |
|
136 | - $writer->writeElement('{DAV:}description', $privilege['description']); |
|
137 | - } |
|
138 | - if (isset($privilege['aggregates'])) { |
|
139 | - foreach ($privilege['aggregates'] as $subPrivName => $subPrivilege) { |
|
140 | - $this->serializePriv($writer, $subPrivName, $subPrivilege); |
|
141 | - } |
|
142 | - } |
|
132 | + if (!empty($privilege['abstract'])) { |
|
133 | + $writer->writeElement('{DAV:}abstract'); |
|
134 | + } |
|
135 | + if (!empty($privilege['description'])) { |
|
136 | + $writer->writeElement('{DAV:}description', $privilege['description']); |
|
137 | + } |
|
138 | + if (isset($privilege['aggregates'])) { |
|
139 | + foreach ($privilege['aggregates'] as $subPrivName => $subPrivilege) { |
|
140 | + $this->serializePriv($writer, $subPrivName, $subPrivilege); |
|
141 | + } |
|
142 | + } |
|
143 | 143 | |
144 | - $writer->endElement(); // supported-privilege |
|
145 | - } |
|
144 | + $writer->endElement(); // supported-privilege |
|
145 | + } |
|
146 | 146 | } |
@@ -86,7 +86,7 @@ |
||
86 | 86 | */ |
87 | 87 | public function toHtml(HtmlOutputHelper $html) |
88 | 88 | { |
89 | - $traverse = function ($privName, $priv) use (&$traverse, $html) { |
|
89 | + $traverse = function($privName, $priv) use (&$traverse, $html) { |
|
90 | 90 | echo '<li>'; |
91 | 91 | echo $html->xmlName($privName); |
92 | 92 | if (isset($priv['abstract']) && $priv['abstract']) { |
@@ -18,25 +18,25 @@ |
||
18 | 18 | */ |
19 | 19 | class AclRestrictions implements XmlSerializable |
20 | 20 | { |
21 | - /** |
|
22 | - * The xmlSerialize method is called during xml writing. |
|
23 | - * |
|
24 | - * Use the $writer argument to write its own xml serialization. |
|
25 | - * |
|
26 | - * An important note: do _not_ create a parent element. Any element |
|
27 | - * implementing XmlSerializable should only ever write what's considered |
|
28 | - * its 'inner xml'. |
|
29 | - * |
|
30 | - * The parent of the current element is responsible for writing a |
|
31 | - * containing element. |
|
32 | - * |
|
33 | - * This allows serializers to be re-used for different element names. |
|
34 | - * |
|
35 | - * If you are opening new elements, you must also close them again. |
|
36 | - */ |
|
37 | - public function xmlSerialize(Writer $writer) |
|
38 | - { |
|
39 | - $writer->writeElement('{DAV:}grant-only'); |
|
40 | - $writer->writeElement('{DAV:}no-invert'); |
|
41 | - } |
|
21 | + /** |
|
22 | + * The xmlSerialize method is called during xml writing. |
|
23 | + * |
|
24 | + * Use the $writer argument to write its own xml serialization. |
|
25 | + * |
|
26 | + * An important note: do _not_ create a parent element. Any element |
|
27 | + * implementing XmlSerializable should only ever write what's considered |
|
28 | + * its 'inner xml'. |
|
29 | + * |
|
30 | + * The parent of the current element is responsible for writing a |
|
31 | + * containing element. |
|
32 | + * |
|
33 | + * This allows serializers to be re-used for different element names. |
|
34 | + * |
|
35 | + * If you are opening new elements, you must also close them again. |
|
36 | + */ |
|
37 | + public function xmlSerialize(Writer $writer) |
|
38 | + { |
|
39 | + $writer->writeElement('{DAV:}grant-only'); |
|
40 | + $writer->writeElement('{DAV:}no-invert'); |
|
41 | + } |
|
42 | 42 | } |
@@ -29,229 +29,229 @@ |
||
29 | 29 | */ |
30 | 30 | class Acl implements Element, HtmlOutput |
31 | 31 | { |
32 | - /** |
|
33 | - * List of privileges. |
|
34 | - * |
|
35 | - * @var array |
|
36 | - */ |
|
37 | - protected $privileges; |
|
32 | + /** |
|
33 | + * List of privileges. |
|
34 | + * |
|
35 | + * @var array |
|
36 | + */ |
|
37 | + protected $privileges; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Whether or not the server base url is required to be prefixed when |
|
41 | - * serializing the property. |
|
42 | - * |
|
43 | - * @var bool |
|
44 | - */ |
|
45 | - protected $prefixBaseUrl; |
|
39 | + /** |
|
40 | + * Whether or not the server base url is required to be prefixed when |
|
41 | + * serializing the property. |
|
42 | + * |
|
43 | + * @var bool |
|
44 | + */ |
|
45 | + protected $prefixBaseUrl; |
|
46 | 46 | |
47 | - /** |
|
48 | - * Constructor. |
|
49 | - * |
|
50 | - * This object requires a structure similar to the return value from |
|
51 | - * Sabre\DAVACL\Plugin::getACL(). |
|
52 | - * |
|
53 | - * Each privilege is a an array with at least a 'privilege' property, and a |
|
54 | - * 'principal' property. A privilege may have a 'protected' property as |
|
55 | - * well. |
|
56 | - * |
|
57 | - * The prefixBaseUrl should be set to false, if the supplied principal urls |
|
58 | - * are already full urls. If this is kept to true, the servers base url |
|
59 | - * will automatically be prefixed. |
|
60 | - * |
|
61 | - * @param bool $prefixBaseUrl |
|
62 | - */ |
|
63 | - public function __construct(array $privileges, $prefixBaseUrl = true) |
|
64 | - { |
|
65 | - $this->privileges = $privileges; |
|
66 | - $this->prefixBaseUrl = $prefixBaseUrl; |
|
67 | - } |
|
47 | + /** |
|
48 | + * Constructor. |
|
49 | + * |
|
50 | + * This object requires a structure similar to the return value from |
|
51 | + * Sabre\DAVACL\Plugin::getACL(). |
|
52 | + * |
|
53 | + * Each privilege is a an array with at least a 'privilege' property, and a |
|
54 | + * 'principal' property. A privilege may have a 'protected' property as |
|
55 | + * well. |
|
56 | + * |
|
57 | + * The prefixBaseUrl should be set to false, if the supplied principal urls |
|
58 | + * are already full urls. If this is kept to true, the servers base url |
|
59 | + * will automatically be prefixed. |
|
60 | + * |
|
61 | + * @param bool $prefixBaseUrl |
|
62 | + */ |
|
63 | + public function __construct(array $privileges, $prefixBaseUrl = true) |
|
64 | + { |
|
65 | + $this->privileges = $privileges; |
|
66 | + $this->prefixBaseUrl = $prefixBaseUrl; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * Returns the list of privileges for this property. |
|
71 | - * |
|
72 | - * @return array |
|
73 | - */ |
|
74 | - public function getPrivileges() |
|
75 | - { |
|
76 | - return $this->privileges; |
|
77 | - } |
|
69 | + /** |
|
70 | + * Returns the list of privileges for this property. |
|
71 | + * |
|
72 | + * @return array |
|
73 | + */ |
|
74 | + public function getPrivileges() |
|
75 | + { |
|
76 | + return $this->privileges; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * The xmlSerialize method is called during xml writing. |
|
81 | - * |
|
82 | - * Use the $writer argument to write its own xml serialization. |
|
83 | - * |
|
84 | - * An important note: do _not_ create a parent element. Any element |
|
85 | - * implementing XmlSerializable should only ever write what's considered |
|
86 | - * its 'inner xml'. |
|
87 | - * |
|
88 | - * The parent of the current element is responsible for writing a |
|
89 | - * containing element. |
|
90 | - * |
|
91 | - * This allows serializers to be re-used for different element names. |
|
92 | - * |
|
93 | - * If you are opening new elements, you must also close them again. |
|
94 | - */ |
|
95 | - public function xmlSerialize(Writer $writer) |
|
96 | - { |
|
97 | - foreach ($this->privileges as $ace) { |
|
98 | - $this->serializeAce($writer, $ace); |
|
99 | - } |
|
100 | - } |
|
79 | + /** |
|
80 | + * The xmlSerialize method is called during xml writing. |
|
81 | + * |
|
82 | + * Use the $writer argument to write its own xml serialization. |
|
83 | + * |
|
84 | + * An important note: do _not_ create a parent element. Any element |
|
85 | + * implementing XmlSerializable should only ever write what's considered |
|
86 | + * its 'inner xml'. |
|
87 | + * |
|
88 | + * The parent of the current element is responsible for writing a |
|
89 | + * containing element. |
|
90 | + * |
|
91 | + * This allows serializers to be re-used for different element names. |
|
92 | + * |
|
93 | + * If you are opening new elements, you must also close them again. |
|
94 | + */ |
|
95 | + public function xmlSerialize(Writer $writer) |
|
96 | + { |
|
97 | + foreach ($this->privileges as $ace) { |
|
98 | + $this->serializeAce($writer, $ace); |
|
99 | + } |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * Generate html representation for this value. |
|
104 | - * |
|
105 | - * The html output is 100% trusted, and no effort is being made to sanitize |
|
106 | - * it. It's up to the implementor to sanitize user provided values. |
|
107 | - * |
|
108 | - * The output must be in UTF-8. |
|
109 | - * |
|
110 | - * The baseUri parameter is a url to the root of the application, and can |
|
111 | - * be used to construct local links. |
|
112 | - * |
|
113 | - * @return string |
|
114 | - */ |
|
115 | - public function toHtml(HtmlOutputHelper $html) |
|
116 | - { |
|
117 | - ob_start(); |
|
118 | - echo '<table>'; |
|
119 | - echo '<tr><th>Principal</th><th>Privilege</th><th></th></tr>'; |
|
120 | - foreach ($this->privileges as $privilege) { |
|
121 | - echo '<tr>'; |
|
122 | - // if it starts with a {, it's a special principal |
|
123 | - if ('{' === $privilege['principal'][0]) { |
|
124 | - echo '<td>', $html->xmlName($privilege['principal']), '</td>'; |
|
125 | - } else { |
|
126 | - echo '<td>', $html->link($privilege['principal']), '</td>'; |
|
127 | - } |
|
128 | - echo '<td>', $html->xmlName($privilege['privilege']), '</td>'; |
|
129 | - echo '<td>'; |
|
130 | - if (!empty($privilege['protected'])) { |
|
131 | - echo '(protected)'; |
|
132 | - } |
|
133 | - echo '</td>'; |
|
134 | - echo '</tr>'; |
|
135 | - } |
|
136 | - echo '</table>'; |
|
102 | + /** |
|
103 | + * Generate html representation for this value. |
|
104 | + * |
|
105 | + * The html output is 100% trusted, and no effort is being made to sanitize |
|
106 | + * it. It's up to the implementor to sanitize user provided values. |
|
107 | + * |
|
108 | + * The output must be in UTF-8. |
|
109 | + * |
|
110 | + * The baseUri parameter is a url to the root of the application, and can |
|
111 | + * be used to construct local links. |
|
112 | + * |
|
113 | + * @return string |
|
114 | + */ |
|
115 | + public function toHtml(HtmlOutputHelper $html) |
|
116 | + { |
|
117 | + ob_start(); |
|
118 | + echo '<table>'; |
|
119 | + echo '<tr><th>Principal</th><th>Privilege</th><th></th></tr>'; |
|
120 | + foreach ($this->privileges as $privilege) { |
|
121 | + echo '<tr>'; |
|
122 | + // if it starts with a {, it's a special principal |
|
123 | + if ('{' === $privilege['principal'][0]) { |
|
124 | + echo '<td>', $html->xmlName($privilege['principal']), '</td>'; |
|
125 | + } else { |
|
126 | + echo '<td>', $html->link($privilege['principal']), '</td>'; |
|
127 | + } |
|
128 | + echo '<td>', $html->xmlName($privilege['privilege']), '</td>'; |
|
129 | + echo '<td>'; |
|
130 | + if (!empty($privilege['protected'])) { |
|
131 | + echo '(protected)'; |
|
132 | + } |
|
133 | + echo '</td>'; |
|
134 | + echo '</tr>'; |
|
135 | + } |
|
136 | + echo '</table>'; |
|
137 | 137 | |
138 | - return ob_get_clean(); |
|
139 | - } |
|
138 | + return ob_get_clean(); |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * The deserialize method is called during xml parsing. |
|
143 | - * |
|
144 | - * This method is called statically, this is because in theory this method |
|
145 | - * may be used as a type of constructor, or factory method. |
|
146 | - * |
|
147 | - * Often you want to return an instance of the current class, but you are |
|
148 | - * free to return other data as well. |
|
149 | - * |
|
150 | - * Important note 2: You are responsible for advancing the reader to the |
|
151 | - * next element. Not doing anything will result in a never-ending loop. |
|
152 | - * |
|
153 | - * If you just want to skip parsing for this element altogether, you can |
|
154 | - * just call $reader->next(); |
|
155 | - * |
|
156 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
157 | - * the next element. |
|
158 | - * |
|
159 | - * @return mixed |
|
160 | - */ |
|
161 | - public static function xmlDeserialize(Reader $reader) |
|
162 | - { |
|
163 | - $elementMap = [ |
|
164 | - '{DAV:}ace' => 'Sabre\Xml\Element\KeyValue', |
|
165 | - '{DAV:}privilege' => 'Sabre\Xml\Element\Elements', |
|
166 | - '{DAV:}principal' => 'Sabre\DAVACL\Xml\Property\Principal', |
|
167 | - ]; |
|
141 | + /** |
|
142 | + * The deserialize method is called during xml parsing. |
|
143 | + * |
|
144 | + * This method is called statically, this is because in theory this method |
|
145 | + * may be used as a type of constructor, or factory method. |
|
146 | + * |
|
147 | + * Often you want to return an instance of the current class, but you are |
|
148 | + * free to return other data as well. |
|
149 | + * |
|
150 | + * Important note 2: You are responsible for advancing the reader to the |
|
151 | + * next element. Not doing anything will result in a never-ending loop. |
|
152 | + * |
|
153 | + * If you just want to skip parsing for this element altogether, you can |
|
154 | + * just call $reader->next(); |
|
155 | + * |
|
156 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
157 | + * the next element. |
|
158 | + * |
|
159 | + * @return mixed |
|
160 | + */ |
|
161 | + public static function xmlDeserialize(Reader $reader) |
|
162 | + { |
|
163 | + $elementMap = [ |
|
164 | + '{DAV:}ace' => 'Sabre\Xml\Element\KeyValue', |
|
165 | + '{DAV:}privilege' => 'Sabre\Xml\Element\Elements', |
|
166 | + '{DAV:}principal' => 'Sabre\DAVACL\Xml\Property\Principal', |
|
167 | + ]; |
|
168 | 168 | |
169 | - $privileges = []; |
|
169 | + $privileges = []; |
|
170 | 170 | |
171 | - foreach ((array) $reader->parseInnerTree($elementMap) as $element) { |
|
172 | - if ('{DAV:}ace' !== $element['name']) { |
|
173 | - continue; |
|
174 | - } |
|
175 | - $ace = $element['value']; |
|
171 | + foreach ((array) $reader->parseInnerTree($elementMap) as $element) { |
|
172 | + if ('{DAV:}ace' !== $element['name']) { |
|
173 | + continue; |
|
174 | + } |
|
175 | + $ace = $element['value']; |
|
176 | 176 | |
177 | - if (empty($ace['{DAV:}principal'])) { |
|
178 | - throw new DAV\Exception\BadRequest('Each {DAV:}ace element must have one {DAV:}principal element'); |
|
179 | - } |
|
180 | - $principal = $ace['{DAV:}principal']; |
|
177 | + if (empty($ace['{DAV:}principal'])) { |
|
178 | + throw new DAV\Exception\BadRequest('Each {DAV:}ace element must have one {DAV:}principal element'); |
|
179 | + } |
|
180 | + $principal = $ace['{DAV:}principal']; |
|
181 | 181 | |
182 | - switch ($principal->getType()) { |
|
183 | - case Principal::HREF: |
|
184 | - $principal = $principal->getHref(); |
|
185 | - break; |
|
186 | - case Principal::AUTHENTICATED: |
|
187 | - $principal = '{DAV:}authenticated'; |
|
188 | - break; |
|
189 | - case Principal::UNAUTHENTICATED: |
|
190 | - $principal = '{DAV:}unauthenticated'; |
|
191 | - break; |
|
192 | - case Principal::ALL: |
|
193 | - $principal = '{DAV:}all'; |
|
194 | - break; |
|
195 | - } |
|
182 | + switch ($principal->getType()) { |
|
183 | + case Principal::HREF: |
|
184 | + $principal = $principal->getHref(); |
|
185 | + break; |
|
186 | + case Principal::AUTHENTICATED: |
|
187 | + $principal = '{DAV:}authenticated'; |
|
188 | + break; |
|
189 | + case Principal::UNAUTHENTICATED: |
|
190 | + $principal = '{DAV:}unauthenticated'; |
|
191 | + break; |
|
192 | + case Principal::ALL: |
|
193 | + $principal = '{DAV:}all'; |
|
194 | + break; |
|
195 | + } |
|
196 | 196 | |
197 | - $protected = array_key_exists('{DAV:}protected', $ace); |
|
197 | + $protected = array_key_exists('{DAV:}protected', $ace); |
|
198 | 198 | |
199 | - if (!isset($ace['{DAV:}grant'])) { |
|
200 | - throw new DAV\Exception\NotImplemented('Every {DAV:}ace element must have a {DAV:}grant element. {DAV:}deny is not yet supported'); |
|
201 | - } |
|
202 | - foreach ($ace['{DAV:}grant'] as $elem) { |
|
203 | - if ('{DAV:}privilege' !== $elem['name']) { |
|
204 | - continue; |
|
205 | - } |
|
199 | + if (!isset($ace['{DAV:}grant'])) { |
|
200 | + throw new DAV\Exception\NotImplemented('Every {DAV:}ace element must have a {DAV:}grant element. {DAV:}deny is not yet supported'); |
|
201 | + } |
|
202 | + foreach ($ace['{DAV:}grant'] as $elem) { |
|
203 | + if ('{DAV:}privilege' !== $elem['name']) { |
|
204 | + continue; |
|
205 | + } |
|
206 | 206 | |
207 | - foreach ($elem['value'] as $priv) { |
|
208 | - $privileges[] = [ |
|
209 | - 'principal' => $principal, |
|
210 | - 'protected' => $protected, |
|
211 | - 'privilege' => $priv, |
|
212 | - ]; |
|
213 | - } |
|
214 | - } |
|
215 | - } |
|
207 | + foreach ($elem['value'] as $priv) { |
|
208 | + $privileges[] = [ |
|
209 | + 'principal' => $principal, |
|
210 | + 'protected' => $protected, |
|
211 | + 'privilege' => $priv, |
|
212 | + ]; |
|
213 | + } |
|
214 | + } |
|
215 | + } |
|
216 | 216 | |
217 | - return new self($privileges); |
|
218 | - } |
|
217 | + return new self($privileges); |
|
218 | + } |
|
219 | 219 | |
220 | - /** |
|
221 | - * Serializes a single access control entry. |
|
222 | - */ |
|
223 | - private function serializeAce(Writer $writer, array $ace) |
|
224 | - { |
|
225 | - $writer->startElement('{DAV:}ace'); |
|
220 | + /** |
|
221 | + * Serializes a single access control entry. |
|
222 | + */ |
|
223 | + private function serializeAce(Writer $writer, array $ace) |
|
224 | + { |
|
225 | + $writer->startElement('{DAV:}ace'); |
|
226 | 226 | |
227 | - switch ($ace['principal']) { |
|
228 | - case '{DAV:}authenticated': |
|
229 | - $principal = new Principal(Principal::AUTHENTICATED); |
|
230 | - break; |
|
231 | - case '{DAV:}unauthenticated': |
|
232 | - $principal = new Principal(Principal::UNAUTHENTICATED); |
|
233 | - break; |
|
234 | - case '{DAV:}all': |
|
235 | - $principal = new Principal(Principal::ALL); |
|
236 | - break; |
|
237 | - default: |
|
238 | - $principal = new Principal(Principal::HREF, $ace['principal']); |
|
239 | - break; |
|
240 | - } |
|
227 | + switch ($ace['principal']) { |
|
228 | + case '{DAV:}authenticated': |
|
229 | + $principal = new Principal(Principal::AUTHENTICATED); |
|
230 | + break; |
|
231 | + case '{DAV:}unauthenticated': |
|
232 | + $principal = new Principal(Principal::UNAUTHENTICATED); |
|
233 | + break; |
|
234 | + case '{DAV:}all': |
|
235 | + $principal = new Principal(Principal::ALL); |
|
236 | + break; |
|
237 | + default: |
|
238 | + $principal = new Principal(Principal::HREF, $ace['principal']); |
|
239 | + break; |
|
240 | + } |
|
241 | 241 | |
242 | - $writer->writeElement('{DAV:}principal', $principal); |
|
243 | - $writer->startElement('{DAV:}grant'); |
|
244 | - $writer->startElement('{DAV:}privilege'); |
|
242 | + $writer->writeElement('{DAV:}principal', $principal); |
|
243 | + $writer->startElement('{DAV:}grant'); |
|
244 | + $writer->startElement('{DAV:}privilege'); |
|
245 | 245 | |
246 | - $writer->writeElement($ace['privilege']); |
|
246 | + $writer->writeElement($ace['privilege']); |
|
247 | 247 | |
248 | - $writer->endElement(); // privilege |
|
249 | - $writer->endElement(); // grant |
|
248 | + $writer->endElement(); // privilege |
|
249 | + $writer->endElement(); // grant |
|
250 | 250 | |
251 | - if (!empty($ace['protected'])) { |
|
252 | - $writer->writeElement('{DAV:}protected'); |
|
253 | - } |
|
251 | + if (!empty($ace['protected'])) { |
|
252 | + $writer->writeElement('{DAV:}protected'); |
|
253 | + } |
|
254 | 254 | |
255 | - $writer->endElement(); // ace |
|
256 | - } |
|
255 | + $writer->endElement(); // ace |
|
256 | + } |
|
257 | 257 | } |
@@ -22,124 +22,124 @@ |
||
22 | 22 | */ |
23 | 23 | class CurrentUserPrivilegeSet implements Element, HtmlOutput |
24 | 24 | { |
25 | - /** |
|
26 | - * List of privileges. |
|
27 | - * |
|
28 | - * @var array |
|
29 | - */ |
|
30 | - private $privileges; |
|
25 | + /** |
|
26 | + * List of privileges. |
|
27 | + * |
|
28 | + * @var array |
|
29 | + */ |
|
30 | + private $privileges; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Creates the object. |
|
34 | - * |
|
35 | - * Pass the privileges in clark-notation |
|
36 | - */ |
|
37 | - public function __construct(array $privileges) |
|
38 | - { |
|
39 | - $this->privileges = $privileges; |
|
40 | - } |
|
32 | + /** |
|
33 | + * Creates the object. |
|
34 | + * |
|
35 | + * Pass the privileges in clark-notation |
|
36 | + */ |
|
37 | + public function __construct(array $privileges) |
|
38 | + { |
|
39 | + $this->privileges = $privileges; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * The xmlSerialize method is called during xml writing. |
|
44 | - * |
|
45 | - * Use the $writer argument to write its own xml serialization. |
|
46 | - * |
|
47 | - * An important note: do _not_ create a parent element. Any element |
|
48 | - * implementing XmlSerializable should only ever write what's considered |
|
49 | - * its 'inner xml'. |
|
50 | - * |
|
51 | - * The parent of the current element is responsible for writing a |
|
52 | - * containing element. |
|
53 | - * |
|
54 | - * This allows serializers to be re-used for different element names. |
|
55 | - * |
|
56 | - * If you are opening new elements, you must also close them again. |
|
57 | - */ |
|
58 | - public function xmlSerialize(Writer $writer) |
|
59 | - { |
|
60 | - foreach ($this->privileges as $privName) { |
|
61 | - $writer->startElement('{DAV:}privilege'); |
|
62 | - $writer->writeElement($privName); |
|
63 | - $writer->endElement(); |
|
64 | - } |
|
65 | - } |
|
42 | + /** |
|
43 | + * The xmlSerialize method is called during xml writing. |
|
44 | + * |
|
45 | + * Use the $writer argument to write its own xml serialization. |
|
46 | + * |
|
47 | + * An important note: do _not_ create a parent element. Any element |
|
48 | + * implementing XmlSerializable should only ever write what's considered |
|
49 | + * its 'inner xml'. |
|
50 | + * |
|
51 | + * The parent of the current element is responsible for writing a |
|
52 | + * containing element. |
|
53 | + * |
|
54 | + * This allows serializers to be re-used for different element names. |
|
55 | + * |
|
56 | + * If you are opening new elements, you must also close them again. |
|
57 | + */ |
|
58 | + public function xmlSerialize(Writer $writer) |
|
59 | + { |
|
60 | + foreach ($this->privileges as $privName) { |
|
61 | + $writer->startElement('{DAV:}privilege'); |
|
62 | + $writer->writeElement($privName); |
|
63 | + $writer->endElement(); |
|
64 | + } |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Returns true or false, whether the specified principal appears in the |
|
69 | - * list. |
|
70 | - * |
|
71 | - * @param string $privilegeName |
|
72 | - * |
|
73 | - * @return bool |
|
74 | - */ |
|
75 | - public function has($privilegeName) |
|
76 | - { |
|
77 | - return in_array($privilegeName, $this->privileges); |
|
78 | - } |
|
67 | + /** |
|
68 | + * Returns true or false, whether the specified principal appears in the |
|
69 | + * list. |
|
70 | + * |
|
71 | + * @param string $privilegeName |
|
72 | + * |
|
73 | + * @return bool |
|
74 | + */ |
|
75 | + public function has($privilegeName) |
|
76 | + { |
|
77 | + return in_array($privilegeName, $this->privileges); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Returns the list of privileges. |
|
82 | - * |
|
83 | - * @return array |
|
84 | - */ |
|
85 | - public function getValue() |
|
86 | - { |
|
87 | - return $this->privileges; |
|
88 | - } |
|
80 | + /** |
|
81 | + * Returns the list of privileges. |
|
82 | + * |
|
83 | + * @return array |
|
84 | + */ |
|
85 | + public function getValue() |
|
86 | + { |
|
87 | + return $this->privileges; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * The deserialize method is called during xml parsing. |
|
92 | - * |
|
93 | - * This method is called statically, this is because in theory this method |
|
94 | - * may be used as a type of constructor, or factory method. |
|
95 | - * |
|
96 | - * Often you want to return an instance of the current class, but you are |
|
97 | - * free to return other data as well. |
|
98 | - * |
|
99 | - * You are responsible for advancing the reader to the next element. Not |
|
100 | - * doing anything will result in a never-ending loop. |
|
101 | - * |
|
102 | - * If you just want to skip parsing for this element altogether, you can |
|
103 | - * just call $reader->next(); |
|
104 | - * |
|
105 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
106 | - * the next element. |
|
107 | - * |
|
108 | - * @return mixed |
|
109 | - */ |
|
110 | - public static function xmlDeserialize(Reader $reader) |
|
111 | - { |
|
112 | - $result = []; |
|
90 | + /** |
|
91 | + * The deserialize method is called during xml parsing. |
|
92 | + * |
|
93 | + * This method is called statically, this is because in theory this method |
|
94 | + * may be used as a type of constructor, or factory method. |
|
95 | + * |
|
96 | + * Often you want to return an instance of the current class, but you are |
|
97 | + * free to return other data as well. |
|
98 | + * |
|
99 | + * You are responsible for advancing the reader to the next element. Not |
|
100 | + * doing anything will result in a never-ending loop. |
|
101 | + * |
|
102 | + * If you just want to skip parsing for this element altogether, you can |
|
103 | + * just call $reader->next(); |
|
104 | + * |
|
105 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
106 | + * the next element. |
|
107 | + * |
|
108 | + * @return mixed |
|
109 | + */ |
|
110 | + public static function xmlDeserialize(Reader $reader) |
|
111 | + { |
|
112 | + $result = []; |
|
113 | 113 | |
114 | - $tree = $reader->parseInnerTree(['{DAV:}privilege' => 'Sabre\\Xml\\Element\\Elements']); |
|
115 | - foreach ($tree as $element) { |
|
116 | - if ('{DAV:}privilege' !== $element['name']) { |
|
117 | - continue; |
|
118 | - } |
|
119 | - $result[] = $element['value'][0]; |
|
120 | - } |
|
114 | + $tree = $reader->parseInnerTree(['{DAV:}privilege' => 'Sabre\\Xml\\Element\\Elements']); |
|
115 | + foreach ($tree as $element) { |
|
116 | + if ('{DAV:}privilege' !== $element['name']) { |
|
117 | + continue; |
|
118 | + } |
|
119 | + $result[] = $element['value'][0]; |
|
120 | + } |
|
121 | 121 | |
122 | - return new self($result); |
|
123 | - } |
|
122 | + return new self($result); |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * Generate html representation for this value. |
|
127 | - * |
|
128 | - * The html output is 100% trusted, and no effort is being made to sanitize |
|
129 | - * it. It's up to the implementor to sanitize user provided values. |
|
130 | - * |
|
131 | - * The output must be in UTF-8. |
|
132 | - * |
|
133 | - * The baseUri parameter is a url to the root of the application, and can |
|
134 | - * be used to construct local links. |
|
135 | - * |
|
136 | - * @return string |
|
137 | - */ |
|
138 | - public function toHtml(HtmlOutputHelper $html) |
|
139 | - { |
|
140 | - return implode( |
|
141 | - ', ', |
|
142 | - array_map([$html, 'xmlName'], $this->getValue()) |
|
143 | - ); |
|
144 | - } |
|
125 | + /** |
|
126 | + * Generate html representation for this value. |
|
127 | + * |
|
128 | + * The html output is 100% trusted, and no effort is being made to sanitize |
|
129 | + * it. It's up to the implementor to sanitize user provided values. |
|
130 | + * |
|
131 | + * The output must be in UTF-8. |
|
132 | + * |
|
133 | + * The baseUri parameter is a url to the root of the application, and can |
|
134 | + * be used to construct local links. |
|
135 | + * |
|
136 | + * @return string |
|
137 | + */ |
|
138 | + public function toHtml(HtmlOutputHelper $html) |
|
139 | + { |
|
140 | + return implode( |
|
141 | + ', ', |
|
142 | + array_map([$html, 'xmlName'], $this->getValue()) |
|
143 | + ); |
|
144 | + } |
|
145 | 145 | } |
@@ -18,77 +18,77 @@ |
||
18 | 18 | */ |
19 | 19 | trait ACLTrait |
20 | 20 | { |
21 | - /** |
|
22 | - * Returns the owner principal. |
|
23 | - * |
|
24 | - * This must be a url to a principal, or null if there's no owner |
|
25 | - * |
|
26 | - * @return string|null |
|
27 | - */ |
|
28 | - public function getOwner() |
|
29 | - { |
|
30 | - return null; |
|
31 | - } |
|
21 | + /** |
|
22 | + * Returns the owner principal. |
|
23 | + * |
|
24 | + * This must be a url to a principal, or null if there's no owner |
|
25 | + * |
|
26 | + * @return string|null |
|
27 | + */ |
|
28 | + public function getOwner() |
|
29 | + { |
|
30 | + return null; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Returns a group principal. |
|
35 | - * |
|
36 | - * This must be a url to a principal, or null if there's no owner |
|
37 | - * |
|
38 | - * @return string|null |
|
39 | - */ |
|
40 | - public function getGroup() |
|
41 | - { |
|
42 | - return null; |
|
43 | - } |
|
33 | + /** |
|
34 | + * Returns a group principal. |
|
35 | + * |
|
36 | + * This must be a url to a principal, or null if there's no owner |
|
37 | + * |
|
38 | + * @return string|null |
|
39 | + */ |
|
40 | + public function getGroup() |
|
41 | + { |
|
42 | + return null; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Returns a list of ACE's for this node. |
|
47 | - * |
|
48 | - * Each ACE has the following properties: |
|
49 | - * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are |
|
50 | - * currently the only supported privileges |
|
51 | - * * 'principal', a url to the principal who owns the node |
|
52 | - * * 'protected' (optional), indicating that this ACE is not allowed to |
|
53 | - * be updated. |
|
54 | - * |
|
55 | - * @return array |
|
56 | - */ |
|
57 | - public function getACL() |
|
58 | - { |
|
59 | - return [ |
|
60 | - [ |
|
61 | - 'privilege' => '{DAV:}all', |
|
62 | - 'principal' => '{DAV:}owner', |
|
63 | - 'protected' => true, |
|
64 | - ], |
|
65 | - ]; |
|
66 | - } |
|
45 | + /** |
|
46 | + * Returns a list of ACE's for this node. |
|
47 | + * |
|
48 | + * Each ACE has the following properties: |
|
49 | + * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are |
|
50 | + * currently the only supported privileges |
|
51 | + * * 'principal', a url to the principal who owns the node |
|
52 | + * * 'protected' (optional), indicating that this ACE is not allowed to |
|
53 | + * be updated. |
|
54 | + * |
|
55 | + * @return array |
|
56 | + */ |
|
57 | + public function getACL() |
|
58 | + { |
|
59 | + return [ |
|
60 | + [ |
|
61 | + 'privilege' => '{DAV:}all', |
|
62 | + 'principal' => '{DAV:}owner', |
|
63 | + 'protected' => true, |
|
64 | + ], |
|
65 | + ]; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Updates the ACL. |
|
70 | - * |
|
71 | - * This method will receive a list of new ACE's as an array argument. |
|
72 | - */ |
|
73 | - public function setACL(array $acl) |
|
74 | - { |
|
75 | - throw new \Sabre\DAV\Exception\Forbidden('Setting ACL is not supported on this node'); |
|
76 | - } |
|
68 | + /** |
|
69 | + * Updates the ACL. |
|
70 | + * |
|
71 | + * This method will receive a list of new ACE's as an array argument. |
|
72 | + */ |
|
73 | + public function setACL(array $acl) |
|
74 | + { |
|
75 | + throw new \Sabre\DAV\Exception\Forbidden('Setting ACL is not supported on this node'); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Returns the list of supported privileges for this node. |
|
80 | - * |
|
81 | - * The returned data structure is a list of nested privileges. |
|
82 | - * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple |
|
83 | - * standard structure. |
|
84 | - * |
|
85 | - * If null is returned from this method, the default privilege set is used, |
|
86 | - * which is fine for most common usecases. |
|
87 | - * |
|
88 | - * @return array|null |
|
89 | - */ |
|
90 | - public function getSupportedPrivilegeSet() |
|
91 | - { |
|
92 | - return null; |
|
93 | - } |
|
78 | + /** |
|
79 | + * Returns the list of supported privileges for this node. |
|
80 | + * |
|
81 | + * The returned data structure is a list of nested privileges. |
|
82 | + * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple |
|
83 | + * standard structure. |
|
84 | + * |
|
85 | + * If null is returned from this method, the default privilege set is used, |
|
86 | + * which is fine for most common usecases. |
|
87 | + * |
|
88 | + * @return array|null |
|
89 | + */ |
|
90 | + public function getSupportedPrivilegeSet() |
|
91 | + { |
|
92 | + return null; |
|
93 | + } |
|
94 | 94 | } |
@@ -16,16 +16,16 @@ |
||
16 | 16 | */ |
17 | 17 | class AceConflict extends DAV\Exception\Conflict |
18 | 18 | { |
19 | - /** |
|
20 | - * Adds in extra information in the xml response. |
|
21 | - * |
|
22 | - * This method adds the {DAV:}no-ace-conflict element as defined in rfc3744 |
|
23 | - */ |
|
24 | - public function serialize(DAV\Server $server, \DOMElement $errorNode) |
|
25 | - { |
|
26 | - $doc = $errorNode->ownerDocument; |
|
19 | + /** |
|
20 | + * Adds in extra information in the xml response. |
|
21 | + * |
|
22 | + * This method adds the {DAV:}no-ace-conflict element as defined in rfc3744 |
|
23 | + */ |
|
24 | + public function serialize(DAV\Server $server, \DOMElement $errorNode) |
|
25 | + { |
|
26 | + $doc = $errorNode->ownerDocument; |
|
27 | 27 | |
28 | - $np = $doc->createElementNS('DAV:', 'd:no-ace-conflict'); |
|
29 | - $errorNode->appendChild($np); |
|
30 | - } |
|
28 | + $np = $doc->createElementNS('DAV:', 'd:no-ace-conflict'); |
|
29 | + $errorNode->appendChild($np); |
|
30 | + } |
|
31 | 31 | } |
@@ -16,16 +16,16 @@ |
||
16 | 16 | */ |
17 | 17 | class NotRecognizedPrincipal extends DAV\Exception\PreconditionFailed |
18 | 18 | { |
19 | - /** |
|
20 | - * Adds in extra information in the xml response. |
|
21 | - * |
|
22 | - * This method adds the {DAV:}recognized-principal element as defined in rfc3744 |
|
23 | - */ |
|
24 | - public function serialize(DAV\Server $server, \DOMElement $errorNode) |
|
25 | - { |
|
26 | - $doc = $errorNode->ownerDocument; |
|
19 | + /** |
|
20 | + * Adds in extra information in the xml response. |
|
21 | + * |
|
22 | + * This method adds the {DAV:}recognized-principal element as defined in rfc3744 |
|
23 | + */ |
|
24 | + public function serialize(DAV\Server $server, \DOMElement $errorNode) |
|
25 | + { |
|
26 | + $doc = $errorNode->ownerDocument; |
|
27 | 27 | |
28 | - $np = $doc->createElementNS('DAV:', 'd:recognized-principal'); |
|
29 | - $errorNode->appendChild($np); |
|
30 | - } |
|
28 | + $np = $doc->createElementNS('DAV:', 'd:recognized-principal'); |
|
29 | + $errorNode->appendChild($np); |
|
30 | + } |
|
31 | 31 | } |
@@ -16,16 +16,16 @@ |
||
16 | 16 | */ |
17 | 17 | class NoAbstract extends DAV\Exception\PreconditionFailed |
18 | 18 | { |
19 | - /** |
|
20 | - * Adds in extra information in the xml response. |
|
21 | - * |
|
22 | - * This method adds the {DAV:}no-abstract element as defined in rfc3744 |
|
23 | - */ |
|
24 | - public function serialize(DAV\Server $server, \DOMElement $errorNode) |
|
25 | - { |
|
26 | - $doc = $errorNode->ownerDocument; |
|
19 | + /** |
|
20 | + * Adds in extra information in the xml response. |
|
21 | + * |
|
22 | + * This method adds the {DAV:}no-abstract element as defined in rfc3744 |
|
23 | + */ |
|
24 | + public function serialize(DAV\Server $server, \DOMElement $errorNode) |
|
25 | + { |
|
26 | + $doc = $errorNode->ownerDocument; |
|
27 | 27 | |
28 | - $np = $doc->createElementNS('DAV:', 'd:no-abstract'); |
|
29 | - $errorNode->appendChild($np); |
|
30 | - } |
|
28 | + $np = $doc->createElementNS('DAV:', 'd:no-abstract'); |
|
29 | + $errorNode->appendChild($np); |
|
30 | + } |
|
31 | 31 | } |