Passed
Push — master ( 6bba82...6aea53 )
by Roeland
13:22 queued 02:30
created
apps/dav/lib/Connector/Sabre/ServerFactory.php 1 patch
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -49,179 +49,179 @@
 block discarded – undo
49 49
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
50 50
 
51 51
 class ServerFactory {
52
-	/** @var IConfig */
53
-	private $config;
54
-	/** @var ILogger */
55
-	private $logger;
56
-	/** @var IDBConnection */
57
-	private $databaseConnection;
58
-	/** @var IUserSession */
59
-	private $userSession;
60
-	/** @var IMountManager */
61
-	private $mountManager;
62
-	/** @var ITagManager */
63
-	private $tagManager;
64
-	/** @var IRequest */
65
-	private $request;
66
-	/** @var IPreview  */
67
-	private $previewManager;
68
-	/** @var EventDispatcherInterface */
69
-	private $eventDispatcher;
70
-	/** @var IL10N */
71
-	private $l10n;
52
+    /** @var IConfig */
53
+    private $config;
54
+    /** @var ILogger */
55
+    private $logger;
56
+    /** @var IDBConnection */
57
+    private $databaseConnection;
58
+    /** @var IUserSession */
59
+    private $userSession;
60
+    /** @var IMountManager */
61
+    private $mountManager;
62
+    /** @var ITagManager */
63
+    private $tagManager;
64
+    /** @var IRequest */
65
+    private $request;
66
+    /** @var IPreview  */
67
+    private $previewManager;
68
+    /** @var EventDispatcherInterface */
69
+    private $eventDispatcher;
70
+    /** @var IL10N */
71
+    private $l10n;
72 72
 
73
-	/**
74
-	 * @param IConfig $config
75
-	 * @param ILogger $logger
76
-	 * @param IDBConnection $databaseConnection
77
-	 * @param IUserSession $userSession
78
-	 * @param IMountManager $mountManager
79
-	 * @param ITagManager $tagManager
80
-	 * @param IRequest $request
81
-	 * @param IPreview $previewManager
82
-	 */
83
-	public function __construct(
84
-		IConfig $config,
85
-		ILogger $logger,
86
-		IDBConnection $databaseConnection,
87
-		IUserSession $userSession,
88
-		IMountManager $mountManager,
89
-		ITagManager $tagManager,
90
-		IRequest $request,
91
-		IPreview $previewManager,
92
-		EventDispatcherInterface $eventDispatcher,
93
-		IL10N $l10n
94
-	) {
95
-		$this->config = $config;
96
-		$this->logger = $logger;
97
-		$this->databaseConnection = $databaseConnection;
98
-		$this->userSession = $userSession;
99
-		$this->mountManager = $mountManager;
100
-		$this->tagManager = $tagManager;
101
-		$this->request = $request;
102
-		$this->previewManager = $previewManager;
103
-		$this->eventDispatcher = $eventDispatcher;
104
-		$this->l10n = $l10n;
105
-	}
73
+    /**
74
+     * @param IConfig $config
75
+     * @param ILogger $logger
76
+     * @param IDBConnection $databaseConnection
77
+     * @param IUserSession $userSession
78
+     * @param IMountManager $mountManager
79
+     * @param ITagManager $tagManager
80
+     * @param IRequest $request
81
+     * @param IPreview $previewManager
82
+     */
83
+    public function __construct(
84
+        IConfig $config,
85
+        ILogger $logger,
86
+        IDBConnection $databaseConnection,
87
+        IUserSession $userSession,
88
+        IMountManager $mountManager,
89
+        ITagManager $tagManager,
90
+        IRequest $request,
91
+        IPreview $previewManager,
92
+        EventDispatcherInterface $eventDispatcher,
93
+        IL10N $l10n
94
+    ) {
95
+        $this->config = $config;
96
+        $this->logger = $logger;
97
+        $this->databaseConnection = $databaseConnection;
98
+        $this->userSession = $userSession;
99
+        $this->mountManager = $mountManager;
100
+        $this->tagManager = $tagManager;
101
+        $this->request = $request;
102
+        $this->previewManager = $previewManager;
103
+        $this->eventDispatcher = $eventDispatcher;
104
+        $this->l10n = $l10n;
105
+    }
106 106
 
107
-	/**
108
-	 * @param string $baseUri
109
-	 * @param string $requestUri
110
-	 * @param Plugin $authPlugin
111
-	 * @param callable $viewCallBack callback that should return the view for the dav endpoint
112
-	 * @return Server
113
-	 */
114
-	public function createServer($baseUri,
115
-								 $requestUri,
116
-								 Plugin $authPlugin,
117
-								 callable $viewCallBack) {
118
-		// Fire up server
119
-		$objectTree = new \OCA\DAV\Connector\Sabre\ObjectTree();
120
-		$server = new \OCA\DAV\Connector\Sabre\Server($objectTree);
121
-		// Set URL explicitly due to reverse-proxy situations
122
-		$server->httpRequest->setUrl($requestUri);
123
-		$server->setBaseUri($baseUri);
107
+    /**
108
+     * @param string $baseUri
109
+     * @param string $requestUri
110
+     * @param Plugin $authPlugin
111
+     * @param callable $viewCallBack callback that should return the view for the dav endpoint
112
+     * @return Server
113
+     */
114
+    public function createServer($baseUri,
115
+                                    $requestUri,
116
+                                    Plugin $authPlugin,
117
+                                    callable $viewCallBack) {
118
+        // Fire up server
119
+        $objectTree = new \OCA\DAV\Connector\Sabre\ObjectTree();
120
+        $server = new \OCA\DAV\Connector\Sabre\Server($objectTree);
121
+        // Set URL explicitly due to reverse-proxy situations
122
+        $server->httpRequest->setUrl($requestUri);
123
+        $server->setBaseUri($baseUri);
124 124
 
125
-		// Load plugins
126
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin($this->config, $this->l10n));
127
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin($this->config));
128
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\AnonymousOptionsPlugin());
129
-		$server->addPlugin($authPlugin);
130
-		// FIXME: The following line is a workaround for legacy components relying on being able to send a GET to /
131
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\DummyGetResponsePlugin());
132
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $this->logger));
133
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
134
-		// Some WebDAV clients do require Class 2 WebDAV support (locking), since
135
-		// we do not provide locking we emulate it using a fake locking plugin.
136
-		if ($this->request->isUserAgent([
137
-			'/WebDAVFS/',
138
-			'/OneNote/',
139
-			'/Microsoft-WebDAV-MiniRedir/',
140
-		])) {
141
-			$server->addPlugin(new \OCA\DAV\Connector\Sabre\FakeLockerPlugin());
142
-		}
125
+        // Load plugins
126
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin($this->config, $this->l10n));
127
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin($this->config));
128
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\AnonymousOptionsPlugin());
129
+        $server->addPlugin($authPlugin);
130
+        // FIXME: The following line is a workaround for legacy components relying on being able to send a GET to /
131
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\DummyGetResponsePlugin());
132
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $this->logger));
133
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
134
+        // Some WebDAV clients do require Class 2 WebDAV support (locking), since
135
+        // we do not provide locking we emulate it using a fake locking plugin.
136
+        if ($this->request->isUserAgent([
137
+            '/WebDAVFS/',
138
+            '/OneNote/',
139
+            '/Microsoft-WebDAV-MiniRedir/',
140
+        ])) {
141
+            $server->addPlugin(new \OCA\DAV\Connector\Sabre\FakeLockerPlugin());
142
+        }
143 143
 
144
-		if (BrowserErrorPagePlugin::isBrowserRequest($this->request)) {
145
-			$server->addPlugin(new BrowserErrorPagePlugin());
146
-		}
144
+        if (BrowserErrorPagePlugin::isBrowserRequest($this->request)) {
145
+            $server->addPlugin(new BrowserErrorPagePlugin());
146
+        }
147 147
 
148
-		// wait with registering these until auth is handled and the filesystem is setup
149
-		$server->on('beforeMethod:*', function () use ($server, $objectTree, $viewCallBack) {
150
-			// ensure the skeleton is copied
151
-			$userFolder = \OC::$server->getUserFolder();
148
+        // wait with registering these until auth is handled and the filesystem is setup
149
+        $server->on('beforeMethod:*', function () use ($server, $objectTree, $viewCallBack) {
150
+            // ensure the skeleton is copied
151
+            $userFolder = \OC::$server->getUserFolder();
152 152
 
153
-			/** @var \OC\Files\View $view */
154
-			$view = $viewCallBack($server);
155
-			if ($userFolder instanceof Folder && $userFolder->getPath() === $view->getRoot()) {
156
-				$rootInfo = $userFolder;
157
-			} else {
158
-				$rootInfo = $view->getFileInfo('');
159
-			}
153
+            /** @var \OC\Files\View $view */
154
+            $view = $viewCallBack($server);
155
+            if ($userFolder instanceof Folder && $userFolder->getPath() === $view->getRoot()) {
156
+                $rootInfo = $userFolder;
157
+            } else {
158
+                $rootInfo = $view->getFileInfo('');
159
+            }
160 160
 
161
-			// Create Nextcloud Dir
162
-			if ($rootInfo->getType() === 'dir') {
163
-				$root = new \OCA\DAV\Connector\Sabre\Directory($view, $rootInfo, $objectTree);
164
-			} else {
165
-				$root = new \OCA\DAV\Connector\Sabre\File($view, $rootInfo);
166
-			}
167
-			$objectTree->init($root, $view, $this->mountManager);
161
+            // Create Nextcloud Dir
162
+            if ($rootInfo->getType() === 'dir') {
163
+                $root = new \OCA\DAV\Connector\Sabre\Directory($view, $rootInfo, $objectTree);
164
+            } else {
165
+                $root = new \OCA\DAV\Connector\Sabre\File($view, $rootInfo);
166
+            }
167
+            $objectTree->init($root, $view, $this->mountManager);
168 168
 
169
-			$server->addPlugin(
170
-				new \OCA\DAV\Connector\Sabre\FilesPlugin(
171
-					$objectTree,
172
-					$this->config,
173
-					$this->request,
174
-					$this->previewManager,
175
-					false,
176
-					!$this->config->getSystemValue('debug', false)
177
-				)
178
-			);
179
-			$server->addPlugin(new \OCA\DAV\Connector\Sabre\QuotaPlugin($view, true));
169
+            $server->addPlugin(
170
+                new \OCA\DAV\Connector\Sabre\FilesPlugin(
171
+                    $objectTree,
172
+                    $this->config,
173
+                    $this->request,
174
+                    $this->previewManager,
175
+                    false,
176
+                    !$this->config->getSystemValue('debug', false)
177
+                )
178
+            );
179
+            $server->addPlugin(new \OCA\DAV\Connector\Sabre\QuotaPlugin($view, true));
180 180
 
181
-			if ($this->userSession->isLoggedIn()) {
182
-				$server->addPlugin(new \OCA\DAV\Connector\Sabre\TagsPlugin($objectTree, $this->tagManager));
183
-				$server->addPlugin(new \OCA\DAV\Connector\Sabre\SharesPlugin(
184
-					$objectTree,
185
-					$this->userSession,
186
-					$userFolder,
187
-					\OC::$server->getShareManager()
188
-				));
189
-				$server->addPlugin(new \OCA\DAV\Connector\Sabre\CommentPropertiesPlugin(\OC::$server->getCommentsManager(), $this->userSession));
190
-				$server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesReportPlugin(
191
-					$objectTree,
192
-					$view,
193
-					\OC::$server->getSystemTagManager(),
194
-					\OC::$server->getSystemTagObjectMapper(),
195
-					\OC::$server->getTagManager(),
196
-					$this->userSession,
197
-					\OC::$server->getGroupManager(),
198
-					$userFolder,
199
-					\OC::$server->getAppManager()
200
-				));
201
-				// custom properties plugin must be the last one
202
-				$server->addPlugin(
203
-					new \Sabre\DAV\PropertyStorage\Plugin(
204
-						new \OCA\DAV\DAV\CustomPropertiesBackend(
205
-							$objectTree,
206
-							$this->databaseConnection,
207
-							$this->userSession->getUser()
208
-						)
209
-					)
210
-				);
211
-			}
212
-			$server->addPlugin(new \OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin());
181
+            if ($this->userSession->isLoggedIn()) {
182
+                $server->addPlugin(new \OCA\DAV\Connector\Sabre\TagsPlugin($objectTree, $this->tagManager));
183
+                $server->addPlugin(new \OCA\DAV\Connector\Sabre\SharesPlugin(
184
+                    $objectTree,
185
+                    $this->userSession,
186
+                    $userFolder,
187
+                    \OC::$server->getShareManager()
188
+                ));
189
+                $server->addPlugin(new \OCA\DAV\Connector\Sabre\CommentPropertiesPlugin(\OC::$server->getCommentsManager(), $this->userSession));
190
+                $server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesReportPlugin(
191
+                    $objectTree,
192
+                    $view,
193
+                    \OC::$server->getSystemTagManager(),
194
+                    \OC::$server->getSystemTagObjectMapper(),
195
+                    \OC::$server->getTagManager(),
196
+                    $this->userSession,
197
+                    \OC::$server->getGroupManager(),
198
+                    $userFolder,
199
+                    \OC::$server->getAppManager()
200
+                ));
201
+                // custom properties plugin must be the last one
202
+                $server->addPlugin(
203
+                    new \Sabre\DAV\PropertyStorage\Plugin(
204
+                        new \OCA\DAV\DAV\CustomPropertiesBackend(
205
+                            $objectTree,
206
+                            $this->databaseConnection,
207
+                            $this->userSession->getUser()
208
+                        )
209
+                    )
210
+                );
211
+            }
212
+            $server->addPlugin(new \OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin());
213 213
 
214
-			// Load dav plugins from apps
215
-			$event = new SabrePluginEvent($server);
216
-			$this->eventDispatcher->dispatch($event);
217
-			$pluginManager = new PluginManager(
218
-				\OC::$server,
219
-				\OC::$server->getAppManager()
220
-			);
221
-			foreach ($pluginManager->getAppPlugins() as $appPlugin) {
222
-				$server->addPlugin($appPlugin);
223
-			}
224
-		}, 30); // priority 30: after auth (10) and acl(20), before lock(50) and handling the request
225
-		return $server;
226
-	}
214
+            // Load dav plugins from apps
215
+            $event = new SabrePluginEvent($server);
216
+            $this->eventDispatcher->dispatch($event);
217
+            $pluginManager = new PluginManager(
218
+                \OC::$server,
219
+                \OC::$server->getAppManager()
220
+            );
221
+            foreach ($pluginManager->getAppPlugins() as $appPlugin) {
222
+                $server->addPlugin($appPlugin);
223
+            }
224
+        }, 30); // priority 30: after auth (10) and acl(20), before lock(50) and handling the request
225
+        return $server;
226
+    }
227 227
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/MaintenancePlugin.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -35,59 +35,59 @@
 block discarded – undo
35 35
 
36 36
 class MaintenancePlugin extends ServerPlugin {
37 37
 
38
-	/** @var IConfig */
39
-	private $config;
38
+    /** @var IConfig */
39
+    private $config;
40 40
 
41
-	/** @var \OCP\IL10N */
42
-	private $l10n;
41
+    /** @var \OCP\IL10N */
42
+    private $l10n;
43 43
 
44
-	/**
45
-	 * Reference to main server object
46
-	 *
47
-	 * @var Server
48
-	 */
49
-	private $server;
44
+    /**
45
+     * Reference to main server object
46
+     *
47
+     * @var Server
48
+     */
49
+    private $server;
50 50
 
51
-	/**
52
-	 * @param IConfig $config
53
-	 */
54
-	public function __construct(IConfig $config, IL10N $l10n) {
55
-		$this->config = $config;
56
-		$this->l10n = \OC::$server->getL10N('dav');
57
-	}
51
+    /**
52
+     * @param IConfig $config
53
+     */
54
+    public function __construct(IConfig $config, IL10N $l10n) {
55
+        $this->config = $config;
56
+        $this->l10n = \OC::$server->getL10N('dav');
57
+    }
58 58
 
59 59
 
60
-	/**
61
-	 * This initializes the plugin.
62
-	 *
63
-	 * This function is called by \Sabre\DAV\Server, after
64
-	 * addPlugin is called.
65
-	 *
66
-	 * This method should set up the required event subscriptions.
67
-	 *
68
-	 * @param \Sabre\DAV\Server $server
69
-	 * @return void
70
-	 */
71
-	public function initialize(\Sabre\DAV\Server $server) {
72
-		$this->server = $server;
73
-		$this->server->on('beforeMethod:*', [$this, 'checkMaintenanceMode'], 1);
74
-	}
60
+    /**
61
+     * This initializes the plugin.
62
+     *
63
+     * This function is called by \Sabre\DAV\Server, after
64
+     * addPlugin is called.
65
+     *
66
+     * This method should set up the required event subscriptions.
67
+     *
68
+     * @param \Sabre\DAV\Server $server
69
+     * @return void
70
+     */
71
+    public function initialize(\Sabre\DAV\Server $server) {
72
+        $this->server = $server;
73
+        $this->server->on('beforeMethod:*', [$this, 'checkMaintenanceMode'], 1);
74
+    }
75 75
 
76
-	/**
77
-	 * This method is called before any HTTP method and returns http status code 503
78
-	 * in case the system is in maintenance mode.
79
-	 *
80
-	 * @throws ServiceUnavailable
81
-	 * @return bool
82
-	 */
83
-	public function checkMaintenanceMode() {
84
-		if ($this->config->getSystemValueBool('maintenance')) {
85
-			throw new ServiceUnavailable($this->l10n->t('System in maintenance mode.'));
86
-		}
87
-		if (Util::needUpgrade()) {
88
-			throw new ServiceUnavailable($this->l10n->t('Upgrade needed'));
89
-		}
76
+    /**
77
+     * This method is called before any HTTP method and returns http status code 503
78
+     * in case the system is in maintenance mode.
79
+     *
80
+     * @throws ServiceUnavailable
81
+     * @return bool
82
+     */
83
+    public function checkMaintenanceMode() {
84
+        if ($this->config->getSystemValueBool('maintenance')) {
85
+            throw new ServiceUnavailable($this->l10n->t('System in maintenance mode.'));
86
+        }
87
+        if (Util::needUpgrade()) {
88
+            throw new ServiceUnavailable($this->l10n->t('Upgrade needed'));
89
+        }
90 90
 
91
-		return true;
92
-	}
91
+        return true;
92
+    }
93 93
 }
Please login to merge, or discard this patch.
apps/dav/lib/Direct/ServerFactory.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -35,31 +35,31 @@
 block discarded – undo
35 35
 use OCP\IRequest;
36 36
 
37 37
 class ServerFactory {
38
-	/** @var IConfig */
39
-	private $config;
40
-	/** @var IL10N */
41
-	private $l10n;
38
+    /** @var IConfig */
39
+    private $config;
40
+    /** @var IL10N */
41
+    private $l10n;
42 42
 
43
-	public function __construct(IConfig $config, IL10N $l10n) {
44
-		$this->config = $config;
45
-		$this->l10n = $l10n;
46
-	}
43
+    public function __construct(IConfig $config, IL10N $l10n) {
44
+        $this->config = $config;
45
+        $this->l10n = $l10n;
46
+    }
47 47
 
48
-	public function createServer(string $baseURI,
49
-								 string $requestURI,
50
-								 IRootFolder $rootFolder,
51
-								 DirectMapper $mapper,
52
-								 ITimeFactory $timeFactory,
53
-								 Throttler $throttler,
54
-								 IRequest $request): Server {
55
-		$home = new DirectHome($rootFolder, $mapper, $timeFactory, $throttler, $request);
56
-		$server = new Server($home);
48
+    public function createServer(string $baseURI,
49
+                                    string $requestURI,
50
+                                    IRootFolder $rootFolder,
51
+                                    DirectMapper $mapper,
52
+                                    ITimeFactory $timeFactory,
53
+                                    Throttler $throttler,
54
+                                    IRequest $request): Server {
55
+        $home = new DirectHome($rootFolder, $mapper, $timeFactory, $throttler, $request);
56
+        $server = new Server($home);
57 57
 
58
-		$server->httpRequest->setUrl($requestURI);
59
-		$server->setBaseUri($baseURI);
58
+        $server->httpRequest->setUrl($requestURI);
59
+        $server->setBaseUri($baseURI);
60 60
 
61
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin($this->config, $this->l10n));
61
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin($this->config, $this->l10n));
62 62
 
63
-		return $server;
64
-	}
63
+        return $server;
64
+    }
65 65
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -37,86 +37,86 @@
 block discarded – undo
37 37
 
38 38
 class InvitationResponseServer {
39 39
 
40
-	/** @var \OCA\DAV\Connector\Sabre\Server */
41
-	public $server;
40
+    /** @var \OCA\DAV\Connector\Sabre\Server */
41
+    public $server;
42 42
 
43
-	/**
44
-	 * InvitationResponseServer constructor.
45
-	 */
46
-	public function __construct() {
47
-		$baseUri = \OC::$WEBROOT . '/remote.php/dav/';
48
-		$logger = \OC::$server->getLogger();
49
-		$dispatcher = \OC::$server->getEventDispatcher();
43
+    /**
44
+     * InvitationResponseServer constructor.
45
+     */
46
+    public function __construct() {
47
+        $baseUri = \OC::$WEBROOT . '/remote.php/dav/';
48
+        $logger = \OC::$server->getLogger();
49
+        $dispatcher = \OC::$server->getEventDispatcher();
50 50
 
51
-		$root = new RootCollection();
52
-		$this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
51
+        $root = new RootCollection();
52
+        $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
53 53
 
54
-		// Add maintenance plugin
55
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav')));
54
+        // Add maintenance plugin
55
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav')));
56 56
 
57
-		// Set URL explicitly due to reverse-proxy situations
58
-		$this->server->httpRequest->setUrl($baseUri);
59
-		$this->server->setBaseUri($baseUri);
57
+        // Set URL explicitly due to reverse-proxy situations
58
+        $this->server->httpRequest->setUrl($baseUri);
59
+        $this->server->setBaseUri($baseUri);
60 60
 
61
-		$this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
62
-		$this->server->addPlugin(new AnonymousOptionsPlugin());
63
-		$this->server->addPlugin(new class() extends Plugin {
64
-			public function getCurrentPrincipal() {
65
-				return 'principals/system/public';
66
-			}
67
-		});
61
+        $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
62
+        $this->server->addPlugin(new AnonymousOptionsPlugin());
63
+        $this->server->addPlugin(new class() extends Plugin {
64
+            public function getCurrentPrincipal() {
65
+                return 'principals/system/public';
66
+            }
67
+        });
68 68
 
69
-		// allow setup of additional auth backends
70
-		$event = new SabrePluginEvent($this->server);
71
-		$dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);
69
+        // allow setup of additional auth backends
70
+        $event = new SabrePluginEvent($this->server);
71
+        $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);
72 72
 
73
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
74
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
75
-		$this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
73
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
74
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
75
+        $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
76 76
 
77
-		// acl
78
-		$acl = new DavAclPlugin();
79
-		$acl->principalCollectionSet = [
80
-			'principals/users', 'principals/groups'
81
-		];
82
-		$acl->defaultUsernamePath = 'principals/users';
83
-		$this->server->addPlugin($acl);
77
+        // acl
78
+        $acl = new DavAclPlugin();
79
+        $acl->principalCollectionSet = [
80
+            'principals/users', 'principals/groups'
81
+        ];
82
+        $acl->defaultUsernamePath = 'principals/users';
83
+        $this->server->addPlugin($acl);
84 84
 
85
-		// calendar plugins
86
-		$this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
87
-		$this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
88
-		$this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(\OC::$server->getConfig()));
89
-		$this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
90
-		$this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
91
-		//$this->server->addPlugin(new \OCA\DAV\DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
92
-		$this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
93
-			\OC::$server->getConfig(),
94
-			\OC::$server->getURLGenerator()
95
-		));
85
+        // calendar plugins
86
+        $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
87
+        $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
88
+        $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(\OC::$server->getConfig()));
89
+        $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
90
+        $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
91
+        //$this->server->addPlugin(new \OCA\DAV\DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
92
+        $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
93
+            \OC::$server->getConfig(),
94
+            \OC::$server->getURLGenerator()
95
+        ));
96 96
 
97
-		// wait with registering these until auth is handled and the filesystem is setup
98
-		$this->server->on('beforeMethod:*', function () use ($root) {
99
-			// register plugins from apps
100
-			$pluginManager = new PluginManager(
101
-				\OC::$server,
102
-				\OC::$server->getAppManager()
103
-			);
104
-			foreach ($pluginManager->getAppPlugins() as $appPlugin) {
105
-				$this->server->addPlugin($appPlugin);
106
-			}
107
-			foreach ($pluginManager->getAppCollections() as $appCollection) {
108
-				$root->addChild($appCollection);
109
-			}
110
-		});
111
-	}
97
+        // wait with registering these until auth is handled and the filesystem is setup
98
+        $this->server->on('beforeMethod:*', function () use ($root) {
99
+            // register plugins from apps
100
+            $pluginManager = new PluginManager(
101
+                \OC::$server,
102
+                \OC::$server->getAppManager()
103
+            );
104
+            foreach ($pluginManager->getAppPlugins() as $appPlugin) {
105
+                $this->server->addPlugin($appPlugin);
106
+            }
107
+            foreach ($pluginManager->getAppCollections() as $appCollection) {
108
+                $root->addChild($appCollection);
109
+            }
110
+        });
111
+    }
112 112
 
113
-	/**
114
-	 * @param Message $iTipMessage
115
-	 * @return void
116
-	 */
117
-	public function handleITipMessage(Message $iTipMessage) {
118
-		/** @var \OCA\DAV\CalDAV\Schedule\Plugin $schedulingPlugin */
119
-		$schedulingPlugin = $this->server->getPlugin('caldav-schedule');
120
-		$schedulingPlugin->scheduleLocalDelivery($iTipMessage);
121
-	}
113
+    /**
114
+     * @param Message $iTipMessage
115
+     * @return void
116
+     */
117
+    public function handleITipMessage(Message $iTipMessage) {
118
+        /** @var \OCA\DAV\CalDAV\Schedule\Plugin $schedulingPlugin */
119
+        $schedulingPlugin = $this->server->getPlugin('caldav-schedule');
120
+        $schedulingPlugin->scheduleLocalDelivery($iTipMessage);
121
+    }
122 122
 }
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
@@ -73,260 +73,260 @@
 block discarded – undo
73 73
 
74 74
 class Server {
75 75
 
76
-	/** @var IRequest */
77
-	private $request;
78
-
79
-	/** @var  string */
80
-	private $baseUri;
81
-
82
-	/** @var Connector\Sabre\Server  */
83
-	public $server;
84
-
85
-	public function __construct(IRequest $request, $baseUri) {
86
-		$this->request = $request;
87
-		$this->baseUri = $baseUri;
88
-		$logger = \OC::$server->getLogger();
89
-		$dispatcher = \OC::$server->getEventDispatcher();
90
-
91
-		$root = new RootCollection();
92
-		$this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
93
-
94
-		// Add maintenance plugin
95
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav')));
96
-
97
-		// Backends
98
-		$authBackend = new Auth(
99
-			\OC::$server->getSession(),
100
-			\OC::$server->getUserSession(),
101
-			\OC::$server->getRequest(),
102
-			\OC::$server->getTwoFactorAuthManager(),
103
-			\OC::$server->getBruteForceThrottler()
104
-		);
105
-
106
-		// Set URL explicitly due to reverse-proxy situations
107
-		$this->server->httpRequest->setUrl($this->request->getRequestUri());
108
-		$this->server->setBaseUri($this->baseUri);
109
-
110
-		$this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
111
-		$this->server->addPlugin(new AnonymousOptionsPlugin());
112
-		$authPlugin = new Plugin();
113
-		$authPlugin->addBackend(new PublicAuth());
114
-		$this->server->addPlugin($authPlugin);
115
-
116
-		// allow setup of additional auth backends
117
-		$event = new SabrePluginEvent($this->server);
118
-		$dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);
119
-
120
-		$bearerAuthBackend = new BearerAuth(
121
-			\OC::$server->getUserSession(),
122
-			\OC::$server->getSession(),
123
-			\OC::$server->getRequest()
124
-		);
125
-		$authPlugin->addBackend($bearerAuthBackend);
126
-		// because we are throwing exceptions this plugin has to be the last one
127
-		$authPlugin->addBackend($authBackend);
128
-
129
-		// debugging
130
-		if (\OC::$server->getConfig()->getSystemValue('debug', false)) {
131
-			$this->server->addPlugin(new \Sabre\DAV\Browser\Plugin());
132
-		} else {
133
-			$this->server->addPlugin(new DummyGetResponsePlugin());
134
-		}
135
-
136
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
137
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
138
-		$this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
139
-
140
-		// acl
141
-		$acl = new DavAclPlugin();
142
-		$acl->principalCollectionSet = [
143
-			'principals/users',
144
-			'principals/groups',
145
-			'principals/calendar-resources',
146
-			'principals/calendar-rooms',
147
-		];
148
-		$acl->defaultUsernamePath = 'principals/users';
149
-		$this->server->addPlugin($acl);
150
-
151
-		// calendar plugins
152
-		if ($this->requestIsForSubtree(['calendars', 'public-calendars', 'system-calendars', 'principals'])) {
153
-			$this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
154
-			$this->server->addPlugin(new \OCA\DAV\CalDAV\ICSExportPlugin\ICSExportPlugin(\OC::$server->getConfig(), \OC::$server->getLogger()));
155
-			$this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(\OC::$server->getConfig()));
156
-			if (\OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') {
157
-				$this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class));
158
-			}
159
-
160
-			$this->server->addPlugin(new CalDAV\WebcalCaching\Plugin($request));
161
-			$this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
162
-
163
-			$this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
164
-			$this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
165
-			$this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
166
-				\OC::$server->getConfig(),
167
-				\OC::$server->getURLGenerator()
168
-			));
169
-		}
170
-
171
-		// addressbook plugins
172
-		if ($this->requestIsForSubtree(['addressbooks', 'principals'])) {
173
-			$this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
174
-			$this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());
175
-			$this->server->addPlugin(new VCFExportPlugin());
176
-			$this->server->addPlugin(new MultiGetExportPlugin());
177
-			$this->server->addPlugin(new HasPhotoPlugin());
178
-			$this->server->addPlugin(new ImageExportPlugin(new PhotoCache(
179
-				\OC::$server->getAppDataDir('dav-photocache'),
180
-				\OC::$server->getLogger())
181
-			));
182
-		}
183
-
184
-		// system tags plugins
185
-		$this->server->addPlugin(new SystemTagPlugin(
186
-			\OC::$server->getSystemTagManager(),
187
-			\OC::$server->getGroupManager(),
188
-			\OC::$server->getUserSession()
189
-		));
190
-
191
-		// comments plugin
192
-		$this->server->addPlugin(new CommentsPlugin(
193
-			\OC::$server->getCommentsManager(),
194
-			\OC::$server->getUserSession()
195
-		));
196
-
197
-		$this->server->addPlugin(new CopyEtagHeaderPlugin());
198
-		$this->server->addPlugin(new ChunkingPlugin());
199
-
200
-		// allow setup of additional plugins
201
-		$dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event);
202
-
203
-		// Some WebDAV clients do require Class 2 WebDAV support (locking), since
204
-		// we do not provide locking we emulate it using a fake locking plugin.
205
-		if ($request->isUserAgent([
206
-			'/WebDAVFS/',
207
-			'/OneNote/',
208
-			'/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601
209
-		])) {
210
-			$this->server->addPlugin(new FakeLockerPlugin());
211
-		}
212
-
213
-		if (BrowserErrorPagePlugin::isBrowserRequest($request)) {
214
-			$this->server->addPlugin(new BrowserErrorPagePlugin());
215
-		}
216
-
217
-		$lazySearchBackend = new LazySearchBackend();
218
-		$this->server->addPlugin(new SearchPlugin($lazySearchBackend));
219
-
220
-		// wait with registering these until auth is handled and the filesystem is setup
221
-		$this->server->on('beforeMethod:*', function () use ($root, $lazySearchBackend) {
222
-			// custom properties plugin must be the last one
223
-			$userSession = \OC::$server->getUserSession();
224
-			$user = $userSession->getUser();
225
-			if ($user !== null) {
226
-				$view = \OC\Files\Filesystem::getView();
227
-				$this->server->addPlugin(
228
-					new FilesPlugin(
229
-						$this->server->tree,
230
-						\OC::$server->getConfig(),
231
-						$this->request,
232
-						\OC::$server->getPreviewManager(),
233
-						false,
234
-						!\OC::$server->getConfig()->getSystemValue('debug', false)
235
-					)
236
-				);
237
-
238
-				$this->server->addPlugin(
239
-					new \Sabre\DAV\PropertyStorage\Plugin(
240
-						new CustomPropertiesBackend(
241
-							$this->server->tree,
242
-							\OC::$server->getDatabaseConnection(),
243
-							\OC::$server->getUserSession()->getUser()
244
-						)
245
-					)
246
-				);
247
-				if ($view !== null) {
248
-					$this->server->addPlugin(
249
-						new QuotaPlugin($view, false));
250
-				}
251
-				$this->server->addPlugin(
252
-					new TagsPlugin(
253
-						$this->server->tree, \OC::$server->getTagManager()
254
-					)
255
-				);
256
-				// TODO: switch to LazyUserFolder
257
-				$userFolder = \OC::$server->getUserFolder();
258
-				$this->server->addPlugin(new SharesPlugin(
259
-					$this->server->tree,
260
-					$userSession,
261
-					$userFolder,
262
-					\OC::$server->getShareManager()
263
-				));
264
-				$this->server->addPlugin(new CommentPropertiesPlugin(
265
-					\OC::$server->getCommentsManager(),
266
-					$userSession
267
-				));
268
-				$this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin());
269
-				if ($view !== null) {
270
-					$this->server->addPlugin(new FilesReportPlugin(
271
-						$this->server->tree,
272
-						$view,
273
-						\OC::$server->getSystemTagManager(),
274
-						\OC::$server->getSystemTagObjectMapper(),
275
-						\OC::$server->getTagManager(),
276
-						$userSession,
277
-						\OC::$server->getGroupManager(),
278
-						$userFolder,
279
-						\OC::$server->getAppManager()
280
-					));
281
-					$lazySearchBackend->setBackend(new \OCA\DAV\Files\FileSearchBackend(
282
-						$this->server->tree,
283
-						$user,
284
-						\OC::$server->getRootFolder(),
285
-						\OC::$server->getShareManager(),
286
-						$view
287
-					));
288
-				}
289
-				$this->server->addPlugin(new \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin(
290
-					\OC::$server->getConfig(),
291
-					\OC::$server->query(BirthdayService::class)
292
-				));
293
-				$this->server->addPlugin(new AppleProvisioningPlugin(
294
-					\OC::$server->getUserSession(),
295
-					\OC::$server->getURLGenerator(),
296
-					\OC::$server->getThemingDefaults(),
297
-					\OC::$server->getRequest(),
298
-					\OC::$server->getL10N('dav'),
299
-					function () {
300
-						return UUIDUtil::getUUID();
301
-					}
302
-				));
303
-			}
304
-
305
-			// register plugins from apps
306
-			$pluginManager = new PluginManager(
307
-				\OC::$server,
308
-				\OC::$server->getAppManager()
309
-			);
310
-			foreach ($pluginManager->getAppPlugins() as $appPlugin) {
311
-				$this->server->addPlugin($appPlugin);
312
-			}
313
-			foreach ($pluginManager->getAppCollections() as $appCollection) {
314
-				$root->addChild($appCollection);
315
-			}
316
-		});
317
-	}
318
-
319
-	public function exec() {
320
-		$this->server->exec();
321
-	}
322
-
323
-	private function requestIsForSubtree(array $subTrees): bool {
324
-		foreach ($subTrees as $subTree) {
325
-			$subTree = trim($subTree, ' /');
326
-			if (strpos($this->server->getRequestUri(), $subTree.'/') === 0) {
327
-				return true;
328
-			}
329
-		}
330
-		return false;
331
-	}
76
+    /** @var IRequest */
77
+    private $request;
78
+
79
+    /** @var  string */
80
+    private $baseUri;
81
+
82
+    /** @var Connector\Sabre\Server  */
83
+    public $server;
84
+
85
+    public function __construct(IRequest $request, $baseUri) {
86
+        $this->request = $request;
87
+        $this->baseUri = $baseUri;
88
+        $logger = \OC::$server->getLogger();
89
+        $dispatcher = \OC::$server->getEventDispatcher();
90
+
91
+        $root = new RootCollection();
92
+        $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
93
+
94
+        // Add maintenance plugin
95
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav')));
96
+
97
+        // Backends
98
+        $authBackend = new Auth(
99
+            \OC::$server->getSession(),
100
+            \OC::$server->getUserSession(),
101
+            \OC::$server->getRequest(),
102
+            \OC::$server->getTwoFactorAuthManager(),
103
+            \OC::$server->getBruteForceThrottler()
104
+        );
105
+
106
+        // Set URL explicitly due to reverse-proxy situations
107
+        $this->server->httpRequest->setUrl($this->request->getRequestUri());
108
+        $this->server->setBaseUri($this->baseUri);
109
+
110
+        $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
111
+        $this->server->addPlugin(new AnonymousOptionsPlugin());
112
+        $authPlugin = new Plugin();
113
+        $authPlugin->addBackend(new PublicAuth());
114
+        $this->server->addPlugin($authPlugin);
115
+
116
+        // allow setup of additional auth backends
117
+        $event = new SabrePluginEvent($this->server);
118
+        $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);
119
+
120
+        $bearerAuthBackend = new BearerAuth(
121
+            \OC::$server->getUserSession(),
122
+            \OC::$server->getSession(),
123
+            \OC::$server->getRequest()
124
+        );
125
+        $authPlugin->addBackend($bearerAuthBackend);
126
+        // because we are throwing exceptions this plugin has to be the last one
127
+        $authPlugin->addBackend($authBackend);
128
+
129
+        // debugging
130
+        if (\OC::$server->getConfig()->getSystemValue('debug', false)) {
131
+            $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin());
132
+        } else {
133
+            $this->server->addPlugin(new DummyGetResponsePlugin());
134
+        }
135
+
136
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
137
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
138
+        $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
139
+
140
+        // acl
141
+        $acl = new DavAclPlugin();
142
+        $acl->principalCollectionSet = [
143
+            'principals/users',
144
+            'principals/groups',
145
+            'principals/calendar-resources',
146
+            'principals/calendar-rooms',
147
+        ];
148
+        $acl->defaultUsernamePath = 'principals/users';
149
+        $this->server->addPlugin($acl);
150
+
151
+        // calendar plugins
152
+        if ($this->requestIsForSubtree(['calendars', 'public-calendars', 'system-calendars', 'principals'])) {
153
+            $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
154
+            $this->server->addPlugin(new \OCA\DAV\CalDAV\ICSExportPlugin\ICSExportPlugin(\OC::$server->getConfig(), \OC::$server->getLogger()));
155
+            $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(\OC::$server->getConfig()));
156
+            if (\OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') {
157
+                $this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class));
158
+            }
159
+
160
+            $this->server->addPlugin(new CalDAV\WebcalCaching\Plugin($request));
161
+            $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
162
+
163
+            $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
164
+            $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
165
+            $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
166
+                \OC::$server->getConfig(),
167
+                \OC::$server->getURLGenerator()
168
+            ));
169
+        }
170
+
171
+        // addressbook plugins
172
+        if ($this->requestIsForSubtree(['addressbooks', 'principals'])) {
173
+            $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
174
+            $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());
175
+            $this->server->addPlugin(new VCFExportPlugin());
176
+            $this->server->addPlugin(new MultiGetExportPlugin());
177
+            $this->server->addPlugin(new HasPhotoPlugin());
178
+            $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(
179
+                \OC::$server->getAppDataDir('dav-photocache'),
180
+                \OC::$server->getLogger())
181
+            ));
182
+        }
183
+
184
+        // system tags plugins
185
+        $this->server->addPlugin(new SystemTagPlugin(
186
+            \OC::$server->getSystemTagManager(),
187
+            \OC::$server->getGroupManager(),
188
+            \OC::$server->getUserSession()
189
+        ));
190
+
191
+        // comments plugin
192
+        $this->server->addPlugin(new CommentsPlugin(
193
+            \OC::$server->getCommentsManager(),
194
+            \OC::$server->getUserSession()
195
+        ));
196
+
197
+        $this->server->addPlugin(new CopyEtagHeaderPlugin());
198
+        $this->server->addPlugin(new ChunkingPlugin());
199
+
200
+        // allow setup of additional plugins
201
+        $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event);
202
+
203
+        // Some WebDAV clients do require Class 2 WebDAV support (locking), since
204
+        // we do not provide locking we emulate it using a fake locking plugin.
205
+        if ($request->isUserAgent([
206
+            '/WebDAVFS/',
207
+            '/OneNote/',
208
+            '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601
209
+        ])) {
210
+            $this->server->addPlugin(new FakeLockerPlugin());
211
+        }
212
+
213
+        if (BrowserErrorPagePlugin::isBrowserRequest($request)) {
214
+            $this->server->addPlugin(new BrowserErrorPagePlugin());
215
+        }
216
+
217
+        $lazySearchBackend = new LazySearchBackend();
218
+        $this->server->addPlugin(new SearchPlugin($lazySearchBackend));
219
+
220
+        // wait with registering these until auth is handled and the filesystem is setup
221
+        $this->server->on('beforeMethod:*', function () use ($root, $lazySearchBackend) {
222
+            // custom properties plugin must be the last one
223
+            $userSession = \OC::$server->getUserSession();
224
+            $user = $userSession->getUser();
225
+            if ($user !== null) {
226
+                $view = \OC\Files\Filesystem::getView();
227
+                $this->server->addPlugin(
228
+                    new FilesPlugin(
229
+                        $this->server->tree,
230
+                        \OC::$server->getConfig(),
231
+                        $this->request,
232
+                        \OC::$server->getPreviewManager(),
233
+                        false,
234
+                        !\OC::$server->getConfig()->getSystemValue('debug', false)
235
+                    )
236
+                );
237
+
238
+                $this->server->addPlugin(
239
+                    new \Sabre\DAV\PropertyStorage\Plugin(
240
+                        new CustomPropertiesBackend(
241
+                            $this->server->tree,
242
+                            \OC::$server->getDatabaseConnection(),
243
+                            \OC::$server->getUserSession()->getUser()
244
+                        )
245
+                    )
246
+                );
247
+                if ($view !== null) {
248
+                    $this->server->addPlugin(
249
+                        new QuotaPlugin($view, false));
250
+                }
251
+                $this->server->addPlugin(
252
+                    new TagsPlugin(
253
+                        $this->server->tree, \OC::$server->getTagManager()
254
+                    )
255
+                );
256
+                // TODO: switch to LazyUserFolder
257
+                $userFolder = \OC::$server->getUserFolder();
258
+                $this->server->addPlugin(new SharesPlugin(
259
+                    $this->server->tree,
260
+                    $userSession,
261
+                    $userFolder,
262
+                    \OC::$server->getShareManager()
263
+                ));
264
+                $this->server->addPlugin(new CommentPropertiesPlugin(
265
+                    \OC::$server->getCommentsManager(),
266
+                    $userSession
267
+                ));
268
+                $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin());
269
+                if ($view !== null) {
270
+                    $this->server->addPlugin(new FilesReportPlugin(
271
+                        $this->server->tree,
272
+                        $view,
273
+                        \OC::$server->getSystemTagManager(),
274
+                        \OC::$server->getSystemTagObjectMapper(),
275
+                        \OC::$server->getTagManager(),
276
+                        $userSession,
277
+                        \OC::$server->getGroupManager(),
278
+                        $userFolder,
279
+                        \OC::$server->getAppManager()
280
+                    ));
281
+                    $lazySearchBackend->setBackend(new \OCA\DAV\Files\FileSearchBackend(
282
+                        $this->server->tree,
283
+                        $user,
284
+                        \OC::$server->getRootFolder(),
285
+                        \OC::$server->getShareManager(),
286
+                        $view
287
+                    ));
288
+                }
289
+                $this->server->addPlugin(new \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin(
290
+                    \OC::$server->getConfig(),
291
+                    \OC::$server->query(BirthdayService::class)
292
+                ));
293
+                $this->server->addPlugin(new AppleProvisioningPlugin(
294
+                    \OC::$server->getUserSession(),
295
+                    \OC::$server->getURLGenerator(),
296
+                    \OC::$server->getThemingDefaults(),
297
+                    \OC::$server->getRequest(),
298
+                    \OC::$server->getL10N('dav'),
299
+                    function () {
300
+                        return UUIDUtil::getUUID();
301
+                    }
302
+                ));
303
+            }
304
+
305
+            // register plugins from apps
306
+            $pluginManager = new PluginManager(
307
+                \OC::$server,
308
+                \OC::$server->getAppManager()
309
+            );
310
+            foreach ($pluginManager->getAppPlugins() as $appPlugin) {
311
+                $this->server->addPlugin($appPlugin);
312
+            }
313
+            foreach ($pluginManager->getAppCollections() as $appCollection) {
314
+                $root->addChild($appCollection);
315
+            }
316
+        });
317
+    }
318
+
319
+    public function exec() {
320
+        $this->server->exec();
321
+    }
322
+
323
+    private function requestIsForSubtree(array $subTrees): bool {
324
+        foreach ($subTrees as $subTree) {
325
+            $subTree = trim($subTree, ' /');
326
+            if (strpos($this->server->getRequestUri(), $subTree.'/') === 0) {
327
+                return true;
328
+            }
329
+        }
330
+        return false;
331
+    }
332 332
 }
Please login to merge, or discard this patch.
apps/dav/appinfo/v1/webdav.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
 // no php execution timeout for webdav
32 32
 if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
33
-	@set_time_limit(0);
33
+    @set_time_limit(0);
34 34
 }
35 35
 ignore_user_abort(true);
36 36
 
@@ -38,40 +38,40 @@  discard block
 block discarded – undo
38 38
 \OC_Util::obEnd();
39 39
 
40 40
 $serverFactory = new \OCA\DAV\Connector\Sabre\ServerFactory(
41
-	\OC::$server->getConfig(),
42
-	\OC::$server->getLogger(),
43
-	\OC::$server->getDatabaseConnection(),
44
-	\OC::$server->getUserSession(),
45
-	\OC::$server->getMountManager(),
46
-	\OC::$server->getTagManager(),
47
-	\OC::$server->getRequest(),
48
-	\OC::$server->getPreviewManager(),
49
-	\OC::$server->getEventDispatcher(),
50
-	\OC::$server->getL10N('dav')
41
+    \OC::$server->getConfig(),
42
+    \OC::$server->getLogger(),
43
+    \OC::$server->getDatabaseConnection(),
44
+    \OC::$server->getUserSession(),
45
+    \OC::$server->getMountManager(),
46
+    \OC::$server->getTagManager(),
47
+    \OC::$server->getRequest(),
48
+    \OC::$server->getPreviewManager(),
49
+    \OC::$server->getEventDispatcher(),
50
+    \OC::$server->getL10N('dav')
51 51
 );
52 52
 
53 53
 // Backends
54 54
 $authBackend = new \OCA\DAV\Connector\Sabre\Auth(
55
-	\OC::$server->getSession(),
56
-	\OC::$server->getUserSession(),
57
-	\OC::$server->getRequest(),
58
-	\OC::$server->getTwoFactorAuthManager(),
59
-	\OC::$server->getBruteForceThrottler(),
60
-	'principals/'
55
+    \OC::$server->getSession(),
56
+    \OC::$server->getUserSession(),
57
+    \OC::$server->getRequest(),
58
+    \OC::$server->getTwoFactorAuthManager(),
59
+    \OC::$server->getBruteForceThrottler(),
60
+    'principals/'
61 61
 );
62 62
 $authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend);
63 63
 $bearerAuthPlugin = new \OCA\DAV\Connector\Sabre\BearerAuth(
64
-	\OC::$server->getUserSession(),
65
-	\OC::$server->getSession(),
66
-	\OC::$server->getRequest()
64
+    \OC::$server->getUserSession(),
65
+    \OC::$server->getSession(),
66
+    \OC::$server->getRequest()
67 67
 );
68 68
 $authPlugin->addBackend($bearerAuthPlugin);
69 69
 
70 70
 $requestUri = \OC::$server->getRequest()->getRequestUri();
71 71
 
72 72
 $server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function () {
73
-	// use the view for the logged in user
74
-	return \OC\Files\Filesystem::getView();
73
+    // use the view for the logged in user
74
+    return \OC\Files\Filesystem::getView();
75 75
 });
76 76
 
77 77
 $dispatcher = \OC::$server->getEventDispatcher();
Please login to merge, or discard this patch.
apps/dav/appinfo/v1/publicwebdav.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -40,23 +40,23 @@  discard block
 block discarded – undo
40 40
 
41 41
 // Backends
42 42
 $authBackend = new OCA\DAV\Connector\PublicAuth(
43
-	\OC::$server->getRequest(),
44
-	\OC::$server->getShareManager(),
45
-	\OC::$server->getSession()
43
+    \OC::$server->getRequest(),
44
+    \OC::$server->getShareManager(),
45
+    \OC::$server->getSession()
46 46
 );
47 47
 $authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend);
48 48
 
49 49
 $serverFactory = new OCA\DAV\Connector\Sabre\ServerFactory(
50
-	\OC::$server->getConfig(),
51
-	\OC::$server->getLogger(),
52
-	\OC::$server->getDatabaseConnection(),
53
-	\OC::$server->getUserSession(),
54
-	\OC::$server->getMountManager(),
55
-	\OC::$server->getTagManager(),
56
-	\OC::$server->getRequest(),
57
-	\OC::$server->getPreviewManager(),
58
-	\OC::$server->getEventDispatcher(),
59
-	\OC::$server->getL10N('dav')
50
+    \OC::$server->getConfig(),
51
+    \OC::$server->getLogger(),
52
+    \OC::$server->getDatabaseConnection(),
53
+    \OC::$server->getUserSession(),
54
+    \OC::$server->getMountManager(),
55
+    \OC::$server->getTagManager(),
56
+    \OC::$server->getRequest(),
57
+    \OC::$server->getPreviewManager(),
58
+    \OC::$server->getEventDispatcher(),
59
+    \OC::$server->getL10N('dav')
60 60
 );
61 61
 
62 62
 $requestUri = \OC::$server->getRequest()->getRequestUri();
@@ -65,45 +65,45 @@  discard block
 block discarded – undo
65 65
 $filesDropPlugin = new \OCA\DAV\Files\Sharing\FilesDropPlugin();
66 66
 
67 67
 $server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) {
68
-	$isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
69
-	$federatedSharingApp = \OC::$server->query(\OCA\FederatedFileSharing\AppInfo\Application::class);
70
-	$federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
71
-	if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
72
-		// this is what is thrown when trying to access a non-existing share
73
-		throw new \Sabre\DAV\Exception\NotAuthenticated();
74
-	}
75
-
76
-	$share = $authBackend->getShare();
77
-	$owner = $share->getShareOwner();
78
-	$isReadable = $share->getPermissions() & \OCP\Constants::PERMISSION_READ;
79
-	$fileId = $share->getNodeId();
80
-
81
-	// FIXME: should not add storage wrappers outside of preSetup, need to find a better way
82
-	$previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false);
83
-	\OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) {
84
-		return new \OC\Files\Storage\Wrapper\PermissionsMask(['storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE]);
85
-	});
86
-	\OC\Files\Filesystem::addStorageWrapper('shareOwner', function ($mountPoint, $storage) use ($share) {
87
-		return new \OCA\DAV\Storage\PublicOwnerWrapper(['storage' => $storage, 'owner' => $share->getShareOwner()]);
88
-	});
89
-	\OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
90
-
91
-	OC_Util::tearDownFS();
92
-	OC_Util::setupFS($owner);
93
-	$ownerView = new \OC\Files\View('/'. $owner . '/files');
94
-	$path = $ownerView->getPath($fileId);
95
-	$fileInfo = $ownerView->getFileInfo($path);
96
-	$linkCheckPlugin->setFileInfo($fileInfo);
97
-
98
-	// If not readble (files_drop) enable the filesdrop plugin
99
-	if (!$isReadable) {
100
-		$filesDropPlugin->enable();
101
-	}
102
-
103
-	$view = new \OC\Files\View($ownerView->getAbsolutePath($path));
104
-	$filesDropPlugin->setView($view);
105
-
106
-	return $view;
68
+    $isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
69
+    $federatedSharingApp = \OC::$server->query(\OCA\FederatedFileSharing\AppInfo\Application::class);
70
+    $federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
71
+    if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
72
+        // this is what is thrown when trying to access a non-existing share
73
+        throw new \Sabre\DAV\Exception\NotAuthenticated();
74
+    }
75
+
76
+    $share = $authBackend->getShare();
77
+    $owner = $share->getShareOwner();
78
+    $isReadable = $share->getPermissions() & \OCP\Constants::PERMISSION_READ;
79
+    $fileId = $share->getNodeId();
80
+
81
+    // FIXME: should not add storage wrappers outside of preSetup, need to find a better way
82
+    $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false);
83
+    \OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) {
84
+        return new \OC\Files\Storage\Wrapper\PermissionsMask(['storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE]);
85
+    });
86
+    \OC\Files\Filesystem::addStorageWrapper('shareOwner', function ($mountPoint, $storage) use ($share) {
87
+        return new \OCA\DAV\Storage\PublicOwnerWrapper(['storage' => $storage, 'owner' => $share->getShareOwner()]);
88
+    });
89
+    \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
90
+
91
+    OC_Util::tearDownFS();
92
+    OC_Util::setupFS($owner);
93
+    $ownerView = new \OC\Files\View('/'. $owner . '/files');
94
+    $path = $ownerView->getPath($fileId);
95
+    $fileInfo = $ownerView->getFileInfo($path);
96
+    $linkCheckPlugin->setFileInfo($fileInfo);
97
+
98
+    // If not readble (files_drop) enable the filesdrop plugin
99
+    if (!$isReadable) {
100
+        $filesDropPlugin->enable();
101
+    }
102
+
103
+    $view = new \OC\Files\View($ownerView->getAbsolutePath($path));
104
+    $filesDropPlugin->setView($view);
105
+
106
+    return $view;
107 107
 });
108 108
 
109 109
 $server->addPlugin($linkCheckPlugin);
Please login to merge, or discard this patch.
apps/dav/appinfo/v2/direct.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 // no php execution timeout for webdav
28 28
 if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
29
-	@set_time_limit(0);
29
+    @set_time_limit(0);
30 30
 }
31 31
 ignore_user_abort(true);
32 32
 
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
 
38 38
 $serverFactory = new \OCA\DAV\Direct\ServerFactory(\OC::$server->getConfig(), \OC::$server->getL10N('dav'));
39 39
 $server = $serverFactory->createServer(
40
-	$baseuri,
41
-	$requestUri,
42
-	\OC::$server->getRootFolder(),
43
-	\OC::$server->query(\OCA\DAV\Db\DirectMapper::class),
44
-	\OC::$server->query(\OCP\AppFramework\Utility\ITimeFactory::class),
45
-	\OC::$server->getBruteForceThrottler(),
46
-	\OC::$server->getRequest()
40
+    $baseuri,
41
+    $requestUri,
42
+    \OC::$server->getRootFolder(),
43
+    \OC::$server->query(\OCA\DAV\Db\DirectMapper::class),
44
+    \OC::$server->query(\OCP\AppFramework\Utility\ITimeFactory::class),
45
+    \OC::$server->getBruteForceThrottler(),
46
+    \OC::$server->getRequest()
47 47
 );
48 48
 
49 49
 $server->exec();
Please login to merge, or discard this patch.