summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-08-11 11:07:36 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-08-11 11:07:36 (GMT)
commitf612a5d7916a24d3b5fa23d21b15728b3c910b2b (patch)
treee34db35a7fa76f015708216291ad5e707367a5d3
parent6ad5a347b6d3ff77ac7f378db99462504f1bda45 (diff)
downloadiRony-f612a5d7916a24d3b5fa23d21b15728b3c910b2b.tar.gz
Return (fake) principal properties for owners of shared folders (#3058)
-rw-r--r--lib/Kolab/CalDAV/Principal/Collection.php38
-rw-r--r--lib/Kolab/CalDAV/Principal/User.php46
-rw-r--r--lib/Kolab/DAVACL/PrincipalBackend.php10
-rw-r--r--public_html/index.php2
4 files changed, 95 insertions, 1 deletions
diff --git a/lib/Kolab/CalDAV/Principal/Collection.php b/lib/Kolab/CalDAV/Principal/Collection.php
new file mode 100644
index 0000000..52e0b14
--- /dev/null
+++ b/lib/Kolab/CalDAV/Principal/Collection.php
@@ -0,0 +1,38 @@
+<?php
+
+/**
+ * SabreDAV Principal Collection derived class for the Kolab service.
+ *
+ * @author Thomas Bruederli <bruederli@kolabsys.com>
+ *
+ * Copyright (C) 2014, Kolab Systems AG <contact@kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Kolab\CalDAV\Principal;
+
+class Collection extends \Sabre\CalDAV\Principal\Collection
+{
+ /**
+ * Returns a child object based on principal information
+ *
+ * @param array $principalInfo
+ * @return User
+ */
+ public function getChildForPrincipal(array $principalInfo)
+ {
+ return new User($this->principalBackend, $principalInfo);
+ }
+} \ No newline at end of file
diff --git a/lib/Kolab/CalDAV/Principal/User.php b/lib/Kolab/CalDAV/Principal/User.php
new file mode 100644
index 0000000..aa8a247
--- /dev/null
+++ b/lib/Kolab/CalDAV/Principal/User.php
@@ -0,0 +1,46 @@
+<?php
+
+/**
+ * SabreDAV Principal User derived class for the Kolab service.
+ *
+ * @author Thomas Bruederli <bruederli@kolabsys.com>
+ *
+ * Copyright (C) 2014, Kolab Systems AG <contact@kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Kolab\CalDAV\Principal;
+
+class User extends \Sabre\CalDAV\Principal\User
+{
+ /**
+ * Returns a list of ACE's for this node.
+ *
+ * Adds {DAV:}read for {DAV:}authenticated to enable access to
+ * principal records which are listed as owner of shared folders.
+ *
+ * @return array
+ */
+ public function getACL()
+ {
+ $acl = parent::getACL();
+ $acl[] = array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => '{DAV:}authenticated',
+ 'protected' => true,
+ );
+ return $acl;
+ }
+} \ No newline at end of file
diff --git a/lib/Kolab/DAVACL/PrincipalBackend.php b/lib/Kolab/DAVACL/PrincipalBackend.php
index bf19c44..908aca3 100644
--- a/lib/Kolab/DAVACL/PrincipalBackend.php
+++ b/lib/Kolab/DAVACL/PrincipalBackend.php
@@ -113,6 +113,16 @@ class PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend\BackendInterfac
if ($prefix == 'principals' && $name == HTTPBasic::$current_user) {
return $this->getCurrentUser();
}
+ else if ($prefix == 'principals' && \rcube_utils::check_email($name, false)) {
+ // TODO: do a user lookup in LDAP
+ list($localname,$domain) = explode('@', $name);
+ return array(
+ 'uri' => $path,
+ '{DAV:}displayname' => $localname,
+ '{http://sabredav.org/ns}email-address' => $name,
+ '{http://calendarserver.org/ns/}email-address-set' => $name,
+ );
+ }
return null;
}
diff --git a/public_html/index.php b/public_html/index.php
index c7e55ee..04e7f53 100644
--- a/public_html/index.php
+++ b/public_html/index.php
@@ -118,7 +118,7 @@ if ($services['WEBDAV']) {
// This is an array which contains the 'top-level' directories in the WebDAV server.
if ($services['CALDAV'] || $services['CARDDAV']) {
$nodes = array(
- new \Sabre\CalDAV\Principal\Collection($principal_backend),
+ new \Kolab\CalDAV\Principal\Collection($principal_backend),
);
if ($services['CALDAV']) {