Lines Matching +full:fetch +full:- +full:depth
23 * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
75 $node = $this->server->tree->getNodeForPath($parent);
79 $node->getChild($name);
112 return ['calendar-access', 'calendar-proxy'];
133 * This will be used in the {DAV:}supported-report-set property.
142 $node = $this->server->tree->getNodeForPath($uri);
146 $reports[] = '{' . self::NS_CALDAV . '}calendar-multiget';
147 $reports[] = '{' . self::NS_CALDAV . '}calendar-query';
150 $reports[] = '{' . self::NS_CALDAV . '}free-busy-query';
153 // if we say we support it on the calendar-home, even though this is
155 if ($node instanceof CalendarHome && $this->server->getPlugin('sync')) {
156 $reports[] = '{DAV:}sync-collection';
170 $this->server = $server;
172 $server->on('method:MKCALENDAR', [$this, 'httpMkCalendar']);
173 $server->on('report', [$this, 'report']);
174 $server->on('propFind', [$this, 'propFind']);
175 $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']);
176 $server->on('beforeCreateFile', [$this, 'beforeCreateFile']);
177 $server->on('beforeWriteContent', [$this, 'beforeWriteContent']);
178 $server->on('afterMethod:GET', [$this, 'httpAfterGET']);
180 $server->xml->namespaceMap[self::NS_CALDAV] = 'cal';
181 $server->xml->namespaceMap[self::NS_CALENDARSERVER] = 'cs';
183 …$server->xml->elementMap['{' . self::NS_CALDAV . '}calendar-query'] = 'Sabre\\CalDAV\\Xml\\Request…
184 …$server->xml->elementMap['{' . self::NS_CALDAV . '}calendar-multiget'] = 'Sabre\\CalDAV\\Xml\\Requ…
185 …$server->xml->elementMap['{' . self::NS_CALDAV . '}free-busy-query'] = 'Sabre\\CalDAV\\Xml\\Reques…
186 …$server->xml->elementMap['{' . self::NS_CALDAV . '}mkcalendar'] = 'Sabre\\CalDAV\\Xml\\Request\\Mk…
187 …$server->xml->elementMap['{' . self::NS_CALDAV . '}schedule-calendar-transp'] = 'Sabre\\CalDAV\\Xm…
188 …$server->xml->elementMap['{' . self::NS_CALDAV . '}supported-calendar-component-set'] = 'Sabre\\Ca…
190 …$server->resourceTypeMapping['\\Sabre\\CalDAV\\ICalendar'] = '{urn:ietf:params:xml:ns:caldav}calen…
192 …$server->resourceTypeMapping['\\Sabre\\CalDAV\\Principal\\IProxyRead'] = '{http://calendarserver.o…
193 …$server->resourceTypeMapping['\\Sabre\\CalDAV\\Principal\\IProxyWrite'] = '{http://calendarserver.…
195 array_push($server->protectedProperties,
197 '{' . self::NS_CALDAV . '}supported-calendar-component-set',
198 '{' . self::NS_CALDAV . '}supported-calendar-data',
199 '{' . self::NS_CALDAV . '}max-resource-size',
200 '{' . self::NS_CALDAV . '}min-date-time',
201 '{' . self::NS_CALDAV . '}max-date-time',
202 '{' . self::NS_CALDAV . '}max-instances',
203 '{' . self::NS_CALDAV . '}max-attendees-per-instance',
204 '{' . self::NS_CALDAV . '}calendar-home-set',
205 '{' . self::NS_CALDAV . '}supported-collation-set',
206 '{' . self::NS_CALDAV . '}calendar-data',
210 '{' . self::NS_CALENDARSERVER . '}calendar-proxy-read-for',
211 '{' . self::NS_CALENDARSERVER . '}calendar-proxy-write-for'
215 if ($aclPlugin = $server->getPlugin('acl')) {
216 …$aclPlugin->principalSearchPropertySet['{' . self::NS_CALDAV . '}calendar-user-address-set'] = 'Ca…
230 case '{' . self::NS_CALDAV . '}calendar-multiget' :
231 $this->server->transactionType = 'report-calendar-multiget';
232 $this->calendarMultiGetReport($report);
234 case '{' . self::NS_CALDAV . '}calendar-query' :
235 $this->server->transactionType = 'report-calendar-query';
236 $this->calendarQueryReport($report);
238 case '{' . self::NS_CALDAV . '}free-busy-query' :
239 $this->server->transactionType = 'report-free-busy-query';
240 $this->freeBusyQueryReport($report);
258 $body = $request->getBodyAsString();
259 $path = $request->getPath();
266 $mkcalendar = $this->server->xml->expect(
271 throw new BadRequest($e->getMessage(), null, $e);
273 $properties = $mkcalendar->getProperties();
277 // iCal abuses MKCALENDAR since iCal 10.9.2 to create server-stored
282 // request, and we simply use it instead of the pre-defined list.
284 $resourceType = $properties['{DAV:}resourcetype']->getValue();
289 $this->server->createCollection($path, new MkCol($resourceType, $properties));
291 $this->server->httpResponse->setStatus(201);
292 $this->server->httpResponse->setHeader('Content-Length', 0);
315 $propFind->handle($ns . 'max-resource-size', $this->maxResourceSize);
316 $propFind->handle($ns . 'supported-calendar-data', function() {
319 $propFind->handle($ns . 'supported-collation-set', function() {
327 $principalUrl = $node->getPrincipalUrl();
329 … $propFind->handle('{' . self::NS_CALDAV . '}calendar-home-set', function() use ($principalUrl) {
331 $calendarHomePath = $this->getCalendarHomeForPrincipal($principalUrl) . '/';
335 // The calendar-user-address-set property is basically mapped to
336 // the {DAV:}alternate-URI-set property.
337 … $propFind->handle('{' . self::NS_CALDAV . '}calendar-user-address-set', function() use ($node) {
338 $addresses = $node->getAlternateUriSet();
339 $addresses[] = $this->server->getBaseUri() . $node->getPrincipalUrl() . '/';
344 … $propFind->handle('{' . self::NS_CALENDARSERVER . '}email-address-set', function() use ($node) {
345 $addresses = $node->getAlternateUriSet();
357 $propRead = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-read-for';
358 $propWrite = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-write-for';
360 … if ($propFind->getStatus($propRead) === 404 || $propFind->getStatus($propWrite) === 404) {
362 $aclPlugin = $this->server->getPlugin('acl');
363 $membership = $aclPlugin->getPrincipalMembership($propFind->getPath());
369 $groupNode = $this->server->tree->getNodeForPath($group);
373 // If the node is either ap proxy-read or proxy-write
385 $propFind->set($propRead, new Href($readList));
386 $propFind->set($propWrite, new Href($writeList));
394 // The calendar-data property is not supposed to be a 'real'
397 $propFind->handle('{' . self::NS_CALDAV . '}calendar-data', function() use ($node) {
398 $val = $node->get();
412 * This function handles the calendar-multiget REPORT.
414 * This report is used by the client to fetch the content of a series
422 $needsJson = $report->contentType === 'application/calendar+json';
428 [$this->server, 'calculateUri'],
429 $report->hrefs
432 …foreach ($this->server->getPropertiesForMultiplePaths($paths, $report->properties) as $uri => $obj…
434 …if (($needsJson || $report->expand) && isset($objProps[200]['{' . self::NS_CALDAV . '}calendar-dat…
435 … $vObject = VObject\Reader::read($objProps[200]['{' . self::NS_CALDAV . '}calendar-data']);
437 if ($report->expand) {
442 // Checking the calendar-timezone property.
443 $tzProp = '{' . self::NS_CALDAV . '}calendar-timezone';
444 $tzResult = $this->server->getProperties($calendarPath, [$tzProp]);
449 $timeZone = $vtimezoneObj->VTIMEZONE->getTimeZone();
457 … $vObject->expand($report->expand['start'], $report->expand['end'], $timeZones[$calendarPath]);
460 … $objProps[200]['{' . self::NS_CALDAV . '}calendar-data'] = json_encode($vObject->jsonSerialize());
462 … $objProps[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize();
470 $prefer = $this->server->getHTTPPrefer();
472 $this->server->httpResponse->setStatus(207);
473 $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
474 $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer');
475 …$this->server->httpResponse->setBody($this->server->generateMultiStatus($propertyList, $prefer['re…
480 * This function handles the calendar-query REPORT
490 $path = $this->server->getRequestUri();
492 $needsJson = $report->contentType === 'application/calendar+json';
494 $node = $this->server->tree->getNodeForPath($this->server->getRequestUri());
495 $depth = $this->server->getHTTPDepth(0);
501 if ($report->expand) {
504 $tzProp = '{' . self::NS_CALDAV . '}calendar-timezone';
505 $tzResult = $this->server->getProperties($path, [$tzProp]);
510 $calendarTimeZone = $vtimezoneObj->VTIMEZONE->getTimeZone();
520 if ($depth == 0 && $node instanceof ICalendarObject) {
523 $requestedProperties = $report->properties;
525 if (!in_array('{urn:ietf:params:xml:ns:caldav}calendar-data', $requestedProperties)) {
527 // We always retrieve calendar-data, as we need it for filtering.
528 $requestedProperties[] = '{urn:ietf:params:xml:ns:caldav}calendar-data';
530 // If calendar-data wasn't explicitly requested, we need to remove
535 $properties = $this->server->getPropertiesForPath(
545 // If there wasn't any calendar-data returned somehow, we ignore
547 if (isset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data'])) {
551 … $vObject = VObject\Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']);
552 if ($validator->validate($vObject, $report->filters)) {
554 // If the client didn't require the calendar-data property,
557 unset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']);
561 if ($report->expand) {
562 … $vObject->expand($report->expand['start'], $report->expand['end'], $calendarTimeZone);
565 …$properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = json_encode($vObject->jsonSerialize()…
566 } elseif ($report->expand) {
567 … $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize();
579 if ($node instanceof ICalendarObjectContainer && $depth === 0) {
581 if (strpos($this->server->httpRequest->getHeader('User-Agent'), 'MSFT-WP/') === 0) {
582 // Windows phone incorrectly supplied depth as 0, when it actually
583 // should have set depth to 1. We're implementing a workaround here
585 $depth = 1;
587 …throw new BadRequest('A calendar-query REPORT on a calendar with a Depth: 0 is undefined. Set Dept…
593 // for the calendar-query.
594 if ($node instanceof ICalendarObjectContainer && $depth == 1) {
596 $nodePaths = $node->calendarQuery($report->filters);
601 …$this->server->getPropertiesForPath($this->server->getRequestUri() . '/' . $path, $report->propert…
603 if (($needsJson || $report->expand)) {
604 … $vObject = VObject\Reader::read($properties[200]['{' . self::NS_CALDAV . '}calendar-data']);
606 if ($report->expand) {
607 … $vObject->expand($report->expand['start'], $report->expand['end'], $calendarTimeZone);
611 …$properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = json_encode($vObject->jsonSerialize()…
613 … $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize();
622 $prefer = $this->server->getHTTPPrefer();
624 $this->server->httpResponse->setStatus(207);
625 $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
626 $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer');
627 …$this->server->httpResponse->setBody($this->server->generateMultiStatus($result, $prefer['return']…
633 * response for the CALDAV:free-busy-query REPORT.
640 $uri = $this->server->getRequestUri();
642 $acl = $this->server->getPlugin('acl');
644 $acl->checkPrivileges($uri, '{' . self::NS_CALDAV . '}read-free-busy');
647 $calendar = $this->server->tree->getNodeForPath($uri);
649 …throw new DAV\Exception\NotImplemented('The free-busy-query REPORT is only implemented on calendar…
652 $tzProp = '{' . self::NS_CALDAV . '}calendar-timezone';
656 $calendarProps = $this->server->getProperties($uri, [$tzProp]);
660 $calendarTimeZone = $vtimezoneObj->VTIMEZONE->getTimeZone();
665 // Doing a calendar-query first, to make sure we get the most
667 $urls = $calendar->calendarQuery([
669 'comp-filters' => [
672 'comp-filters' => [],
673 'prop-filters' => [],
674 'is-not-defined' => false,
675 'time-range' => [
676 'start' => $report->start,
677 'end' => $report->end,
681 'prop-filters' => [],
682 'is-not-defined' => false,
683 'time-range' => null,
687 $obj = $calendar->getChild($url)->get();
692 $generator->setObjects($objects);
693 $generator->setTimeRange($report->start, $report->end);
694 $generator->setTimeZone($calendarTimeZone);
695 $result = $generator->getResult();
696 $result = $result->serialize();
698 $this->server->httpResponse->setStatus(200);
699 $this->server->httpResponse->setHeader('Content-Type', 'text/calendar');
700 $this->server->httpResponse->setHeader('Content-Length', strlen($result));
701 $this->server->httpResponse->setBody($result);
725 // for non-calendars (such as an inbox).
727 $parentNode = $this->server->tree->getNodeForPath($parent);
732 $this->validateICalendar(
736 $this->server->httpRequest,
737 $this->server->httpResponse,
761 $this->validateICalendar(
765 $this->server->httpRequest,
766 $this->server->httpResponse,
808 $data = $vobj->serialize();
816 …ediaType('This resource only supports valid iCalendar 2.0 data. Parse error: ' . $e->getMessage());
820 if ($vobj->name !== 'VCALENDAR') {
824 $sCCS = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set';
828 $calendarProperties = $this->server->getProperties($parentPath, [$sCCS]);
831 $supportedComponents = $calendarProperties[$sCCS]->getValue();
838 foreach ($vobj->getComponents() as $component) {
839 switch ($component->name) {
846 $foundType = $component->name;
850 if (!isset($component->UID)) {
851 … throw new DAV\Exception\BadRequest('Every ' . $component->name . ' component must have an UID');
853 $foundUID = (string)$component->UID;
855 if ($foundType !== $component->name) {
856 …('A calendar object must only contain 1 component. We found a ' . $component->name . ' as well as …
858 if ($foundUID !== (string)$component->UID) {
859 …throw new DAV\Exception\BadRequest('Every ' . $component->name . ' in this object must have identi…
864 …tion\BadRequest('You are not allowed to create components of type: ' . $component->name . ' here');
874 // This helps us determine if we need to re-serialize the object.
877 $this->server->emit(
891 $data = $vobj->serialize();
942 if (strpos($response->getHeader('Content-Type'), 'text/calendar') === false) {
947 $request->getHeader('Accept'),
957 $vobj = VObject\Reader::read($response->getBody());
959 $jsonBody = json_encode($vobj->jsonSerialize());
960 $response->setBody($jsonBody);
962 $response->setHeader('Content-Type', 'application/calendar+json');
963 $response->setHeader('Content-Length', strlen($jsonBody));
968 * Returns a bunch of meta-data about the plugin.
981 'name' => $this->getPluginName(),