ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Subscription.php
Go to the documentation of this file.
1<?php
2
4
9use Sabre\DAVACL\ACLTrait;
11
21class Subscription extends Collection implements ISubscription, IACL {
22
23 use ACLTrait;
24
30 protected $caldavBackend;
31
38
46
47 $this->caldavBackend = $caldavBackend;
48 $this->subscriptionInfo = $subscriptionInfo;
49
50 $required = [
51 'id',
52 'uri',
53 'principaluri',
54 'source',
55 ];
56
57 foreach ($required as $r) {
58 if (!isset($subscriptionInfo[$r])) {
59 throw new \InvalidArgumentException('The ' . $r . ' field is required when creating a subscription node');
60 }
61 }
62
63 }
64
72 function getName() {
73
74 return $this->subscriptionInfo['uri'];
75
76 }
77
83 function getLastModified() {
84
85 if (isset($this->subscriptionInfo['lastmodified'])) {
86 return $this->subscriptionInfo['lastmodified'];
87 }
88
89 }
90
96 function delete() {
97
98 $this->caldavBackend->deleteSubscription(
99 $this->subscriptionInfo['id']
100 );
101
102 }
103
109 function getChildren() {
110
111 return [];
112
113 }
114
127 function propPatch(PropPatch $propPatch) {
128
129 return $this->caldavBackend->updateSubscription(
130 $this->subscriptionInfo['id'],
131 $propPatch
132 );
133
134 }
135
151 function getProperties($properties) {
152
153 $r = [];
154
155 foreach ($properties as $prop) {
156
157 switch ($prop) {
158 case '{http://calendarserver.org/ns/}source' :
159 $r[$prop] = new Href($this->subscriptionInfo['source']);
160 break;
161 default :
162 if (array_key_exists($prop, $this->subscriptionInfo)) {
163 $r[$prop] = $this->subscriptionInfo[$prop];
164 }
165 break;
166 }
167
168 }
169
170 return $r;
171
172 }
173
181 function getOwner() {
182
183 return $this->subscriptionInfo['principaluri'];
184
185 }
186
199 function getACL() {
200
201 return [
202 [
203 'privilege' => '{DAV:}all',
204 'principal' => $this->getOwner(),
205 'protected' => true,
206 ],
207 [
208 'privilege' => '{DAV:}all',
209 'principal' => $this->getOwner() . '/calendar-proxy-write',
210 'protected' => true,
211 ],
212 [
213 'privilege' => '{DAV:}read',
214 'principal' => $this->getOwner() . '/calendar-proxy-read',
215 'protected' => true,
216 ]
217 ];
218
219 }
220
221}
An exception for terminatinating execution or to throw for unit testing.
getACL()
Returns a list of ACE's for this node.
getChildren()
Returns an array with all the child nodes.
getOwner()
Returns the owner principal.
propPatch(PropPatch $propPatch)
Updates properties on this node.
getProperties($properties)
Returns a list of properties for this nodes.
__construct(SubscriptionSupport $caldavBackend, array $subscriptionInfo)
Constructor.
getLastModified()
Returns the last modification time.
getName()
Returns the name of the node.
Collection class.
Definition: Collection.php:15
This class represents a set of properties that are going to be updated.
Definition: PropPatch.php:20
Href property.
Definition: Href.php:26
$r
Definition: example_031.php:79
Every CalDAV backend must at least implement this interface.
ACL-enabled node.
Definition: IACL.php:16