Blame view
sources/apps/contacts/appinfo/remote.php
2.71 KB
|
d1bafeea1
|
1 2 3 4 5 |
<?php /** * ownCloud - Addressbook * * @author Jakob Sack |
|
6d9380f96
|
6 |
* @author Thomas Tanghus |
|
d1bafeea1
|
7 |
* @copyright 2011 Jakob Sack mail@jakobsack.de |
|
6d9380f96
|
8 |
* @copyright 2011-2014 Thomas Tanghus (thomas@tanghus.net) |
|
d1bafeea1
|
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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 library. If not, see <http://www.gnu.org/licenses/>.
*
*/
OCP\App::checkAppEnabled('contacts');
|
|
6d9380f96
|
26 |
if (substr(OCP\Util::getRequestUri(), 0, strlen(OC_App::getAppWebPath('contacts').'/carddav.php'))
|
|
d1bafeea1
|
27 28 29 30 31 32 |
=== OC_App::getAppWebPath('contacts').'/carddav.php'
) {
$baseuri = OC_App::getAppWebPath('contacts').'/carddav.php';
}
// only need authentication apps
|
|
6d9380f96
|
33 |
$RUNTIME_APPTYPES = array('authentication');
|
|
d1bafeea1
|
34 35 36 37 38 39 40 41 |
OC_App::loadApps($RUNTIME_APPTYPES); // Backends $authBackend = new OC_Connector_Sabre_Auth(); $principalBackend = new OC_Connector_Sabre_Principal(); $addressbookbackends = array(); $addressbookbackends[] = new OCA\Contacts\Backend\Database(\OCP\User::getUser()); |
|
6d9380f96
|
42 43 44 45 46 |
$backends = array('local', 'shared');
if (\OCP\Config::getAppValue('contacts', 'backend_ldap', "false") === "true") {
$backends[] = 'ldap';
}
$carddavBackend = new OCA\Contacts\CardDAV\Backend($backends);
|
|
d1bafeea1
|
47 48 49 |
$requestBackend = new OC_Connector_Sabre_Request(); // Root nodes |
|
6d9380f96
|
50 |
$principalCollection = new \Sabre\CalDAV\Principal\Collection($principalBackend); |
|
d1bafeea1
|
51 52 53 54 55 56 57 58 |
$principalCollection->disableListing = true; // Disable listing $addressBookRoot = new OCA\Contacts\CardDAV\AddressBookRoot($principalBackend, $carddavBackend); $addressBookRoot->disableListing = true; // Disable listing $nodes = array( $principalCollection, $addressBookRoot, |
|
6d9380f96
|
59 |
); |
|
d1bafeea1
|
60 61 |
// Fire up server |
|
6d9380f96
|
62 |
$server = new \Sabre\DAV\Server($nodes); |
|
d1bafeea1
|
63 64 65 |
$server->httpRequest = $requestBackend; $server->setBaseUri($baseuri); // Add plugins |
|
6d9380f96
|
66 |
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, 'ownCloud')); |
|
d1bafeea1
|
67 |
$server->addPlugin(new OCA\Contacts\CardDAV\Plugin()); |
|
6d9380f96
|
68 69 70 71 |
$server->addPlugin(new \Sabre\DAVACL\Plugin());
$server->addPlugin(new \Sabre\DAV\Browser\Plugin(false)); // Show something in the Browser, but no upload
$server->addPlugin(new \Sabre\CardDAV\VCFExportPlugin());
$server->addPlugin(new OC_Connector_Sabre_ExceptionLoggerPlugin('carddav'));
|
|
d1bafeea1
|
72 |
|
|
6d9380f96
|
73 |
if (defined('DEBUG') && DEBUG) {
|
|
d1bafeea1
|
74 75 |
$server->debugExceptions = true; } |
|
6d9380f96
|
76 |
|
|
d1bafeea1
|
77 78 |
// And off we go! $server->exec(); |