-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f51851
commit 0dcdb3d
Showing
20 changed files
with
487 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
namespace OCA\DAV\CalDAV; | ||
|
||
use OCA\DAV\DAV\Sharing\IShareable; | ||
|
||
class Calendar extends \Sabre\CalDAV\Calendar implements IShareable { | ||
|
||
/** | ||
* Updates the list of shares. | ||
* | ||
* The first array is a list of people that are to be added to the | ||
* resource. | ||
* | ||
* Every element in the add array has the following properties: | ||
* * href - A url. Usually a mailto: address | ||
* * commonName - Usually a first and last name, or false | ||
* * summary - A description of the share, can also be false | ||
* * readOnly - A boolean value | ||
* | ||
* Every element in the remove array is just the address string. | ||
* | ||
* @param array $add | ||
* @param array $remove | ||
* @return void | ||
*/ | ||
function updateShares(array $add, array $remove) { | ||
/** @var CalDavBackend $calDavBackend */ | ||
$calDavBackend = $this->caldavBackend; | ||
$calDavBackend->updateShares($this, $add, $remove); | ||
} | ||
|
||
/** | ||
* Returns the list of people whom this resource is shared with. | ||
* | ||
* Every element in this array should have the following properties: | ||
* * href - Often a mailto: address | ||
* * commonName - Optional, for example a first + last name | ||
* * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants. | ||
* * readOnly - boolean | ||
* * summary - Optional, a description for the share | ||
* | ||
* @return array | ||
*/ | ||
function getShares() { | ||
/** @var CalDavBackend $caldavBackend */ | ||
$caldavBackend = $this->caldavBackend; | ||
return $caldavBackend->getShares($this->getResourceId()); | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getResourceId() { | ||
return $this->calendarInfo['id']; | ||
} | ||
|
||
function getACL() { | ||
$acl = parent::getACL(); | ||
|
||
// add the current user | ||
if (isset($this->calendarInfo['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'])) { | ||
$owner = $this->calendarInfo['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal']; | ||
$acl[] = [ | ||
'privilege' => '{DAV:}read', | ||
'principal' => $owner, | ||
'protected' => true, | ||
]; | ||
if ($this->calendarInfo['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only']) { | ||
$acl[] = [ | ||
'privilege' => '{DAV:}write', | ||
'principal' => $owner, | ||
'protected' => true, | ||
]; | ||
} | ||
} | ||
|
||
/** @var CalDavBackend $caldavBackend */ | ||
$caldavBackend = $this->caldavBackend; | ||
return $caldavBackend->applyShareAcl($this->getResourceId(), $acl); | ||
} | ||
|
||
function getChildACL() { | ||
$acl = parent::getChildACL(); | ||
|
||
/** @var CalDavBackend $caldavBackend */ | ||
$caldavBackend = $this->caldavBackend; | ||
return $caldavBackend->applyShareAcl($this->getResourceId(), $acl); | ||
} | ||
|
||
function getOwner() { | ||
if (isset($this->calendarInfo['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'])) { | ||
return $this->calendarInfo['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal']; | ||
} | ||
return parent::getOwner(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace OCA\DAV\CalDAV; | ||
|
||
use Sabre\CalDAV\Backend\NotificationSupport; | ||
use Sabre\CalDAV\Backend\SchedulingSupport; | ||
use Sabre\CalDAV\Backend\SubscriptionSupport; | ||
use Sabre\CalDAV\Schedule\Inbox; | ||
use Sabre\CalDAV\Schedule\Outbox; | ||
use Sabre\CalDAV\Subscriptions\Subscription; | ||
use Sabre\DAV\Exception\NotFound; | ||
|
||
class CalendarHome extends \Sabre\CalDAV\CalendarHome { | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
function getChildren() { | ||
$calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']); | ||
$objs = []; | ||
foreach ($calendars as $calendar) { | ||
$objs[] = new Calendar($this->caldavBackend, $calendar); | ||
} | ||
|
||
if ($this->caldavBackend instanceof SchedulingSupport) { | ||
$objs[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']); | ||
$objs[] = new Outbox($this->principalInfo['uri']); | ||
} | ||
|
||
// We're adding a notifications node, if it's supported by the backend. | ||
if ($this->caldavBackend instanceof NotificationSupport) { | ||
$objs[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); | ||
} | ||
|
||
// If the backend supports subscriptions, we'll add those as well, | ||
if ($this->caldavBackend instanceof SubscriptionSupport) { | ||
foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) { | ||
$objs[] = new Subscription($this->caldavBackend, $subscription); | ||
} | ||
} | ||
|
||
return $objs; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
function getChild($name) { | ||
// Special nodes | ||
if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) { | ||
return new Inbox($this->caldavBackend, $this->principalInfo['uri']); | ||
} | ||
if ($name === 'outbox' && $this->caldavBackend instanceof SchedulingSupport) { | ||
return new Outbox($this->principalInfo['uri']); | ||
} | ||
if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) { | ||
return new \Sabre\CalDAv\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); | ||
} | ||
|
||
// Calendars | ||
foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) { | ||
if ($calendar['uri'] === $name) { | ||
return new Calendar($this->caldavBackend, $calendar); | ||
} | ||
} | ||
|
||
if ($this->caldavBackend instanceof SubscriptionSupport) { | ||
foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) { | ||
if ($subscription['uri'] === $name) { | ||
return new Subscription($this->caldavBackend, $subscription); | ||
} | ||
} | ||
|
||
} | ||
|
||
throw new NotFound('Node with name \'' . $name . '\' could not be found'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace OCA\DAV\CalDAV; | ||
|
||
class CalendarRoot extends \Sabre\CalDAV\CalendarRoot { | ||
|
||
function getChildForPrincipal(array $principal) { | ||
return new CalendarHome($this->caldavBackend, $principal); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.