commit vendor

This commit is contained in:
2025-11-11 14:49:30 +01:00
parent f33121a308
commit 6d03080c00
2436 changed files with 483781 additions and 0 deletions

View File

@ -0,0 +1,119 @@
<?php
declare(strict_types=1);
namespace Sabre\CalDAV\Xml\Request;
use Sabre\CalDAV\Plugin;
use Sabre\Uri;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
/**
* CalendarMultiGetReport request parser.
*
* This class parses the {urn:ietf:params:xml:ns:caldav}calendar-multiget
* REPORT, as defined in:
*
* https://tools.ietf.org/html/rfc4791#section-7.9
*
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://sabre.io/license/ Modified BSD License
*/
class CalendarMultiGetReport implements XmlDeserializable
{
/**
* An array with requested properties.
*
* @var array
*/
public $properties;
/**
* This is an array with the urls that are being requested.
*
* @var array
*/
public $hrefs;
/**
* If the calendar data must be expanded, this will contain an array with 2
* elements: start and end.
*
* Each may be a DateTime or null.
*
* @var array|null
*/
public $expand = null;
/**
* The mimetype of the content that should be returend. Usually
* text/calendar.
*
* @var string
*/
public $contentType = null;
/**
* The version of calendar-data that should be returned. Usually '2.0',
* referring to iCalendar 2.0.
*
* @var string
*/
public $version = null;
/**
* The deserialize method is called during xml parsing.
*
* This method is called statically, 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.
*
* @return mixed
*/
public static function xmlDeserialize(Reader $reader)
{
$elems = $reader->parseInnerTree([
'{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData',
'{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
]);
$newProps = [
'hrefs' => [],
'properties' => [],
];
foreach ($elems as $elem) {
switch ($elem['name']) {
case '{DAV:}prop':
$newProps['properties'] = array_keys($elem['value']);
if (isset($elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'])) {
$newProps += $elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'];
}
break;
case '{DAV:}href':
$newProps['hrefs'][] = Uri\resolve($reader->contextUri, $elem['value']);
break;
}
}
$obj = new self();
foreach ($newProps as $key => $value) {
$obj->$key = $value;
}
return $obj;
}
}

View File

@ -0,0 +1,137 @@
<?php
declare(strict_types=1);
namespace Sabre\CalDAV\Xml\Request;
use Sabre\CalDAV\Plugin;
use Sabre\DAV\Exception\BadRequest;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
/**
* CalendarQueryReport request parser.
*
* This class parses the {urn:ietf:params:xml:ns:caldav}calendar-query
* REPORT, as defined in:
*
* https://tools.ietf.org/html/rfc4791#section-7.9
*
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://sabre.io/license/ Modified BSD License
*/
class CalendarQueryReport implements XmlDeserializable
{
/**
* An array with requested properties.
*
* @var array
*/
public $properties;
/**
* List of property/component filters.
*
* @var array
*/
public $filters;
/**
* If the calendar data must be expanded, this will contain an array with 2
* elements: start and end.
*
* Each may be a DateTime or null.
*
* @var array|null
*/
public $expand = null;
/**
* The mimetype of the content that should be returend. Usually
* text/calendar.
*
* @var string
*/
public $contentType = null;
/**
* The version of calendar-data that should be returned. Usually '2.0',
* referring to iCalendar 2.0.
*
* @var string
*/
public $version = null;
/**
* The deserialize method is called during xml parsing.
*
* This method is called statically, 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.
*
* @return mixed
*/
public static function xmlDeserialize(Reader $reader)
{
$elems = $reader->parseInnerTree([
'{urn:ietf:params:xml:ns:caldav}comp-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\CompFilter',
'{urn:ietf:params:xml:ns:caldav}prop-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\PropFilter',
'{urn:ietf:params:xml:ns:caldav}param-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\ParamFilter',
'{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData',
'{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
]);
$newProps = [
'filters' => null,
'properties' => [],
];
if (!is_array($elems)) {
$elems = [];
}
foreach ($elems as $elem) {
switch ($elem['name']) {
case '{DAV:}prop':
$newProps['properties'] = array_keys($elem['value']);
if (isset($elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'])) {
$newProps += $elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'];
}
break;
case '{'.Plugin::NS_CALDAV.'}filter':
foreach ($elem['value'] as $subElem) {
if ($subElem['name'] === '{'.Plugin::NS_CALDAV.'}comp-filter') {
if (!is_null($newProps['filters'])) {
throw new BadRequest('Only one top-level comp-filter may be defined');
}
$newProps['filters'] = $subElem['value'];
}
}
break;
}
}
if (is_null($newProps['filters'])) {
throw new BadRequest('The {'.Plugin::NS_CALDAV.'}filter element is required for this request');
}
$obj = new self();
foreach ($newProps as $key => $value) {
$obj->$key = $value;
}
return $obj;
}
}

View File

@ -0,0 +1,90 @@
<?php
declare(strict_types=1);
namespace Sabre\CalDAV\Xml\Request;
use Sabre\CalDAV\Plugin;
use Sabre\DAV\Exception\BadRequest;
use Sabre\VObject\DateTimeParser;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
/**
* FreeBusyQueryReport.
*
* This class parses the {DAV:}free-busy-query REPORT, as defined in:
*
* http://tools.ietf.org/html/rfc3253#section-3.8
*
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
class FreeBusyQueryReport implements XmlDeserializable
{
/**
* Starttime of report.
*
* @var \DateTime|null
*/
public $start;
/**
* End time of report.
*
* @var \DateTime|null
*/
public $end;
/**
* The deserialize method is called during xml parsing.
*
* This method is called statically, 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.
*
* @return mixed
*/
public static function xmlDeserialize(Reader $reader)
{
$timeRange = '{'.Plugin::NS_CALDAV.'}time-range';
$start = null;
$end = null;
foreach ((array) $reader->parseInnerTree([]) as $elem) {
if ($elem['name'] !== $timeRange) {
continue;
}
$start = empty($elem['attributes']['start']) ?: $elem['attributes']['start'];
$end = empty($elem['attributes']['end']) ?: $elem['attributes']['end'];
}
if (!$start && !$end) {
throw new BadRequest('The freebusy report must have a time-range element');
}
if ($start) {
$start = DateTimeParser::parseDateTime($start);
}
if ($end) {
$end = DateTimeParser::parseDateTime($end);
}
$result = new self();
$result->start = $start;
$result->end = $end;
return $result;
}
}

View File

@ -0,0 +1,145 @@
<?php
declare(strict_types=1);
namespace Sabre\CalDAV\Xml\Request;
use Sabre\CalDAV\Plugin;
use Sabre\CalDAV\SharingPlugin;
use Sabre\DAV;
use Sabre\DAV\Exception\BadRequest;
use Sabre\Xml\Element\KeyValue;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
/**
* Invite-reply POST request parser.
*
* This class parses the invite-reply POST request, as defined in:
*
* http://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk/doc/Extensions/caldav-sharing.txt
*
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
class InviteReply implements XmlDeserializable
{
/**
* The sharee calendar user address.
*
* This is the address that the original invite was set to
*
* @var string
*/
public $href;
/**
* The uri to the calendar that was being shared.
*
* @var string
*/
public $calendarUri;
/**
* The id of the invite message that's being responded to.
*
* @var string
*/
public $inReplyTo;
/**
* An optional message.
*
* @var string
*/
public $summary;
/**
* Either SharingPlugin::STATUS_ACCEPTED or SharingPlugin::STATUS_DECLINED.
*
* @var int
*/
public $status;
/**
* Constructor.
*
* @param string $href
* @param string $calendarUri
* @param string $inReplyTo
* @param string $summary
* @param int $status
*/
public function __construct($href, $calendarUri, $inReplyTo, $summary, $status)
{
$this->href = $href;
$this->calendarUri = $calendarUri;
$this->inReplyTo = $inReplyTo;
$this->summary = $summary;
$this->status = $status;
}
/**
* The deserialize method is called during xml parsing.
*
* This method is called statically, 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.
*
* @return mixed
*/
public static function xmlDeserialize(Reader $reader)
{
$elems = KeyValue::xmlDeserialize($reader);
$href = null;
$calendarUri = null;
$inReplyTo = null;
$summary = null;
$status = null;
foreach ($elems as $name => $value) {
switch ($name) {
case '{'.Plugin::NS_CALENDARSERVER.'}hosturl':
foreach ($value as $bla) {
if ('{DAV:}href' === $bla['name']) {
$calendarUri = $bla['value'];
}
}
break;
case '{'.Plugin::NS_CALENDARSERVER.'}invite-accepted':
$status = DAV\Sharing\Plugin::INVITE_ACCEPTED;
break;
case '{'.Plugin::NS_CALENDARSERVER.'}invite-declined':
$status = DAV\Sharing\Plugin::INVITE_DECLINED;
break;
case '{'.Plugin::NS_CALENDARSERVER.'}in-reply-to':
$inReplyTo = $value;
break;
case '{'.Plugin::NS_CALENDARSERVER.'}summary':
$summary = $value;
break;
case '{DAV:}href':
$href = $value;
break;
}
}
if (is_null($calendarUri)) {
throw new BadRequest('The {http://calendarserver.org/ns/}hosturl/{DAV:}href element must exist');
}
return new self($href, $calendarUri, $inReplyTo, $summary, $status);
}
}

View File

@ -0,0 +1,77 @@
<?php
declare(strict_types=1);
namespace Sabre\CalDAV\Xml\Request;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
/**
* MKCALENDAR parser.
*
* This class parses the MKCALENDAR request, as defined in:
*
* https://tools.ietf.org/html/rfc4791#section-5.3.1
*
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
class MkCalendar implements XmlDeserializable
{
/**
* The list of properties that will be set.
*
* @var array
*/
public $properties = [];
/**
* Returns the list of properties the calendar will be initialized with.
*
* @return array
*/
public function getProperties()
{
return $this->properties;
}
/**
* The deserialize method is called during xml parsing.
*
* This method is called statically, 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.
*
* @return mixed
*/
public 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';
$elems = $reader->parseInnerTree($elementMap);
foreach ($elems as $elem) {
if ('{DAV:}set' === $elem['name']) {
$self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']);
}
}
return $self;
}
}

View File

@ -0,0 +1,107 @@
<?php
declare(strict_types=1);
namespace Sabre\CalDAV\Xml\Request;
use Sabre\CalDAV\Plugin;
use Sabre\DAV\Xml\Element\Sharee;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
/**
* Share POST request parser.
*
* This class parses the share POST request, as defined in:
*
* http://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk/doc/Extensions/caldav-sharing.txt
*
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
class Share implements XmlDeserializable
{
/**
* The list of new people added or updated or removed from the share.
*
* @var Sharee[]
*/
public $sharees = [];
/**
* Constructor.
*
* @param Sharee[] $sharees
*/
public function __construct(array $sharees)
{
$this->sharees = $sharees;
}
/**
* The deserialize method is called during xml parsing.
*
* This method is called statically, 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.
*
* @return mixed
*/
public static function xmlDeserialize(Reader $reader)
{
$elems = $reader->parseGetElements([
'{'.Plugin::NS_CALENDARSERVER.'}set' => 'Sabre\\Xml\\Element\\KeyValue',
'{'.Plugin::NS_CALENDARSERVER.'}remove' => 'Sabre\\Xml\\Element\\KeyValue',
]);
$sharees = [];
foreach ($elems as $elem) {
switch ($elem['name']) {
case '{'.Plugin::NS_CALENDARSERVER.'}set':
$sharee = $elem['value'];
$sumElem = '{'.Plugin::NS_CALENDARSERVER.'}summary';
$commonName = '{'.Plugin::NS_CALENDARSERVER.'}common-name';
$properties = [];
if (isset($sharee[$commonName])) {
$properties['{DAV:}displayname'] = $sharee[$commonName];
}
$access = array_key_exists('{'.Plugin::NS_CALENDARSERVER.'}read-write', $sharee)
? \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE
: \Sabre\DAV\Sharing\Plugin::ACCESS_READ;
$sharees[] = new Sharee([
'href' => $sharee['{DAV:}href'],
'properties' => $properties,
'access' => $access,
'comment' => isset($sharee[$sumElem]) ? $sharee[$sumElem] : null,
]);
break;
case '{'.Plugin::NS_CALENDARSERVER.'}remove':
$sharees[] = new Sharee([
'href' => $elem['value']['{DAV:}href'],
'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS,
]);
break;
}
}
return new self($sharees);
}
}