ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
CalendarObject.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\CalDAV;
4
13
14 use \Sabre\DAVACL\ACLTrait;
15
21 protected $caldavBackend;
22
28 protected $objectData;
29
35 protected $calendarInfo;
36
56
57 $this->caldavBackend = $caldavBackend;
58
59 if (!isset($objectData['uri'])) {
60 throw new \InvalidArgumentException('The objectData argument must contain an \'uri\' property');
61 }
62
63 $this->calendarInfo = $calendarInfo;
64 $this->objectData = $objectData;
65
66 }
67
73 function getName() {
74
75 return $this->objectData['uri'];
76
77 }
78
84 function get() {
85
86 // Pre-populating the 'calendardata' is optional, if we don't have it
87 // already we fetch it from the backend.
88 if (!isset($this->objectData['calendardata'])) {
89 $this->objectData = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $this->objectData['uri']);
90 }
91 return $this->objectData['calendardata'];
92
93 }
94
101 function put($calendarData) {
102
103 if (is_resource($calendarData)) {
104 $calendarData = stream_get_contents($calendarData);
105 }
106 $etag = $this->caldavBackend->updateCalendarObject($this->calendarInfo['id'], $this->objectData['uri'], $calendarData);
107 $this->objectData['calendardata'] = $calendarData;
108 $this->objectData['etag'] = $etag;
109
110 return $etag;
111
112 }
113
119 function delete() {
120
121 $this->caldavBackend->deleteCalendarObject($this->calendarInfo['id'], $this->objectData['uri']);
122
123 }
124
130 function getContentType() {
131
132 $mime = 'text/calendar; charset=utf-8';
133 if (isset($this->objectData['component']) && $this->objectData['component']) {
134 $mime .= '; component=' . $this->objectData['component'];
135 }
136 return $mime;
137
138 }
139
147 function getETag() {
148
149 if (isset($this->objectData['etag'])) {
150 return $this->objectData['etag'];
151 } else {
152 return '"' . md5($this->get()) . '"';
153 }
154
155 }
156
162 function getLastModified() {
163
164 return $this->objectData['lastmodified'];
165
166 }
167
173 function getSize() {
174
175 if (array_key_exists('size', $this->objectData)) {
176 return $this->objectData['size'];
177 } else {
178 return strlen($this->get());
179 }
180
181 }
182
190 function getOwner() {
191
192 return $this->calendarInfo['principaluri'];
193
194 }
195
208 function getACL() {
209
210 // An alternative acl may be specified in the object data.
211 if (isset($this->objectData['acl'])) {
212 return $this->objectData['acl'];
213 }
214
215 // The default ACL
216 return [
217 [
218 'privilege' => '{DAV:}all',
219 'principal' => $this->calendarInfo['principaluri'],
220 'protected' => true,
221 ],
222 [
223 'privilege' => '{DAV:}all',
224 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write',
225 'protected' => true,
226 ],
227 [
228 'privilege' => '{DAV:}read',
229 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-read',
230 'protected' => true,
231 ],
232
233 ];
234
235 }
236
237}
An exception for terminatinating execution or to throw for unit testing.
The CalendarObject represents a single VEVENT or VTODO within a Calendar.
getOwner()
Returns the owner principal.
getSize()
Returns the size of this object in bytes.
__construct(Backend\BackendInterface $caldavBackend, array $calendarInfo, array $objectData)
Constructor.
put($calendarData)
Updates the ICalendar-formatted object.
getContentType()
Returns the mime content-type.
getACL()
Returns a list of ACE's for this node.
getETag()
Returns an ETag for this object.
getName()
Returns the uri for this object.
getLastModified()
Returns the last modification date as a unix timestamp.
File class.
Definition: File.php:15
CalendarObject interface.
ACL-enabled node.
Definition: IACL.php:16
Implement this interface to create your own principal backends.