migrate therinaldos.com data
Build & Deploy to DigitalOcean Space / build (push) Failing after 2m38s

This commit is contained in:
2024-05-05 15:50:45 -04:00
commit ef1ff240d4
23182 changed files with 3801898 additions and 0 deletions
@@ -0,0 +1,165 @@
<?php
/**
* @copyright Copyright (c) 2017 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\CalDAV\Search;
use OCA\DAV\CalDAV\CalendarHome;
use OCA\DAV\CalDAV\Search\Xml\Request\CalendarSearchReport;
use Sabre\DAV\Server;
use Sabre\DAV\ServerPlugin;
class SearchPlugin extends ServerPlugin {
public const NS_Nextcloud = 'http://nextcloud.com/ns';
/**
* Reference to SabreDAV server object.
*
* @var \Sabre\DAV\Server
*/
protected $server;
/**
* 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 string[]
*/
public function getFeatures() {
// May have to be changed to be detected
return ['nc-calendar-search'];
}
/**
* 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 'nc-calendar-search';
}
/**
* 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
*/
public function initialize(Server $server) {
$this->server = $server;
$server->on('report', [$this, 'report']);
$server->xml->elementMap['{' . self::NS_Nextcloud . '}calendar-search'] =
CalendarSearchReport::class;
}
/**
* This functions handles REPORT requests specific to CalDAV
*
* @param string $reportName
* @param mixed $report
* @param mixed $path
* @return bool
*/
public function report($reportName, $report, $path) {
switch ($reportName) {
case '{' . self::NS_Nextcloud . '}calendar-search':
$this->server->transactionType = 'report-nc-calendar-search';
$this->calendarSearch($report);
return false;
}
}
/**
* Returns a list of reports this plugin supports.
*
* This will be used in the {DAV:}supported-report-set property.
* Note that you still need to subscribe to the 'report' event to actually
* implement them
*
* @param string $uri
* @return array
*/
public function getSupportedReportSet($uri) {
$node = $this->server->tree->getNodeForPath($uri);
$reports = [];
if ($node instanceof CalendarHome) {
$reports[] = '{' . self::NS_Nextcloud . '}calendar-search';
}
return $reports;
}
/**
* This function handles the calendar-query REPORT
*
* This report is used by clients to request calendar objects based on
* complex conditions.
*
* @param Xml\Request\CalendarSearchReport $report
* @return void
*/
private function calendarSearch($report) {
$node = $this->server->tree->getNodeForPath($this->server->getRequestUri());
$depth = $this->server->getHTTPDepth(2);
// The default result is an empty array
$result = [];
// If we're dealing with the calendar home, the calendar home itself is
// responsible for the calendar-query
if ($node instanceof CalendarHome && $depth === 2) {
$nodePaths = $node->calendarSearch($report->filters, $report->limit, $report->offset);
foreach ($nodePaths as $path) {
[$properties] = $this->server->getPropertiesForPath(
$this->server->getRequestUri() . '/' . $path,
$report->properties);
$result[] = $properties;
}
}
$prefer = $this->server->getHTTPPrefer();
$this->server->httpResponse->setStatus(207);
$this->server->httpResponse->setHeader('Content-Type',
'application/xml; charset=utf-8');
$this->server->httpResponse->setHeader('Vary', 'Brief,Prefer');
$this->server->httpResponse->setBody(
$this->server->generateMultiStatus($result,
$prefer['return'] === 'minimal'));
}
}
@@ -0,0 +1,51 @@
<?php
/**
* @copyright Copyright (c) 2017 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\CalDAV\Search\Xml\Filter;
use OCA\DAV\CalDAV\Search\SearchPlugin;
use Sabre\DAV\Exception\BadRequest;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
class CompFilter implements XmlDeserializable {
/**
* @param Reader $reader
* @throws BadRequest
* @return string
*/
public static function xmlDeserialize(Reader $reader) {
$att = $reader->parseAttributes();
$componentName = $att['name'];
$reader->parseInnerTree();
if (!is_string($componentName)) {
throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute');
}
return $componentName;
}
}
@@ -0,0 +1,48 @@
<?php
/**
* @copyright Copyright (c) 2017 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\CalDAV\Search\Xml\Filter;
use OCA\DAV\CalDAV\Search\SearchPlugin;
use Sabre\DAV\Exception\BadRequest;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
class LimitFilter implements XmlDeserializable {
/**
* @param Reader $reader
* @throws BadRequest
* @return int
*/
public static function xmlDeserialize(Reader $reader) {
$value = $reader->parseInnerTree();
if (!is_int($value) && !is_string($value)) {
throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}limit has illegal value');
}
return (int)$value;
}
}
@@ -0,0 +1,48 @@
<?php
/**
* @copyright Copyright (c) 2017 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\CalDAV\Search\Xml\Filter;
use OCA\DAV\CalDAV\Search\SearchPlugin;
use Sabre\DAV\Exception\BadRequest;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
class OffsetFilter implements XmlDeserializable {
/**
* @param Reader $reader
* @throws BadRequest
* @return int
*/
public static function xmlDeserialize(Reader $reader) {
$value = $reader->parseInnerTree();
if (!is_int($value) && !is_string($value)) {
throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}offset has illegal value');
}
return (int)$value;
}
}
@@ -0,0 +1,58 @@
<?php
/**
* @copyright Copyright (c) 2017 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\CalDAV\Search\Xml\Filter;
use OCA\DAV\CalDAV\Search\SearchPlugin;
use Sabre\DAV\Exception\BadRequest;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
class ParamFilter implements XmlDeserializable {
/**
* @param Reader $reader
* @throws BadRequest
* @return string
*/
public static function xmlDeserialize(Reader $reader) {
$att = $reader->parseAttributes();
$property = $att['property'];
$parameter = $att['name'];
$reader->parseInnerTree();
if (!is_string($property)) {
throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute');
}
if (!is_string($parameter)) {
throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute');
}
return [
'property' => $property,
'parameter' => $parameter,
];
}
}
@@ -0,0 +1,51 @@
<?php
/**
* @copyright Copyright (c) 2017 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\CalDAV\Search\Xml\Filter;
use OCA\DAV\CalDAV\Search\SearchPlugin;
use Sabre\DAV\Exception\BadRequest;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
class PropFilter implements XmlDeserializable {
/**
* @param Reader $reader
* @throws BadRequest
* @return string
*/
public static function xmlDeserialize(Reader $reader) {
$att = $reader->parseAttributes();
$componentName = $att['name'];
$reader->parseInnerTree();
if (!is_string($componentName)) {
throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute');
}
return $componentName;
}
}
@@ -0,0 +1,47 @@
<?php
/**
* @copyright Copyright (c) 2017 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\CalDAV\Search\Xml\Filter;
use OCA\DAV\CalDAV\Search\SearchPlugin;
use Sabre\DAV\Exception\BadRequest;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
class SearchTermFilter implements XmlDeserializable {
/**
* @param Reader $reader
* @throws BadRequest
* @return string
*/
public static function xmlDeserialize(Reader $reader) {
$value = $reader->parseInnerTree();
if (!is_string($value)) {
throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}search-term has illegal value');
}
return $value;
}
}
@@ -0,0 +1,171 @@
<?php
/**
* @copyright Copyright (c) 2017 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\CalDAV\Search\Xml\Request;
use OCA\DAV\CalDAV\Search\SearchPlugin;
use Sabre\DAV\Exception\BadRequest;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
/**
* CalendarSearchReport request parser.
*
* This class parses the {urn:ietf:params:xml:ns:caldav}calendar-query
* REPORT, as defined in:
*
* https:// link to standard
*/
class CalendarSearchReport implements XmlDeserializable {
/**
* An array with requested properties.
*
* @var array
*/
public $properties;
/**
* List of property/component filters.
*
* @var array
*/
public $filters;
/**
* @var int
*/
public $limit;
/**
* @var int
*/
public $offset;
/**
* 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.
*
* @param Reader $reader
* @return mixed
*/
public static function xmlDeserialize(Reader $reader) {
$elems = $reader->parseInnerTree([
'{http://nextcloud.com/ns}comp-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter',
'{http://nextcloud.com/ns}prop-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter',
'{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter',
'{http://nextcloud.com/ns}search-term' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter',
'{http://nextcloud.com/ns}limit' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter',
'{http://nextcloud.com/ns}offset' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter',
'{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
]);
$newProps = [
'filters' => [],
'properties' => [],
'limit' => null,
'offset' => null
];
if (!is_array($elems)) {
$elems = [];
}
foreach ($elems as $elem) {
switch ($elem['name']) {
case '{DAV:}prop':
$newProps['properties'] = array_keys($elem['value']);
break;
case '{' . SearchPlugin::NS_Nextcloud . '}filter':
foreach ($elem['value'] as $subElem) {
if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') {
if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) {
$newProps['filters']['comps'] = [];
}
$newProps['filters']['comps'][] = $subElem['value'];
} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') {
if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) {
$newProps['filters']['props'] = [];
}
$newProps['filters']['props'][] = $subElem['value'];
} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') {
if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) {
$newProps['filters']['params'] = [];
}
$newProps['filters']['params'][] = $subElem['value'];
} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') {
$newProps['filters']['search-term'] = $subElem['value'];
}
}
break;
case '{' . SearchPlugin::NS_Nextcloud . '}limit':
$newProps['limit'] = $elem['value'];
break;
case '{' . SearchPlugin::NS_Nextcloud . '}offset':
$newProps['offset'] = $elem['value'];
break;
}
}
if (empty($newProps['filters'])) {
throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request');
}
$propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params']));
$noCompsDefined = empty($newProps['filters']['comps']);
if ($propsOrParamsDefined && $noCompsDefined) {
throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter');
}
if (!isset($newProps['filters']['search-term'])) {
throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');
}
if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) {
throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request');
}
$obj = new self();
foreach ($newProps as $key => $value) {
$obj->$key = $value;
}
return $obj;
}
}