ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\CalDAV\CalendarHome Class Reference

The CalendarHome represents a node that is usually in a users' calendar-homeset. More...

+ Inheritance diagram for Sabre\CalDAV\CalendarHome:
+ Collaboration diagram for Sabre\CalDAV\CalendarHome:

Public Member Functions

 __construct (Backend\BackendInterface $caldavBackend, $principalInfo)
 Constructor. More...
 
 getName ()
 Returns the name of this object. More...
 
 setName ($name)
 Updates the name of this object. More...
 
 delete ()
 Deletes this object. More...
 
 getLastModified ()
 Returns the last modification date. More...
 
 createFile ($filename, $data=null)
 Creates a new file under this object. More...
 
 createDirectory ($filename)
 Creates a new directory under this object. More...
 
 getChild ($name)
 Returns a single calendar, by name. More...
 
 childExists ($name)
 Checks if a calendar exists. More...
 
 getChildren ()
 Returns a list of calendars. More...
 
 createExtendedCollection ($name, MkCol $mkCol)
 Creates a new calendar or subscription. More...
 
 getOwner ()
 Returns the owner of the calendar home. More...
 
 getACL ()
 Returns a list of ACE's for this node. More...
 
 shareReply ($href, $status, $calendarUri, $inReplyTo, $summary=null)
 This method is called when a user replied to a request to share. More...
 
 getCalendarObjectByUID ($uid)
 Searches through all of a users calendars and calendar objects to find an object with a specific UID. More...
 
 createExtendedCollection ($name, MkCol $mkCol)
 Creates a new collection. More...
 
 createFile ($name, $data=null)
 Creates a new file in the directory. More...
 
 createDirectory ($name)
 Creates a new subdirectory. More...
 
 getChild ($name)
 Returns a specific child node, referenced by its name. More...
 
 getChildren ()
 Returns an array with all the child nodes. More...
 
 childExists ($name)
 Checks if a child-node with the specified name exists. More...
 
 delete ()
 Deleted the current node. More...
 
 getName ()
 Returns the name of the node. More...
 
 setName ($name)
 Renames the node. More...
 
 getLastModified ()
 Returns the last modification time, as a unix timestamp. More...
 
- Public Member Functions inherited from Sabre\DAVACL\IACL
 getOwner ()
 Returns the owner principal. More...
 
 getGroup ()
 Returns a group principal. More...
 
 getACL ()
 Returns a list of ACE's for this node. More...
 
 setACL (array $acl)
 Updates the ACL. More...
 
 getSupportedPrivilegeSet ()
 Returns the list of supported privileges for this node. More...
 

Protected Attributes

 $caldavBackend
 
 $principalInfo
 

Detailed Description

The CalendarHome represents a node that is usually in a users' calendar-homeset.

It contains all the users' calendars, and can optionally contain a notifications collection, calendar subscriptions, a users' inbox, and a users' outbox.

Author
Evert Pot (http://evertpot.com/) @license http://sabre.io/license/ Modified BSD License

Definition at line 23 of file CalendarHome.php.

Constructor & Destructor Documentation

◆ __construct()

Sabre\CalDAV\CalendarHome::__construct ( Backend\BackendInterface  $caldavBackend,
  $principalInfo 
)

Constructor.

Parameters
Backend\BackendInterface$caldavBackend
array$principalInfo

Definition at line 47 of file CalendarHome.php.

47 {
48
49 $this->caldavBackend = $caldavBackend;
50 $this->principalInfo = $principalInfo;
51
52 }

References Sabre\CalDAV\CalendarHome\$caldavBackend, and Sabre\CalDAV\CalendarHome\$principalInfo.

Member Function Documentation

◆ childExists()

Sabre\CalDAV\CalendarHome::childExists (   $name)

Checks if a calendar exists.

Parameters
string$name
Returns
bool

Implements Sabre\DAV\ICollection.

Definition at line 178 of file CalendarHome.php.

178 {
179
180 try {
181 return !!$this->getChild($name);
182 } catch (NotFound $e) {
183 return false;
184 }
185
186 }
getChild($name)
Returns a single calendar, by name.

◆ createDirectory()

Sabre\CalDAV\CalendarHome::createDirectory (   $filename)

Creates a new directory under this object.

This is currently not allowed.

Parameters
string$filename
Returns
void

Implements Sabre\DAV\ICollection.

Definition at line 123 of file CalendarHome.php.

123 {
124
125 throw new DAV\Exception\MethodNotAllowed('Creating new collections in this collection is not supported');
126
127 }

◆ createExtendedCollection()

Sabre\CalDAV\CalendarHome::createExtendedCollection (   $name,
MkCol  $mkCol 
)

Creates a new calendar or subscription.

Parameters
string$name
MkCol$mkCol
Exceptions
DAV

Exception\InvalidResourceType

Returns
void

Implements Sabre\DAV\IExtendedCollection.

Definition at line 234 of file CalendarHome.php.

234 {
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 }

References $name, Sabre\DAV\PropPatch\getRemainingValues(), Sabre\DAV\MkCol\getResourceType(), and Sabre\DAV\PropPatch\setRemainingResultCode().

+ Here is the call graph for this function:

◆ createFile()

Sabre\CalDAV\CalendarHome::createFile (   $filename,
  $data = null 
)

Creates a new file under this object.

This is currently not allowed

Parameters
string$filename
resource$data
Returns
void

Implements Sabre\DAV\ICollection.

Definition at line 109 of file CalendarHome.php.

109 {
110
111 throw new DAV\Exception\MethodNotAllowed('Creating new files in this collection is not supported');
112
113 }

◆ delete()

Sabre\CalDAV\CalendarHome::delete ( )

Deletes this object.

Returns
void

Implements Sabre\DAV\INode.

Definition at line 83 of file CalendarHome.php.

83 {
84
85 throw new DAV\Exception\Forbidden();
86
87 }

◆ getACL()

Sabre\CalDAV\CalendarHome::getACL ( )

Returns a list of ACE's for this node.

Each ACE has the following properties:

  • 'privilege', a string such as {DAV:}read or {DAV:}write. These are currently the only supported privileges
  • 'principal', a url to the principal who owns the node
  • 'protected' (optional), indicating that this ACE is not allowed to be updated.
Returns
array

Implements Sabre\DAVACL\IACL.

Definition at line 297 of file CalendarHome.php.

297 {
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 }

◆ getCalendarObjectByUID()

Sabre\CalDAV\CalendarHome::getCalendarObjectByUID (   $uid)

Searches through all of a users calendars and calendar objects to find an object with a specific UID.

This method should return the path to this object, relative to the calendar home, so this path usually only contains two parts:

calendarpath/objectpath.ics

If the uid is not found, return null.

This method should only consider * objects that the principal owns, so any calendars owned by other principals that also appear in this collection should be ignored.

Parameters
string$uid
Returns
string|null

Definition at line 372 of file CalendarHome.php.

372 {
373
374 return $this->caldavBackend->getCalendarObjectByUID($this->principalInfo['uri'], $uid);
375
376 }

◆ getChild()

Sabre\CalDAV\CalendarHome::getChild (   $name)

Returns a single calendar, by name.

Parameters
string$name
Returns
Calendar

Implements Sabre\DAV\ICollection.

Definition at line 135 of file CalendarHome.php.

135 {
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 }

References $calendar, and $name.

◆ getChildren()

Sabre\CalDAV\CalendarHome::getChildren ( )

Returns a list of calendars.

Returns
array

Implements Sabre\DAV\ICollection.

Definition at line 193 of file CalendarHome.php.

193 {
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 }

◆ getLastModified()

Sabre\CalDAV\CalendarHome::getLastModified ( )

Returns the last modification date.

Returns
int

Implements Sabre\DAV\INode.

Definition at line 94 of file CalendarHome.php.

94 {
95
96 return null;
97
98 }

◆ getName()

Sabre\CalDAV\CalendarHome::getName ( )

Returns the name of this object.

Returns
string

Implements Sabre\DAV\INode.

Definition at line 59 of file CalendarHome.php.

59 {
60
61 list(, $name) = URLUtil::splitPath($this->principalInfo['uri']);
62 return $name;
63
64 }
static splitPath($path)
Returns the 'dirname' and 'basename' for a path.
Definition: URLUtil.php:83

References $name, and Sabre\HTTP\URLUtil\splitPath().

+ Here is the call graph for this function:

◆ getOwner()

Sabre\CalDAV\CalendarHome::getOwner ( )

Returns the owner of the calendar home.

Returns
string

Implements Sabre\DAVACL\IACL.

Definition at line 279 of file CalendarHome.php.

279 {
280
281 return $this->principalInfo['uri'];
282
283 }

◆ setName()

Sabre\CalDAV\CalendarHome::setName (   $name)

Updates the name of this object.

Parameters
string$name
Returns
void

Implements Sabre\DAV\INode.

Definition at line 72 of file CalendarHome.php.

72 {
73
74 throw new DAV\Exception\Forbidden();
75
76 }

◆ shareReply()

Sabre\CalDAV\CalendarHome::shareReply (   $href,
  $status,
  $calendarUri,
  $inReplyTo,
  $summary = null 
)

This method is called when a user replied to a request to share.

This method should return the url of the newly created calendar if the share was accepted.

Parameters
string$hrefThe sharee who is replying (often a mailto: address)
int$statusOne of the SharingPlugin::STATUS_* constants
string$calendarUriThe url to the calendar thats being shared
string$inReplyToThe unique id this message is a response to
string$summaryA description of the reply
Returns
null|string

Definition at line 344 of file CalendarHome.php.

344 {
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 }
$summary
Definition: cron.php:24

References $summary.

Field Documentation

◆ $caldavBackend

Sabre\CalDAV\CalendarHome::$caldavBackend
protected

Definition at line 32 of file CalendarHome.php.

Referenced by Sabre\CalDAV\CalendarHome\__construct().

◆ $principalInfo

Sabre\CalDAV\CalendarHome::$principalInfo
protected

Definition at line 39 of file CalendarHome.php.

Referenced by Sabre\CalDAV\CalendarHome\__construct().


The documentation for this class was generated from the following file: