aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/DAV/Xml/Request
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/lib/DAV/Xml/Request')
-rw-r--r--vendor/sabre/dav/lib/DAV/Xml/Request/Lock.php81
-rw-r--r--vendor/sabre/dav/lib/DAV/Xml/Request/MkCol.php82
-rw-r--r--vendor/sabre/dav/lib/DAV/Xml/Request/PropFind.php83
-rw-r--r--vendor/sabre/dav/lib/DAV/Xml/Request/PropPatch.php118
-rw-r--r--vendor/sabre/dav/lib/DAV/Xml/Request/SyncCollectionReport.php122
5 files changed, 486 insertions, 0 deletions
diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/Lock.php b/vendor/sabre/dav/lib/DAV/Xml/Request/Lock.php
new file mode 100644
index 000000000..76df98d13
--- /dev/null
+++ b/vendor/sabre/dav/lib/DAV/Xml/Request/Lock.php
@@ -0,0 +1,81 @@
+<?php
+
+namespace Sabre\DAV\Xml\Request;
+
+use Sabre\DAV\Locks\LockInfo;
+use Sabre\Xml\Element\KeyValue;
+use Sabre\Xml\Reader;
+use Sabre\Xml\XmlDeserializable;
+
+/**
+ * WebDAV LOCK request parser.
+ *
+ * This class parses the {DAV:}lockinfo request, as defined in:
+ *
+ * http://tools.ietf.org/html/rfc4918#section-9.10
+ *
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class Lock implements XmlDeserializable {
+
+ /**
+ * Owner of the lock
+ *
+ * @var string
+ */
+ public $owner;
+
+ /**
+ * Scope of the lock.
+ *
+ * Either LockInfo::SHARED or LockInfo::EXCLUSIVE
+ * @var int
+ */
+ public $scope;
+
+ /**
+ * 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) {
+
+ $reader->pushContext();
+ $reader->elementMap['{DAV:}owner'] = 'Sabre\\Xml\\Element\\XmlFragment';
+
+ $values = KeyValue::xmlDeserialize($reader);
+
+ $reader->popContext();
+
+ $new = new self();
+ $new->owner = !empty($values['{DAV:}owner']) ? $values['{DAV:}owner']->getXml() : null;
+ $new->scope = LockInfo::SHARED;
+
+ if (isset($values['{DAV:}lockscope'])) {
+ foreach ($values['{DAV:}lockscope'] as $elem) {
+ if ($elem['name'] === '{DAV:}exclusive') $new->scope = LockInfo::EXCLUSIVE;
+ }
+ }
+ return $new;
+
+ }
+
+}
diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/MkCol.php b/vendor/sabre/dav/lib/DAV/Xml/Request/MkCol.php
new file mode 100644
index 000000000..5db239061
--- /dev/null
+++ b/vendor/sabre/dav/lib/DAV/Xml/Request/MkCol.php
@@ -0,0 +1,82 @@
+<?php
+
+namespace Sabre\DAV\Xml\Request;
+
+use Sabre\Xml\Reader;
+use Sabre\Xml\XmlDeserializable;
+
+/**
+ * WebDAV Extended MKCOL request parser.
+ *
+ * This class parses the {DAV:}mkol request, as defined in:
+ *
+ * https://tools.ietf.org/html/rfc5689#section-5.1
+ *
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class MkCol implements XmlDeserializable {
+
+ /**
+ * The list of properties that will be set.
+ *
+ * @var array
+ */
+ protected $properties = [];
+
+ /**
+ * Returns a key=>value array with properties that are supposed to get set
+ * during creation of the new collection.
+ *
+ * @return array
+ */
+ function getProperties() {
+
+ return $this->properties;
+
+ }
+
+ /**
+ * 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) {
+
+ $self = new self();
+
+ $elementMap = $reader->elementMap;
+ $elementMap['{DAV:}prop'] = 'Sabre\DAV\Xml\Element\Prop';
+ $elementMap['{DAV:}set'] = 'Sabre\Xml\Element\KeyValue';
+ $elementMap['{DAV:}remove'] = 'Sabre\Xml\Element\KeyValue';
+
+ $elems = $reader->parseInnerTree($elementMap);
+
+ foreach ($elems as $elem) {
+ if ($elem['name'] === '{DAV:}set') {
+ $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']);
+ }
+ }
+
+ return $self;
+
+ }
+
+}
diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/PropFind.php b/vendor/sabre/dav/lib/DAV/Xml/Request/PropFind.php
new file mode 100644
index 000000000..ad3ad7c43
--- /dev/null
+++ b/vendor/sabre/dav/lib/DAV/Xml/Request/PropFind.php
@@ -0,0 +1,83 @@
+<?php
+
+namespace Sabre\DAV\Xml\Request;
+
+use Sabre\Xml\Element\KeyValue;
+use Sabre\Xml\Reader;
+use Sabre\Xml\XmlDeserializable;
+
+/**
+ * WebDAV PROPFIND request parser.
+ *
+ * This class parses the {DAV:}propfind request, as defined in:
+ *
+ * https://tools.ietf.org/html/rfc4918#section-14.20
+ *
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
+ * @author Evert Pot (http://www.rooftopsolutions.nl/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class PropFind implements XmlDeserializable {
+
+ /**
+ * If this is set to true, this was an 'allprop' request.
+ *
+ * @var bool
+ */
+ public $allProp = false;
+
+ /**
+ * The property list
+ *
+ * @var null|array
+ */
+ public $properties;
+
+ /**
+ * 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) {
+
+ $self = new self();
+
+ $reader->pushContext();
+ $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Element\Elements';
+
+ foreach (KeyValue::xmlDeserialize($reader) as $k => $v) {
+
+ switch ($k) {
+ case '{DAV:}prop' :
+ $self->properties = $v;
+ break;
+ case '{DAV:}allprop' :
+ $self->allProp = true;
+
+ }
+
+ }
+
+ $reader->popContext();
+
+ return $self;
+
+ }
+
+}
diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/PropPatch.php b/vendor/sabre/dav/lib/DAV/Xml/Request/PropPatch.php
new file mode 100644
index 000000000..07a05f887
--- /dev/null
+++ b/vendor/sabre/dav/lib/DAV/Xml/Request/PropPatch.php
@@ -0,0 +1,118 @@
+<?php
+
+namespace Sabre\DAV\Xml\Request;
+
+use Sabre\Xml\Element;
+use Sabre\Xml\Reader;
+use Sabre\Xml\Writer;
+
+/**
+ * WebDAV PROPPATCH request parser.
+ *
+ * This class parses the {DAV:}propertyupdate request, as defined in:
+ *
+ * https://tools.ietf.org/html/rfc4918#section-14.20
+ *
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
+ * @author Evert Pot (http://www.rooftopsolutions.nl/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class PropPatch implements Element {
+
+ /**
+ * The list of properties that will be updated and removed.
+ *
+ * If a property will be removed, it's value will be set to null.
+ *
+ * @var array
+ */
+ public $properties = [];
+
+ /**
+ * The xmlSerialize metod 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->properties as $propertyName => $propertyValue) {
+
+ if (is_null($propertyValue)) {
+ $writer->startElement("{DAV:}remove");
+ $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]);
+ $writer->endElement();
+ } else {
+ $writer->startElement("{DAV:}set");
+ $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]);
+ $writer->endElement();
+ }
+
+ }
+
+ }
+
+ /**
+ * 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) {
+
+ $self = new self();
+
+ $elementMap = $reader->elementMap;
+ $elementMap['{DAV:}prop'] = 'Sabre\DAV\Xml\Element\Prop';
+ $elementMap['{DAV:}set'] = 'Sabre\Xml\Element\KeyValue';
+ $elementMap['{DAV:}remove'] = 'Sabre\Xml\Element\KeyValue';
+
+ $elems = $reader->parseInnerTree($elementMap);
+
+ foreach ($elems as $elem) {
+ if ($elem['name'] === '{DAV:}set') {
+ $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']);
+ }
+ if ($elem['name'] === '{DAV:}remove') {
+
+ // Ensuring there are no values.
+ foreach ($elem['value']['{DAV:}prop'] as $remove => $value) {
+ $self->properties[$remove] = null;
+ }
+
+ }
+ }
+
+ return $self;
+
+ }
+
+}
diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/SyncCollectionReport.php b/vendor/sabre/dav/lib/DAV/Xml/Request/SyncCollectionReport.php
new file mode 100644
index 000000000..3092ada47
--- /dev/null
+++ b/vendor/sabre/dav/lib/DAV/Xml/Request/SyncCollectionReport.php
@@ -0,0 +1,122 @@
+<?php
+
+namespace Sabre\DAV\Xml\Request;
+
+use Sabre\Xml\Reader;
+use Sabre\Xml\XmlDeserializable;
+use Sabre\Xml\Element\KeyValue;
+use Sabre\DAV\Exception\BadRequest;
+
+/**
+ * SyncCollection request parser.
+ *
+ * This class parses the {DAV:}sync-collection reprot, as defined in:
+ *
+ * http://tools.ietf.org/html/rfc6578#section-3.2
+ *
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
+ * @author Evert Pot (http://www.rooftopsolutions.nl/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class SyncCollectionReport implements XmlDeserializable {
+
+ /**
+ * The sync-token the client supplied for the report.
+ *
+ * @var string|null
+ */
+ public $syncToken;
+
+ /**
+ * The 'depth' of the sync the client is interested in.
+ *
+ * @var int
+ */
+ public $syncLevel;
+
+ /**
+ * Maximum amount of items returned.
+ *
+ * @var int|null
+ */
+ public $limit;
+
+ /**
+ * The list of properties that are being requested for every change.
+ *
+ * @var null|array
+ */
+ public $properties;
+
+ /**
+ * 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) {
+
+ $self = new self();
+
+ $reader->pushContext();
+
+ $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Element\Elements';
+ $elems = KeyValue::xmlDeserialize($reader);
+
+ $reader->popContext();
+
+ $required = [
+ '{DAV:}sync-token',
+ '{DAV:}prop',
+ ];
+
+ foreach ($required as $elem) {
+ if (!array_key_exists($elem, $elems)) {
+ throw new BadRequest('The ' . $elem . ' element in the {DAV:}sync-collection report is required');
+ }
+ }
+
+
+ $self->properties = $elems['{DAV:}prop'];
+ $self->syncToken = $elems['{DAV:}sync-token'];
+
+ if (isset($elems['{DAV:}limit'])) {
+ $nresults = null;
+ foreach ($elems['{DAV:}limit'] as $child) {
+ if ($child['name'] === '{DAV:}nresults') {
+ $nresults = (int)$child['value'];
+ }
+ }
+ $self->limit = $nresults;
+ }
+
+ if (isset($elems['{DAV:}sync-level'])) {
+
+ $value = $elems['{DAV:}sync-level'];
+ if ($value === 'infinity') {
+ $value = \Sabre\DAV\Server::DEPTH_INFINITY;
+ }
+ $self->syncLevel = $value;
+
+ }
+
+ return $self;
+
+ }
+
+}