aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/CalDAV/Subscriptions
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-05-10 17:26:44 -0700
committerredmatrix <git@macgirvin.com>2016-05-10 17:26:44 -0700
commit0b02a6d123b2014705998c94ddf3d460948d3eac (patch)
tree78ff2cab9944a4f5ab3f80ec93cbe1120de90bb2 /vendor/sabre/dav/lib/CalDAV/Subscriptions
parent40b5b6e9d2da7ab65c8b4d38cdceac83a4d78deb (diff)
downloadvolse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.tar.gz
volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.tar.bz2
volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.zip
initial sabre upgrade (needs lots of work - to wit: authentication, redo the browser interface, and rework event export/import)
Diffstat (limited to 'vendor/sabre/dav/lib/CalDAV/Subscriptions')
-rw-r--r--vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php40
-rw-r--r--vendor/sabre/dav/lib/CalDAV/Subscriptions/Plugin.php120
-rw-r--r--vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php274
3 files changed, 434 insertions, 0 deletions
diff --git a/vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php b/vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php
new file mode 100644
index 000000000..7ba259c7b
--- /dev/null
+++ b/vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php
@@ -0,0 +1,40 @@
+<?php
+
+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 {
+
+
+}
diff --git a/vendor/sabre/dav/lib/CalDAV/Subscriptions/Plugin.php b/vendor/sabre/dav/lib/CalDAV/Subscriptions/Plugin.php
new file mode 100644
index 000000000..7abbfb1f9
--- /dev/null
+++ b/vendor/sabre/dav/lib/CalDAV/Subscriptions/Plugin.php
@@ -0,0 +1,120 @@
+<?php
+
+namespace Sabre\CalDAV\Subscriptions;
+
+use Sabre\DAV\INode;
+use Sabre\DAV\PropFind;
+use Sabre\DAV\ServerPlugin;
+use Sabre\DAV\Server;
+
+/**
+ * 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.
+ *
+ * @param Server $server
+ * @return void
+ */
+ 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
+ */
+ function getFeatures() {
+
+ return ['calendarserver-subscribed'];
+
+ }
+
+ /**
+ * Triggered after properties have been fetched.
+ *
+ * @param PropFind $propFind
+ * @param INode $node
+ * @return void
+ */
+ 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 ($propFind->getStatus($prop) === 200) {
+ $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
+ */
+ 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
+ */
+ function getPluginInfo() {
+
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'This plugin allows users to store iCalendar subscriptions in their calendar-home.',
+ 'link' => null,
+ ];
+
+ }
+}
diff --git a/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php b/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php
new file mode 100644
index 000000000..ee53da2c6
--- /dev/null
+++ b/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php
@@ -0,0 +1,274 @@
+<?php
+
+namespace Sabre\CalDAV\Subscriptions;
+
+use Sabre\DAV\Collection;
+use Sabre\DAV\Xml\Property\Href;
+use Sabre\DAV\PropPatch;
+use Sabre\DAV\Exception\MethodNotAllowed;
+use Sabre\DAVACL\IACL;
+use Sabre\CalDAV\Backend\SubscriptionSupport;
+
+/**
+ * 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 {
+
+ /**
+ * caldavBackend
+ *
+ * @var SupportsSubscriptions
+ */
+ protected $caldavBackend;
+
+ /**
+ * subscriptionInfo
+ *
+ * @var array
+ */
+ protected $subscriptionInfo;
+
+ /**
+ * Constructor
+ *
+ * @param SubscriptionSupport $caldavBackend
+ * @param array $calendarInfo
+ */
+ 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
+ */
+ function getName() {
+
+ return $this->subscriptionInfo['uri'];
+
+ }
+
+ /**
+ * Returns the last modification time
+ *
+ * @return int
+ */
+ function getLastModified() {
+
+ if (isset($this->subscriptionInfo['lastmodified'])) {
+ return $this->subscriptionInfo['lastmodified'];
+ }
+
+ }
+
+ /**
+ * Deletes the current node
+ *
+ * @return void
+ */
+ function delete() {
+
+ $this->caldavBackend->deleteSubscription(
+ $this->subscriptionInfo['id']
+ );
+
+ }
+
+ /**
+ * Returns an array with all the child nodes
+ *
+ * @return DAV\INode[]
+ */
+ 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.
+ *
+ * @param PropPatch $propPatch
+ * @return void
+ */
+ 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 void
+ */
+ function getProperties($properties) {
+
+ $r = [];
+
+ foreach ($properties as $prop) {
+
+ switch ($prop) {
+ case '{http://calendarserver.org/ns/}source' :
+ $r[$prop] = new Href($this->subscriptionInfo['source'], false);
+ 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
+ */
+ function getOwner() {
+
+ return $this->subscriptionInfo['principaluri'];
+
+ }
+
+ /**
+ * Returns a group principal.
+ *
+ * This must be a url to a principal, or null if there's no owner
+ *
+ * @return string|null
+ */
+ function getGroup() {
+
+ return null;
+
+ }
+
+ /**
+ * 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
+ */
+ function getACL() {
+
+ return [
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->getOwner(),
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}write',
+ 'principal' => $this->getOwner(),
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->getOwner() . '/calendar-proxy-write',
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}write',
+ 'principal' => $this->getOwner() . '/calendar-proxy-write',
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->getOwner() . '/calendar-proxy-read',
+ 'protected' => true,
+ ]
+ ];
+
+ }
+
+ /**
+ * Updates the ACL.
+ *
+ * This method will receive a list of new ACE's.
+ *
+ * @param array $acl
+ * @return void
+ */
+ function setACL(array $acl) {
+
+ throw new MethodNotAllowed('Changing ACL is not yet supported');
+
+ }
+
+ /**
+ * Returns the list of supported privileges for this node.
+ *
+ * The returned data structure is a list of nested privileges.
+ * See \Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple
+ * standard structure.
+ *
+ * If null is returned from this method, the default privilege set is used,
+ * which is fine for most common usecases.
+ *
+ * @return array|null
+ */
+ function getSupportedPrivilegeSet() {
+
+ return null;
+
+ }
+
+}