2015-11-05 15:46:37 +00:00
|
|
|
<?php
|
2016-01-12 14:02:16 +00:00
|
|
|
/**
|
2016-07-21 14:49:16 +00:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2016-01-12 14:02:16 +00:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
|
|
|
*
|
|
|
|
* @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/>
|
|
|
|
*
|
|
|
|
*/
|
2015-11-05 15:46:37 +00:00
|
|
|
namespace OCA\DAV\CardDAV;
|
|
|
|
|
2016-09-20 12:15:23 +00:00
|
|
|
use OCP\IL10N;
|
|
|
|
|
2015-11-05 15:46:37 +00:00
|
|
|
class AddressBookRoot extends \Sabre\CardDAV\AddressBookRoot {
|
|
|
|
|
2016-09-20 12:15:23 +00:00
|
|
|
/** @var IL10N */
|
|
|
|
protected $l10n;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param \Sabre\DAVACL\PrincipalBackend\BackendInterface $principalBackend
|
|
|
|
* @param \Sabre\CardDAV\Backend\BackendInterface $carddavBackend
|
|
|
|
* @param string $principalPrefix
|
|
|
|
*/
|
|
|
|
public function __construct(\Sabre\DAVACL\PrincipalBackend\BackendInterface $principalBackend, \Sabre\CardDAV\Backend\BackendInterface $carddavBackend, $principalPrefix = 'principals') {
|
|
|
|
parent::__construct($principalBackend, $carddavBackend, $principalPrefix);
|
|
|
|
$this->l10n = \OC::$server->getL10N('dav');
|
|
|
|
}
|
|
|
|
|
2015-11-05 15:46:37 +00:00
|
|
|
/**
|
|
|
|
* This method returns a node for a principal.
|
|
|
|
*
|
|
|
|
* The passed array contains principal information, and is guaranteed to
|
|
|
|
* at least contain a uri item. Other properties may or may not be
|
|
|
|
* supplied by the authentication backend.
|
|
|
|
*
|
|
|
|
* @param array $principal
|
|
|
|
* @return \Sabre\DAV\INode
|
|
|
|
*/
|
|
|
|
function getChildForPrincipal(array $principal) {
|
|
|
|
|
2016-09-20 12:15:23 +00:00
|
|
|
return new UserAddressBooks($this->carddavBackend, $principal['uri'], $this->l10n);
|
2015-11-05 15:46:37 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-11-27 12:14:55 +00:00
|
|
|
function getName() {
|
|
|
|
|
2016-01-20 20:08:23 +00:00
|
|
|
if ($this->principalPrefix === 'principals') {
|
|
|
|
return parent::getName();
|
|
|
|
}
|
2015-11-27 12:14:55 +00:00
|
|
|
// Grabbing all the components of the principal path.
|
|
|
|
$parts = explode('/', $this->principalPrefix);
|
|
|
|
|
|
|
|
// We are only interested in the second part.
|
|
|
|
return $parts[1];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|