1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Christoph Wurst <[email protected]> |
4
|
|
|
* @author Georg Ehrke <[email protected]> |
5
|
|
|
* @author Joas Schilling <[email protected]> |
6
|
|
|
* @author Lukas Reschke <[email protected]> |
7
|
|
|
* @author Thomas Müller <[email protected]> |
8
|
|
|
* |
9
|
|
|
* @copyright Copyright (c) 2018, ownCloud GmbH |
10
|
|
|
* @license AGPL-3.0 |
11
|
|
|
* |
12
|
|
|
* This code is free software: you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
14
|
|
|
* as published by the Free Software Foundation. |
15
|
|
|
* |
16
|
|
|
* This program is distributed in the hope that it will be useful, |
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19
|
|
|
* GNU Affero General Public License for more details. |
20
|
|
|
* |
21
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
23
|
|
|
* |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
// Backends |
27
|
|
|
use OCA\DAV\CardDAV\AddressBookRoot; |
28
|
|
|
use OCA\DAV\CardDAV\CardDavBackend; |
29
|
|
|
use OCA\DAV\Connector\LegacyDAVACL; |
30
|
|
|
use OCA\DAV\Connector\Sabre\Auth; |
31
|
|
|
use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin; |
32
|
|
|
use OCA\DAV\Connector\Sabre\MaintenancePlugin; |
33
|
|
|
use OCA\DAV\Connector\Sabre\Principal; |
34
|
|
|
use Sabre\CardDAV\Plugin; |
35
|
|
|
|
36
|
|
|
$authBackend = new Auth( |
37
|
|
|
\OC::$server->getSession(), |
38
|
|
|
\OC::$server->getUserSession(), |
39
|
|
|
\OC::$server->getRequest(), |
40
|
|
|
\OC::$server->getTwoFactorAuthManager(), |
41
|
|
|
\OC::$server->getAccountModuleManager(), |
42
|
|
|
'principals/' |
43
|
|
|
); |
44
|
|
|
$principalBackend = new Principal( |
45
|
|
|
\OC::$server->getUserManager(), |
46
|
|
|
\OC::$server->getGroupManager(), |
47
|
|
|
'principals/' |
48
|
|
|
); |
49
|
|
|
$groupPrincipalBackend = new \OCA\DAV\DAV\GroupPrincipalBackend( |
50
|
|
|
\OC::$server->getGroupManager() |
51
|
|
|
); |
52
|
|
|
$db = \OC::$server->getDatabaseConnection(); |
53
|
|
|
$cardDavBackend = new CardDavBackend($db, $principalBackend, $groupPrincipalBackend, null, true); |
54
|
|
|
|
55
|
|
|
$debugging = \OC::$server->getConfig()->getSystemValue('debug', false); |
56
|
|
|
|
57
|
|
|
// Root nodes |
58
|
|
|
$principalCollection = new \Sabre\CalDAV\Principal\Collection($principalBackend); |
59
|
|
|
$principalCollection->disableListing = !$debugging; // Disable listing |
60
|
|
|
|
61
|
|
|
$addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend); |
62
|
|
|
$addressBookRoot->disableListing = !$debugging; // Disable listing |
63
|
|
|
|
64
|
|
|
$nodes = [ |
65
|
|
|
$principalCollection, |
66
|
|
|
$addressBookRoot, |
67
|
|
|
]; |
68
|
|
|
|
69
|
|
|
// Fire up server |
70
|
|
|
$server = new \Sabre\DAV\Server($nodes); |
71
|
|
|
$server->httpRequest->setUrl(\OC::$server->getRequest()->getRequestUri()); |
72
|
|
|
$server->setBaseUri($baseuri); |
73
|
|
|
// Add plugins |
74
|
|
|
$server->addPlugin(new MaintenancePlugin()); |
75
|
|
|
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend)); |
76
|
|
|
$server->addPlugin(new Plugin()); |
77
|
|
|
|
78
|
|
|
$server->addPlugin(new LegacyDAVACL()); |
79
|
|
|
if ($debugging) { |
80
|
|
|
$server->addPlugin(new Sabre\DAV\Browser\Plugin()); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
$server->addPlugin(new Sabre\DAV\Sync\Plugin()); |
84
|
|
|
$server->addPlugin(new \Sabre\CardDAV\VCFExportPlugin()); |
85
|
|
|
$server->addPlugin(new \OCA\DAV\CardDAV\ImageExportPlugin(\OC::$server->getLogger())); |
86
|
|
|
$server->addPlugin(new ExceptionLoggerPlugin('carddav', \OC::$server->getLogger())); |
87
|
|
|
|
88
|
|
|
// And off we go! |
89
|
|
|
$server->exec(); |
|
|
|
|
90
|
|
|
|
This method has been deprecated.