Completed
Pull Request — master (#9542)
by Robin
28:24
created
apps/dav/lib/Connector/Sabre/ServerFactory.php 1 patch
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -42,159 +42,159 @@
 block discarded – undo
42 42
 use Sabre\DAV\Auth\Plugin;
43 43
 
44 44
 class ServerFactory {
45
-	/** @var IConfig */
46
-	private $config;
47
-	/** @var ILogger */
48
-	private $logger;
49
-	/** @var IDBConnection */
50
-	private $databaseConnection;
51
-	/** @var IUserSession */
52
-	private $userSession;
53
-	/** @var IMountManager */
54
-	private $mountManager;
55
-	/** @var ITagManager */
56
-	private $tagManager;
57
-	/** @var IRequest */
58
-	private $request;
59
-	/** @var IPreview  */
60
-	private $previewManager;
45
+    /** @var IConfig */
46
+    private $config;
47
+    /** @var ILogger */
48
+    private $logger;
49
+    /** @var IDBConnection */
50
+    private $databaseConnection;
51
+    /** @var IUserSession */
52
+    private $userSession;
53
+    /** @var IMountManager */
54
+    private $mountManager;
55
+    /** @var ITagManager */
56
+    private $tagManager;
57
+    /** @var IRequest */
58
+    private $request;
59
+    /** @var IPreview  */
60
+    private $previewManager;
61 61
 
62
-	/**
63
-	 * @param IConfig $config
64
-	 * @param ILogger $logger
65
-	 * @param IDBConnection $databaseConnection
66
-	 * @param IUserSession $userSession
67
-	 * @param IMountManager $mountManager
68
-	 * @param ITagManager $tagManager
69
-	 * @param IRequest $request
70
-	 * @param IPreview $previewManager
71
-	 */
72
-	public function __construct(
73
-		IConfig $config,
74
-		ILogger $logger,
75
-		IDBConnection $databaseConnection,
76
-		IUserSession $userSession,
77
-		IMountManager $mountManager,
78
-		ITagManager $tagManager,
79
-		IRequest $request,
80
-		IPreview $previewManager
81
-	) {
82
-		$this->config = $config;
83
-		$this->logger = $logger;
84
-		$this->databaseConnection = $databaseConnection;
85
-		$this->userSession = $userSession;
86
-		$this->mountManager = $mountManager;
87
-		$this->tagManager = $tagManager;
88
-		$this->request = $request;
89
-		$this->previewManager = $previewManager;
90
-	}
62
+    /**
63
+     * @param IConfig $config
64
+     * @param ILogger $logger
65
+     * @param IDBConnection $databaseConnection
66
+     * @param IUserSession $userSession
67
+     * @param IMountManager $mountManager
68
+     * @param ITagManager $tagManager
69
+     * @param IRequest $request
70
+     * @param IPreview $previewManager
71
+     */
72
+    public function __construct(
73
+        IConfig $config,
74
+        ILogger $logger,
75
+        IDBConnection $databaseConnection,
76
+        IUserSession $userSession,
77
+        IMountManager $mountManager,
78
+        ITagManager $tagManager,
79
+        IRequest $request,
80
+        IPreview $previewManager
81
+    ) {
82
+        $this->config = $config;
83
+        $this->logger = $logger;
84
+        $this->databaseConnection = $databaseConnection;
85
+        $this->userSession = $userSession;
86
+        $this->mountManager = $mountManager;
87
+        $this->tagManager = $tagManager;
88
+        $this->request = $request;
89
+        $this->previewManager = $previewManager;
90
+    }
91 91
 
92
-	/**
93
-	 * @param string $baseUri
94
-	 * @param string $requestUri
95
-	 * @param Plugin $authPlugin
96
-	 * @param callable $viewCallBack callback that should return the view for the dav endpoint
97
-	 * @return Server
98
-	 */
99
-	public function createServer($baseUri,
100
-								 $requestUri,
101
-								 Plugin $authPlugin,
102
-								 callable $viewCallBack) {
103
-		// Fire up server
104
-		$objectTree = new \OCA\DAV\Connector\Sabre\ObjectTree();
105
-		$server = new \OCA\DAV\Connector\Sabre\Server($objectTree);
106
-		// Set URL explicitly due to reverse-proxy situations
107
-		$server->httpRequest->setUrl($requestUri);
108
-		$server->setBaseUri($baseUri);
92
+    /**
93
+     * @param string $baseUri
94
+     * @param string $requestUri
95
+     * @param Plugin $authPlugin
96
+     * @param callable $viewCallBack callback that should return the view for the dav endpoint
97
+     * @return Server
98
+     */
99
+    public function createServer($baseUri,
100
+                                    $requestUri,
101
+                                    Plugin $authPlugin,
102
+                                    callable $viewCallBack) {
103
+        // Fire up server
104
+        $objectTree = new \OCA\DAV\Connector\Sabre\ObjectTree();
105
+        $server = new \OCA\DAV\Connector\Sabre\Server($objectTree);
106
+        // Set URL explicitly due to reverse-proxy situations
107
+        $server->httpRequest->setUrl($requestUri);
108
+        $server->setBaseUri($baseUri);
109 109
 
110
-		// Load plugins
111
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin($this->config));
112
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin($this->config));
113
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\AnonymousOptionsPlugin());
114
-		$server->addPlugin($authPlugin);
115
-		// FIXME: The following line is a workaround for legacy components relying on being able to send a GET to /
116
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\DummyGetResponsePlugin());
117
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $this->logger));
118
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
119
-		// Some WebDAV clients do require Class 2 WebDAV support (locking), since
120
-		// we do not provide locking we emulate it using a fake locking plugin.
121
-		if($this->request->isUserAgent([
122
-				'/WebDAVFS/',
123
-				'/OneNote/',
124
-				'/Microsoft-WebDAV-MiniRedir/',
125
-		])) {
126
-			$server->addPlugin(new \OCA\DAV\Connector\Sabre\FakeLockerPlugin());
127
-		}
110
+        // Load plugins
111
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin($this->config));
112
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin($this->config));
113
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\AnonymousOptionsPlugin());
114
+        $server->addPlugin($authPlugin);
115
+        // FIXME: The following line is a workaround for legacy components relying on being able to send a GET to /
116
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\DummyGetResponsePlugin());
117
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $this->logger));
118
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
119
+        // Some WebDAV clients do require Class 2 WebDAV support (locking), since
120
+        // we do not provide locking we emulate it using a fake locking plugin.
121
+        if($this->request->isUserAgent([
122
+                '/WebDAVFS/',
123
+                '/OneNote/',
124
+                '/Microsoft-WebDAV-MiniRedir/',
125
+        ])) {
126
+            $server->addPlugin(new \OCA\DAV\Connector\Sabre\FakeLockerPlugin());
127
+        }
128 128
 
129
-		if (BrowserErrorPagePlugin::isBrowserRequest($this->request)) {
130
-			$server->addPlugin(new BrowserErrorPagePlugin());
131
-		}
129
+        if (BrowserErrorPagePlugin::isBrowserRequest($this->request)) {
130
+            $server->addPlugin(new BrowserErrorPagePlugin());
131
+        }
132 132
 
133
-		// wait with registering these until auth is handled and the filesystem is setup
134
-		$server->on('beforeMethod', function () use ($server, $objectTree, $viewCallBack) {
135
-			// ensure the skeleton is copied
136
-			$userFolder = \OC::$server->getUserFolder();
133
+        // wait with registering these until auth is handled and the filesystem is setup
134
+        $server->on('beforeMethod', function () use ($server, $objectTree, $viewCallBack) {
135
+            // ensure the skeleton is copied
136
+            $userFolder = \OC::$server->getUserFolder();
137 137
 			
138
-			/** @var \OC\Files\View $view */
139
-			$view = $viewCallBack($server);
140
-			if ($userFolder instanceof Folder && $userFolder->getPath() === $view->getRoot()) {
141
-				$rootInfo = $userFolder;
142
-			} else {
143
-				$rootInfo = $view->getFileInfo('');
144
-			}
138
+            /** @var \OC\Files\View $view */
139
+            $view = $viewCallBack($server);
140
+            if ($userFolder instanceof Folder && $userFolder->getPath() === $view->getRoot()) {
141
+                $rootInfo = $userFolder;
142
+            } else {
143
+                $rootInfo = $view->getFileInfo('');
144
+            }
145 145
 
146
-			// Create Nextcloud Dir
147
-			if ($rootInfo->getType() === 'dir') {
148
-				$root = new \OCA\DAV\Connector\Sabre\Directory($view, $rootInfo, $objectTree);
149
-			} else {
150
-				$root = new \OCA\DAV\Connector\Sabre\File($view, $rootInfo);
151
-			}
152
-			$objectTree->init($root, $view, $this->mountManager);
146
+            // Create Nextcloud Dir
147
+            if ($rootInfo->getType() === 'dir') {
148
+                $root = new \OCA\DAV\Connector\Sabre\Directory($view, $rootInfo, $objectTree);
149
+            } else {
150
+                $root = new \OCA\DAV\Connector\Sabre\File($view, $rootInfo);
151
+            }
152
+            $objectTree->init($root, $view, $this->mountManager);
153 153
 
154
-			$server->addPlugin(
155
-				new \OCA\DAV\Connector\Sabre\FilesPlugin(
156
-					$objectTree,
157
-					$this->config,
158
-					$this->request,
159
-					$this->previewManager,
160
-					false,
161
-					!$this->config->getSystemValue('debug', false)
162
-				)
163
-			);
164
-			$server->addPlugin(new \OCA\DAV\Connector\Sabre\QuotaPlugin($view, true));
154
+            $server->addPlugin(
155
+                new \OCA\DAV\Connector\Sabre\FilesPlugin(
156
+                    $objectTree,
157
+                    $this->config,
158
+                    $this->request,
159
+                    $this->previewManager,
160
+                    false,
161
+                    !$this->config->getSystemValue('debug', false)
162
+                )
163
+            );
164
+            $server->addPlugin(new \OCA\DAV\Connector\Sabre\QuotaPlugin($view, true));
165 165
 
166
-			if($this->userSession->isLoggedIn()) {
167
-				$server->addPlugin(new \OCA\DAV\Connector\Sabre\TagsPlugin($objectTree, $this->tagManager));
168
-				$server->addPlugin(new \OCA\DAV\Connector\Sabre\SharesPlugin(
169
-					$objectTree,
170
-					$this->userSession,
171
-					$userFolder,
172
-					\OC::$server->getShareManager()
173
-				));
174
-				$server->addPlugin(new \OCA\DAV\Connector\Sabre\CommentPropertiesPlugin(\OC::$server->getCommentsManager(), $this->userSession));
175
-				$server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesReportPlugin(
176
-					$objectTree,
177
-					$view,
178
-					\OC::$server->getSystemTagManager(),
179
-					\OC::$server->getSystemTagObjectMapper(),
180
-					\OC::$server->getTagManager(),
181
-					$this->userSession,
182
-					\OC::$server->getGroupManager(),
183
-					$userFolder
184
-				));
185
-				// custom properties plugin must be the last one
186
-				$server->addPlugin(
187
-					new \Sabre\DAV\PropertyStorage\Plugin(
188
-						new \OCA\DAV\Connector\Sabre\CustomPropertiesBackend(
189
-							$objectTree,
190
-							$this->databaseConnection,
191
-							$this->userSession->getUser()
192
-						)
193
-					)
194
-				);
195
-			}
196
-			$server->addPlugin(new \OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin());
197
-		}, 30); // priority 30: after auth (10) and acl(20), before lock(50) and handling the request
198
-		return $server;
199
-	}
166
+            if($this->userSession->isLoggedIn()) {
167
+                $server->addPlugin(new \OCA\DAV\Connector\Sabre\TagsPlugin($objectTree, $this->tagManager));
168
+                $server->addPlugin(new \OCA\DAV\Connector\Sabre\SharesPlugin(
169
+                    $objectTree,
170
+                    $this->userSession,
171
+                    $userFolder,
172
+                    \OC::$server->getShareManager()
173
+                ));
174
+                $server->addPlugin(new \OCA\DAV\Connector\Sabre\CommentPropertiesPlugin(\OC::$server->getCommentsManager(), $this->userSession));
175
+                $server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesReportPlugin(
176
+                    $objectTree,
177
+                    $view,
178
+                    \OC::$server->getSystemTagManager(),
179
+                    \OC::$server->getSystemTagObjectMapper(),
180
+                    \OC::$server->getTagManager(),
181
+                    $this->userSession,
182
+                    \OC::$server->getGroupManager(),
183
+                    $userFolder
184
+                ));
185
+                // custom properties plugin must be the last one
186
+                $server->addPlugin(
187
+                    new \Sabre\DAV\PropertyStorage\Plugin(
188
+                        new \OCA\DAV\Connector\Sabre\CustomPropertiesBackend(
189
+                            $objectTree,
190
+                            $this->databaseConnection,
191
+                            $this->userSession->getUser()
192
+                        )
193
+                    )
194
+                );
195
+            }
196
+            $server->addPlugin(new \OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin());
197
+        }, 30); // priority 30: after auth (10) and acl(20), before lock(50) and handling the request
198
+        return $server;
199
+    }
200 200
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -30,34 +30,34 @@
 block discarded – undo
30 30
 
31 31
 class AnonymousOptionsPlugin extends ServerPlugin {
32 32
 
33
-	/**
34
-	 * @var \Sabre\DAV\Server
35
-	 */
36
-	private $server;
33
+    /**
34
+     * @var \Sabre\DAV\Server
35
+     */
36
+    private $server;
37 37
 
38
-	/**
39
-	 * @param \Sabre\DAV\Server $server
40
-	 * @return void
41
-	 */
42
-	public function initialize(\Sabre\DAV\Server $server) {
43
-		$this->server = $server;
44
-		// before auth
45
-		$this->server->on('beforeMethod', [$this, 'checkAppEnabled'], 9);
46
-	}
38
+    /**
39
+     * @param \Sabre\DAV\Server $server
40
+     * @return void
41
+     */
42
+    public function initialize(\Sabre\DAV\Server $server) {
43
+        $this->server = $server;
44
+        // before auth
45
+        $this->server->on('beforeMethod', [$this, 'checkAppEnabled'], 9);
46
+    }
47 47
 
48
-	/**
49
-	 * @throws \Sabre\DAV\Exception\Forbidden
50
-	 * @return bool
51
-	 */
52
-	public function checkAppEnabled(RequestInterface $request, ResponseInterface $response) {
53
-		if ($request->getMethod() === 'OPTIONS' && $request->getPath() === '') {
54
-			/** @var CorePlugin $corePlugin */
55
-			$corePlugin = $this->server->getPlugin('core');
56
-			// setup a fake tree for anonymous access
57
-			$this->server->tree = new Tree(new Directory(''));
58
-			$corePlugin->httpOptions($request, $response);
59
-			$this->server->sapi->sendResponse($response);
60
-			return false;
61
-		}
62
-	}
48
+    /**
49
+     * @throws \Sabre\DAV\Exception\Forbidden
50
+     * @return bool
51
+     */
52
+    public function checkAppEnabled(RequestInterface $request, ResponseInterface $response) {
53
+        if ($request->getMethod() === 'OPTIONS' && $request->getPath() === '') {
54
+            /** @var CorePlugin $corePlugin */
55
+            $corePlugin = $this->server->getPlugin('core');
56
+            // setup a fake tree for anonymous access
57
+            $this->server->tree = new Tree(new Directory(''));
58
+            $corePlugin->httpOptions($request, $response);
59
+            $this->server->sapi->sendResponse($response);
60
+            return false;
61
+        }
62
+    }
63 63
 }
Please login to merge, or discard this patch.
apps/dav/lib/Server.php 1 patch
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -65,221 +65,221 @@
 block discarded – undo
65 65
 
66 66
 class Server {
67 67
 
68
-	/** @var IRequest */
69
-	private $request;
68
+    /** @var IRequest */
69
+    private $request;
70 70
 
71
-	/** @var  string */
72
-	private $baseUri;
71
+    /** @var  string */
72
+    private $baseUri;
73 73
 
74
-	/** @var Connector\Sabre\Server  */
75
-	private $server;
74
+    /** @var Connector\Sabre\Server  */
75
+    private $server;
76 76
 
77
-	public function __construct(IRequest $request, $baseUri) {
78
-		$this->request = $request;
79
-		$this->baseUri = $baseUri;
80
-		$logger = \OC::$server->getLogger();
81
-		$dispatcher = \OC::$server->getEventDispatcher();
82
-		$sendInvitations = \OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes';
77
+    public function __construct(IRequest $request, $baseUri) {
78
+        $this->request = $request;
79
+        $this->baseUri = $baseUri;
80
+        $logger = \OC::$server->getLogger();
81
+        $dispatcher = \OC::$server->getEventDispatcher();
82
+        $sendInvitations = \OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes';
83 83
 
84
-		$root = new RootCollection();
85
-		$this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
84
+        $root = new RootCollection();
85
+        $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
86 86
 
87
-		// Add maintenance plugin
88
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig()));
87
+        // Add maintenance plugin
88
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig()));
89 89
 
90
-		// Backends
91
-		$authBackend = new Auth(
92
-			\OC::$server->getSession(),
93
-			\OC::$server->getUserSession(),
94
-			\OC::$server->getRequest(),
95
-			\OC::$server->getTwoFactorAuthManager(),
96
-			\OC::$server->getBruteForceThrottler()
97
-		);
90
+        // Backends
91
+        $authBackend = new Auth(
92
+            \OC::$server->getSession(),
93
+            \OC::$server->getUserSession(),
94
+            \OC::$server->getRequest(),
95
+            \OC::$server->getTwoFactorAuthManager(),
96
+            \OC::$server->getBruteForceThrottler()
97
+        );
98 98
 
99
-		// Set URL explicitly due to reverse-proxy situations
100
-		$this->server->httpRequest->setUrl($this->request->getRequestUri());
101
-		$this->server->setBaseUri($this->baseUri);
99
+        // Set URL explicitly due to reverse-proxy situations
100
+        $this->server->httpRequest->setUrl($this->request->getRequestUri());
101
+        $this->server->setBaseUri($this->baseUri);
102 102
 
103
-		$this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
104
-		$this->server->addPlugin(new AnonymousOptionsPlugin());
105
-		$authPlugin = new Plugin();
106
-		$authPlugin->addBackend(new PublicAuth());
107
-		$this->server->addPlugin($authPlugin);
103
+        $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
104
+        $this->server->addPlugin(new AnonymousOptionsPlugin());
105
+        $authPlugin = new Plugin();
106
+        $authPlugin->addBackend(new PublicAuth());
107
+        $this->server->addPlugin($authPlugin);
108 108
 
109
-		// allow setup of additional auth backends
110
-		$event = new SabrePluginEvent($this->server);
111
-		$dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);
109
+        // allow setup of additional auth backends
110
+        $event = new SabrePluginEvent($this->server);
111
+        $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);
112 112
 
113
-		$bearerAuthBackend = new BearerAuth(
114
-			\OC::$server->getUserSession(),
115
-			\OC::$server->getSession(),
116
-			\OC::$server->getRequest()
117
-		);
118
-		$authPlugin->addBackend($bearerAuthBackend);
119
-		// because we are throwing exceptions this plugin has to be the last one
120
-		$authPlugin->addBackend($authBackend);
113
+        $bearerAuthBackend = new BearerAuth(
114
+            \OC::$server->getUserSession(),
115
+            \OC::$server->getSession(),
116
+            \OC::$server->getRequest()
117
+        );
118
+        $authPlugin->addBackend($bearerAuthBackend);
119
+        // because we are throwing exceptions this plugin has to be the last one
120
+        $authPlugin->addBackend($authBackend);
121 121
 
122
-		// debugging
123
-		if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
124
-			$this->server->addPlugin(new \Sabre\DAV\Browser\Plugin());
125
-		} else {
126
-			$this->server->addPlugin(new DummyGetResponsePlugin());
127
-		}
122
+        // debugging
123
+        if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
124
+            $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin());
125
+        } else {
126
+            $this->server->addPlugin(new DummyGetResponsePlugin());
127
+        }
128 128
 
129
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
130
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
131
-		$this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
129
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
130
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
131
+        $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
132 132
 
133
-		// acl
134
-		$acl = new DavAclPlugin();
135
-		$acl->principalCollectionSet = [
136
-			'principals/users', 'principals/groups'
137
-		];
138
-		$acl->defaultUsernamePath = 'principals/users';
139
-		$this->server->addPlugin($acl);
133
+        // acl
134
+        $acl = new DavAclPlugin();
135
+        $acl->principalCollectionSet = [
136
+            'principals/users', 'principals/groups'
137
+        ];
138
+        $acl->defaultUsernamePath = 'principals/users';
139
+        $this->server->addPlugin($acl);
140 140
 
141
-		// calendar plugins
142
-		$this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
143
-		$this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
144
-		$this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin());
145
-		if ($sendInvitations) {
146
-			$this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class));
147
-		}
148
-		$this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
149
-		$this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
150
-		$this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
151
-		$this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
152
-			\OC::$server->getConfig(),
153
-			\OC::$server->getURLGenerator()
154
-		));
141
+        // calendar plugins
142
+        $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
143
+        $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
144
+        $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin());
145
+        if ($sendInvitations) {
146
+            $this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class));
147
+        }
148
+        $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
149
+        $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
150
+        $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
151
+        $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
152
+            \OC::$server->getConfig(),
153
+            \OC::$server->getURLGenerator()
154
+        ));
155 155
 
156
-		// addressbook plugins
157
-		$this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());
158
-		$this->server->addPlugin(new VCFExportPlugin());
159
-		$this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache'))));
156
+        // addressbook plugins
157
+        $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());
158
+        $this->server->addPlugin(new VCFExportPlugin());
159
+        $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache'))));
160 160
 
161
-		// system tags plugins
162
-		$this->server->addPlugin(new SystemTagPlugin(
163
-			\OC::$server->getSystemTagManager(),
164
-			\OC::$server->getGroupManager(),
165
-			\OC::$server->getUserSession()
166
-		));
161
+        // system tags plugins
162
+        $this->server->addPlugin(new SystemTagPlugin(
163
+            \OC::$server->getSystemTagManager(),
164
+            \OC::$server->getGroupManager(),
165
+            \OC::$server->getUserSession()
166
+        ));
167 167
 
168
-		// comments plugin
169
-		$this->server->addPlugin(new CommentsPlugin(
170
-			\OC::$server->getCommentsManager(),
171
-			\OC::$server->getUserSession()
172
-		));
168
+        // comments plugin
169
+        $this->server->addPlugin(new CommentsPlugin(
170
+            \OC::$server->getCommentsManager(),
171
+            \OC::$server->getUserSession()
172
+        ));
173 173
 
174
-		$this->server->addPlugin(new CopyEtagHeaderPlugin());
175
-		$this->server->addPlugin(new ChunkingPlugin());
174
+        $this->server->addPlugin(new CopyEtagHeaderPlugin());
175
+        $this->server->addPlugin(new ChunkingPlugin());
176 176
 
177
-		// allow setup of additional plugins
178
-		$dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event);
177
+        // allow setup of additional plugins
178
+        $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event);
179 179
 
180
-		// Some WebDAV clients do require Class 2 WebDAV support (locking), since
181
-		// we do not provide locking we emulate it using a fake locking plugin.
182
-		if($request->isUserAgent([
183
-			'/WebDAVFS/',
184
-			'/OneNote/',
185
-			'/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601
186
-		])) {
187
-			$this->server->addPlugin(new FakeLockerPlugin());
188
-		}
180
+        // Some WebDAV clients do require Class 2 WebDAV support (locking), since
181
+        // we do not provide locking we emulate it using a fake locking plugin.
182
+        if($request->isUserAgent([
183
+            '/WebDAVFS/',
184
+            '/OneNote/',
185
+            '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601
186
+        ])) {
187
+            $this->server->addPlugin(new FakeLockerPlugin());
188
+        }
189 189
 
190
-		if (BrowserErrorPagePlugin::isBrowserRequest($request)) {
191
-			$this->server->addPlugin(new BrowserErrorPagePlugin());
192
-		}
190
+        if (BrowserErrorPagePlugin::isBrowserRequest($request)) {
191
+            $this->server->addPlugin(new BrowserErrorPagePlugin());
192
+        }
193 193
 
194
-		// wait with registering these until auth is handled and the filesystem is setup
195
-		$this->server->on('beforeMethod', function () use ($root) {
196
-			// custom properties plugin must be the last one
197
-			$userSession = \OC::$server->getUserSession();
198
-			$user = $userSession->getUser();
199
-			if ($user !== null) {
200
-				$view = \OC\Files\Filesystem::getView();
201
-				$this->server->addPlugin(
202
-					new FilesPlugin(
203
-						$this->server->tree,
204
-						\OC::$server->getConfig(),
205
-						$this->request,
206
-						\OC::$server->getPreviewManager(),
207
-						false,
208
-						!\OC::$server->getConfig()->getSystemValue('debug', false)
209
-					)
210
-				);
194
+        // wait with registering these until auth is handled and the filesystem is setup
195
+        $this->server->on('beforeMethod', function () use ($root) {
196
+            // custom properties plugin must be the last one
197
+            $userSession = \OC::$server->getUserSession();
198
+            $user = $userSession->getUser();
199
+            if ($user !== null) {
200
+                $view = \OC\Files\Filesystem::getView();
201
+                $this->server->addPlugin(
202
+                    new FilesPlugin(
203
+                        $this->server->tree,
204
+                        \OC::$server->getConfig(),
205
+                        $this->request,
206
+                        \OC::$server->getPreviewManager(),
207
+                        false,
208
+                        !\OC::$server->getConfig()->getSystemValue('debug', false)
209
+                    )
210
+                );
211 211
 
212
-				$this->server->addPlugin(
213
-					new \Sabre\DAV\PropertyStorage\Plugin(
214
-						new CustomPropertiesBackend(
215
-							$this->server->tree,
216
-							\OC::$server->getDatabaseConnection(),
217
-							\OC::$server->getUserSession()->getUser()
218
-						)
219
-					)
220
-				);
221
-				if ($view !== null) {
222
-					$this->server->addPlugin(
223
-						new QuotaPlugin($view, false));
224
-				}
225
-				$this->server->addPlugin(
226
-					new TagsPlugin(
227
-						$this->server->tree, \OC::$server->getTagManager()
228
-					)
229
-				);
230
-				// TODO: switch to LazyUserFolder
231
-				$userFolder = \OC::$server->getUserFolder();
232
-				$this->server->addPlugin(new SharesPlugin(
233
-					$this->server->tree,
234
-					$userSession,
235
-					$userFolder,
236
-					\OC::$server->getShareManager()
237
-				));
238
-				$this->server->addPlugin(new CommentPropertiesPlugin(
239
-					\OC::$server->getCommentsManager(),
240
-					$userSession
241
-				));
242
-				$this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin());
243
-				if ($view !== null) {
244
-					$this->server->addPlugin(new FilesReportPlugin(
245
-						$this->server->tree,
246
-						$view,
247
-						\OC::$server->getSystemTagManager(),
248
-						\OC::$server->getSystemTagObjectMapper(),
249
-						\OC::$server->getTagManager(),
250
-						$userSession,
251
-						\OC::$server->getGroupManager(),
252
-						$userFolder
253
-					));
254
-					$this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend(
255
-						$this->server->tree,
256
-						$user,
257
-						\OC::$server->getRootFolder(),
258
-						\OC::$server->getShareManager(),
259
-						$view
260
-					)));
261
-				}
262
-				$this->server->addPlugin(new \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin(
263
-					\OC::$server->getConfig(),
264
-					\OC::$server->query(BirthdayService::class)
265
-				));
266
-			}
212
+                $this->server->addPlugin(
213
+                    new \Sabre\DAV\PropertyStorage\Plugin(
214
+                        new CustomPropertiesBackend(
215
+                            $this->server->tree,
216
+                            \OC::$server->getDatabaseConnection(),
217
+                            \OC::$server->getUserSession()->getUser()
218
+                        )
219
+                    )
220
+                );
221
+                if ($view !== null) {
222
+                    $this->server->addPlugin(
223
+                        new QuotaPlugin($view, false));
224
+                }
225
+                $this->server->addPlugin(
226
+                    new TagsPlugin(
227
+                        $this->server->tree, \OC::$server->getTagManager()
228
+                    )
229
+                );
230
+                // TODO: switch to LazyUserFolder
231
+                $userFolder = \OC::$server->getUserFolder();
232
+                $this->server->addPlugin(new SharesPlugin(
233
+                    $this->server->tree,
234
+                    $userSession,
235
+                    $userFolder,
236
+                    \OC::$server->getShareManager()
237
+                ));
238
+                $this->server->addPlugin(new CommentPropertiesPlugin(
239
+                    \OC::$server->getCommentsManager(),
240
+                    $userSession
241
+                ));
242
+                $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin());
243
+                if ($view !== null) {
244
+                    $this->server->addPlugin(new FilesReportPlugin(
245
+                        $this->server->tree,
246
+                        $view,
247
+                        \OC::$server->getSystemTagManager(),
248
+                        \OC::$server->getSystemTagObjectMapper(),
249
+                        \OC::$server->getTagManager(),
250
+                        $userSession,
251
+                        \OC::$server->getGroupManager(),
252
+                        $userFolder
253
+                    ));
254
+                    $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend(
255
+                        $this->server->tree,
256
+                        $user,
257
+                        \OC::$server->getRootFolder(),
258
+                        \OC::$server->getShareManager(),
259
+                        $view
260
+                    )));
261
+                }
262
+                $this->server->addPlugin(new \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin(
263
+                    \OC::$server->getConfig(),
264
+                    \OC::$server->query(BirthdayService::class)
265
+                ));
266
+            }
267 267
 
268
-			// register plugins from apps
269
-			$pluginManager = new PluginManager(
270
-				\OC::$server,
271
-				\OC::$server->getAppManager()
272
-			);
273
-			foreach ($pluginManager->getAppPlugins() as $appPlugin) {
274
-				$this->server->addPlugin($appPlugin);
275
-			}
276
-			foreach ($pluginManager->getAppCollections() as $appCollection) {
277
-				$root->addChild($appCollection);
278
-			}
279
-		});
280
-	}
268
+            // register plugins from apps
269
+            $pluginManager = new PluginManager(
270
+                \OC::$server,
271
+                \OC::$server->getAppManager()
272
+            );
273
+            foreach ($pluginManager->getAppPlugins() as $appPlugin) {
274
+                $this->server->addPlugin($appPlugin);
275
+            }
276
+            foreach ($pluginManager->getAppCollections() as $appCollection) {
277
+                $root->addChild($appCollection);
278
+            }
279
+        });
280
+    }
281 281
 
282
-	public function exec() {
283
-		$this->server->exec();
284
-	}
282
+    public function exec() {
283
+        $this->server->exec();
284
+    }
285 285
 }
Please login to merge, or discard this patch.