Passed
Push — master ( 54a973...87c8a7 )
by Morris
11:42 queued 10s
created
apps/dav/lib/Provisioning/Apple/AppleProvisioningNode.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -31,61 +31,61 @@
 block discarded – undo
31 31
 
32 32
 class AppleProvisioningNode implements INode, IProperties {
33 33
 
34
-	const FILENAME = 'apple-provisioning.mobileconfig';
34
+    const FILENAME = 'apple-provisioning.mobileconfig';
35 35
 
36
-	protected $timeFactory;
36
+    protected $timeFactory;
37 37
 
38
-	/**
39
-	 * @param ITimeFactory $timeFactory
40
-	 */
41
-	public function __construct(ITimeFactory $timeFactory) {
42
-		$this->timeFactory = $timeFactory;
43
-	}
38
+    /**
39
+     * @param ITimeFactory $timeFactory
40
+     */
41
+    public function __construct(ITimeFactory $timeFactory) {
42
+        $this->timeFactory = $timeFactory;
43
+    }
44 44
 
45
-	/**
46
-	 * @return string
47
-	 */
48
-	public function getName() {
49
-		return self::FILENAME;
50
-	}
45
+    /**
46
+     * @return string
47
+     */
48
+    public function getName() {
49
+        return self::FILENAME;
50
+    }
51 51
 
52 52
 
53
-	public function setName($name) {
54
-		throw new Forbidden('Renaming ' . self::FILENAME . ' is forbidden');
55
-	}
53
+    public function setName($name) {
54
+        throw new Forbidden('Renaming ' . self::FILENAME . ' is forbidden');
55
+    }
56 56
 
57
-	/**
58
-	 * @return null
59
-	 */
60
-	public function getLastModified() {
61
-		return null;
62
-	}
57
+    /**
58
+     * @return null
59
+     */
60
+    public function getLastModified() {
61
+        return null;
62
+    }
63 63
 
64
-	/**
65
-	 * @throws Forbidden
66
-	 */
67
-	public function delete() {
68
-		throw new Forbidden(self::FILENAME . ' may not be deleted.');
69
-	}
64
+    /**
65
+     * @throws Forbidden
66
+     */
67
+    public function delete() {
68
+        throw new Forbidden(self::FILENAME . ' may not be deleted.');
69
+    }
70 70
 
71
-	/**
72
-	 * @param array $properties
73
-	 * @return array
74
-	 */
75
-	public function getProperties($properties) {
76
-		$datetime = $this->timeFactory->getDateTime();
71
+    /**
72
+     * @param array $properties
73
+     * @return array
74
+     */
75
+    public function getProperties($properties) {
76
+        $datetime = $this->timeFactory->getDateTime();
77 77
 
78
-		return [
79
-			'{DAV:}getcontentlength' => 42,
80
-			'{DAV:}getlastmodified' => $datetime->format(\DateTime::RFC2822),
81
-		];
82
-	}
78
+        return [
79
+            '{DAV:}getcontentlength' => 42,
80
+            '{DAV:}getlastmodified' => $datetime->format(\DateTime::RFC2822),
81
+        ];
82
+    }
83 83
 
84
-	/**
85
-	 * @param PropPatch $propPatch
86
-	 * @throws Forbidden
87
-	 */
88
-	public function propPatch(PropPatch $propPatch) {
89
-		throw new Forbidden(self::FILENAME . '\'s properties may not be altered.');
90
-	}
84
+    /**
85
+     * @param PropPatch $propPatch
86
+     * @throws Forbidden
87
+     */
88
+    public function propPatch(PropPatch $propPatch) {
89
+        throw new Forbidden(self::FILENAME . '\'s properties may not be altered.');
90
+    }
91 91
 }
Please login to merge, or discard this patch.
apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php 1 patch
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -34,164 +34,164 @@  discard block
 block discarded – undo
34 34
 
35 35
 class AppleProvisioningPlugin extends ServerPlugin {
36 36
 
37
-	/**
38
-	 * @var Server
39
-	 */
40
-	protected $server;
37
+    /**
38
+     * @var Server
39
+     */
40
+    protected $server;
41 41
 
42
-	/**
43
-	 * @var IURLGenerator
44
-	 */
45
-	protected $urlGenerator;
42
+    /**
43
+     * @var IURLGenerator
44
+     */
45
+    protected $urlGenerator;
46 46
 
47
-	/**
48
-	 * @var IUserSession
49
-	 */
50
-	protected $userSession;
47
+    /**
48
+     * @var IUserSession
49
+     */
50
+    protected $userSession;
51 51
 
52
-	/**
53
-	 * @var \OC_Defaults
54
-	 */
55
-	protected $themingDefaults;
52
+    /**
53
+     * @var \OC_Defaults
54
+     */
55
+    protected $themingDefaults;
56 56
 
57
-	/**
58
-	 * @var IRequest
59
-	 */
60
-	protected $request;
57
+    /**
58
+     * @var IRequest
59
+     */
60
+    protected $request;
61 61
 
62
-	/**
63
-	 * @var IL10N
64
-	 */
65
-	protected $l10n;
62
+    /**
63
+     * @var IL10N
64
+     */
65
+    protected $l10n;
66 66
 
67
-	/**
68
-	 * @var \closure
69
-	 */
70
-	protected $uuidClosure;
67
+    /**
68
+     * @var \closure
69
+     */
70
+    protected $uuidClosure;
71 71
 
72
-	/**
73
-	 * AppleProvisioningPlugin constructor.
74
-	 *
75
-	 * @param IUserSession $userSession
76
-	 * @param IURLGenerator $urlGenerator
77
-	 * @param \OC_Defaults $themingDefaults
78
-	 * @param IRequest $request
79
-	 * @param IL10N $l10n
80
-	 * @param \closure $uuidClosure
81
-	 */
82
-	public function __construct(IUserSession $userSession, IURLGenerator $urlGenerator,
83
-								\OC_Defaults $themingDefaults, IRequest $request,
84
-								IL10N $l10n, \closure $uuidClosure) {
85
-		$this->userSession = $userSession;
86
-		$this->urlGenerator = $urlGenerator;
87
-		$this->themingDefaults = $themingDefaults;
88
-		$this->request = $request;
89
-		$this->l10n = $l10n;
90
-		$this->uuidClosure = $uuidClosure;
91
-	}
72
+    /**
73
+     * AppleProvisioningPlugin constructor.
74
+     *
75
+     * @param IUserSession $userSession
76
+     * @param IURLGenerator $urlGenerator
77
+     * @param \OC_Defaults $themingDefaults
78
+     * @param IRequest $request
79
+     * @param IL10N $l10n
80
+     * @param \closure $uuidClosure
81
+     */
82
+    public function __construct(IUserSession $userSession, IURLGenerator $urlGenerator,
83
+                                \OC_Defaults $themingDefaults, IRequest $request,
84
+                                IL10N $l10n, \closure $uuidClosure) {
85
+        $this->userSession = $userSession;
86
+        $this->urlGenerator = $urlGenerator;
87
+        $this->themingDefaults = $themingDefaults;
88
+        $this->request = $request;
89
+        $this->l10n = $l10n;
90
+        $this->uuidClosure = $uuidClosure;
91
+    }
92 92
 
93
-	/**
94
-	 * @param Server $server
95
-	 */
96
-	public function initialize(Server $server) {
97
-		$this->server = $server;
98
-		$this->server->on('method:GET', [$this, 'httpGet'], 90);
99
-	}
93
+    /**
94
+     * @param Server $server
95
+     */
96
+    public function initialize(Server $server) {
97
+        $this->server = $server;
98
+        $this->server->on('method:GET', [$this, 'httpGet'], 90);
99
+    }
100 100
 
101
-	/**
102
-	 * @param RequestInterface $request
103
-	 * @param ResponseInterface $response
104
-	 * @return boolean
105
-	 */
106
-	public function httpGet(RequestInterface $request, ResponseInterface $response):bool {
107
-		if ($request->getPath() !== 'provisioning/' . AppleProvisioningNode::FILENAME) {
108
-			return true;
109
-		}
101
+    /**
102
+     * @param RequestInterface $request
103
+     * @param ResponseInterface $response
104
+     * @return boolean
105
+     */
106
+    public function httpGet(RequestInterface $request, ResponseInterface $response):bool {
107
+        if ($request->getPath() !== 'provisioning/' . AppleProvisioningNode::FILENAME) {
108
+            return true;
109
+        }
110 110
 
111
-		$user = $this->userSession->getUser();
112
-		if (!$user) {
113
-			return true;
114
-		}
111
+        $user = $this->userSession->getUser();
112
+        if (!$user) {
113
+            return true;
114
+        }
115 115
 
116
-		$serverProtocol = $this->request->getServerProtocol();
117
-		$useSSL = ($serverProtocol === 'https');
116
+        $serverProtocol = $this->request->getServerProtocol();
117
+        $useSSL = ($serverProtocol === 'https');
118 118
 
119
-		if (!$useSSL) {
120
-			$response->setStatus(200);
121
-			$response->setHeader('Content-Type', 'text/plain; charset=utf-8');
122
-			$response->setBody($this->l10n->t('Your %s needs to be configured to use HTTPS in order to use CalDAV and CardDAV with iOS/macOS.', [$this->themingDefaults->getName()]));
119
+        if (!$useSSL) {
120
+            $response->setStatus(200);
121
+            $response->setHeader('Content-Type', 'text/plain; charset=utf-8');
122
+            $response->setBody($this->l10n->t('Your %s needs to be configured to use HTTPS in order to use CalDAV and CardDAV with iOS/macOS.', [$this->themingDefaults->getName()]));
123 123
 
124
-			return false;
125
-		}
124
+            return false;
125
+        }
126 126
 
127
-		$absoluteURL = $request->getAbsoluteUrl();
128
-		$parsedUrl = parse_url($absoluteURL);
129
-		if (isset($parsedUrl['port'])) {
130
-			$serverPort = (int) $parsedUrl['port'];
131
-		} else {
132
-			$serverPort = 443;
133
-		}
134
-		$server_url = $parsedUrl['host'];
127
+        $absoluteURL = $request->getAbsoluteUrl();
128
+        $parsedUrl = parse_url($absoluteURL);
129
+        if (isset($parsedUrl['port'])) {
130
+            $serverPort = (int) $parsedUrl['port'];
131
+        } else {
132
+            $serverPort = 443;
133
+        }
134
+        $server_url = $parsedUrl['host'];
135 135
 
136
-		$description = $this->themingDefaults->getName();
137
-		$userId = $user->getUID();
136
+        $description = $this->themingDefaults->getName();
137
+        $userId = $user->getUID();
138 138
 
139
-		$reverseDomain = implode('.', array_reverse(explode('.', $parsedUrl['host'])));
139
+        $reverseDomain = implode('.', array_reverse(explode('.', $parsedUrl['host'])));
140 140
 
141
-		$caldavUUID = call_user_func($this->uuidClosure);
142
-		$carddavUUID = call_user_func($this->uuidClosure);
143
-		$profileUUID = call_user_func($this->uuidClosure);
141
+        $caldavUUID = call_user_func($this->uuidClosure);
142
+        $carddavUUID = call_user_func($this->uuidClosure);
143
+        $profileUUID = call_user_func($this->uuidClosure);
144 144
 
145
-		$caldavIdentifier = $reverseDomain . '.' . $caldavUUID;
146
-		$carddavIdentifier = $reverseDomain . '.' . $carddavUUID;
147
-		$profileIdentifier = $reverseDomain . '.' . $profileUUID;
145
+        $caldavIdentifier = $reverseDomain . '.' . $caldavUUID;
146
+        $carddavIdentifier = $reverseDomain . '.' . $carddavUUID;
147
+        $profileIdentifier = $reverseDomain . '.' . $profileUUID;
148 148
 
149
-		$caldavDescription = $this->l10n->t('Configures a CalDAV account');
150
-		$caldavDisplayname = $description . ' CalDAV';
151
-		$carddavDescription = $this->l10n->t('Configures a CardDAV account');
152
-		$carddavDisplayname = $description . ' CardDAV';
149
+        $caldavDescription = $this->l10n->t('Configures a CalDAV account');
150
+        $caldavDisplayname = $description . ' CalDAV';
151
+        $carddavDescription = $this->l10n->t('Configures a CardDAV account');
152
+        $carddavDisplayname = $description . ' CardDAV';
153 153
 
154
-		$filename = $userId . '-' . AppleProvisioningNode::FILENAME;
154
+        $filename = $userId . '-' . AppleProvisioningNode::FILENAME;
155 155
 
156
-		$xmlSkeleton = $this->getTemplate();
157
-		$body = vsprintf($xmlSkeleton, array_map(function($v) {
158
-				return \htmlspecialchars($v, ENT_XML1, 'UTF-8');
159
-			}, [
160
-				$description,
161
-				$server_url,
162
-				$userId,
163
-				$serverPort,
164
-				$caldavDescription,
165
-				$caldavDisplayname,
166
-				$caldavIdentifier,
167
-				$caldavUUID,
168
-				$description,
169
-				$server_url,
170
-				$userId,
171
-				$serverPort,
172
-				$carddavDescription,
173
-				$carddavDisplayname,
174
-				$carddavIdentifier,
175
-				$carddavUUID,
176
-				$description,
177
-				$profileIdentifier,
178
-				$profileUUID
179
-			]
180
-		));
156
+        $xmlSkeleton = $this->getTemplate();
157
+        $body = vsprintf($xmlSkeleton, array_map(function($v) {
158
+                return \htmlspecialchars($v, ENT_XML1, 'UTF-8');
159
+            }, [
160
+                $description,
161
+                $server_url,
162
+                $userId,
163
+                $serverPort,
164
+                $caldavDescription,
165
+                $caldavDisplayname,
166
+                $caldavIdentifier,
167
+                $caldavUUID,
168
+                $description,
169
+                $server_url,
170
+                $userId,
171
+                $serverPort,
172
+                $carddavDescription,
173
+                $carddavDisplayname,
174
+                $carddavIdentifier,
175
+                $carddavUUID,
176
+                $description,
177
+                $profileIdentifier,
178
+                $profileUUID
179
+            ]
180
+        ));
181 181
 
182
-		$response->setStatus(200);
183
-		$response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
184
-		$response->setHeader('Content-Type', 'application/xml; charset=utf-8');
185
-		$response->setBody($body);
182
+        $response->setStatus(200);
183
+        $response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
184
+        $response->setHeader('Content-Type', 'application/xml; charset=utf-8');
185
+        $response->setBody($body);
186 186
 
187
-		return false;
188
-	}
187
+        return false;
188
+    }
189 189
 
190
-	/**
191
-	 * @return string
192
-	 */
193
-	private function getTemplate():string {
194
-		return <<<EOF
190
+    /**
191
+     * @return string
192
+     */
193
+    private function getTemplate():string {
194
+        return <<<EOF
195 195
 <?xml version="1.0" encoding="UTF-8"?>
196 196
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
197 197
 <plist version="1.0">
@@ -263,5 +263,5 @@  discard block
 block discarded – undo
263 263
 </plist>
264 264
 
265 265
 EOF;
266
-	}
266
+    }
267 267
 }
Please login to merge, or discard this patch.
apps/dav/lib/RootCollection.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -42,127 +42,127 @@
 block discarded – undo
42 42
 
43 43
 class RootCollection extends SimpleCollection {
44 44
 
45
-	public function __construct() {
46
-		$config = \OC::$server->getConfig();
47
-		$l10n = \OC::$server->getL10N('dav');
48
-		$random = \OC::$server->getSecureRandom();
49
-		$logger = \OC::$server->getLogger();
50
-		$userManager = \OC::$server->getUserManager();
51
-		$userSession = \OC::$server->getUserSession();
52
-		$groupManager = \OC::$server->getGroupManager();
53
-		$shareManager = \OC::$server->getShareManager();
54
-		$db = \OC::$server->getDatabaseConnection();
55
-		$dispatcher = \OC::$server->getEventDispatcher();
56
-		$userPrincipalBackend = new Principal(
57
-			$userManager,
58
-			$groupManager,
59
-			$shareManager,
60
-			\OC::$server->getUserSession(),
61
-			$config
62
-		);
63
-		$groupPrincipalBackend = new GroupPrincipalBackend($groupManager, $userSession, $shareManager, $l10n);
64
-		$calendarResourcePrincipalBackend = new ResourcePrincipalBackend($db, $userSession, $groupManager, $logger);
65
-		$calendarRoomPrincipalBackend = new RoomPrincipalBackend($db, $userSession, $groupManager, $logger);
66
-		// as soon as debug mode is enabled we allow listing of principals
67
-		$disableListing = !$config->getSystemValue('debug', false);
68
-
69
-		// setup the first level of the dav tree
70
-		$userPrincipals = new Collection($userPrincipalBackend, 'principals/users');
71
-		$userPrincipals->disableListing = $disableListing;
72
-		$groupPrincipals = new Collection($groupPrincipalBackend, 'principals/groups');
73
-		$groupPrincipals->disableListing = $disableListing;
74
-		$systemPrincipals = new Collection(new SystemPrincipalBackend(), 'principals/system');
75
-		$systemPrincipals->disableListing = $disableListing;
76
-		$calendarResourcePrincipals = new Collection($calendarResourcePrincipalBackend, 'principals/calendar-resources');
77
-		$calendarResourcePrincipals->disableListing = $disableListing;
78
-		$calendarRoomPrincipals = new Collection($calendarRoomPrincipalBackend, 'principals/calendar-rooms');
79
-		$calendarRoomPrincipals->disableListing = $disableListing;
80
-
81
-
82
-		$filesCollection = new Files\RootCollection($userPrincipalBackend, 'principals/users');
83
-		$filesCollection->disableListing = $disableListing;
84
-		$caldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher);
85
-		$userCalendarRoot = new CalendarRoot($userPrincipalBackend, $caldavBackend, 'principals/users');
86
-		$userCalendarRoot->disableListing = $disableListing;
87
-
88
-		$resourceCalendarCaldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher);
89
-		$resourceCalendarRoot = new CalendarRoot($calendarResourcePrincipalBackend, $caldavBackend, 'principals/calendar-resources');
90
-		$resourceCalendarRoot->disableListing = $disableListing;
91
-		$roomCalendarCaldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher);
92
-		$roomCalendarRoot = new CalendarRoot($calendarRoomPrincipalBackend, $roomCalendarCaldavBackend, 'principals/calendar-rooms');
93
-		$roomCalendarRoot->disableListing = $disableListing;
94
-
95
-		$publicCalendarRoot = new PublicCalendarRoot($caldavBackend, $l10n, $config);
96
-		$publicCalendarRoot->disableListing = $disableListing;
97
-
98
-		$systemTagCollection = new SystemTag\SystemTagsByIdCollection(
99
-			\OC::$server->getSystemTagManager(),
100
-			\OC::$server->getUserSession(),
101
-			$groupManager
102
-		);
103
-		$systemTagRelationsCollection = new SystemTag\SystemTagsRelationsCollection(
104
-			\OC::$server->getSystemTagManager(),
105
-			\OC::$server->getSystemTagObjectMapper(),
106
-			\OC::$server->getUserSession(),
107
-			$groupManager,
108
-			\OC::$server->getEventDispatcher()
109
-		);
110
-		$commentsCollection = new Comments\RootCollection(
111
-			\OC::$server->getCommentsManager(),
112
-			$userManager,
113
-			\OC::$server->getUserSession(),
114
-			\OC::$server->getEventDispatcher(),
115
-			\OC::$server->getLogger()
116
-		);
117
-
118
-		$usersCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $dispatcher);
119
-		$usersAddressBookRoot = new AddressBookRoot($userPrincipalBackend, $usersCardDavBackend, 'principals/users');
120
-		$usersAddressBookRoot->disableListing = $disableListing;
121
-
122
-		$systemCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $dispatcher);
123
-		$systemAddressBookRoot = new AddressBookRoot(new SystemPrincipalBackend(), $systemCardDavBackend, 'principals/system');
124
-		$systemAddressBookRoot->disableListing = $disableListing;
125
-
126
-		$uploadCollection = new Upload\RootCollection(
127
-			$userPrincipalBackend,
128
-			'principals/users',
129
-			\OC::$server->query(CleanupService::class));
130
-		$uploadCollection->disableListing = $disableListing;
131
-
132
-		$avatarCollection = new Avatars\RootCollection($userPrincipalBackend, 'principals/users');
133
-		$avatarCollection->disableListing = $disableListing;
134
-
135
-		$appleProvisioning = new AppleProvisioningNode(
136
-			\OC::$server->query(ITimeFactory::class));
137
-
138
-		$children = [
139
-				new SimpleCollection('principals', [
140
-						$userPrincipals,
141
-						$groupPrincipals,
142
-						$systemPrincipals,
143
-						$calendarResourcePrincipals,
144
-						$calendarRoomPrincipals]),
145
-				$filesCollection,
146
-				$userCalendarRoot,
147
-				new SimpleCollection('system-calendars', [
148
-					$resourceCalendarRoot,
149
-					$roomCalendarRoot,
150
-				]),
151
-				$publicCalendarRoot,
152
-				new SimpleCollection('addressbooks', [
153
-						$usersAddressBookRoot,
154
-						$systemAddressBookRoot]),
155
-				$systemTagCollection,
156
-				$systemTagRelationsCollection,
157
-				$commentsCollection,
158
-				$uploadCollection,
159
-				$avatarCollection,
160
-				new SimpleCollection('provisioning', [
161
-					$appleProvisioning
162
-				])
163
-		];
164
-
165
-		parent::__construct('root', $children);
166
-	}
45
+    public function __construct() {
46
+        $config = \OC::$server->getConfig();
47
+        $l10n = \OC::$server->getL10N('dav');
48
+        $random = \OC::$server->getSecureRandom();
49
+        $logger = \OC::$server->getLogger();
50
+        $userManager = \OC::$server->getUserManager();
51
+        $userSession = \OC::$server->getUserSession();
52
+        $groupManager = \OC::$server->getGroupManager();
53
+        $shareManager = \OC::$server->getShareManager();
54
+        $db = \OC::$server->getDatabaseConnection();
55
+        $dispatcher = \OC::$server->getEventDispatcher();
56
+        $userPrincipalBackend = new Principal(
57
+            $userManager,
58
+            $groupManager,
59
+            $shareManager,
60
+            \OC::$server->getUserSession(),
61
+            $config
62
+        );
63
+        $groupPrincipalBackend = new GroupPrincipalBackend($groupManager, $userSession, $shareManager, $l10n);
64
+        $calendarResourcePrincipalBackend = new ResourcePrincipalBackend($db, $userSession, $groupManager, $logger);
65
+        $calendarRoomPrincipalBackend = new RoomPrincipalBackend($db, $userSession, $groupManager, $logger);
66
+        // as soon as debug mode is enabled we allow listing of principals
67
+        $disableListing = !$config->getSystemValue('debug', false);
68
+
69
+        // setup the first level of the dav tree
70
+        $userPrincipals = new Collection($userPrincipalBackend, 'principals/users');
71
+        $userPrincipals->disableListing = $disableListing;
72
+        $groupPrincipals = new Collection($groupPrincipalBackend, 'principals/groups');
73
+        $groupPrincipals->disableListing = $disableListing;
74
+        $systemPrincipals = new Collection(new SystemPrincipalBackend(), 'principals/system');
75
+        $systemPrincipals->disableListing = $disableListing;
76
+        $calendarResourcePrincipals = new Collection($calendarResourcePrincipalBackend, 'principals/calendar-resources');
77
+        $calendarResourcePrincipals->disableListing = $disableListing;
78
+        $calendarRoomPrincipals = new Collection($calendarRoomPrincipalBackend, 'principals/calendar-rooms');
79
+        $calendarRoomPrincipals->disableListing = $disableListing;
80
+
81
+
82
+        $filesCollection = new Files\RootCollection($userPrincipalBackend, 'principals/users');
83
+        $filesCollection->disableListing = $disableListing;
84
+        $caldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher);
85
+        $userCalendarRoot = new CalendarRoot($userPrincipalBackend, $caldavBackend, 'principals/users');
86
+        $userCalendarRoot->disableListing = $disableListing;
87
+
88
+        $resourceCalendarCaldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher);
89
+        $resourceCalendarRoot = new CalendarRoot($calendarResourcePrincipalBackend, $caldavBackend, 'principals/calendar-resources');
90
+        $resourceCalendarRoot->disableListing = $disableListing;
91
+        $roomCalendarCaldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher);
92
+        $roomCalendarRoot = new CalendarRoot($calendarRoomPrincipalBackend, $roomCalendarCaldavBackend, 'principals/calendar-rooms');
93
+        $roomCalendarRoot->disableListing = $disableListing;
94
+
95
+        $publicCalendarRoot = new PublicCalendarRoot($caldavBackend, $l10n, $config);
96
+        $publicCalendarRoot->disableListing = $disableListing;
97
+
98
+        $systemTagCollection = new SystemTag\SystemTagsByIdCollection(
99
+            \OC::$server->getSystemTagManager(),
100
+            \OC::$server->getUserSession(),
101
+            $groupManager
102
+        );
103
+        $systemTagRelationsCollection = new SystemTag\SystemTagsRelationsCollection(
104
+            \OC::$server->getSystemTagManager(),
105
+            \OC::$server->getSystemTagObjectMapper(),
106
+            \OC::$server->getUserSession(),
107
+            $groupManager,
108
+            \OC::$server->getEventDispatcher()
109
+        );
110
+        $commentsCollection = new Comments\RootCollection(
111
+            \OC::$server->getCommentsManager(),
112
+            $userManager,
113
+            \OC::$server->getUserSession(),
114
+            \OC::$server->getEventDispatcher(),
115
+            \OC::$server->getLogger()
116
+        );
117
+
118
+        $usersCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $dispatcher);
119
+        $usersAddressBookRoot = new AddressBookRoot($userPrincipalBackend, $usersCardDavBackend, 'principals/users');
120
+        $usersAddressBookRoot->disableListing = $disableListing;
121
+
122
+        $systemCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $dispatcher);
123
+        $systemAddressBookRoot = new AddressBookRoot(new SystemPrincipalBackend(), $systemCardDavBackend, 'principals/system');
124
+        $systemAddressBookRoot->disableListing = $disableListing;
125
+
126
+        $uploadCollection = new Upload\RootCollection(
127
+            $userPrincipalBackend,
128
+            'principals/users',
129
+            \OC::$server->query(CleanupService::class));
130
+        $uploadCollection->disableListing = $disableListing;
131
+
132
+        $avatarCollection = new Avatars\RootCollection($userPrincipalBackend, 'principals/users');
133
+        $avatarCollection->disableListing = $disableListing;
134
+
135
+        $appleProvisioning = new AppleProvisioningNode(
136
+            \OC::$server->query(ITimeFactory::class));
137
+
138
+        $children = [
139
+                new SimpleCollection('principals', [
140
+                        $userPrincipals,
141
+                        $groupPrincipals,
142
+                        $systemPrincipals,
143
+                        $calendarResourcePrincipals,
144
+                        $calendarRoomPrincipals]),
145
+                $filesCollection,
146
+                $userCalendarRoot,
147
+                new SimpleCollection('system-calendars', [
148
+                    $resourceCalendarRoot,
149
+                    $roomCalendarRoot,
150
+                ]),
151
+                $publicCalendarRoot,
152
+                new SimpleCollection('addressbooks', [
153
+                        $usersAddressBookRoot,
154
+                        $systemAddressBookRoot]),
155
+                $systemTagCollection,
156
+                $systemTagRelationsCollection,
157
+                $commentsCollection,
158
+                $uploadCollection,
159
+                $avatarCollection,
160
+                new SimpleCollection('provisioning', [
161
+                    $appleProvisioning
162
+                ])
163
+        ];
164
+
165
+        parent::__construct('root', $children);
166
+    }
167 167
 
168 168
 }
Please login to merge, or discard this patch.
apps/dav/lib/Server.php 1 patch
Indentation   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -69,257 +69,257 @@
 block discarded – undo
69 69
 
70 70
 class Server {
71 71
 
72
-	/** @var IRequest */
73
-	private $request;
74
-
75
-	/** @var  string */
76
-	private $baseUri;
77
-
78
-	/** @var Connector\Sabre\Server  */
79
-	public $server;
80
-
81
-	public function __construct(IRequest $request, $baseUri) {
82
-		$this->request = $request;
83
-		$this->baseUri = $baseUri;
84
-		$logger = \OC::$server->getLogger();
85
-		$dispatcher = \OC::$server->getEventDispatcher();
86
-
87
-		$root = new RootCollection();
88
-		$this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
89
-
90
-		// Add maintenance plugin
91
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig()));
92
-
93
-		// Backends
94
-		$authBackend = new Auth(
95
-			\OC::$server->getSession(),
96
-			\OC::$server->getUserSession(),
97
-			\OC::$server->getRequest(),
98
-			\OC::$server->getTwoFactorAuthManager(),
99
-			\OC::$server->getBruteForceThrottler()
100
-		);
101
-
102
-		// Set URL explicitly due to reverse-proxy situations
103
-		$this->server->httpRequest->setUrl($this->request->getRequestUri());
104
-		$this->server->setBaseUri($this->baseUri);
105
-
106
-		$this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
107
-		$this->server->addPlugin(new AnonymousOptionsPlugin());
108
-		$authPlugin = new Plugin();
109
-		$authPlugin->addBackend(new PublicAuth());
110
-		$this->server->addPlugin($authPlugin);
111
-
112
-		// allow setup of additional auth backends
113
-		$event = new SabrePluginEvent($this->server);
114
-		$dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);
115
-
116
-		$bearerAuthBackend = new BearerAuth(
117
-			\OC::$server->getUserSession(),
118
-			\OC::$server->getSession(),
119
-			\OC::$server->getRequest()
120
-		);
121
-		$authPlugin->addBackend($bearerAuthBackend);
122
-		// because we are throwing exceptions this plugin has to be the last one
123
-		$authPlugin->addBackend($authBackend);
124
-
125
-		// debugging
126
-		if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
127
-			$this->server->addPlugin(new \Sabre\DAV\Browser\Plugin());
128
-		} else {
129
-			$this->server->addPlugin(new DummyGetResponsePlugin());
130
-		}
131
-
132
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
133
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
134
-		$this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
135
-
136
-		// acl
137
-		$acl = new DavAclPlugin();
138
-		$acl->principalCollectionSet = [
139
-			'principals/users', 'principals/groups',
140
-			'principals/calendar-resources',
141
-			'principals/calendar-rooms',
142
-		];
143
-		$acl->defaultUsernamePath = 'principals/users';
144
-		$this->server->addPlugin($acl);
145
-
146
-		// calendar plugins
147
-		if ($this->requestIsForSubtree(['calendars', 'public-calendars', 'system-calendars', 'principals'])) {
148
-			$this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
149
-			$this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
150
-			$this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin());
151
-			if (\OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') {
152
-				$this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class));
153
-			}
154
-
155
-			$this->server->addPlugin(new CalDAV\WebcalCaching\Plugin($request));
156
-			$this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
157
-
158
-			$this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
159
-			$this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
160
-			$this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
161
-				\OC::$server->getConfig(),
162
-				\OC::$server->getURLGenerator()
163
-			));
164
-		}
165
-
166
-		// addressbook plugins
167
-		if ($this->requestIsForSubtree(['addressbooks', 'principals'])) {
168
-			$this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
169
-			$this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());
170
-			$this->server->addPlugin(new VCFExportPlugin());
171
-			$this->server->addPlugin(new MultiGetExportPlugin());
172
-			$this->server->addPlugin(new ImageExportPlugin(new PhotoCache(
173
-				\OC::$server->getAppDataDir('dav-photocache'),
174
-				\OC::$server->getLogger())
175
-			));
176
-		}
177
-
178
-		// system tags plugins
179
-		$this->server->addPlugin(new SystemTagPlugin(
180
-			\OC::$server->getSystemTagManager(),
181
-			\OC::$server->getGroupManager(),
182
-			\OC::$server->getUserSession()
183
-		));
184
-
185
-		// comments plugin
186
-		$this->server->addPlugin(new CommentsPlugin(
187
-			\OC::$server->getCommentsManager(),
188
-			\OC::$server->getUserSession()
189
-		));
190
-
191
-		$this->server->addPlugin(new CopyEtagHeaderPlugin());
192
-		$this->server->addPlugin(new ChunkingPlugin());
193
-
194
-		// allow setup of additional plugins
195
-		$dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event);
196
-
197
-		// Some WebDAV clients do require Class 2 WebDAV support (locking), since
198
-		// we do not provide locking we emulate it using a fake locking plugin.
199
-		if($request->isUserAgent([
200
-			'/WebDAVFS/',
201
-			'/OneNote/',
202
-			'/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601
203
-		])) {
204
-			$this->server->addPlugin(new FakeLockerPlugin());
205
-		}
206
-
207
-		if (BrowserErrorPagePlugin::isBrowserRequest($request)) {
208
-			$this->server->addPlugin(new BrowserErrorPagePlugin());
209
-		}
210
-
211
-		$lazySearchBackend = new LazySearchBackend();
212
-		$this->server->addPlugin(new SearchPlugin($lazySearchBackend));
213
-
214
-		// wait with registering these until auth is handled and the filesystem is setup
215
-		$this->server->on('beforeMethod', function () use ($root, $lazySearchBackend) {
216
-			// custom properties plugin must be the last one
217
-			$userSession = \OC::$server->getUserSession();
218
-			$user = $userSession->getUser();
219
-			if ($user !== null) {
220
-				$view = \OC\Files\Filesystem::getView();
221
-				$this->server->addPlugin(
222
-					new FilesPlugin(
223
-						$this->server->tree,
224
-						\OC::$server->getConfig(),
225
-						$this->request,
226
-						\OC::$server->getPreviewManager(),
227
-						false,
228
-						!\OC::$server->getConfig()->getSystemValue('debug', false)
229
-					)
230
-				);
231
-
232
-				$this->server->addPlugin(
233
-					new \Sabre\DAV\PropertyStorage\Plugin(
234
-						new CustomPropertiesBackend(
235
-							$this->server->tree,
236
-							\OC::$server->getDatabaseConnection(),
237
-							\OC::$server->getUserSession()->getUser()
238
-						)
239
-					)
240
-				);
241
-				if ($view !== null) {
242
-					$this->server->addPlugin(
243
-						new QuotaPlugin($view, false));
244
-				}
245
-				$this->server->addPlugin(
246
-					new TagsPlugin(
247
-						$this->server->tree, \OC::$server->getTagManager()
248
-					)
249
-				);
250
-				// TODO: switch to LazyUserFolder
251
-				$userFolder = \OC::$server->getUserFolder();
252
-				$this->server->addPlugin(new SharesPlugin(
253
-					$this->server->tree,
254
-					$userSession,
255
-					$userFolder,
256
-					\OC::$server->getShareManager()
257
-				));
258
-				$this->server->addPlugin(new CommentPropertiesPlugin(
259
-					\OC::$server->getCommentsManager(),
260
-					$userSession
261
-				));
262
-				$this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin());
263
-				if ($view !== null) {
264
-					$this->server->addPlugin(new FilesReportPlugin(
265
-						$this->server->tree,
266
-						$view,
267
-						\OC::$server->getSystemTagManager(),
268
-						\OC::$server->getSystemTagObjectMapper(),
269
-						\OC::$server->getTagManager(),
270
-						$userSession,
271
-						\OC::$server->getGroupManager(),
272
-						$userFolder
273
-					));
274
-					$lazySearchBackend->setBackend(new \OCA\DAV\Files\FileSearchBackend(
275
-						$this->server->tree,
276
-						$user,
277
-						\OC::$server->getRootFolder(),
278
-						\OC::$server->getShareManager(),
279
-						$view
280
-					));
281
-				}
282
-				$this->server->addPlugin(new \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin(
283
-					\OC::$server->getConfig(),
284
-					\OC::$server->query(BirthdayService::class)
285
-				));
286
-				$this->server->addPlugin(new AppleProvisioningPlugin(
287
-					\OC::$server->getUserSession(),
288
-					\OC::$server->getURLGenerator(),
289
-					\OC::$server->getThemingDefaults(),
290
-					\OC::$server->getRequest(),
291
-					\OC::$server->getL10N('dav'),
292
-					function() {
293
-						return UUIDUtil::getUUID();
294
-					}
295
-				));
296
-			}
297
-
298
-			// register plugins from apps
299
-			$pluginManager = new PluginManager(
300
-				\OC::$server,
301
-				\OC::$server->getAppManager()
302
-			);
303
-			foreach ($pluginManager->getAppPlugins() as $appPlugin) {
304
-				$this->server->addPlugin($appPlugin);
305
-			}
306
-			foreach ($pluginManager->getAppCollections() as $appCollection) {
307
-				$root->addChild($appCollection);
308
-			}
309
-		});
310
-	}
311
-
312
-	public function exec() {
313
-		$this->server->exec();
314
-	}
315
-
316
-	private function requestIsForSubtree(array $subTrees): bool {
317
-		foreach ($subTrees as $subTree) {
318
-			$subTree = trim($subTree, ' /');
319
-			if (strpos($this->server->getRequestUri(), $subTree.'/') === 0) {
320
-				return true;
321
-			}
322
-		}
323
-		return false;
324
-	}
72
+    /** @var IRequest */
73
+    private $request;
74
+
75
+    /** @var  string */
76
+    private $baseUri;
77
+
78
+    /** @var Connector\Sabre\Server  */
79
+    public $server;
80
+
81
+    public function __construct(IRequest $request, $baseUri) {
82
+        $this->request = $request;
83
+        $this->baseUri = $baseUri;
84
+        $logger = \OC::$server->getLogger();
85
+        $dispatcher = \OC::$server->getEventDispatcher();
86
+
87
+        $root = new RootCollection();
88
+        $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
89
+
90
+        // Add maintenance plugin
91
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig()));
92
+
93
+        // Backends
94
+        $authBackend = new Auth(
95
+            \OC::$server->getSession(),
96
+            \OC::$server->getUserSession(),
97
+            \OC::$server->getRequest(),
98
+            \OC::$server->getTwoFactorAuthManager(),
99
+            \OC::$server->getBruteForceThrottler()
100
+        );
101
+
102
+        // Set URL explicitly due to reverse-proxy situations
103
+        $this->server->httpRequest->setUrl($this->request->getRequestUri());
104
+        $this->server->setBaseUri($this->baseUri);
105
+
106
+        $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
107
+        $this->server->addPlugin(new AnonymousOptionsPlugin());
108
+        $authPlugin = new Plugin();
109
+        $authPlugin->addBackend(new PublicAuth());
110
+        $this->server->addPlugin($authPlugin);
111
+
112
+        // allow setup of additional auth backends
113
+        $event = new SabrePluginEvent($this->server);
114
+        $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);
115
+
116
+        $bearerAuthBackend = new BearerAuth(
117
+            \OC::$server->getUserSession(),
118
+            \OC::$server->getSession(),
119
+            \OC::$server->getRequest()
120
+        );
121
+        $authPlugin->addBackend($bearerAuthBackend);
122
+        // because we are throwing exceptions this plugin has to be the last one
123
+        $authPlugin->addBackend($authBackend);
124
+
125
+        // debugging
126
+        if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
127
+            $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin());
128
+        } else {
129
+            $this->server->addPlugin(new DummyGetResponsePlugin());
130
+        }
131
+
132
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
133
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
134
+        $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
135
+
136
+        // acl
137
+        $acl = new DavAclPlugin();
138
+        $acl->principalCollectionSet = [
139
+            'principals/users', 'principals/groups',
140
+            'principals/calendar-resources',
141
+            'principals/calendar-rooms',
142
+        ];
143
+        $acl->defaultUsernamePath = 'principals/users';
144
+        $this->server->addPlugin($acl);
145
+
146
+        // calendar plugins
147
+        if ($this->requestIsForSubtree(['calendars', 'public-calendars', 'system-calendars', 'principals'])) {
148
+            $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
149
+            $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
150
+            $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin());
151
+            if (\OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') {
152
+                $this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class));
153
+            }
154
+
155
+            $this->server->addPlugin(new CalDAV\WebcalCaching\Plugin($request));
156
+            $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
157
+
158
+            $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
159
+            $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
160
+            $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
161
+                \OC::$server->getConfig(),
162
+                \OC::$server->getURLGenerator()
163
+            ));
164
+        }
165
+
166
+        // addressbook plugins
167
+        if ($this->requestIsForSubtree(['addressbooks', 'principals'])) {
168
+            $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
169
+            $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());
170
+            $this->server->addPlugin(new VCFExportPlugin());
171
+            $this->server->addPlugin(new MultiGetExportPlugin());
172
+            $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(
173
+                \OC::$server->getAppDataDir('dav-photocache'),
174
+                \OC::$server->getLogger())
175
+            ));
176
+        }
177
+
178
+        // system tags plugins
179
+        $this->server->addPlugin(new SystemTagPlugin(
180
+            \OC::$server->getSystemTagManager(),
181
+            \OC::$server->getGroupManager(),
182
+            \OC::$server->getUserSession()
183
+        ));
184
+
185
+        // comments plugin
186
+        $this->server->addPlugin(new CommentsPlugin(
187
+            \OC::$server->getCommentsManager(),
188
+            \OC::$server->getUserSession()
189
+        ));
190
+
191
+        $this->server->addPlugin(new CopyEtagHeaderPlugin());
192
+        $this->server->addPlugin(new ChunkingPlugin());
193
+
194
+        // allow setup of additional plugins
195
+        $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event);
196
+
197
+        // Some WebDAV clients do require Class 2 WebDAV support (locking), since
198
+        // we do not provide locking we emulate it using a fake locking plugin.
199
+        if($request->isUserAgent([
200
+            '/WebDAVFS/',
201
+            '/OneNote/',
202
+            '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601
203
+        ])) {
204
+            $this->server->addPlugin(new FakeLockerPlugin());
205
+        }
206
+
207
+        if (BrowserErrorPagePlugin::isBrowserRequest($request)) {
208
+            $this->server->addPlugin(new BrowserErrorPagePlugin());
209
+        }
210
+
211
+        $lazySearchBackend = new LazySearchBackend();
212
+        $this->server->addPlugin(new SearchPlugin($lazySearchBackend));
213
+
214
+        // wait with registering these until auth is handled and the filesystem is setup
215
+        $this->server->on('beforeMethod', function () use ($root, $lazySearchBackend) {
216
+            // custom properties plugin must be the last one
217
+            $userSession = \OC::$server->getUserSession();
218
+            $user = $userSession->getUser();
219
+            if ($user !== null) {
220
+                $view = \OC\Files\Filesystem::getView();
221
+                $this->server->addPlugin(
222
+                    new FilesPlugin(
223
+                        $this->server->tree,
224
+                        \OC::$server->getConfig(),
225
+                        $this->request,
226
+                        \OC::$server->getPreviewManager(),
227
+                        false,
228
+                        !\OC::$server->getConfig()->getSystemValue('debug', false)
229
+                    )
230
+                );
231
+
232
+                $this->server->addPlugin(
233
+                    new \Sabre\DAV\PropertyStorage\Plugin(
234
+                        new CustomPropertiesBackend(
235
+                            $this->server->tree,
236
+                            \OC::$server->getDatabaseConnection(),
237
+                            \OC::$server->getUserSession()->getUser()
238
+                        )
239
+                    )
240
+                );
241
+                if ($view !== null) {
242
+                    $this->server->addPlugin(
243
+                        new QuotaPlugin($view, false));
244
+                }
245
+                $this->server->addPlugin(
246
+                    new TagsPlugin(
247
+                        $this->server->tree, \OC::$server->getTagManager()
248
+                    )
249
+                );
250
+                // TODO: switch to LazyUserFolder
251
+                $userFolder = \OC::$server->getUserFolder();
252
+                $this->server->addPlugin(new SharesPlugin(
253
+                    $this->server->tree,
254
+                    $userSession,
255
+                    $userFolder,
256
+                    \OC::$server->getShareManager()
257
+                ));
258
+                $this->server->addPlugin(new CommentPropertiesPlugin(
259
+                    \OC::$server->getCommentsManager(),
260
+                    $userSession
261
+                ));
262
+                $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin());
263
+                if ($view !== null) {
264
+                    $this->server->addPlugin(new FilesReportPlugin(
265
+                        $this->server->tree,
266
+                        $view,
267
+                        \OC::$server->getSystemTagManager(),
268
+                        \OC::$server->getSystemTagObjectMapper(),
269
+                        \OC::$server->getTagManager(),
270
+                        $userSession,
271
+                        \OC::$server->getGroupManager(),
272
+                        $userFolder
273
+                    ));
274
+                    $lazySearchBackend->setBackend(new \OCA\DAV\Files\FileSearchBackend(
275
+                        $this->server->tree,
276
+                        $user,
277
+                        \OC::$server->getRootFolder(),
278
+                        \OC::$server->getShareManager(),
279
+                        $view
280
+                    ));
281
+                }
282
+                $this->server->addPlugin(new \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin(
283
+                    \OC::$server->getConfig(),
284
+                    \OC::$server->query(BirthdayService::class)
285
+                ));
286
+                $this->server->addPlugin(new AppleProvisioningPlugin(
287
+                    \OC::$server->getUserSession(),
288
+                    \OC::$server->getURLGenerator(),
289
+                    \OC::$server->getThemingDefaults(),
290
+                    \OC::$server->getRequest(),
291
+                    \OC::$server->getL10N('dav'),
292
+                    function() {
293
+                        return UUIDUtil::getUUID();
294
+                    }
295
+                ));
296
+            }
297
+
298
+            // register plugins from apps
299
+            $pluginManager = new PluginManager(
300
+                \OC::$server,
301
+                \OC::$server->getAppManager()
302
+            );
303
+            foreach ($pluginManager->getAppPlugins() as $appPlugin) {
304
+                $this->server->addPlugin($appPlugin);
305
+            }
306
+            foreach ($pluginManager->getAppCollections() as $appCollection) {
307
+                $root->addChild($appCollection);
308
+            }
309
+        });
310
+    }
311
+
312
+    public function exec() {
313
+        $this->server->exec();
314
+    }
315
+
316
+    private function requestIsForSubtree(array $subTrees): bool {
317
+        foreach ($subTrees as $subTree) {
318
+            $subTree = trim($subTree, ' /');
319
+            if (strpos($this->server->getRequestUri(), $subTree.'/') === 0) {
320
+                return true;
321
+            }
322
+        }
323
+        return false;
324
+    }
325 325
 }
Please login to merge, or discard this patch.