Passed
Push — master ( b552da...09c1d8 )
by Roeland
12:09 queued 12s
created
apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -36,62 +36,62 @@
 block discarded – undo
36 36
  */
37 37
 class ICSExportPlugin extends \Sabre\CalDAV\ICSExportPlugin {
38 38
 
39
-	/** @var IConfig */
40
-	private $config;
39
+    /** @var IConfig */
40
+    private $config;
41 41
 
42
-	/** @var ILogger */
43
-	private $logger;
42
+    /** @var ILogger */
43
+    private $logger;
44 44
 
45
-	/** @var string */
46
-	private const DEFAULT_REFRESH_INTERVAL = 'PT4H';
45
+    /** @var string */
46
+    private const DEFAULT_REFRESH_INTERVAL = 'PT4H';
47 47
 
48
-	/**
49
-	 * ICSExportPlugin constructor.
50
-	 *
51
-	 * @param IConfig $config
52
-	 */
53
-	public function __construct(IConfig $config, ILogger $logger) {
54
-		$this->config = $config;
55
-		$this->logger = $logger;
56
-	}
48
+    /**
49
+     * ICSExportPlugin constructor.
50
+     *
51
+     * @param IConfig $config
52
+     */
53
+    public function __construct(IConfig $config, ILogger $logger) {
54
+        $this->config = $config;
55
+        $this->logger = $logger;
56
+    }
57 57
 
58
-	/**
59
-	 * @inheritDoc
60
-	 */
61
-	protected function generateResponse($path, $start, $end, $expand, $componentType, $format, $properties, ResponseInterface $response) {
62
-		if (!isset($properties['{http://nextcloud.com/ns}refresh-interval'])) {
63
-			$value = $this->config->getAppValue('dav', 'defaultRefreshIntervalExportedCalendars', self::DEFAULT_REFRESH_INTERVAL);
64
-			$properties['{http://nextcloud.com/ns}refresh-interval'] = $value;
65
-		}
58
+    /**
59
+     * @inheritDoc
60
+     */
61
+    protected function generateResponse($path, $start, $end, $expand, $componentType, $format, $properties, ResponseInterface $response) {
62
+        if (!isset($properties['{http://nextcloud.com/ns}refresh-interval'])) {
63
+            $value = $this->config->getAppValue('dav', 'defaultRefreshIntervalExportedCalendars', self::DEFAULT_REFRESH_INTERVAL);
64
+            $properties['{http://nextcloud.com/ns}refresh-interval'] = $value;
65
+        }
66 66
 
67
-		return parent::generateResponse($path, $start, $end, $expand, $componentType, $format, $properties, $response);
68
-	}
67
+        return parent::generateResponse($path, $start, $end, $expand, $componentType, $format, $properties, $response);
68
+    }
69 69
 
70
-	/**
71
-	 * @inheritDoc
72
-	 */
73
-	public function mergeObjects(array $properties, array $inputObjects) {
74
-		$vcalendar = parent::mergeObjects($properties, $inputObjects);
70
+    /**
71
+     * @inheritDoc
72
+     */
73
+    public function mergeObjects(array $properties, array $inputObjects) {
74
+        $vcalendar = parent::mergeObjects($properties, $inputObjects);
75 75
 
76
-		if (isset($properties['{http://nextcloud.com/ns}refresh-interval'])) {
77
-			$refreshIntervalValue = $properties['{http://nextcloud.com/ns}refresh-interval'];
78
-			try {
79
-				DateTimeParser::parseDuration($refreshIntervalValue);
80
-			} catch (InvalidDataException $ex) {
81
-				$this->logger->debug('Invalid refresh interval for exported calendar, falling back to default value ...');
82
-				$refreshIntervalValue = self::DEFAULT_REFRESH_INTERVAL;
83
-			}
76
+        if (isset($properties['{http://nextcloud.com/ns}refresh-interval'])) {
77
+            $refreshIntervalValue = $properties['{http://nextcloud.com/ns}refresh-interval'];
78
+            try {
79
+                DateTimeParser::parseDuration($refreshIntervalValue);
80
+            } catch (InvalidDataException $ex) {
81
+                $this->logger->debug('Invalid refresh interval for exported calendar, falling back to default value ...');
82
+                $refreshIntervalValue = self::DEFAULT_REFRESH_INTERVAL;
83
+            }
84 84
 
85
-			// https://tools.ietf.org/html/rfc7986#section-5.7
86
-			$refreshInterval = new Duration($vcalendar, 'REFRESH-INTERVAL', $refreshIntervalValue);
87
-			$refreshInterval->add('VALUE', 'DURATION');
88
-			$vcalendar->add($refreshInterval);
85
+            // https://tools.ietf.org/html/rfc7986#section-5.7
86
+            $refreshInterval = new Duration($vcalendar, 'REFRESH-INTERVAL', $refreshIntervalValue);
87
+            $refreshInterval->add('VALUE', 'DURATION');
88
+            $vcalendar->add($refreshInterval);
89 89
 
90
-			// Legacy property for compatibility
91
-			$vcalendar->{'X-PUBLISHED-TTL'} = $refreshIntervalValue;
92
-		}
90
+            // Legacy property for compatibility
91
+            $vcalendar->{'X-PUBLISHED-TTL'} = $refreshIntervalValue;
92
+        }
93 93
 
94
-		return $vcalendar;
95
-	}
94
+        return $vcalendar;
95
+    }
96 96
 
97 97
 }
Please login to merge, or discard this patch.
apps/dav/lib/Server.php 1 patch
Indentation   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -71,260 +71,260 @@
 block discarded – undo
71 71
 
72 72
 class Server {
73 73
 
74
-	/** @var IRequest */
75
-	private $request;
76
-
77
-	/** @var  string */
78
-	private $baseUri;
79
-
80
-	/** @var Connector\Sabre\Server  */
81
-	public $server;
82
-
83
-	public function __construct(IRequest $request, $baseUri) {
84
-		$this->request = $request;
85
-		$this->baseUri = $baseUri;
86
-		$logger = \OC::$server->getLogger();
87
-		$dispatcher = \OC::$server->getEventDispatcher();
88
-
89
-		$root = new RootCollection();
90
-		$this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
91
-
92
-		// Add maintenance plugin
93
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig()));
94
-
95
-		// Backends
96
-		$authBackend = new Auth(
97
-			\OC::$server->getSession(),
98
-			\OC::$server->getUserSession(),
99
-			\OC::$server->getRequest(),
100
-			\OC::$server->getTwoFactorAuthManager(),
101
-			\OC::$server->getBruteForceThrottler()
102
-		);
103
-
104
-		// Set URL explicitly due to reverse-proxy situations
105
-		$this->server->httpRequest->setUrl($this->request->getRequestUri());
106
-		$this->server->setBaseUri($this->baseUri);
107
-
108
-		$this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
109
-		$this->server->addPlugin(new AnonymousOptionsPlugin());
110
-		$authPlugin = new Plugin();
111
-		$authPlugin->addBackend(new PublicAuth());
112
-		$this->server->addPlugin($authPlugin);
113
-
114
-		// allow setup of additional auth backends
115
-		$event = new SabrePluginEvent($this->server);
116
-		$dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);
117
-
118
-		$bearerAuthBackend = new BearerAuth(
119
-			\OC::$server->getUserSession(),
120
-			\OC::$server->getSession(),
121
-			\OC::$server->getRequest()
122
-		);
123
-		$authPlugin->addBackend($bearerAuthBackend);
124
-		// because we are throwing exceptions this plugin has to be the last one
125
-		$authPlugin->addBackend($authBackend);
126
-
127
-		// debugging
128
-		if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
129
-			$this->server->addPlugin(new \Sabre\DAV\Browser\Plugin());
130
-		} else {
131
-			$this->server->addPlugin(new DummyGetResponsePlugin());
132
-		}
133
-
134
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
135
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
136
-		$this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
137
-
138
-		// acl
139
-		$acl = new DavAclPlugin();
140
-		$acl->principalCollectionSet = [
141
-			'principals/users',
142
-			'principals/groups',
143
-			'principals/calendar-resources',
144
-			'principals/calendar-rooms',
145
-		];
146
-		$acl->defaultUsernamePath = 'principals/users';
147
-		$this->server->addPlugin($acl);
148
-
149
-		// calendar plugins
150
-		if ($this->requestIsForSubtree(['calendars', 'public-calendars', 'system-calendars', 'principals'])) {
151
-			$this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
152
-			$this->server->addPlugin(new \OCA\DAV\CalDAV\ICSExportPlugin\ICSExportPlugin(\OC::$server->getConfig(), \OC::$server->getLogger()));
153
-			$this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin());
154
-			if (\OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') {
155
-				$this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class));
156
-			}
157
-
158
-			$this->server->addPlugin(new CalDAV\WebcalCaching\Plugin($request));
159
-			$this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
160
-
161
-			$this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
162
-			$this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
163
-			$this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
164
-				\OC::$server->getConfig(),
165
-				\OC::$server->getURLGenerator()
166
-			));
167
-		}
168
-
169
-		// addressbook plugins
170
-		if ($this->requestIsForSubtree(['addressbooks', 'principals'])) {
171
-			$this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
172
-			$this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());
173
-			$this->server->addPlugin(new VCFExportPlugin());
174
-			$this->server->addPlugin(new MultiGetExportPlugin());
175
-			$this->server->addPlugin(new HasPhotoPlugin());
176
-			$this->server->addPlugin(new ImageExportPlugin(new PhotoCache(
177
-				\OC::$server->getAppDataDir('dav-photocache'),
178
-				\OC::$server->getLogger())
179
-			));
180
-		}
181
-
182
-		// system tags plugins
183
-		$this->server->addPlugin(new SystemTagPlugin(
184
-			\OC::$server->getSystemTagManager(),
185
-			\OC::$server->getGroupManager(),
186
-			\OC::$server->getUserSession()
187
-		));
188
-
189
-		// comments plugin
190
-		$this->server->addPlugin(new CommentsPlugin(
191
-			\OC::$server->getCommentsManager(),
192
-			\OC::$server->getUserSession()
193
-		));
194
-
195
-		$this->server->addPlugin(new CopyEtagHeaderPlugin());
196
-		$this->server->addPlugin(new ChunkingPlugin());
197
-
198
-		// allow setup of additional plugins
199
-		$dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event);
200
-
201
-		// Some WebDAV clients do require Class 2 WebDAV support (locking), since
202
-		// we do not provide locking we emulate it using a fake locking plugin.
203
-		if($request->isUserAgent([
204
-			'/WebDAVFS/',
205
-			'/OneNote/',
206
-			'/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601
207
-		])) {
208
-			$this->server->addPlugin(new FakeLockerPlugin());
209
-		}
210
-
211
-		if (BrowserErrorPagePlugin::isBrowserRequest($request)) {
212
-			$this->server->addPlugin(new BrowserErrorPagePlugin());
213
-		}
214
-
215
-		$lazySearchBackend = new LazySearchBackend();
216
-		$this->server->addPlugin(new SearchPlugin($lazySearchBackend));
217
-
218
-		// wait with registering these until auth is handled and the filesystem is setup
219
-		$this->server->on('beforeMethod', function () use ($root, $lazySearchBackend) {
220
-			// custom properties plugin must be the last one
221
-			$userSession = \OC::$server->getUserSession();
222
-			$user = $userSession->getUser();
223
-			if ($user !== null) {
224
-				$view = \OC\Files\Filesystem::getView();
225
-				$this->server->addPlugin(
226
-					new FilesPlugin(
227
-						$this->server->tree,
228
-						\OC::$server->getConfig(),
229
-						$this->request,
230
-						\OC::$server->getPreviewManager(),
231
-						false,
232
-						!\OC::$server->getConfig()->getSystemValue('debug', false)
233
-					)
234
-				);
235
-
236
-				$this->server->addPlugin(
237
-					new \Sabre\DAV\PropertyStorage\Plugin(
238
-						new CustomPropertiesBackend(
239
-							$this->server->tree,
240
-							\OC::$server->getDatabaseConnection(),
241
-							\OC::$server->getUserSession()->getUser()
242
-						)
243
-					)
244
-				);
245
-				if ($view !== null) {
246
-					$this->server->addPlugin(
247
-						new QuotaPlugin($view, false));
248
-				}
249
-				$this->server->addPlugin(
250
-					new TagsPlugin(
251
-						$this->server->tree, \OC::$server->getTagManager()
252
-					)
253
-				);
254
-				// TODO: switch to LazyUserFolder
255
-				$userFolder = \OC::$server->getUserFolder();
256
-				$this->server->addPlugin(new SharesPlugin(
257
-					$this->server->tree,
258
-					$userSession,
259
-					$userFolder,
260
-					\OC::$server->getShareManager()
261
-				));
262
-				$this->server->addPlugin(new CommentPropertiesPlugin(
263
-					\OC::$server->getCommentsManager(),
264
-					$userSession
265
-				));
266
-				$this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin());
267
-				if ($view !== null) {
268
-					$this->server->addPlugin(new FilesReportPlugin(
269
-						$this->server->tree,
270
-						$view,
271
-						\OC::$server->getSystemTagManager(),
272
-						\OC::$server->getSystemTagObjectMapper(),
273
-						\OC::$server->getTagManager(),
274
-						$userSession,
275
-						\OC::$server->getGroupManager(),
276
-						$userFolder,
277
-						\OC::$server->getAppManager()
278
-					));
279
-					$lazySearchBackend->setBackend(new \OCA\DAV\Files\FileSearchBackend(
280
-						$this->server->tree,
281
-						$user,
282
-						\OC::$server->getRootFolder(),
283
-						\OC::$server->getShareManager(),
284
-						$view
285
-					));
286
-				}
287
-				$this->server->addPlugin(new \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin(
288
-					\OC::$server->getConfig(),
289
-					\OC::$server->query(BirthdayService::class)
290
-				));
291
-				$this->server->addPlugin(new AppleProvisioningPlugin(
292
-					\OC::$server->getUserSession(),
293
-					\OC::$server->getURLGenerator(),
294
-					\OC::$server->getThemingDefaults(),
295
-					\OC::$server->getRequest(),
296
-					\OC::$server->getL10N('dav'),
297
-					function() {
298
-						return UUIDUtil::getUUID();
299
-					}
300
-				));
301
-			}
302
-
303
-			// register plugins from apps
304
-			$pluginManager = new PluginManager(
305
-				\OC::$server,
306
-				\OC::$server->getAppManager()
307
-			);
308
-			foreach ($pluginManager->getAppPlugins() as $appPlugin) {
309
-				$this->server->addPlugin($appPlugin);
310
-			}
311
-			foreach ($pluginManager->getAppCollections() as $appCollection) {
312
-				$root->addChild($appCollection);
313
-			}
314
-		});
315
-	}
316
-
317
-	public function exec() {
318
-		$this->server->exec();
319
-	}
320
-
321
-	private function requestIsForSubtree(array $subTrees): bool {
322
-		foreach ($subTrees as $subTree) {
323
-			$subTree = trim($subTree, ' /');
324
-			if (strpos($this->server->getRequestUri(), $subTree.'/') === 0) {
325
-				return true;
326
-			}
327
-		}
328
-		return false;
329
-	}
74
+    /** @var IRequest */
75
+    private $request;
76
+
77
+    /** @var  string */
78
+    private $baseUri;
79
+
80
+    /** @var Connector\Sabre\Server  */
81
+    public $server;
82
+
83
+    public function __construct(IRequest $request, $baseUri) {
84
+        $this->request = $request;
85
+        $this->baseUri = $baseUri;
86
+        $logger = \OC::$server->getLogger();
87
+        $dispatcher = \OC::$server->getEventDispatcher();
88
+
89
+        $root = new RootCollection();
90
+        $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
91
+
92
+        // Add maintenance plugin
93
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig()));
94
+
95
+        // Backends
96
+        $authBackend = new Auth(
97
+            \OC::$server->getSession(),
98
+            \OC::$server->getUserSession(),
99
+            \OC::$server->getRequest(),
100
+            \OC::$server->getTwoFactorAuthManager(),
101
+            \OC::$server->getBruteForceThrottler()
102
+        );
103
+
104
+        // Set URL explicitly due to reverse-proxy situations
105
+        $this->server->httpRequest->setUrl($this->request->getRequestUri());
106
+        $this->server->setBaseUri($this->baseUri);
107
+
108
+        $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
109
+        $this->server->addPlugin(new AnonymousOptionsPlugin());
110
+        $authPlugin = new Plugin();
111
+        $authPlugin->addBackend(new PublicAuth());
112
+        $this->server->addPlugin($authPlugin);
113
+
114
+        // allow setup of additional auth backends
115
+        $event = new SabrePluginEvent($this->server);
116
+        $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);
117
+
118
+        $bearerAuthBackend = new BearerAuth(
119
+            \OC::$server->getUserSession(),
120
+            \OC::$server->getSession(),
121
+            \OC::$server->getRequest()
122
+        );
123
+        $authPlugin->addBackend($bearerAuthBackend);
124
+        // because we are throwing exceptions this plugin has to be the last one
125
+        $authPlugin->addBackend($authBackend);
126
+
127
+        // debugging
128
+        if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
129
+            $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin());
130
+        } else {
131
+            $this->server->addPlugin(new DummyGetResponsePlugin());
132
+        }
133
+
134
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
135
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
136
+        $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
137
+
138
+        // acl
139
+        $acl = new DavAclPlugin();
140
+        $acl->principalCollectionSet = [
141
+            'principals/users',
142
+            'principals/groups',
143
+            'principals/calendar-resources',
144
+            'principals/calendar-rooms',
145
+        ];
146
+        $acl->defaultUsernamePath = 'principals/users';
147
+        $this->server->addPlugin($acl);
148
+
149
+        // calendar plugins
150
+        if ($this->requestIsForSubtree(['calendars', 'public-calendars', 'system-calendars', 'principals'])) {
151
+            $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
152
+            $this->server->addPlugin(new \OCA\DAV\CalDAV\ICSExportPlugin\ICSExportPlugin(\OC::$server->getConfig(), \OC::$server->getLogger()));
153
+            $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin());
154
+            if (\OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') {
155
+                $this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class));
156
+            }
157
+
158
+            $this->server->addPlugin(new CalDAV\WebcalCaching\Plugin($request));
159
+            $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
160
+
161
+            $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
162
+            $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
163
+            $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
164
+                \OC::$server->getConfig(),
165
+                \OC::$server->getURLGenerator()
166
+            ));
167
+        }
168
+
169
+        // addressbook plugins
170
+        if ($this->requestIsForSubtree(['addressbooks', 'principals'])) {
171
+            $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
172
+            $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());
173
+            $this->server->addPlugin(new VCFExportPlugin());
174
+            $this->server->addPlugin(new MultiGetExportPlugin());
175
+            $this->server->addPlugin(new HasPhotoPlugin());
176
+            $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(
177
+                \OC::$server->getAppDataDir('dav-photocache'),
178
+                \OC::$server->getLogger())
179
+            ));
180
+        }
181
+
182
+        // system tags plugins
183
+        $this->server->addPlugin(new SystemTagPlugin(
184
+            \OC::$server->getSystemTagManager(),
185
+            \OC::$server->getGroupManager(),
186
+            \OC::$server->getUserSession()
187
+        ));
188
+
189
+        // comments plugin
190
+        $this->server->addPlugin(new CommentsPlugin(
191
+            \OC::$server->getCommentsManager(),
192
+            \OC::$server->getUserSession()
193
+        ));
194
+
195
+        $this->server->addPlugin(new CopyEtagHeaderPlugin());
196
+        $this->server->addPlugin(new ChunkingPlugin());
197
+
198
+        // allow setup of additional plugins
199
+        $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event);
200
+
201
+        // Some WebDAV clients do require Class 2 WebDAV support (locking), since
202
+        // we do not provide locking we emulate it using a fake locking plugin.
203
+        if($request->isUserAgent([
204
+            '/WebDAVFS/',
205
+            '/OneNote/',
206
+            '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601
207
+        ])) {
208
+            $this->server->addPlugin(new FakeLockerPlugin());
209
+        }
210
+
211
+        if (BrowserErrorPagePlugin::isBrowserRequest($request)) {
212
+            $this->server->addPlugin(new BrowserErrorPagePlugin());
213
+        }
214
+
215
+        $lazySearchBackend = new LazySearchBackend();
216
+        $this->server->addPlugin(new SearchPlugin($lazySearchBackend));
217
+
218
+        // wait with registering these until auth is handled and the filesystem is setup
219
+        $this->server->on('beforeMethod', function () use ($root, $lazySearchBackend) {
220
+            // custom properties plugin must be the last one
221
+            $userSession = \OC::$server->getUserSession();
222
+            $user = $userSession->getUser();
223
+            if ($user !== null) {
224
+                $view = \OC\Files\Filesystem::getView();
225
+                $this->server->addPlugin(
226
+                    new FilesPlugin(
227
+                        $this->server->tree,
228
+                        \OC::$server->getConfig(),
229
+                        $this->request,
230
+                        \OC::$server->getPreviewManager(),
231
+                        false,
232
+                        !\OC::$server->getConfig()->getSystemValue('debug', false)
233
+                    )
234
+                );
235
+
236
+                $this->server->addPlugin(
237
+                    new \Sabre\DAV\PropertyStorage\Plugin(
238
+                        new CustomPropertiesBackend(
239
+                            $this->server->tree,
240
+                            \OC::$server->getDatabaseConnection(),
241
+                            \OC::$server->getUserSession()->getUser()
242
+                        )
243
+                    )
244
+                );
245
+                if ($view !== null) {
246
+                    $this->server->addPlugin(
247
+                        new QuotaPlugin($view, false));
248
+                }
249
+                $this->server->addPlugin(
250
+                    new TagsPlugin(
251
+                        $this->server->tree, \OC::$server->getTagManager()
252
+                    )
253
+                );
254
+                // TODO: switch to LazyUserFolder
255
+                $userFolder = \OC::$server->getUserFolder();
256
+                $this->server->addPlugin(new SharesPlugin(
257
+                    $this->server->tree,
258
+                    $userSession,
259
+                    $userFolder,
260
+                    \OC::$server->getShareManager()
261
+                ));
262
+                $this->server->addPlugin(new CommentPropertiesPlugin(
263
+                    \OC::$server->getCommentsManager(),
264
+                    $userSession
265
+                ));
266
+                $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin());
267
+                if ($view !== null) {
268
+                    $this->server->addPlugin(new FilesReportPlugin(
269
+                        $this->server->tree,
270
+                        $view,
271
+                        \OC::$server->getSystemTagManager(),
272
+                        \OC::$server->getSystemTagObjectMapper(),
273
+                        \OC::$server->getTagManager(),
274
+                        $userSession,
275
+                        \OC::$server->getGroupManager(),
276
+                        $userFolder,
277
+                        \OC::$server->getAppManager()
278
+                    ));
279
+                    $lazySearchBackend->setBackend(new \OCA\DAV\Files\FileSearchBackend(
280
+                        $this->server->tree,
281
+                        $user,
282
+                        \OC::$server->getRootFolder(),
283
+                        \OC::$server->getShareManager(),
284
+                        $view
285
+                    ));
286
+                }
287
+                $this->server->addPlugin(new \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin(
288
+                    \OC::$server->getConfig(),
289
+                    \OC::$server->query(BirthdayService::class)
290
+                ));
291
+                $this->server->addPlugin(new AppleProvisioningPlugin(
292
+                    \OC::$server->getUserSession(),
293
+                    \OC::$server->getURLGenerator(),
294
+                    \OC::$server->getThemingDefaults(),
295
+                    \OC::$server->getRequest(),
296
+                    \OC::$server->getL10N('dav'),
297
+                    function() {
298
+                        return UUIDUtil::getUUID();
299
+                    }
300
+                ));
301
+            }
302
+
303
+            // register plugins from apps
304
+            $pluginManager = new PluginManager(
305
+                \OC::$server,
306
+                \OC::$server->getAppManager()
307
+            );
308
+            foreach ($pluginManager->getAppPlugins() as $appPlugin) {
309
+                $this->server->addPlugin($appPlugin);
310
+            }
311
+            foreach ($pluginManager->getAppCollections() as $appCollection) {
312
+                $root->addChild($appCollection);
313
+            }
314
+        });
315
+    }
316
+
317
+    public function exec() {
318
+        $this->server->exec();
319
+    }
320
+
321
+    private function requestIsForSubtree(array $subTrees): bool {
322
+        foreach ($subTrees as $subTree) {
323
+            $subTree = trim($subTree, ' /');
324
+            if (strpos($this->server->getRequestUri(), $subTree.'/') === 0) {
325
+                return true;
326
+            }
327
+        }
328
+        return false;
329
+    }
330 330
 }
Please login to merge, or discard this patch.