ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
CalendarHome.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\CalDAV;
4 
5 use Sabre\DAV;
8 use Sabre\DAVACL;
10 
24 
25  use DAVACL\ACLTrait;
26 
32  protected $caldavBackend;
33 
39  protected $principalInfo;
40 
48 
49  $this->caldavBackend = $caldavBackend;
50  $this->principalInfo = $principalInfo;
51 
52  }
53 
59  function getName() {
60 
61  list(, $name) = URLUtil::splitPath($this->principalInfo['uri']);
62  return $name;
63 
64  }
65 
72  function setName($name) {
73 
74  throw new DAV\Exception\Forbidden();
75 
76  }
77 
83  function delete() {
84 
85  throw new DAV\Exception\Forbidden();
86 
87  }
88 
94  function getLastModified() {
95 
96  return null;
97 
98  }
99 
109  function createFile($filename, $data = null) {
110 
111  throw new DAV\Exception\MethodNotAllowed('Creating new files in this collection is not supported');
112 
113  }
114 
124 
125  throw new DAV\Exception\MethodNotAllowed('Creating new collections in this collection is not supported');
126 
127  }
128 
135  function getChild($name) {
136 
137  // Special nodes
138  if ($name === 'inbox' && $this->caldavBackend instanceof Backend\SchedulingSupport) {
139  return new Schedule\Inbox($this->caldavBackend, $this->principalInfo['uri']);
140  }
141  if ($name === 'outbox' && $this->caldavBackend instanceof Backend\SchedulingSupport) {
142  return new Schedule\Outbox($this->principalInfo['uri']);
143  }
144  if ($name === 'notifications' && $this->caldavBackend instanceof Backend\NotificationSupport) {
145  return new Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
146  }
147 
148  // Calendars
149  foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) {
150  if ($calendar['uri'] === $name) {
151  if ($this->caldavBackend instanceof Backend\SharingSupport) {
152  return new SharedCalendar($this->caldavBackend, $calendar);
153  } else {
154  return new Calendar($this->caldavBackend, $calendar);
155  }
156  }
157  }
158 
159  if ($this->caldavBackend instanceof Backend\SubscriptionSupport) {
160  foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
161  if ($subscription['uri'] === $name) {
162  return new Subscriptions\Subscription($this->caldavBackend, $subscription);
163  }
164  }
165 
166  }
167 
168  throw new NotFound('Node with name \'' . $name . '\' could not be found');
169 
170  }
171 
178  function childExists($name) {
179 
180  try {
181  return !!$this->getChild($name);
182  } catch (NotFound $e) {
183  return false;
184  }
185 
186  }
187 
193  function getChildren() {
194 
195  $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']);
196  $objs = [];
197  foreach ($calendars as $calendar) {
198  if ($this->caldavBackend instanceof Backend\SharingSupport) {
199  $objs[] = new SharedCalendar($this->caldavBackend, $calendar);
200  } else {
201  $objs[] = new Calendar($this->caldavBackend, $calendar);
202  }
203  }
204 
205  if ($this->caldavBackend instanceof Backend\SchedulingSupport) {
206  $objs[] = new Schedule\Inbox($this->caldavBackend, $this->principalInfo['uri']);
207  $objs[] = new Schedule\Outbox($this->principalInfo['uri']);
208  }
209 
210  // We're adding a notifications node, if it's supported by the backend.
211  if ($this->caldavBackend instanceof Backend\NotificationSupport) {
212  $objs[] = new Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
213  }
214 
215  // If the backend supports subscriptions, we'll add those as well,
216  if ($this->caldavBackend instanceof Backend\SubscriptionSupport) {
217  foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
218  $objs[] = new Subscriptions\Subscription($this->caldavBackend, $subscription);
219  }
220  }
221 
222  return $objs;
223 
224  }
225 
235 
236  $isCalendar = false;
237  $isSubscription = false;
238  foreach ($mkCol->getResourceType() as $rt) {
239  switch ($rt) {
240  case '{DAV:}collection' :
241  case '{http://calendarserver.org/ns/}shared-owner' :
242  // ignore
243  break;
244  case '{urn:ietf:params:xml:ns:caldav}calendar' :
245  $isCalendar = true;
246  break;
247  case '{http://calendarserver.org/ns/}subscribed' :
248  $isSubscription = true;
249  break;
250  default :
251  throw new DAV\Exception\InvalidResourceType('Unknown resourceType: ' . $rt);
252  }
253  }
254 
255  $properties = $mkCol->getRemainingValues();
256  $mkCol->setRemainingResultCode(201);
257 
258  if ($isSubscription) {
259  if (!$this->caldavBackend instanceof Backend\SubscriptionSupport) {
260  throw new DAV\Exception\InvalidResourceType('This backend does not support subscriptions');
261  }
262  $this->caldavBackend->createSubscription($this->principalInfo['uri'], $name, $properties);
263 
264  } elseif ($isCalendar) {
265  $this->caldavBackend->createCalendar($this->principalInfo['uri'], $name, $properties);
266 
267  } else {
268  throw new DAV\Exception\InvalidResourceType('You can only create calendars and subscriptions in this collection');
269 
270  }
271 
272  }
273 
279  function getOwner() {
280 
281  return $this->principalInfo['uri'];
282 
283  }
284 
297  function getACL() {
298 
299  return [
300  [
301  'privilege' => '{DAV:}read',
302  'principal' => $this->principalInfo['uri'],
303  'protected' => true,
304  ],
305  [
306  'privilege' => '{DAV:}write',
307  'principal' => $this->principalInfo['uri'],
308  'protected' => true,
309  ],
310  [
311  'privilege' => '{DAV:}read',
312  'principal' => $this->principalInfo['uri'] . '/calendar-proxy-write',
313  'protected' => true,
314  ],
315  [
316  'privilege' => '{DAV:}write',
317  'principal' => $this->principalInfo['uri'] . '/calendar-proxy-write',
318  'protected' => true,
319  ],
320  [
321  'privilege' => '{DAV:}read',
322  'principal' => $this->principalInfo['uri'] . '/calendar-proxy-read',
323  'protected' => true,
324  ],
325 
326  ];
327 
328  }
329 
330 
344  function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null) {
345 
346  if (!$this->caldavBackend instanceof Backend\SharingSupport) {
347  throw new DAV\Exception\NotImplemented('Sharing support is not implemented by this backend.');
348  }
349 
350  return $this->caldavBackend->shareReply($href, $status, $calendarUri, $inReplyTo, $summary);
351 
352  }
353 
372  function getCalendarObjectByUID($uid) {
373 
374  return $this->caldavBackend->getCalendarObjectByUID($this->principalInfo['uri'], $uid);
375 
376  }
377 
378 }
This node represents a list of notifications.
Definition: Collection.php:23
shareReply($href, $status, $calendarUri, $inReplyTo, $summary=null)
This method is called when a user replied to a request to share.
createDirectory($filename)
Creates a new directory under this object.
The CalendarHome represents a node that is usually in a users&#39; calendar-homeset.
The CalDAV scheduling outbox.
Definition: Outbox.php:20
getCalendarObjectByUID($uid)
Searches through all of a users calendars and calendar objects to find an object with a specific UID...
This object represents a CalDAV calendar that is shared by a different user.
getOwner()
Returns the owner of the calendar home.
getChild($name)
Returns a single calendar, by name.
getName()
Returns the name of this object.
The CalDAV scheduling inbox.
Definition: Inbox.php:18
$summary
Definition: cron.php:24
createFile($filename, $data=null)
Creates a new file under this object.
The IExtendedCollection interface.
__construct(Backend\BackendInterface $caldavBackend, $principalInfo)
Constructor.
setRemainingResultCode($resultCode)
Sets the result code for all properties that did not have a result yet.
Definition: PropPatch.php:168
setName($name)
Updates the name of this object.
getLastModified()
Returns the last modification date.
createExtendedCollection($name, MkCol $mkCol)
Creates a new calendar or subscription.
ACL-enabled node.
Definition: IACL.php:16
add()
Definition: add.php:2
$filename
Definition: buildRTE.php:89
This class represents a MKCOL operation.
Definition: MkCol.php:23
getACL()
Returns a list of ACE&#39;s for this node.
getRemainingValues()
Returns the list of properties that don&#39;t have a result code yet.
Definition: PropPatch.php:204
This object represents a CalDAV calendar.
Definition: Calendar.php:19
Implement this interface to create your own principal backends.
static splitPath($path)
Returns the &#39;dirname&#39; and &#39;basename&#39; for a path.
Definition: URLUtil.php:83
$data
Definition: bench.php:6
getResourceType()
Returns the resourcetype of the new collection.
Definition: MkCol.php:50