commit vendor
This commit is contained in:
41
vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php
vendored
Normal file
41
vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\CalDAV\Subscriptions;
|
||||
|
||||
use Sabre\DAV\ICollection;
|
||||
use Sabre\DAV\IProperties;
|
||||
|
||||
/**
|
||||
* ISubscription.
|
||||
*
|
||||
* Nodes implementing this interface represent calendar subscriptions.
|
||||
*
|
||||
* The subscription node doesn't do much, other than returning and updating
|
||||
* subscription-related properties.
|
||||
*
|
||||
* The following properties should be supported:
|
||||
*
|
||||
* 1. {DAV:}displayname
|
||||
* 2. {http://apple.com/ns/ical/}refreshrate
|
||||
* 3. {http://calendarserver.org/ns/}subscribed-strip-todos (omit if todos
|
||||
* should not be stripped).
|
||||
* 4. {http://calendarserver.org/ns/}subscribed-strip-alarms (omit if alarms
|
||||
* should not be stripped).
|
||||
* 5. {http://calendarserver.org/ns/}subscribed-strip-attachments (omit if
|
||||
* attachments should not be stripped).
|
||||
* 6. {http://calendarserver.org/ns/}source (Must be a
|
||||
* Sabre\DAV\Property\Href).
|
||||
* 7. {http://apple.com/ns/ical/}calendar-color
|
||||
* 8. {http://apple.com/ns/ical/}calendar-order
|
||||
*
|
||||
* It is recommended to support every property.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
interface ISubscription extends ICollection, IProperties
|
||||
{
|
||||
}
|
||||
108
vendor/sabre/dav/lib/CalDAV/Subscriptions/Plugin.php
vendored
Normal file
108
vendor/sabre/dav/lib/CalDAV/Subscriptions/Plugin.php
vendored
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\CalDAV\Subscriptions;
|
||||
|
||||
use Sabre\DAV\INode;
|
||||
use Sabre\DAV\PropFind;
|
||||
use Sabre\DAV\Server;
|
||||
use Sabre\DAV\ServerPlugin;
|
||||
|
||||
/**
|
||||
* This plugin adds calendar-subscription support to your CalDAV server.
|
||||
*
|
||||
* Some clients support 'managed subscriptions' server-side. This is basically
|
||||
* a list of subscription urls a user is using.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class Plugin extends ServerPlugin
|
||||
{
|
||||
/**
|
||||
* This initializes the plugin.
|
||||
*
|
||||
* This function is called by Sabre\DAV\Server, after
|
||||
* addPlugin is called.
|
||||
*
|
||||
* This method should set up the required event subscriptions.
|
||||
*/
|
||||
public function initialize(Server $server)
|
||||
{
|
||||
$server->resourceTypeMapping['Sabre\\CalDAV\\Subscriptions\\ISubscription'] =
|
||||
'{http://calendarserver.org/ns/}subscribed';
|
||||
|
||||
$server->xml->elementMap['{http://calendarserver.org/ns/}source'] =
|
||||
'Sabre\\DAV\\Xml\\Property\\Href';
|
||||
|
||||
$server->on('propFind', [$this, 'propFind'], 150);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should return a list of server-features.
|
||||
*
|
||||
* This is for example 'versioning' and is added to the DAV: header
|
||||
* in an OPTIONS response.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFeatures()
|
||||
{
|
||||
return ['calendarserver-subscribed'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered after properties have been fetched.
|
||||
*/
|
||||
public function propFind(PropFind $propFind, INode $node)
|
||||
{
|
||||
// There's a bunch of properties that must appear as a self-closing
|
||||
// xml-element. This event handler ensures that this will be the case.
|
||||
$props = [
|
||||
'{http://calendarserver.org/ns/}subscribed-strip-alarms',
|
||||
'{http://calendarserver.org/ns/}subscribed-strip-attachments',
|
||||
'{http://calendarserver.org/ns/}subscribed-strip-todos',
|
||||
];
|
||||
|
||||
foreach ($props as $prop) {
|
||||
if (200 === $propFind->getStatus($prop)) {
|
||||
$propFind->set($prop, '', 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a plugin name.
|
||||
*
|
||||
* Using this name other plugins will be able to access other plugins
|
||||
* using \Sabre\DAV\Server::getPlugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPluginName()
|
||||
{
|
||||
return 'subscriptions';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bunch of meta-data about the plugin.
|
||||
*
|
||||
* Providing this information is optional, and is mainly displayed by the
|
||||
* Browser plugin.
|
||||
*
|
||||
* The description key in the returned array may contain html and will not
|
||||
* be sanitized.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPluginInfo()
|
||||
{
|
||||
return [
|
||||
'name' => $this->getPluginName(),
|
||||
'description' => 'This plugin allows users to store iCalendar subscriptions in their calendar-home.',
|
||||
'link' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
204
vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php
vendored
Normal file
204
vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php
vendored
Normal file
@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\CalDAV\Subscriptions;
|
||||
|
||||
use Sabre\CalDAV\Backend\SubscriptionSupport;
|
||||
use Sabre\DAV\Collection;
|
||||
use Sabre\DAV\PropPatch;
|
||||
use Sabre\DAV\Xml\Property\Href;
|
||||
use Sabre\DAVACL\ACLTrait;
|
||||
use Sabre\DAVACL\IACL;
|
||||
|
||||
/**
|
||||
* Subscription Node.
|
||||
*
|
||||
* This node represents a subscription.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class Subscription extends Collection implements ISubscription, IACL
|
||||
{
|
||||
use ACLTrait;
|
||||
|
||||
/**
|
||||
* caldavBackend.
|
||||
*
|
||||
* @var SubscriptionSupport
|
||||
*/
|
||||
protected $caldavBackend;
|
||||
|
||||
/**
|
||||
* subscriptionInfo.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $subscriptionInfo;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(SubscriptionSupport $caldavBackend, array $subscriptionInfo)
|
||||
{
|
||||
$this->caldavBackend = $caldavBackend;
|
||||
$this->subscriptionInfo = $subscriptionInfo;
|
||||
|
||||
$required = [
|
||||
'id',
|
||||
'uri',
|
||||
'principaluri',
|
||||
'source',
|
||||
];
|
||||
|
||||
foreach ($required as $r) {
|
||||
if (!isset($subscriptionInfo[$r])) {
|
||||
throw new \InvalidArgumentException('The '.$r.' field is required when creating a subscription node');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the node.
|
||||
*
|
||||
* This is used to generate the url.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->subscriptionInfo['uri'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last modification time.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLastModified()
|
||||
{
|
||||
if (isset($this->subscriptionInfo['lastmodified'])) {
|
||||
return $this->subscriptionInfo['lastmodified'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the current node.
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$this->caldavBackend->deleteSubscription(
|
||||
$this->subscriptionInfo['id']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with all the child nodes.
|
||||
*
|
||||
* @return \Sabre\DAV\INode[]
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates properties on this node.
|
||||
*
|
||||
* This method received a PropPatch object, which contains all the
|
||||
* information about the update.
|
||||
*
|
||||
* To update specific properties, call the 'handle' method on this object.
|
||||
* Read the PropPatch documentation for more information.
|
||||
*/
|
||||
public function propPatch(PropPatch $propPatch)
|
||||
{
|
||||
return $this->caldavBackend->updateSubscription(
|
||||
$this->subscriptionInfo['id'],
|
||||
$propPatch
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of properties for this nodes.
|
||||
*
|
||||
* The properties list is a list of propertynames the client requested,
|
||||
* encoded in clark-notation {xmlnamespace}tagname.
|
||||
*
|
||||
* If the array is empty, it means 'all properties' were requested.
|
||||
*
|
||||
* Note that it's fine to liberally give properties back, instead of
|
||||
* conforming to the list of requested properties.
|
||||
* The Server class will filter out the extra.
|
||||
*
|
||||
* @param array $properties
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getProperties($properties)
|
||||
{
|
||||
$r = [];
|
||||
|
||||
foreach ($properties as $prop) {
|
||||
switch ($prop) {
|
||||
case '{http://calendarserver.org/ns/}source':
|
||||
$r[$prop] = new Href($this->subscriptionInfo['source']);
|
||||
break;
|
||||
default:
|
||||
if (array_key_exists($prop, $this->subscriptionInfo)) {
|
||||
$r[$prop] = $this->subscriptionInfo[$prop];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owner principal.
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOwner()
|
||||
{
|
||||
return $this->subscriptionInfo['principaluri'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'privilege' => '{DAV:}all',
|
||||
'principal' => $this->getOwner(),
|
||||
'protected' => true,
|
||||
],
|
||||
[
|
||||
'privilege' => '{DAV:}all',
|
||||
'principal' => $this->getOwner().'/calendar-proxy-write',
|
||||
'protected' => true,
|
||||
],
|
||||
[
|
||||
'privilege' => '{DAV:}read',
|
||||
'principal' => $this->getOwner().'/calendar-proxy-read',
|
||||
'protected' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user