aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/DAV/Xml
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/lib/DAV/Xml')
-rw-r--r--vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php199
-rw-r--r--vendor/sabre/dav/lib/DAV/Xml/Property/Href.php17
-rw-r--r--vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php70
-rw-r--r--vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php48
-rw-r--r--vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php143
-rw-r--r--vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php11
-rw-r--r--vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php81
7 files changed, 547 insertions, 22 deletions
diff --git a/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php b/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php
new file mode 100644
index 000000000..dcfd7bd2e
--- /dev/null
+++ b/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php
@@ -0,0 +1,199 @@
+<?php
+
+namespace Sabre\DAV\Xml\Element;
+
+use Sabre\DAV\Exception\BadRequest;
+use Sabre\DAV\Sharing\Plugin;
+use Sabre\DAV\Xml\Property\Href;
+use Sabre\DAV\Xml\Property\ShareAccess;
+use Sabre\Xml\Deserializer;
+use Sabre\Xml\Element;
+use Sabre\Xml\Reader;
+use Sabre\Xml\Writer;
+
+/**
+ * This class represents the {DAV:}sharee element.
+ *
+ * @copyright Copyright (C) fruux GmbH. (https://fruux.com/)
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class Sharee implements Element {
+
+ /**
+ * A URL. Usually a mailto: address, could also be a principal url.
+ * This uniquely identifies the sharee.
+ *
+ * @var string
+ */
+ public $href;
+
+ /**
+ * A local principal path. The server will do its best to locate the
+ * principal uri based on the given uri. If we could find a local matching
+ * principal uri, this property will contain the value.
+ *
+ * @var string|null
+ */
+ public $principal;
+
+ /**
+ * A list of WebDAV properties that describe the sharee. This might for
+ * example contain a {DAV:}displayname with the real name of the user.
+ *
+ * @var array
+ */
+ public $properties = [];
+
+ /**
+ * Share access level. One of the Sabre\DAV\Sharing\Plugin::ACCESS
+ * constants.
+ *
+ * Can be one of:
+ *
+ * ACCESS_READ
+ * ACCESS_READWRITE
+ * ACCESS_SHAREDOWNER
+ * ACCESS_NOACCESS
+ *
+ * depending on context.
+ *
+ * @var int
+ */
+ public $access;
+
+ /**
+ * When a sharee is originally invited to a share, the sharer may add
+ * a comment. This will be placed in this property.
+ *
+ * @var string
+ */
+ public $comment;
+
+ /**
+ * The status of the invite, should be one of the
+ * Sabre\DAV\Sharing\Plugin::INVITE constants.
+ *
+ * @var int
+ */
+ public $inviteStatus;
+
+ /**
+ * Creates the object
+ *
+ * $properties will be used to populate all internal properties.
+ *
+ * @param array $properties
+ */
+ function __construct(array $properties = []) {
+
+ foreach ($properties as $k => $v) {
+
+ if (property_exists($this, $k)) {
+ $this->$k = $v;
+ } else {
+ throw new \InvalidArgumentException('Unknown property: ' . $k);
+ }
+
+ }
+
+ }
+
+ /**
+ * The xmlSerialize method is called during xml writing.
+ *
+ * Use the $writer argument to write its own xml serialization.
+ *
+ * An important note: do _not_ create a parent element. Any element
+ * implementing XmlSerializble should only ever write what's considered
+ * its 'inner xml'.
+ *
+ * The parent of the current element is responsible for writing a
+ * containing element.
+ *
+ * This allows serializers to be re-used for different element names.
+ *
+ * If you are opening new elements, you must also close them again.
+ *
+ * @param Writer $writer
+ * @return void
+ */
+ function xmlSerialize(Writer $writer) {
+
+
+ $writer->write([
+ new Href($this->href),
+ '{DAV:}prop' => $this->properties,
+ '{DAV:}share-access' => new ShareAccess($this->access),
+ ]);
+ switch ($this->inviteStatus) {
+ case Plugin::INVITE_NORESPONSE :
+ $writer->writeElement('{DAV:}invite-noresponse');
+ break;
+ case Plugin::INVITE_ACCEPTED :
+ $writer->writeElement('{DAV:}invite-accepted');
+ break;
+ case Plugin::INVITE_DECLINED :
+ $writer->writeElement('{DAV:}invite-declined');
+ break;
+ case Plugin::INVITE_INVALID :
+ $writer->writeElement('{DAV:}invite-invalid');
+ break;
+ }
+
+ }
+
+ /**
+ * The deserialize method is called during xml parsing.
+ *
+ * This method is called statictly, this is because in theory this method
+ * may be used as a type of constructor, or factory method.
+ *
+ * Often you want to return an instance of the current class, but you are
+ * free to return other data as well.
+ *
+ * You are responsible for advancing the reader to the next element. Not
+ * doing anything will result in a never-ending loop.
+ *
+ * If you just want to skip parsing for this element altogether, you can
+ * just call $reader->next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @param Reader $reader
+ * @return mixed
+ */
+ static function xmlDeserialize(Reader $reader) {
+
+ // Temporarily override configuration
+ $reader->pushContext();
+ $reader->elementMap['{DAV:}share-access'] = 'Sabre\DAV\Xml\Property\ShareAccess';
+ $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Deserializer\keyValue';
+
+ $elems = Deserializer\keyValue($reader, 'DAV:');
+
+ // Restore previous configuration
+ $reader->popContext();
+
+ $sharee = new self();
+ if (!isset($elems['href'])) {
+ throw new BadRequest('Every {DAV:}sharee must have a {DAV:}href child-element');
+ }
+ $sharee->href = $elems['href'];
+
+ if (isset($elems['prop'])) {
+ $sharee->properties = $elems['prop'];
+ }
+ if (isset($elems['comment'])) {
+ $sharee->comment = $elems['comment'];
+ }
+ if (!isset($elems['share-access'])) {
+ throw new BadRequest('Every {DAV:}sharee must have a {DAV:}share-access child element');
+ }
+ $sharee->access = $elems['share-access']->getValue();
+ return $sharee;
+
+ }
+
+}
diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php
index 538e98d0f..0027f72e1 100644
--- a/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php
+++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php
@@ -7,6 +7,7 @@ use Sabre\DAV\Browser\HtmlOutputHelper;
use Sabre\Xml\Element;
use Sabre\Xml\Reader;
use Sabre\Xml\Writer;
+use Sabre\Uri;
/**
* Href property
@@ -32,13 +33,6 @@ class Href implements Element, HtmlOutput {
protected $hrefs;
/**
- * Automatically prefix the url with the server base directory
- *
- * @var bool
- */
- protected $autoPrefix = true;
-
- /**
* Constructor
*
* You must either pass a string for a single href, or an array of hrefs.
@@ -47,16 +41,13 @@ class Href implements Element, HtmlOutput {
* and not relative to the servers base uri.
*
* @param string|string[] $href
- * @param bool $autoPrefix
*/
- function __construct($hrefs, $autoPrefix = true) {
+ function __construct($hrefs) {
if (is_string($hrefs)) {
$hrefs = [$hrefs];
}
$this->hrefs = $hrefs;
- $this->autoPrefix = $autoPrefix;
-
}
@@ -104,9 +95,7 @@ class Href implements Element, HtmlOutput {
function xmlSerialize(Writer $writer) {
foreach ($this->getHrefs() as $href) {
- if ($this->autoPrefix) {
- $href = $writer->contextUri . \Sabre\HTTP\encodePath($href);
- }
+ $href = Uri\resolve($writer->contextUri, $href);
$writer->writeElement('{DAV:}href', $href);
}
diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php
new file mode 100644
index 000000000..0616ff113
--- /dev/null
+++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php
@@ -0,0 +1,70 @@
+<?php
+
+namespace Sabre\DAV\Xml\Property;
+
+use Sabre\DAV\Sharing\Sharee;
+use Sabre\Xml\XmlSerializable;
+use Sabre\Xml\Writer;
+
+/**
+ * This class represents the {DAV:}invite property.
+ *
+ * This property is defined here:
+ * https://tools.ietf.org/html/draft-pot-webdav-resource-sharing-03#section-4.4.2
+ *
+ * This property is used by clients to determine who currently has access to
+ * a shared resource, what their access level is and what their invite status
+ * is.
+ *
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/).
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class Invite implements XmlSerializable {
+
+ /**
+ * A list of sharees
+ *
+ * @var Sharee[]
+ */
+ public $sharees = [];
+
+ /**
+ * Creates the property.
+ *
+ * @param Sharee[] $sharees
+ */
+ function __construct(array $sharees) {
+
+ $this->sharees = $sharees;
+
+ }
+
+ /**
+ * The xmlSerialize method is called during xml writing.
+ *
+ * Use the $writer argument to write its own xml serialization.
+ *
+ * An important note: do _not_ create a parent element. Any element
+ * implementing XmlSerializble should only ever write what's considered
+ * its 'inner xml'.
+ *
+ * The parent of the current element is responsible for writing a
+ * containing element.
+ *
+ * This allows serializers to be re-used for different element names.
+ *
+ * If you are opening new elements, you must also close them again.
+ *
+ * @param Writer $writer
+ * @return void
+ */
+ function xmlSerialize(Writer $writer) {
+
+ foreach ($this->sharees as $sharee) {
+ $writer->writeElement('{DAV:}sharee', $sharee);
+ }
+
+ }
+
+}
diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php b/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php
new file mode 100644
index 000000000..76a27b95d
--- /dev/null
+++ b/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php
@@ -0,0 +1,48 @@
+<?php
+
+namespace Sabre\DAV\Xml\Property;
+
+use Sabre\HTTP;
+
+/**
+ * LocalHref property
+ *
+ * Like the Href property, this element represents {DAV:}href. The difference
+ * is that this is used stricly for paths on the server. The LocalHref property
+ * will prepare the path so it's a valid URI.
+ *
+ * These two objects behave identically:
+ * new LocalHref($path)
+ * new Href(\Sabre\HTTP\encodePath($path))
+ *
+ * LocalPath basically ensures that your spaces are %20, and everything that
+ * needs to be is uri encoded.
+ *
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
+ * @author Evert Pot (http://www.rooftopsolutions.nl/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class LocalHref extends Href {
+
+ /**
+ * Constructor
+ *
+ * You must either pass a string for a single href, or an array of hrefs.
+ *
+ * If auto-prefix is set to false, the hrefs will be treated as absolute
+ * and not relative to the servers base uri.
+ *
+ * @param string|string[] $href
+ */
+ function __construct($hrefs) {
+
+ parent::__construct(array_map(
+ function($href) {
+ return \Sabre\HTTP\encodePath($href);
+ },
+ (array)$hrefs
+ ));
+
+ }
+
+}
diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php b/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php
new file mode 100644
index 000000000..a3fc6b0e1
--- /dev/null
+++ b/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php
@@ -0,0 +1,143 @@
+<?php
+
+namespace Sabre\DAV\Xml\Property;
+
+use Sabre\DAV\Sharing\Plugin as SharingPlugin;
+use Sabre\DAV\Exception\BadRequest;
+use Sabre\Xml\Element;
+use Sabre\Xml\Reader;
+use Sabre\Xml\Writer;
+
+/**
+ * This class represents the {DAV:}share-access property.
+ *
+ * This property is defined here:
+ * https://tools.ietf.org/html/draft-pot-webdav-resource-sharing-03#section-4.4.1
+ *
+ * This property is used to indicate if a resource is a shared resource, and
+ * whether the instance of the shared resource is the original instance, or
+ * an instance belonging to a sharee.
+ *
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/).
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class ShareAccess implements Element {
+
+ /**
+ * Either SHARED or SHAREDOWNER
+ *
+ * @var int
+ */
+ protected $value;
+
+ /**
+ * Creates the property.
+ *
+ * The constructor value must be one of the
+ * \Sabre\DAV\Sharing\Plugin::ACCESS_ constants.
+ *
+ * @param int $shareAccess
+ */
+ function __construct($shareAccess) {
+
+ $this->value = $shareAccess;
+
+ }
+
+ /**
+ * Returns the current value.
+ *
+ * @return int
+ */
+ function getValue() {
+
+ return $this->value;
+
+ }
+
+ /**
+ * The xmlSerialize method is called during xml writing.
+ *
+ * Use the $writer argument to write its own xml serialization.
+ *
+ * An important note: do _not_ create a parent element. Any element
+ * implementing XmlSerializble should only ever write what's considered
+ * its 'inner xml'.
+ *
+ * The parent of the current element is responsible for writing a
+ * containing element.
+ *
+ * This allows serializers to be re-used for different element names.
+ *
+ * If you are opening new elements, you must also close them again.
+ *
+ * @param Writer $writer
+ * @return void
+ */
+ function xmlSerialize(Writer $writer) {
+
+ switch ($this->value) {
+
+ case SharingPlugin::ACCESS_NOTSHARED :
+ $writer->writeElement('{DAV:}not-shared');
+ break;
+ case SharingPlugin::ACCESS_SHAREDOWNER :
+ $writer->writeElement('{DAV:}shared-owner');
+ break;
+ case SharingPlugin::ACCESS_READ :
+ $writer->writeElement('{DAV:}read');
+ break;
+ case SharingPlugin::ACCESS_READWRITE :
+ $writer->writeElement('{DAV:}read-write');
+ break;
+ case SharingPlugin::ACCESS_NOACCESS :
+ $writer->writeElement('{DAV:}no-access');
+ break;
+
+ }
+
+ }
+
+ /**
+ * The deserialize method is called during xml parsing.
+ *
+ * This method is called statictly, this is because in theory this method
+ * may be used as a type of constructor, or factory method.
+ *
+ * Often you want to return an instance of the current class, but you are
+ * free to return other data as well.
+ *
+ * You are responsible for advancing the reader to the next element. Not
+ * doing anything will result in a never-ending loop.
+ *
+ * If you just want to skip parsing for this element altogether, you can
+ * just call $reader->next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @param Reader $reader
+ * @return mixed
+ */
+ static function xmlDeserialize(Reader $reader) {
+
+ $elems = $reader->parseInnerTree();
+ foreach ($elems as $elem) {
+ switch ($elem['name']) {
+ case '{DAV:}not-shared' :
+ return new self(SharingPlugin::ACCESS_NOTSHARED);
+ case '{DAV:}shared-owner' :
+ return new self(SharingPlugin::ACCESS_SHAREDOWNER);
+ case '{DAV:}read' :
+ return new self(SharingPlugin::ACCESS_READ);
+ case '{DAV:}read-write' :
+ return new self(SharingPlugin::ACCESS_READWRITE);
+ case '{DAV:}no-access' :
+ return new self(SharingPlugin::ACCESS_NOACCESS);
+ }
+ }
+ throw new BadRequest('Invalid value for {DAV:}share-access element');
+
+ }
+}
diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php
index 56b418db6..7641f3739 100644
--- a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php
+++ b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php
@@ -32,16 +32,11 @@ class SupportedMethodSet implements XmlSerializable, HtmlOutput {
/**
* Creates the property
*
- * Any reports passed in the constructor
- * should be valid report-types in clark-notation.
- *
- * Either a string or an array of strings must be passed.
- *
- * @param string|string[] $methods
+ * @param string[] $methods
*/
- function __construct($methods = null) {
+ function __construct(array $methods) {
- $this->methods = (array)$methods;
+ $this->methods = $methods;
}
diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php b/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php
new file mode 100644
index 000000000..965e5857c
--- /dev/null
+++ b/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php
@@ -0,0 +1,81 @@
+<?php
+
+namespace Sabre\DAV\Xml\Request;
+
+use Sabre\Xml\Reader;
+use Sabre\Xml\XmlDeserializable;
+use Sabre\DAV\Xml\Element\Sharee;
+
+/**
+ * ShareResource request parser.
+ *
+ * This class parses the {DAV:}share-resource POST request as defined in:
+ *
+ * https://tools.ietf.org/html/draft-pot-webdav-resource-sharing-01#section-5.3.2.1
+ *
+ * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
+ * @author Evert Pot (http://www.rooftopsolutions.nl/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class ShareResource implements XmlDeserializable {
+
+ /**
+ * The list of new people added or updated or removed from the share.
+ *
+ * @var Sharee[]
+ */
+ public $sharees = [];
+
+ /**
+ * Constructor
+ *
+ * @param Sharee[] $sharees
+ */
+ function __construct(array $sharees) {
+
+ $this->sharees = $sharees;
+
+ }
+
+ /**
+ * The deserialize method is called during xml parsing.
+ *
+ * This method is called statictly, this is because in theory this method
+ * may be used as a type of constructor, or factory method.
+ *
+ * Often you want to return an instance of the current class, but you are
+ * free to return other data as well.
+ *
+ * You are responsible for advancing the reader to the next element. Not
+ * doing anything will result in a never-ending loop.
+ *
+ * If you just want to skip parsing for this element altogether, you can
+ * just call $reader->next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @param Reader $reader
+ * @return mixed
+ */
+ static function xmlDeserialize(Reader $reader) {
+
+ $elems = $reader->parseInnerTree([
+ '{DAV:}sharee' => 'Sabre\DAV\Xml\Element\Sharee',
+ '{DAV:}share-access' => 'Sabre\DAV\Xml\Property\ShareAccess',
+ '{DAV:}prop' => 'Sabre\Xml\Deserializer\keyValue',
+ ]);
+
+ $sharees = [];
+
+ foreach ($elems as $elem) {
+ if ($elem['name'] !== '{DAV:}sharee') continue;
+ $sharees[] = $elem['value'];
+
+ }
+
+ return new self($sharees);
+
+ }
+
+}