]> git.mxchange.org Git - friendica-addons.git/blob - dav/FriendicaACLPlugin.inc.php
Merge branch 'master' of git://github.com/friendica/friendica-addons
[friendica-addons.git] / dav / FriendicaACLPlugin.inc.php
1 <?php
2
3 class Sabre_DAVACL_Plugin_Friendica extends Sabre_DAVACL_Plugin {
4
5         /*
6          * A dirty hack to make iOS CalDAV work with subdirectorys.
7          * When using a Root URL like /dav/ (as it is necessary for friendica), iOS does not evaluate the current-user-principal property,
8          * but only principal-URL. Actually principal-URL is not allowed in /dav/, only for Principal collections, but this seems
9          * to be the only way to force iOS to look at the right location.
10          */
11
12         public function beforeGetProperties($uri, Sabre_DAV_INode $node, &$requestedProperties, &$returnedProperties) {
13
14                 parent::beforeGetProperties($uri, $node, $requestedProperties, $returnedProperties);
15
16                 if (false !== ($index = array_search('{DAV:}principal-URL', $requestedProperties))) {
17
18                         unset($requestedProperties[$index]);
19                         $returnedProperties[200]['{DAV:}principal-URL'] = new Sabre_DAV_Property_Href('principals/users/' . strtolower($_SERVER["PHP_AUTH_USER"]) . '/');
20
21                 }
22                 if (false !== ($index = array_search('{urn:ietf:params:xml:ns:caldav}calendar-home-set', $requestedProperties))) {
23
24                         unset($requestedProperties[$index]);
25                         $returnedProperties[200]['{urn:ietf:params:xml:ns:caldav}calendar-home-set'] = new Sabre_DAV_Property_Href('calendars/' . strtolower($_SERVER["PHP_AUTH_USER"]) . '/');
26
27                 }
28
29         }
30
31 }