Completed
Push — master ( 64a4da...21cb6b )
by Thomas
07:39
created

RootCollection   B

Complexity

Total Complexity 1

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 17

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 76
rs 7.8571
wmc 1
lcom 0
cbo 17

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 72 1
1
<?php
2
/**
3
 * @author Arthur Schiwon <[email protected]>
4
 * @author Joas Schilling <[email protected]>
5
 * @author Thomas Müller <[email protected]>
6
 * @author Vincent Petry <[email protected]>
7
 *
8
 * @copyright Copyright (c) 2016, ownCloud GmbH.
9
 * @license AGPL-3.0
10
 *
11
 * This code is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License, version 3,
13
 * as published by the Free Software Foundation.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU Affero General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Affero General Public License, version 3,
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
22
 *
23
 */
24
namespace OCA\DAV;
25
26
use OCA\DAV\CalDAV\CalDavBackend;
27
use OCA\DAV\CalDAV\CalendarRoot;
28
use OCA\DAV\CalDAV\PublicCalendarRoot;
29
use OCA\DAV\CardDAV\AddressBookRoot;
30
use OCA\DAV\CardDAV\CardDavBackend;
31
use OCA\DAV\Connector\Sabre\Principal;
32
use OCA\DAV\DAV\GroupPrincipalBackend;
33
use OCA\DAV\DAV\SystemPrincipalBackend;
34
use Sabre\CalDAV\Principal\Collection;
35
use Sabre\DAV\SimpleCollection;
36
37
class RootCollection extends SimpleCollection {
38
39
	public function __construct() {
40
		$config = \OC::$server->getConfig();
41
		$random = \OC::$server->getSecureRandom();
42
		$db = \OC::$server->getDatabaseConnection();
43
		$dispatcher = \OC::$server->getEventDispatcher();
44
		$userPrincipalBackend = new Principal(
45
			\OC::$server->getUserManager(),
46
			\OC::$server->getGroupManager()
47
		);
48
		$groupPrincipalBackend = new GroupPrincipalBackend(
49
			\OC::$server->getGroupManager()
50
		);
51
		// as soon as debug mode is enabled we allow listing of principals
52
		$disableListing = !$config->getSystemValue('debug', false);
53
54
		// setup the first level of the dav tree
55
		$userPrincipals = new Collection($userPrincipalBackend, 'principals/users');
56
		$userPrincipals->disableListing = $disableListing;
57
		$groupPrincipals = new Collection($groupPrincipalBackend, 'principals/groups');
58
		$groupPrincipals->disableListing = $disableListing;
59
		$systemPrincipals = new Collection(new SystemPrincipalBackend(), 'principals/system');
60
		$systemPrincipals->disableListing = $disableListing;
61
		$filesCollection = new Files\RootCollection($userPrincipalBackend, 'principals/users');
62
		$filesCollection->disableListing = $disableListing;
63
		$caldavBackend = new CalDavBackend($db, $userPrincipalBackend, $config, $random);
64
		$calendarRoot = new CalendarRoot($userPrincipalBackend, $caldavBackend, 'principals/users');
65
		$calendarRoot->disableListing = $disableListing;
66
		$publicCalendarRoot = new PublicCalendarRoot($caldavBackend);
67
		$publicCalendarRoot->disableListing = $disableListing;
0 ignored issues
show
Bug introduced by
The property disableListing does not seem to exist in OCA\DAV\CalDAV\PublicCalendarRoot.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
68
69
		$systemTagCollection = new SystemTag\SystemTagsByIdCollection(
70
			\OC::$server->getSystemTagManager(),
71
			\OC::$server->getUserSession(),
72
			\OC::$server->getGroupManager()
73
		);
74
		$systemTagRelationsCollection = new SystemTag\SystemTagsRelationsCollection(
75
			\OC::$server->getSystemTagManager(),
76
			\OC::$server->getSystemTagObjectMapper(),
77
			\OC::$server->getUserSession(),
78
			\OC::$server->getGroupManager(),
79
			\OC::$server->getRootFolder()
80
		);
81
82
		$usersCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $dispatcher);
83
		$usersAddressBookRoot = new AddressBookRoot($userPrincipalBackend, $usersCardDavBackend, 'principals/users');
84
		$usersAddressBookRoot->disableListing = $disableListing;
85
86
		$systemCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $dispatcher);
87
		$systemAddressBookRoot = new AddressBookRoot(new SystemPrincipalBackend(), $systemCardDavBackend, 'principals/system');
88
		$systemAddressBookRoot->disableListing = $disableListing;
89
90
		$uploadCollection = new Upload\RootCollection($userPrincipalBackend, 'principals/users');
91
		$uploadCollection->disableListing = $disableListing;
92
93
		$children = [
94
				new SimpleCollection('principals', [
95
						$userPrincipals,
96
						$groupPrincipals,
97
						$systemPrincipals]),
98
				$filesCollection,
99
				$calendarRoot,
100
				$publicCalendarRoot,
101
				new SimpleCollection('addressbooks', [
102
						$usersAddressBookRoot,
103
						$systemAddressBookRoot]),
104
				$systemTagCollection,
105
				$systemTagRelationsCollection,
106
				$uploadCollection,
107
		];
108
109
		parent::__construct('root', $children);
110
	}
111
112
}
113