/** * This event is triggered when fetching properties. * * This event is scheduled late in the process, after most work for * propfind has been done. */ function propFindLate(DAV\PropFind $propFind, DAV\INode $node) { // If the request was made using the SOGO connector, we must rewrite // the content-type property. By default SabreDAV will send back // text/x-vcard; charset=utf-8, but for SOGO we must strip that last // part. if (strpos($this->server->httpRequest->getHeader('User-Agent'), 'Thunderbird') === false) { return; } $contentType = $propFind->get('{DAV:}getcontenttype'); list($part) = explode(';', $contentType); if ($part === 'text/x-vcard' || $part === 'text/vcard') { $propFind->set('{DAV:}getcontenttype', 'text/x-vcard'); } }
/** * This method is triggered *after* all properties have been retrieved. * This allows us to inject the correct resourcetype for calendars that * have been shared. * * @param DAV\PropFind $propFind * @param DAV\INode $node * @return void */ function propFindLate(DAV\PropFind $propFind, DAV\INode $node) { if ($node instanceof IShareableCalendar) { if ($rt = $propFind->get('{DAV:}resourcetype')) { if (count($node->getShares()) > 0) { $rt->add('{' . Plugin::NS_CALENDARSERVER . '}shared-owner'); } } $propFind->handle('{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes', function () { return new Xml\Property\AllowedSharingModes(true, false); }); } }
/** * This method is called when properties are retrieved. * * This specific handler is called very late in the process, because we * want other systems to first have a chance to handle the properties. * * @param PropFind $propFind * @param INode $node * @return void */ function propFindLate(PropFind $propFind, INode $node) { $propFind->handle('{http://calendarserver.org/ns/}getctag', function () use($propFind) { // If we already have a sync-token from the current propFind // request, we can re-use that. $val = $propFind->get('{http://sabredav.org/ns}sync-token'); if ($val) { return $val; } $val = $propFind->get('{DAV:}sync-token'); if ($val && is_scalar($val)) { return $val; } if ($val && $val instanceof Property\IHref) { return substr($val->getHref(), strlen(Sync\Plugin::SYNCTOKEN_PREFIX)); } // If we got here, the earlier two properties may simply not have // been part of the earlier request. We're going to fetch them. $result = $this->server->getProperties($propFind->getPath(), ['{http://sabredav.org/ns}sync-token', '{DAV:}sync-token']); if (isset($result['{http://sabredav.org/ns}sync-token'])) { return $result['{http://sabredav.org/ns}sync-token']; } if (isset($result['{DAV:}sync-token'])) { $val = $result['{DAV:}sync-token']; if (is_scalar($val)) { return $val; } elseif ($val instanceof Property\IHref) { return substr($val->getHref(), strlen(Sync\Plugin::SYNCTOKEN_PREFIX)); } } }); }
/** * This method is triggered *after* all properties have been retrieved. * This allows us to inject the correct resourcetype for calendars that * have been shared. * * @param DAV\PropFind $propFind * @param DAV\INode $node * @return void */ function propFindLate(DAV\PropFind $propFind, DAV\INode $node) { if ($node instanceof ISharedCalendar) { $shareAccess = $node->getShareAccess(); if ($rt = $propFind->get('{DAV:}resourcetype')) { switch ($shareAccess) { case \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER: $rt->add('{' . Plugin::NS_CALENDARSERVER . '}shared-owner'); break; case \Sabre\DAV\Sharing\Plugin::ACCESS_READ: case \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE: $rt->add('{' . Plugin::NS_CALENDARSERVER . '}shared'); break; } } $propFind->handle('{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes', function () { return new Xml\Property\AllowedSharingModes(true, false); }); } }