summaryrefslogtreecommitdiff
path: root/lib/Kolab/CardDAV/UserAddressBooks.php
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-03-12 11:13:27 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-03-13 09:18:42 (GMT)
commit3fe616421a8d7340b4dd29ce56dafec4733d4d3c (patch)
treece37ebf1c32e4a716b205d52b4867f590fdb5638 /lib/Kolab/CardDAV/UserAddressBooks.php
parent12e71c361fce1e132d35d29d2001f69c34be5e3e (diff)
downloadiRony-3fe616421a8d7340b4dd29ce56dafec4733d4d3c.tar.gz
Implement the CardDAV Directory Gateway Extension for Apple clients (and SOGo connector).
This exposes an LDAP-based address book inside the principals address book collection. According to the spec [1], this should be used for querying only. Listing, however, can be enabled by setting 'searchonly' => false in config. CARDDAV:addressbook-query requests will be translated into LDAP filters and post-processed by SabreDAV internals. [1] http://tools.ietf.org/html/draft-daboo-carddav-directory-gateway-02
Diffstat (limited to 'lib/Kolab/CardDAV/UserAddressBooks.php')
-rw-r--r--lib/Kolab/CardDAV/UserAddressBooks.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/Kolab/CardDAV/UserAddressBooks.php b/lib/Kolab/CardDAV/UserAddressBooks.php
index 02707f0..db71bbe 100644
--- a/lib/Kolab/CardDAV/UserAddressBooks.php
+++ b/lib/Kolab/CardDAV/UserAddressBooks.php
@@ -23,6 +23,7 @@
namespace Kolab\CardDAV;
+use \rcube;
use Sabre\DAV;
use Sabre\DAVACL;
@@ -33,6 +34,9 @@ use Sabre\DAVACL;
*/
class UserAddressBooks extends \Sabre\CardDAV\UserAddressBooks implements DAV\IExtendedCollection, DAVACL\IACL
{
+ // pseudo-singleton instance
+ private $ldap_directory;
+
/**
* Returns a list of addressbooks
*
@@ -45,6 +49,11 @@ class UserAddressBooks extends \Sabre\CardDAV\UserAddressBooks implements DAV\IE
foreach($addressbooks as $addressbook) {
$objs[] = new AddressBook($this->carddavBackend, $addressbook);
}
+
+ if (rcube::get_instance()->config->get('global_ldap_directory')) {
+ $objs[] = $this->getLDAPDirectory();
+ }
+
return $objs;
}
@@ -56,6 +65,10 @@ class UserAddressBooks extends \Sabre\CardDAV\UserAddressBooks implements DAV\IE
*/
public function getChild($name)
{
+ if ($name == LDAPDirectory::DIRECTORY_NAME) {
+ return $this->getLDAPDirectory();
+ }
+
if ($addressbook = $this->carddavBackend->getAddressBookByName($name)) {
$addressbook['principaluri'] = $this->principalUri;
return new AddressBook($this->carddavBackend, $addressbook);
@@ -64,4 +77,18 @@ class UserAddressBooks extends \Sabre\CardDAV\UserAddressBooks implements DAV\IE
throw new DAV\Exception\NotFound('Addressbook with name \'' . $name . '\' could not be found');
}
+ /**
+ * Getter for the singleton instance of the LDAP directory
+ */
+ private function getLDAPDirectory()
+ {
+ if (!$this->ldap_directory) {
+ $rcube = rcube::get_instance();
+ $config = $rcube->config->get('global_ldap_directory');
+ $config['debug'] = $rcube->config->get('ldap_debug');
+ $this->ldap_directory = new LDAPDirectory($config, $this->principalUri, $this->carddavBackend);
+ }
+
+ return $this->ldap_directory;
+ }
}