| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- <?php
- declare(strict_types=1);
- namespace Sabre\CalDAV;
- use Sabre\DAV\Sharing\Plugin as SPlugin;
- /**
- * This object represents a CalDAV calendar that is shared by a different user.
- *
- * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
- * @author Evert Pot (http://evertpot.com/)
- * @license http://sabre.io/license/ Modified BSD License
- */
- class SharedCalendar extends Calendar implements ISharedCalendar
- {
- /**
- * Returns the 'access level' for the instance of this shared resource.
- *
- * The value should be one of the Sabre\DAV\Sharing\Plugin::ACCESS_
- * constants.
- *
- * @return int
- */
- public function getShareAccess()
- {
- return isset($this->calendarInfo['share-access']) ? $this->calendarInfo['share-access'] : SPlugin::ACCESS_NOTSHARED;
- }
- /**
- * This function must return a URI that uniquely identifies the shared
- * resource. This URI should be identical across instances, and is
- * also used in several other XML bodies to connect invites to
- * resources.
- *
- * This may simply be a relative reference to the original shared instance,
- * but it could also be a urn. As long as it's a valid URI and unique.
- *
- * @return string
- */
- public function getShareResourceUri()
- {
- return $this->calendarInfo['share-resource-uri'];
- }
- /**
- * Updates the list of sharees.
- *
- * Every item must be a Sharee object.
- *
- * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees
- */
- public function updateInvites(array $sharees)
- {
- $this->caldavBackend->updateInvites($this->calendarInfo['id'], $sharees);
- }
- /**
- * Returns the list of people whom this resource is shared with.
- *
- * Every item in the returned array must be a Sharee object with
- * at least the following properties set:
- *
- * * $href
- * * $shareAccess
- * * $inviteStatus
- *
- * and optionally:
- *
- * * $properties
- *
- * @return \Sabre\DAV\Xml\Element\Sharee[]
- */
- public function getInvites()
- {
- return $this->caldavBackend->getInvites($this->calendarInfo['id']);
- }
- /**
- * Marks this calendar as published.
- *
- * Publishing a calendar should automatically create a read-only, public,
- * subscribable calendar.
- *
- * @param bool $value
- */
- public function setPublishStatus($value)
- {
- $this->caldavBackend->setPublishStatus($this->calendarInfo['id'], $value);
- }
- /**
- * 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.
- *
- * @return array
- */
- public function getACL()
- {
- $acl = [];
- switch ($this->getShareAccess()) {
- case SPlugin::ACCESS_NOTSHARED:
- case SPlugin::ACCESS_SHAREDOWNER:
- $acl[] = [
- 'privilege' => '{DAV:}share',
- 'principal' => $this->calendarInfo['principaluri'],
- 'protected' => true,
- ];
- $acl[] = [
- 'privilege' => '{DAV:}share',
- 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
- 'protected' => true,
- ];
- // no break intentional!
- case SPlugin::ACCESS_READWRITE:
- $acl[] = [
- 'privilege' => '{DAV:}write',
- 'principal' => $this->calendarInfo['principaluri'],
- 'protected' => true,
- ];
- $acl[] = [
- 'privilege' => '{DAV:}write',
- 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
- 'protected' => true,
- ];
- // no break intentional!
- case SPlugin::ACCESS_READ:
- $acl[] = [
- 'privilege' => '{DAV:}write-properties',
- 'principal' => $this->calendarInfo['principaluri'],
- 'protected' => true,
- ];
- $acl[] = [
- 'privilege' => '{DAV:}write-properties',
- 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
- 'protected' => true,
- ];
- $acl[] = [
- 'privilege' => '{DAV:}read',
- 'principal' => $this->calendarInfo['principaluri'],
- 'protected' => true,
- ];
- $acl[] = [
- 'privilege' => '{DAV:}read',
- 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-read',
- 'protected' => true,
- ];
- $acl[] = [
- 'privilege' => '{DAV:}read',
- 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
- 'protected' => true,
- ];
- $acl[] = [
- 'privilege' => '{'.Plugin::NS_CALDAV.'}read-free-busy',
- 'principal' => '{DAV:}authenticated',
- 'protected' => true,
- ];
- break;
- }
- return $acl;
- }
- /**
- * This method returns the ACL's for calendar objects in this calendar.
- * The result of this method automatically gets passed to the
- * calendar-object nodes in the calendar.
- *
- * @return array
- */
- public function getChildACL()
- {
- $acl = [];
- switch ($this->getShareAccess()) {
- case SPlugin::ACCESS_NOTSHARED:
- case SPlugin::ACCESS_SHAREDOWNER:
- case SPlugin::ACCESS_READWRITE:
- $acl[] = [
- 'privilege' => '{DAV:}write',
- 'principal' => $this->calendarInfo['principaluri'],
- 'protected' => true,
- ];
- $acl[] = [
- 'privilege' => '{DAV:}write',
- 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
- 'protected' => true,
- ];
- // no break intentional
- case SPlugin::ACCESS_READ:
- $acl[] = [
- 'privilege' => '{DAV:}read',
- 'principal' => $this->calendarInfo['principaluri'],
- 'protected' => true,
- ];
- $acl[] = [
- 'privilege' => '{DAV:}read',
- 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
- 'protected' => true,
- ];
- $acl[] = [
- 'privilege' => '{DAV:}read',
- 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-read',
- 'protected' => true,
- ];
- break;
- }
- return $acl;
- }
- }
|