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

The CalendarObject represents a single VEVENT or VTODO within a Calendar. More...

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

Public Member Functions

 __construct (Backend\BackendInterface $caldavBackend, array $calendarInfo, array $objectData)
 Constructor. More...
 
 getName ()
 Returns the uri for this object. More...
 
 get ()
 Returns the ICalendar-formatted object. More...
 
 put ($calendarData)
 Updates the ICalendar-formatted object. More...
 
 delete ()
 Deletes the calendar object. More...
 
 getContentType ()
 Returns the mime content-type. More...
 
 getETag ()
 Returns an ETag for this object. More...
 
 getLastModified ()
 Returns the last modification date as a unix timestamp. More...
 
 getSize ()
 Returns the size of this object in bytes. More...
 
 getOwner ()
 Returns the owner principal. More...
 
 getACL ()
 Returns a list of ACE's for this node. More...
 
- Public Member Functions inherited from Sabre\DAV\File
 put ($data)
 Replaces the contents of the file. More...
 
 get ()
 Returns the data. More...
 
 getSize ()
 Returns the size of the file, in bytes. More...
 
 getETag ()
 Returns the ETag for a file. More...
 
 getContentType ()
 Returns the mime-type for a file. More...
 
- Public Member Functions inherited from Sabre\DAV\Node
 getLastModified ()
 Returns the last modification time as a unix timestamp. More...
 
 delete ()
 Deletes the current node. More...
 
 setName ($name)
 Renames the node. More...
 
- Public Member Functions inherited from Sabre\DAVACL\IACL
 getGroup ()
 Returns a group principal. More...
 
 setACL (array $acl)
 Updates the ACL. More...
 
 getSupportedPrivilegeSet ()
 Returns the list of supported privileges for this node. More...
 

Protected Attributes

 $caldavBackend
 
 $objectData
 
 $calendarInfo
 

Detailed Description

The CalendarObject represents a single VEVENT or VTODO within a Calendar.

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

Definition at line 12 of file CalendarObject.php.

Constructor & Destructor Documentation

◆ __construct()

Sabre\CalDAV\CalendarObject::__construct ( Backend\BackendInterface  $caldavBackend,
array  $calendarInfo,
array  $objectData 
)

Constructor.

The following properties may be passed within $objectData:

  • calendarid - This must refer to a calendarid from a caldavBackend
  • uri - A unique uri. Only the 'basename' must be passed.
  • calendardata (optional) - The iCalendar data
  • etag - (optional) The etag for this object, MUST be encloded with double-quotes.
  • size - (optional) The size of the data in bytes.
  • lastmodified - (optional) format as a unix timestamp.
  • acl - (optional) Use this to override the default ACL for the node.
Parameters
Backend\BackendInterface$caldavBackend
array$calendarInfo
array$objectData

Definition at line 55 of file CalendarObject.php.

References Sabre\CalDAV\CalendarObject\$caldavBackend, Sabre\CalDAV\CalendarObject\$calendarInfo, and Sabre\CalDAV\CalendarObject\$objectData.

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

Member Function Documentation

◆ delete()

Sabre\CalDAV\CalendarObject::delete ( )

Deletes the calendar object.

Returns
void

Implements Sabre\DAV\INode.

Definition at line 119 of file CalendarObject.php.

119  {
120 
121  $this->caldavBackend->deleteCalendarObject($this->calendarInfo['id'], $this->objectData['uri']);
122 
123  }

◆ get()

Sabre\CalDAV\CalendarObject::get ( )

Returns the ICalendar-formatted object.

Returns
string

Implements Sabre\DAV\IFile.

Definition at line 84 of file CalendarObject.php.

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

◆ getACL()

Sabre\CalDAV\CalendarObject::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 208 of file CalendarObject.php.

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

◆ getContentType()

Sabre\CalDAV\CalendarObject::getContentType ( )

Returns the mime content-type.

Returns
string

Implements Sabre\DAV\IFile.

Definition at line 130 of file CalendarObject.php.

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

◆ getETag()

Sabre\CalDAV\CalendarObject::getETag ( )

Returns an ETag for this object.

The ETag is an arbitrary string, but MUST be surrounded by double-quotes.

Returns
string

Implements Sabre\DAV\IFile.

Definition at line 147 of file CalendarObject.php.

147  {
148 
149  if (isset($this->objectData['etag'])) {
150  return $this->objectData['etag'];
151  } else {
152  return '"' . md5($this->get()) . '"';
153  }
154 
155  }

◆ getLastModified()

Sabre\CalDAV\CalendarObject::getLastModified ( )

Returns the last modification date as a unix timestamp.

Returns
int

Implements Sabre\DAV\INode.

Definition at line 162 of file CalendarObject.php.

162  {
163 
164  return $this->objectData['lastmodified'];
165 
166  }

◆ getName()

Sabre\CalDAV\CalendarObject::getName ( )

Returns the uri for this object.

Returns
string

Implements Sabre\DAV\INode.

Definition at line 73 of file CalendarObject.php.

73  {
74 
75  return $this->objectData['uri'];
76 
77  }

◆ getOwner()

Sabre\CalDAV\CalendarObject::getOwner ( )

Returns the owner principal.

This must be a url to a principal, or null if there's no owner

Returns
string|null

Implements Sabre\DAVACL\IACL.

Definition at line 190 of file CalendarObject.php.

190  {
191 
192  return $this->calendarInfo['principaluri'];
193 
194  }

◆ getSize()

Sabre\CalDAV\CalendarObject::getSize ( )

Returns the size of this object in bytes.

Returns
int

Implements Sabre\DAV\IFile.

Definition at line 173 of file CalendarObject.php.

173  {
174 
175  if (array_key_exists('size', $this->objectData)) {
176  return $this->objectData['size'];
177  } else {
178  return strlen($this->get());
179  }
180 
181  }

◆ put()

Sabre\CalDAV\CalendarObject::put (   $calendarData)

Updates the ICalendar-formatted object.

Parameters
string | resource$calendarData
Returns
string

Implements Sabre\DAV\IFile.

Definition at line 101 of file CalendarObject.php.

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

Field Documentation

◆ $caldavBackend

Sabre\CalDAV\CalendarObject::$caldavBackend
protected

Definition at line 21 of file CalendarObject.php.

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

◆ $calendarInfo

Sabre\CalDAV\CalendarObject::$calendarInfo
protected

Definition at line 35 of file CalendarObject.php.

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

◆ $objectData

Sabre\CalDAV\CalendarObject::$objectData
protected

Definition at line 28 of file CalendarObject.php.

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


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