[Pkg-owncloud-commits] [php-sabredav] 14/163: Allowing easier overriding of the addressbook home.

David Prévot taffit at moszumanska.debian.org
Tue May 20 18:54:49 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag upstream/2.0.0_beta1
in repository php-sabredav.

commit 1702fb8c06b4b13b3ec2c77375ae3eda507fc229
Author: Evert Pot <evert at rooftopsolutions.nl>
Date:   Tue Feb 25 19:47:52 2014 -0500

    Allowing easier overriding of the addressbook home.
---
 ChangeLog.md                 |  6 ++++++
 lib/Sabre/CardDAV/Plugin.php | 20 ++++++++++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index c14a365..e96f094 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,6 +1,12 @@
 ChangeLog
 =========
 
+1.9.0-alpha3 (????-??-??)
+-------------------------
+
+* Making it easier for implementors to override how the CardDAV addressbook
+  home is located.
+
 1.9.0-alpha2 (2014-01-14)
 -------------------------
 
diff --git a/lib/Sabre/CardDAV/Plugin.php b/lib/Sabre/CardDAV/Plugin.php
index 86db7fb..54761d9 100644
--- a/lib/Sabre/CardDAV/Plugin.php
+++ b/lib/Sabre/CardDAV/Plugin.php
@@ -132,10 +132,9 @@ class Plugin extends DAV\ServerPlugin {
             // calendar-home-set property
             $addHome = '{' . self::NS_CARDDAV . '}addressbook-home-set';
             if (in_array($addHome,$requestedProperties)) {
-                $principalId = $node->getName();
-                $addressbookHomePath = self::ADDRESSBOOK_ROOT . '/' . $principalId . '/';
+
                 unset($requestedProperties[array_search($addHome, $requestedProperties)]);
-                $returnedProperties[200][$addHome] = new DAV\Property\Href($addressbookHomePath);
+                $returnedProperties[200][$addHome] = new DAV\Property\Href($this->getAddressBookHomeForPrincipal($path) . '/');
             }
 
             $directories = '{' . self::NS_CARDDAV . '}directory-gateway';
@@ -263,6 +262,20 @@ class Plugin extends DAV\ServerPlugin {
     }
 
     /**
+     * Returns the addressbook home for a given principal
+     *
+     * @param string $principal
+     * @return string
+     */
+    protected function getAddressbookHomeForPrincipal($principal) {
+
+        list(, $principalId) = \Sabre\HTTP\URLUtil::splitPath($principal);
+        return self::ADDRESSBOOK_ROOT . '/' . $principalId;
+
+    }
+
+
+    /**
      * This function handles the addressbook-multiget REPORT.
      *
      * This report is used by the client to fetch the content of a series
@@ -719,5 +732,4 @@ class Plugin extends DAV\ServerPlugin {
         return false;
 
     }
-
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git



More information about the Pkg-owncloud-commits mailing list