user and system addressbooks are now living in sub folders
This commit is contained in:
parent
dcfd089a6c
commit
6a2dde6400
|
@ -100,6 +100,7 @@ class SyncSystemAddressBook extends Command {
|
|||
}
|
||||
}
|
||||
$progress->finish();
|
||||
$output->writeln('');
|
||||
}
|
||||
|
||||
protected function ensureSystemAddressBookExists() {
|
||||
|
@ -107,7 +108,7 @@ class SyncSystemAddressBook extends Command {
|
|||
if (!is_null($book)) {
|
||||
return $book;
|
||||
}
|
||||
$systemPrincipal = "principals/system";
|
||||
$systemPrincipal = "principals/system/system";
|
||||
$this->backend->createAddressBook($systemPrincipal, 'system', [
|
||||
'{' . Plugin::NS_CARDDAV . '}addressbook-description' => 'System addressbook which holds all users of this instance'
|
||||
]);
|
||||
|
|
|
@ -54,7 +54,7 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareableAddres
|
|||
|
||||
function getACL() {
|
||||
$acl = parent::getACL();
|
||||
if ($this->getOwner() === 'principals/system') {
|
||||
if ($this->getOwner() === 'principals/system/system') {
|
||||
$acl[] = [
|
||||
'privilege' => '{DAV:}read',
|
||||
'principal' => '{DAV:}authenticated',
|
||||
|
@ -67,7 +67,7 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareableAddres
|
|||
|
||||
function getChildACL() {
|
||||
$acl = parent::getChildACL();
|
||||
if ($this->getOwner() === 'principals/system') {
|
||||
if ($this->getOwner() === 'principals/system/system') {
|
||||
$acl[] = [
|
||||
'privilege' => '{DAV:}read',
|
||||
'principal' => '{DAV:}authenticated',
|
||||
|
|
|
@ -20,4 +20,14 @@ class AddressBookRoot extends \Sabre\CardDAV\AddressBookRoot {
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
function getName() {
|
||||
|
||||
// Grabbing all the components of the principal path.
|
||||
$parts = explode('/', $this->principalPrefix);
|
||||
|
||||
// We are only interested in the second part.
|
||||
return $parts[1];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
||||
*
|
||||
* @copyright Copyright (c) 2015, ownCloud, Inc.
|
||||
* @license AGPL-3.0
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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, version 3,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\DAV\CardDAV;
|
||||
|
||||
use Sabre\HTTP\URLUtil;
|
||||
|
||||
class Plugin extends \Sabre\CardDAV\Plugin {
|
||||
|
||||
/**
|
||||
* Returns the addressbook home for a given principal
|
||||
*
|
||||
* @param string $principal
|
||||
* @return string
|
||||
*/
|
||||
protected function getAddressbookHomeForPrincipal($principal) {
|
||||
|
||||
if (strrpos($principal, 'principals/users', -strlen($principal)) !== FALSE) {
|
||||
list(, $principalId) = URLUtil::splitPath($principal);
|
||||
return self::ADDRESSBOOK_ROOT . '/users/' . $principalId;
|
||||
}
|
||||
if (strrpos($principal, 'principals/system', -strlen($principal)) !== FALSE) {
|
||||
list(, $principalId) = URLUtil::splitPath($principal);
|
||||
return self::ADDRESSBOOK_ROOT . '/system/' . $principalId;
|
||||
}
|
||||
|
||||
throw new \LogicException('This is not supposed to happen');
|
||||
}
|
||||
}
|
|
@ -11,12 +11,12 @@ class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome {
|
|||
*/
|
||||
function getChildren() {
|
||||
|
||||
$addressbooks = $this->carddavBackend->getAddressBooksForUser($this->principalUri);
|
||||
$objs = [];
|
||||
foreach($addressbooks as $addressbook) {
|
||||
$objs[] = new AddressBook($this->carddavBackend, $addressbook);
|
||||
$addressBooks = $this->carddavBackend->getAddressBooksForUser($this->principalUri);
|
||||
$objects = [];
|
||||
foreach($addressBooks as $addressBook) {
|
||||
$objects[] = new AddressBook($this->carddavBackend, $addressBook);
|
||||
}
|
||||
return $objs;
|
||||
return $objects;
|
||||
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome {
|
|||
function getACL() {
|
||||
|
||||
$acl = parent::getACL();
|
||||
if ($this->principalUri === 'principals/system') {
|
||||
if ($this->principalUri === 'principals/system/system') {
|
||||
$acl[] = [
|
||||
'privilege' => '{DAV:}read',
|
||||
'principal' => '{DAV:}authenticated',
|
||||
|
|
|
@ -34,10 +34,13 @@ class RootCollection extends SimpleCollection {
|
|||
$calendarRoot = new CalendarRoot($principalBackend, $caldavBackend, 'principals/users');
|
||||
$calendarRoot->disableListing = $disableListing;
|
||||
|
||||
$cardDavBackend = new CardDavBackend(\OC::$server->getDatabaseConnection(), $principalBackend);
|
||||
$usersCardDavBackend = new CardDavBackend($db, $principalBackend);
|
||||
$usersAddressBookRoot = new AddressBookRoot($principalBackend, $usersCardDavBackend, 'principals/users');
|
||||
$usersAddressBookRoot->disableListing = $disableListing;
|
||||
|
||||
$addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend, 'principals/users');
|
||||
$addressBookRoot->disableListing = $disableListing;
|
||||
$systemCardDavBackend = new CardDavBackend($db, $principalBackend);
|
||||
$systemAddressBookRoot = new AddressBookRoot(new SystemPrincipalBackend(), $systemCardDavBackend, 'principals/system');
|
||||
$systemAddressBookRoot->disableListing = $disableListing;
|
||||
|
||||
$children = [
|
||||
new SimpleCollection('principals', [
|
||||
|
@ -45,7 +48,9 @@ class RootCollection extends SimpleCollection {
|
|||
$systemPrincipals]),
|
||||
$filesCollection,
|
||||
$calendarRoot,
|
||||
$addressBookRoot,
|
||||
new SimpleCollection('addressbooks', [
|
||||
$usersAddressBookRoot,
|
||||
$systemAddressBookRoot]),
|
||||
];
|
||||
|
||||
parent::__construct('root', $children);
|
||||
|
|
|
@ -58,7 +58,7 @@ class Server {
|
|||
$this->server->addPlugin(new CardDAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
|
||||
|
||||
// addressbook plugins
|
||||
$this->server->addPlugin(new \Sabre\CardDAV\Plugin());
|
||||
$this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());
|
||||
|
||||
// Finder on OS X requires Class 2 WebDAV support (locking), since we do
|
||||
// not provide locking we emulate it using a fake locking plugin.
|
||||
|
|
Loading…
Reference in New Issue