Passed
Push — master ( fc4181...16d0ef )
by Morris
13:45 queued 01:50
created
apps/files_sharing/lib/Controller/ShareController.php 1 patch
Indentation   +657 added lines, -657 removed lines patch added patch discarded remove patch
@@ -85,663 +85,663 @@
 block discarded – undo
85 85
  */
86 86
 class ShareController extends AuthPublicShareController {
87 87
 
88
-	/** @var IConfig */
89
-	protected $config;
90
-	/** @var IUserManager */
91
-	protected $userManager;
92
-	/** @var ILogger */
93
-	protected $logger;
94
-	/** @var \OCP\Activity\IManager */
95
-	protected $activityManager;
96
-	/** @var IPreview */
97
-	protected $previewManager;
98
-	/** @var IRootFolder */
99
-	protected $rootFolder;
100
-	/** @var FederatedShareProvider */
101
-	protected $federatedShareProvider;
102
-	/** @var IAccountManager */
103
-	protected $accountManager;
104
-	/** @var IEventDispatcher */
105
-	protected $eventDispatcher;
106
-	/** @var IL10N */
107
-	protected $l10n;
108
-	/** @var Defaults */
109
-	protected $defaults;
110
-	/** @var ShareManager */
111
-	protected $shareManager;
112
-
113
-	/** @var Share\IShare */
114
-	protected $share;
115
-
116
-	/**
117
-	 * @param string $appName
118
-	 * @param IRequest $request
119
-	 * @param IConfig $config
120
-	 * @param IURLGenerator $urlGenerator
121
-	 * @param IUserManager $userManager
122
-	 * @param ILogger $logger
123
-	 * @param \OCP\Activity\IManager $activityManager
124
-	 * @param \OCP\Share\IManager $shareManager
125
-	 * @param ISession $session
126
-	 * @param IPreview $previewManager
127
-	 * @param IRootFolder $rootFolder
128
-	 * @param FederatedShareProvider $federatedShareProvider
129
-	 * @param IAccountManager $accountManager
130
-	 * @param IEventDispatcher $eventDispatcher
131
-	 * @param IL10N $l10n
132
-	 * @param Defaults $defaults
133
-	 */
134
-	public function __construct(string $appName,
135
-								IRequest $request,
136
-								IConfig $config,
137
-								IURLGenerator $urlGenerator,
138
-								IUserManager $userManager,
139
-								ILogger $logger,
140
-								\OCP\Activity\IManager $activityManager,
141
-								ShareManager $shareManager,
142
-								ISession $session,
143
-								IPreview $previewManager,
144
-								IRootFolder $rootFolder,
145
-								FederatedShareProvider $federatedShareProvider,
146
-								IAccountManager $accountManager,
147
-								IEventDispatcher $eventDispatcher,
148
-								IL10N $l10n,
149
-								Defaults $defaults) {
150
-		parent::__construct($appName, $request, $session, $urlGenerator);
151
-
152
-		$this->config = $config;
153
-		$this->userManager = $userManager;
154
-		$this->logger = $logger;
155
-		$this->activityManager = $activityManager;
156
-		$this->previewManager = $previewManager;
157
-		$this->rootFolder = $rootFolder;
158
-		$this->federatedShareProvider = $federatedShareProvider;
159
-		$this->accountManager = $accountManager;
160
-		$this->eventDispatcher = $eventDispatcher;
161
-		$this->l10n = $l10n;
162
-		$this->defaults = $defaults;
163
-		$this->shareManager = $shareManager;
164
-	}
165
-
166
-	/**
167
-	 * @PublicPage
168
-	 * @NoCSRFRequired
169
-	 *
170
-	 * Show the authentication page
171
-	 * The form has to submit to the authenticate method route
172
-	 */
173
-	public function showAuthenticate(): TemplateResponse {
174
-		$templateParameters = ['share' => $this->share];
175
-
176
-		$this->eventDispatcher->dispatchTyped(new BeforeTemplateRenderedEvent($this->share, BeforeTemplateRenderedEvent::SCOPE_PUBLIC_SHARE_AUTH));
177
-
178
-		$response = new TemplateResponse('core', 'publicshareauth', $templateParameters, 'guest');
179
-		if ($this->share->getSendPasswordByTalk()) {
180
-			$csp = new ContentSecurityPolicy();
181
-			$csp->addAllowedConnectDomain('*');
182
-			$csp->addAllowedMediaDomain('blob:');
183
-			$response->setContentSecurityPolicy($csp);
184
-		}
185
-
186
-		return $response;
187
-	}
188
-
189
-	/**
190
-	 * The template to show when authentication failed
191
-	 */
192
-	protected function showAuthFailed(): TemplateResponse {
193
-		$templateParameters = ['share' => $this->share, 'wrongpw' => true];
194
-
195
-		$this->eventDispatcher->dispatchTyped(new BeforeTemplateRenderedEvent($this->share, BeforeTemplateRenderedEvent::SCOPE_PUBLIC_SHARE_AUTH));
196
-
197
-		$response = new TemplateResponse('core', 'publicshareauth', $templateParameters, 'guest');
198
-		if ($this->share->getSendPasswordByTalk()) {
199
-			$csp = new ContentSecurityPolicy();
200
-			$csp->addAllowedConnectDomain('*');
201
-			$csp->addAllowedMediaDomain('blob:');
202
-			$response->setContentSecurityPolicy($csp);
203
-		}
204
-
205
-		return $response;
206
-	}
207
-
208
-	protected function verifyPassword(string $password): bool {
209
-		return $this->shareManager->checkPassword($this->share, $password);
210
-	}
211
-
212
-	protected function getPasswordHash(): string {
213
-		return $this->share->getPassword();
214
-	}
215
-
216
-	public function isValidToken(): bool {
217
-		try {
218
-			$this->share = $this->shareManager->getShareByToken($this->getToken());
219
-		} catch (ShareNotFound $e) {
220
-			return false;
221
-		}
222
-
223
-		return true;
224
-	}
225
-
226
-	protected function isPasswordProtected(): bool {
227
-		return $this->share->getPassword() !== null;
228
-	}
229
-
230
-	protected function authSucceeded() {
231
-		// For share this was always set so it is still used in other apps
232
-		$this->session->set('public_link_authenticated', (string)$this->share->getId());
233
-	}
234
-
235
-	protected function authFailed() {
236
-		$this->emitAccessShareHook($this->share, 403, 'Wrong password');
237
-	}
238
-
239
-	/**
240
-	 * throws hooks when a share is attempted to be accessed
241
-	 *
242
-	 * @param \OCP\Share\IShare|string $share the Share instance if available,
243
-	 * otherwise token
244
-	 * @param int $errorCode
245
-	 * @param string $errorMessage
246
-	 * @throws \OC\HintException
247
-	 * @throws \OC\ServerNotAvailableException
248
-	 */
249
-	protected function emitAccessShareHook($share, $errorCode = 200, $errorMessage = '') {
250
-		$itemType = $itemSource = $uidOwner = '';
251
-		$token = $share;
252
-		$exception = null;
253
-		if ($share instanceof \OCP\Share\IShare) {
254
-			try {
255
-				$token = $share->getToken();
256
-				$uidOwner = $share->getSharedBy();
257
-				$itemType = $share->getNodeType();
258
-				$itemSource = $share->getNodeId();
259
-			} catch (\Exception $e) {
260
-				// we log what we know and pass on the exception afterwards
261
-				$exception = $e;
262
-			}
263
-		}
264
-		\OC_Hook::emit(Share::class, 'share_link_access', [
265
-			'itemType' => $itemType,
266
-			'itemSource' => $itemSource,
267
-			'uidOwner' => $uidOwner,
268
-			'token' => $token,
269
-			'errorCode' => $errorCode,
270
-			'errorMessage' => $errorMessage,
271
-		]);
272
-		if (!is_null($exception)) {
273
-			throw $exception;
274
-		}
275
-	}
276
-
277
-	/**
278
-	 * Validate the permissions of the share
279
-	 *
280
-	 * @param Share\IShare $share
281
-	 * @return bool
282
-	 */
283
-	private function validateShare(\OCP\Share\IShare $share) {
284
-		// If the owner is disabled no access to the linke is granted
285
-		$owner = $this->userManager->get($share->getShareOwner());
286
-		if ($owner === null || !$owner->isEnabled()) {
287
-			return false;
288
-		}
289
-
290
-		// If the initiator of the share is disabled no access is granted
291
-		$initiator = $this->userManager->get($share->getSharedBy());
292
-		if ($initiator === null || !$initiator->isEnabled()) {
293
-			return false;
294
-		}
295
-
296
-		return $share->getNode()->isReadable() && $share->getNode()->isShareable();
297
-	}
298
-
299
-	/**
300
-	 * @PublicPage
301
-	 * @NoCSRFRequired
302
-	 *
303
-	 *
304
-	 * @param string $path
305
-	 * @return TemplateResponse
306
-	 * @throws NotFoundException
307
-	 * @throws \Exception
308
-	 */
309
-	public function showShare($path = ''): TemplateResponse {
310
-		\OC_User::setIncognitoMode(true);
311
-
312
-		// Check whether share exists
313
-		try {
314
-			$share = $this->shareManager->getShareByToken($this->getToken());
315
-		} catch (ShareNotFound $e) {
316
-			$this->emitAccessShareHook($this->getToken(), 404, 'Share not found');
317
-			throw new NotFoundException();
318
-		}
319
-
320
-		if (!$this->validateShare($share)) {
321
-			throw new NotFoundException();
322
-		}
323
-
324
-		$shareNode = $share->getNode();
325
-
326
-		// We can't get the path of a file share
327
-		try {
328
-			if ($shareNode instanceof \OCP\Files\File && $path !== '') {
329
-				$this->emitAccessShareHook($share, 404, 'Share not found');
330
-				throw new NotFoundException();
331
-			}
332
-		} catch (\Exception $e) {
333
-			$this->emitAccessShareHook($share, 404, 'Share not found');
334
-			throw $e;
335
-		}
336
-
337
-		$shareTmpl = [];
338
-		$shareTmpl['owner'] = '';
339
-		$shareTmpl['shareOwner'] = '';
340
-
341
-		$owner = $this->userManager->get($share->getShareOwner());
342
-		if ($owner instanceof IUser) {
343
-			$ownerAccount = $this->accountManager->getAccount($owner);
344
-
345
-			$ownerName = $ownerAccount->getProperty(IAccountManager::PROPERTY_DISPLAYNAME);
346
-			if ($ownerName->getScope() === IAccountManager::VISIBILITY_PUBLIC) {
347
-				$shareTmpl['owner'] = $owner->getUID();
348
-				$shareTmpl['shareOwner'] = $owner->getDisplayName();
349
-			}
350
-		}
351
-
352
-		$shareTmpl['filename'] = $shareNode->getName();
353
-		$shareTmpl['directory_path'] = $share->getTarget();
354
-		$shareTmpl['note'] = $share->getNote();
355
-		$shareTmpl['mimetype'] = $shareNode->getMimetype();
356
-		$shareTmpl['previewSupported'] = $this->previewManager->isMimeSupported($shareNode->getMimetype());
357
-		$shareTmpl['dirToken'] = $this->getToken();
358
-		$shareTmpl['sharingToken'] = $this->getToken();
359
-		$shareTmpl['server2serversharing'] = $this->federatedShareProvider->isOutgoingServer2serverShareEnabled();
360
-		$shareTmpl['protected'] = $share->getPassword() !== null ? 'true' : 'false';
361
-		$shareTmpl['dir'] = '';
362
-		$shareTmpl['nonHumanFileSize'] = $shareNode->getSize();
363
-		$shareTmpl['fileSize'] = \OCP\Util::humanFileSize($shareNode->getSize());
364
-		$shareTmpl['hideDownload'] = $share->getHideDownload();
365
-
366
-		$hideFileList = false;
367
-
368
-		if ($shareNode instanceof \OCP\Files\Folder) {
369
-			$shareIsFolder = true;
370
-
371
-			try {
372
-				$folderNode = $shareNode->get($path);
373
-			} catch (\OCP\Files\NotFoundException $e) {
374
-				$this->emitAccessShareHook($share, 404, 'Share not found');
375
-				throw new NotFoundException();
376
-			}
377
-
378
-			$shareTmpl['dir'] = $shareNode->getRelativePath($folderNode->getPath());
379
-
380
-			/*
88
+    /** @var IConfig */
89
+    protected $config;
90
+    /** @var IUserManager */
91
+    protected $userManager;
92
+    /** @var ILogger */
93
+    protected $logger;
94
+    /** @var \OCP\Activity\IManager */
95
+    protected $activityManager;
96
+    /** @var IPreview */
97
+    protected $previewManager;
98
+    /** @var IRootFolder */
99
+    protected $rootFolder;
100
+    /** @var FederatedShareProvider */
101
+    protected $federatedShareProvider;
102
+    /** @var IAccountManager */
103
+    protected $accountManager;
104
+    /** @var IEventDispatcher */
105
+    protected $eventDispatcher;
106
+    /** @var IL10N */
107
+    protected $l10n;
108
+    /** @var Defaults */
109
+    protected $defaults;
110
+    /** @var ShareManager */
111
+    protected $shareManager;
112
+
113
+    /** @var Share\IShare */
114
+    protected $share;
115
+
116
+    /**
117
+     * @param string $appName
118
+     * @param IRequest $request
119
+     * @param IConfig $config
120
+     * @param IURLGenerator $urlGenerator
121
+     * @param IUserManager $userManager
122
+     * @param ILogger $logger
123
+     * @param \OCP\Activity\IManager $activityManager
124
+     * @param \OCP\Share\IManager $shareManager
125
+     * @param ISession $session
126
+     * @param IPreview $previewManager
127
+     * @param IRootFolder $rootFolder
128
+     * @param FederatedShareProvider $federatedShareProvider
129
+     * @param IAccountManager $accountManager
130
+     * @param IEventDispatcher $eventDispatcher
131
+     * @param IL10N $l10n
132
+     * @param Defaults $defaults
133
+     */
134
+    public function __construct(string $appName,
135
+                                IRequest $request,
136
+                                IConfig $config,
137
+                                IURLGenerator $urlGenerator,
138
+                                IUserManager $userManager,
139
+                                ILogger $logger,
140
+                                \OCP\Activity\IManager $activityManager,
141
+                                ShareManager $shareManager,
142
+                                ISession $session,
143
+                                IPreview $previewManager,
144
+                                IRootFolder $rootFolder,
145
+                                FederatedShareProvider $federatedShareProvider,
146
+                                IAccountManager $accountManager,
147
+                                IEventDispatcher $eventDispatcher,
148
+                                IL10N $l10n,
149
+                                Defaults $defaults) {
150
+        parent::__construct($appName, $request, $session, $urlGenerator);
151
+
152
+        $this->config = $config;
153
+        $this->userManager = $userManager;
154
+        $this->logger = $logger;
155
+        $this->activityManager = $activityManager;
156
+        $this->previewManager = $previewManager;
157
+        $this->rootFolder = $rootFolder;
158
+        $this->federatedShareProvider = $federatedShareProvider;
159
+        $this->accountManager = $accountManager;
160
+        $this->eventDispatcher = $eventDispatcher;
161
+        $this->l10n = $l10n;
162
+        $this->defaults = $defaults;
163
+        $this->shareManager = $shareManager;
164
+    }
165
+
166
+    /**
167
+     * @PublicPage
168
+     * @NoCSRFRequired
169
+     *
170
+     * Show the authentication page
171
+     * The form has to submit to the authenticate method route
172
+     */
173
+    public function showAuthenticate(): TemplateResponse {
174
+        $templateParameters = ['share' => $this->share];
175
+
176
+        $this->eventDispatcher->dispatchTyped(new BeforeTemplateRenderedEvent($this->share, BeforeTemplateRenderedEvent::SCOPE_PUBLIC_SHARE_AUTH));
177
+
178
+        $response = new TemplateResponse('core', 'publicshareauth', $templateParameters, 'guest');
179
+        if ($this->share->getSendPasswordByTalk()) {
180
+            $csp = new ContentSecurityPolicy();
181
+            $csp->addAllowedConnectDomain('*');
182
+            $csp->addAllowedMediaDomain('blob:');
183
+            $response->setContentSecurityPolicy($csp);
184
+        }
185
+
186
+        return $response;
187
+    }
188
+
189
+    /**
190
+     * The template to show when authentication failed
191
+     */
192
+    protected function showAuthFailed(): TemplateResponse {
193
+        $templateParameters = ['share' => $this->share, 'wrongpw' => true];
194
+
195
+        $this->eventDispatcher->dispatchTyped(new BeforeTemplateRenderedEvent($this->share, BeforeTemplateRenderedEvent::SCOPE_PUBLIC_SHARE_AUTH));
196
+
197
+        $response = new TemplateResponse('core', 'publicshareauth', $templateParameters, 'guest');
198
+        if ($this->share->getSendPasswordByTalk()) {
199
+            $csp = new ContentSecurityPolicy();
200
+            $csp->addAllowedConnectDomain('*');
201
+            $csp->addAllowedMediaDomain('blob:');
202
+            $response->setContentSecurityPolicy($csp);
203
+        }
204
+
205
+        return $response;
206
+    }
207
+
208
+    protected function verifyPassword(string $password): bool {
209
+        return $this->shareManager->checkPassword($this->share, $password);
210
+    }
211
+
212
+    protected function getPasswordHash(): string {
213
+        return $this->share->getPassword();
214
+    }
215
+
216
+    public function isValidToken(): bool {
217
+        try {
218
+            $this->share = $this->shareManager->getShareByToken($this->getToken());
219
+        } catch (ShareNotFound $e) {
220
+            return false;
221
+        }
222
+
223
+        return true;
224
+    }
225
+
226
+    protected function isPasswordProtected(): bool {
227
+        return $this->share->getPassword() !== null;
228
+    }
229
+
230
+    protected function authSucceeded() {
231
+        // For share this was always set so it is still used in other apps
232
+        $this->session->set('public_link_authenticated', (string)$this->share->getId());
233
+    }
234
+
235
+    protected function authFailed() {
236
+        $this->emitAccessShareHook($this->share, 403, 'Wrong password');
237
+    }
238
+
239
+    /**
240
+     * throws hooks when a share is attempted to be accessed
241
+     *
242
+     * @param \OCP\Share\IShare|string $share the Share instance if available,
243
+     * otherwise token
244
+     * @param int $errorCode
245
+     * @param string $errorMessage
246
+     * @throws \OC\HintException
247
+     * @throws \OC\ServerNotAvailableException
248
+     */
249
+    protected function emitAccessShareHook($share, $errorCode = 200, $errorMessage = '') {
250
+        $itemType = $itemSource = $uidOwner = '';
251
+        $token = $share;
252
+        $exception = null;
253
+        if ($share instanceof \OCP\Share\IShare) {
254
+            try {
255
+                $token = $share->getToken();
256
+                $uidOwner = $share->getSharedBy();
257
+                $itemType = $share->getNodeType();
258
+                $itemSource = $share->getNodeId();
259
+            } catch (\Exception $e) {
260
+                // we log what we know and pass on the exception afterwards
261
+                $exception = $e;
262
+            }
263
+        }
264
+        \OC_Hook::emit(Share::class, 'share_link_access', [
265
+            'itemType' => $itemType,
266
+            'itemSource' => $itemSource,
267
+            'uidOwner' => $uidOwner,
268
+            'token' => $token,
269
+            'errorCode' => $errorCode,
270
+            'errorMessage' => $errorMessage,
271
+        ]);
272
+        if (!is_null($exception)) {
273
+            throw $exception;
274
+        }
275
+    }
276
+
277
+    /**
278
+     * Validate the permissions of the share
279
+     *
280
+     * @param Share\IShare $share
281
+     * @return bool
282
+     */
283
+    private function validateShare(\OCP\Share\IShare $share) {
284
+        // If the owner is disabled no access to the linke is granted
285
+        $owner = $this->userManager->get($share->getShareOwner());
286
+        if ($owner === null || !$owner->isEnabled()) {
287
+            return false;
288
+        }
289
+
290
+        // If the initiator of the share is disabled no access is granted
291
+        $initiator = $this->userManager->get($share->getSharedBy());
292
+        if ($initiator === null || !$initiator->isEnabled()) {
293
+            return false;
294
+        }
295
+
296
+        return $share->getNode()->isReadable() && $share->getNode()->isShareable();
297
+    }
298
+
299
+    /**
300
+     * @PublicPage
301
+     * @NoCSRFRequired
302
+     *
303
+     *
304
+     * @param string $path
305
+     * @return TemplateResponse
306
+     * @throws NotFoundException
307
+     * @throws \Exception
308
+     */
309
+    public function showShare($path = ''): TemplateResponse {
310
+        \OC_User::setIncognitoMode(true);
311
+
312
+        // Check whether share exists
313
+        try {
314
+            $share = $this->shareManager->getShareByToken($this->getToken());
315
+        } catch (ShareNotFound $e) {
316
+            $this->emitAccessShareHook($this->getToken(), 404, 'Share not found');
317
+            throw new NotFoundException();
318
+        }
319
+
320
+        if (!$this->validateShare($share)) {
321
+            throw new NotFoundException();
322
+        }
323
+
324
+        $shareNode = $share->getNode();
325
+
326
+        // We can't get the path of a file share
327
+        try {
328
+            if ($shareNode instanceof \OCP\Files\File && $path !== '') {
329
+                $this->emitAccessShareHook($share, 404, 'Share not found');
330
+                throw new NotFoundException();
331
+            }
332
+        } catch (\Exception $e) {
333
+            $this->emitAccessShareHook($share, 404, 'Share not found');
334
+            throw $e;
335
+        }
336
+
337
+        $shareTmpl = [];
338
+        $shareTmpl['owner'] = '';
339
+        $shareTmpl['shareOwner'] = '';
340
+
341
+        $owner = $this->userManager->get($share->getShareOwner());
342
+        if ($owner instanceof IUser) {
343
+            $ownerAccount = $this->accountManager->getAccount($owner);
344
+
345
+            $ownerName = $ownerAccount->getProperty(IAccountManager::PROPERTY_DISPLAYNAME);
346
+            if ($ownerName->getScope() === IAccountManager::VISIBILITY_PUBLIC) {
347
+                $shareTmpl['owner'] = $owner->getUID();
348
+                $shareTmpl['shareOwner'] = $owner->getDisplayName();
349
+            }
350
+        }
351
+
352
+        $shareTmpl['filename'] = $shareNode->getName();
353
+        $shareTmpl['directory_path'] = $share->getTarget();
354
+        $shareTmpl['note'] = $share->getNote();
355
+        $shareTmpl['mimetype'] = $shareNode->getMimetype();
356
+        $shareTmpl['previewSupported'] = $this->previewManager->isMimeSupported($shareNode->getMimetype());
357
+        $shareTmpl['dirToken'] = $this->getToken();
358
+        $shareTmpl['sharingToken'] = $this->getToken();
359
+        $shareTmpl['server2serversharing'] = $this->federatedShareProvider->isOutgoingServer2serverShareEnabled();
360
+        $shareTmpl['protected'] = $share->getPassword() !== null ? 'true' : 'false';
361
+        $shareTmpl['dir'] = '';
362
+        $shareTmpl['nonHumanFileSize'] = $shareNode->getSize();
363
+        $shareTmpl['fileSize'] = \OCP\Util::humanFileSize($shareNode->getSize());
364
+        $shareTmpl['hideDownload'] = $share->getHideDownload();
365
+
366
+        $hideFileList = false;
367
+
368
+        if ($shareNode instanceof \OCP\Files\Folder) {
369
+            $shareIsFolder = true;
370
+
371
+            try {
372
+                $folderNode = $shareNode->get($path);
373
+            } catch (\OCP\Files\NotFoundException $e) {
374
+                $this->emitAccessShareHook($share, 404, 'Share not found');
375
+                throw new NotFoundException();
376
+            }
377
+
378
+            $shareTmpl['dir'] = $shareNode->getRelativePath($folderNode->getPath());
379
+
380
+            /*
381 381
 			 * The OC_Util methods require a view. This just uses the node API
382 382
 			 */
383
-			$freeSpace = $share->getNode()->getStorage()->free_space($share->getNode()->getInternalPath());
384
-			if ($freeSpace < \OCP\Files\FileInfo::SPACE_UNLIMITED) {
385
-				$freeSpace = max($freeSpace, 0);
386
-			} else {
387
-				$freeSpace = (INF > 0) ? INF: PHP_INT_MAX; // work around https://bugs.php.net/bug.php?id=69188
388
-			}
389
-
390
-			$hideFileList = !($share->getPermissions() & \OCP\Constants::PERMISSION_READ);
391
-			$maxUploadFilesize = $freeSpace;
392
-
393
-			$folder = new Template('files', 'list', '');
394
-
395
-			$folder->assign('dir', $shareNode->getRelativePath($folderNode->getPath()));
396
-			$folder->assign('dirToken', $this->getToken());
397
-			$folder->assign('permissions', \OCP\Constants::PERMISSION_READ);
398
-			$folder->assign('isPublic', true);
399
-			$folder->assign('hideFileList', $hideFileList);
400
-			$folder->assign('publicUploadEnabled', 'no');
401
-			// default to list view
402
-			$folder->assign('showgridview', false);
403
-			$folder->assign('uploadMaxFilesize', $maxUploadFilesize);
404
-			$folder->assign('uploadMaxHumanFilesize', \OCP\Util::humanFileSize($maxUploadFilesize));
405
-			$folder->assign('freeSpace', $freeSpace);
406
-			$folder->assign('usedSpacePercent', 0);
407
-			$folder->assign('trash', false);
408
-			$shareTmpl['folder'] = $folder->fetchPage();
409
-		} else {
410
-			$shareIsFolder = false;
411
-		}
412
-
413
-		// default to list view
414
-		$shareTmpl['showgridview'] = false;
415
-
416
-		$shareTmpl['hideFileList'] = $hideFileList;
417
-		$shareTmpl['downloadURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', ['token' => $this->getToken()]);
418
-		$shareTmpl['shareUrl'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $this->getToken()]);
419
-		$shareTmpl['maxSizeAnimateGif'] = $this->config->getSystemValue('max_filesize_animated_gifs_public_sharing', 10);
420
-		$shareTmpl['previewEnabled'] = $this->config->getSystemValue('enable_previews', true);
421
-		$shareTmpl['previewMaxX'] = $this->config->getSystemValue('preview_max_x', 1024);
422
-		$shareTmpl['previewMaxY'] = $this->config->getSystemValue('preview_max_y', 1024);
423
-		$shareTmpl['disclaimer'] = $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', null);
424
-		$shareTmpl['previewURL'] = $shareTmpl['downloadURL'];
425
-
426
-		if ($shareTmpl['previewSupported']) {
427
-			$shareTmpl['previewImage'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.PublicPreview.getPreview',
428
-				['x' => 200, 'y' => 200, 'file' => $shareTmpl['directory_path'], 'token' => $shareTmpl['dirToken']]);
429
-			$ogPreview = $shareTmpl['previewImage'];
430
-
431
-			// We just have direct previews for image files
432
-			if ($shareNode->getMimePart() === 'image') {
433
-				$shareTmpl['previewURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.publicpreview.directLink', ['token' => $this->getToken()]);
434
-
435
-				$ogPreview = $shareTmpl['previewURL'];
436
-
437
-				//Whatapp is kind of picky about their size requirements
438
-				if ($this->request->isUserAgent(['/^WhatsApp/'])) {
439
-					$ogPreview = $this->urlGenerator->linkToRouteAbsolute('files_sharing.PublicPreview.getPreview', [
440
-						'token' => $this->getToken(),
441
-						'x' => 256,
442
-						'y' => 256,
443
-						'a' => true,
444
-					]);
445
-				}
446
-			}
447
-		} else {
448
-			$shareTmpl['previewImage'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'favicon-fb.png'));
449
-			$ogPreview = $shareTmpl['previewImage'];
450
-		}
451
-
452
-		// Load files we need
453
-		\OCP\Util::addScript('files', 'semaphore');
454
-		\OCP\Util::addScript('files', 'file-upload');
455
-		\OCP\Util::addStyle('files_sharing', 'publicView');
456
-		\OCP\Util::addScript('files_sharing', 'public');
457
-		\OCP\Util::addScript('files_sharing', 'templates');
458
-		\OCP\Util::addScript('files', 'fileactions');
459
-		\OCP\Util::addScript('files', 'fileactionsmenu');
460
-		\OCP\Util::addScript('files', 'jquery.fileupload');
461
-		\OCP\Util::addScript('files_sharing', 'files_drop');
462
-
463
-		if (isset($shareTmpl['folder'])) {
464
-			// JS required for folders
465
-			\OCP\Util::addStyle('files', 'merged');
466
-			\OCP\Util::addScript('files', 'filesummary');
467
-			\OCP\Util::addScript('files', 'templates');
468
-			\OCP\Util::addScript('files', 'breadcrumb');
469
-			\OCP\Util::addScript('files', 'fileinfomodel');
470
-			\OCP\Util::addScript('files', 'newfilemenu');
471
-			\OCP\Util::addScript('files', 'files');
472
-			\OCP\Util::addScript('files', 'filemultiselectmenu');
473
-			\OCP\Util::addScript('files', 'filelist');
474
-			\OCP\Util::addScript('files', 'keyboardshortcuts');
475
-			\OCP\Util::addScript('files', 'operationprogressbar');
476
-
477
-			// Load Viewer scripts
478
-			if (class_exists(LoadViewer::class)) {
479
-				$this->eventDispatcher->dispatchTyped(new LoadViewer());
480
-			}
481
-		}
482
-
483
-		// OpenGraph Support: http://ogp.me/
484
-		\OCP\Util::addHeader('meta', ['property' => "og:title", 'content' => $shareTmpl['filename']]);
485
-		\OCP\Util::addHeader('meta', ['property' => "og:description", 'content' => $this->defaults->getName() . ($this->defaults->getSlogan() !== '' ? ' - ' . $this->defaults->getSlogan() : '')]);
486
-		\OCP\Util::addHeader('meta', ['property' => "og:site_name", 'content' => $this->defaults->getName()]);
487
-		\OCP\Util::addHeader('meta', ['property' => "og:url", 'content' => $shareTmpl['shareUrl']]);
488
-		\OCP\Util::addHeader('meta', ['property' => "og:type", 'content' => "object"]);
489
-		\OCP\Util::addHeader('meta', ['property' => "og:image", 'content' => $ogPreview]);
490
-
491
-		$this->eventDispatcher->dispatchTyped(new BeforeTemplateRenderedEvent($share));
492
-
493
-		$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
494
-		$csp->addAllowedFrameDomain('\'self\'');
495
-
496
-		$response = new PublicTemplateResponse($this->appName, 'public', $shareTmpl);
497
-		$response->setHeaderTitle($shareTmpl['filename']);
498
-		if ($shareTmpl['shareOwner'] !== '') {
499
-			$response->setHeaderDetails($this->l10n->t('shared by %s', [$shareTmpl['shareOwner']]));
500
-		}
501
-
502
-		$isNoneFileDropFolder = $shareIsFolder === false || $share->getPermissions() !== \OCP\Constants::PERMISSION_CREATE;
503
-
504
-		if ($isNoneFileDropFolder && !$share->getHideDownload()) {
505
-			\OCP\Util::addScript('files_sharing', 'public_note');
506
-
507
-			$downloadWhite = new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download-white', $shareTmpl['downloadURL'], 0);
508
-			$downloadAllWhite = new SimpleMenuAction('download', $this->l10n->t('Download all files'), 'icon-download-white', $shareTmpl['downloadURL'], 0);
509
-			$download = new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download', $shareTmpl['downloadURL'], 10, $shareTmpl['fileSize']);
510
-			$downloadAll = new SimpleMenuAction('download', $this->l10n->t('Download all files'), 'icon-download', $shareTmpl['downloadURL'], 10, $shareTmpl['fileSize']);
511
-			$directLink = new LinkMenuAction($this->l10n->t('Direct link'), 'icon-public', $shareTmpl['previewURL']);
512
-			$externalShare = new ExternalShareMenuAction($this->l10n->t('Add to your Nextcloud'), 'icon-external', $shareTmpl['owner'], $shareTmpl['shareOwner'], $shareTmpl['filename']);
513
-
514
-			$responseComposer = [];
515
-
516
-			if ($shareIsFolder) {
517
-				$responseComposer[] = $downloadAllWhite;
518
-				$responseComposer[] = $downloadAll;
519
-			} else {
520
-				$responseComposer[] = $downloadWhite;
521
-				$responseComposer[] = $download;
522
-			}
523
-			$responseComposer[] = $directLink;
524
-			if ($this->federatedShareProvider->isOutgoingServer2serverShareEnabled()) {
525
-				$responseComposer[] = $externalShare;
526
-			}
527
-
528
-			$response->setHeaderActions($responseComposer);
529
-		}
530
-
531
-		$response->setContentSecurityPolicy($csp);
532
-
533
-		$this->emitAccessShareHook($share);
534
-
535
-		return $response;
536
-	}
537
-
538
-	/**
539
-	 * @PublicPage
540
-	 * @NoCSRFRequired
541
-	 * @NoSameSiteCookieRequired
542
-	 *
543
-	 * @param string $token
544
-	 * @param string $files
545
-	 * @param string $path
546
-	 * @param string $downloadStartSecret
547
-	 * @return void|\OCP\AppFramework\Http\Response
548
-	 * @throws NotFoundException
549
-	 */
550
-	public function downloadShare($token, $files = null, $path = '', $downloadStartSecret = '') {
551
-		\OC_User::setIncognitoMode(true);
552
-
553
-		$share = $this->shareManager->getShareByToken($token);
554
-
555
-		if (!($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) {
556
-			return new \OCP\AppFramework\Http\DataResponse('Share is read-only');
557
-		}
558
-
559
-		$files_list = null;
560
-		if (!is_null($files)) { // download selected files
561
-			$files_list = json_decode($files);
562
-			// in case we get only a single file
563
-			if ($files_list === null) {
564
-				$files_list = [$files];
565
-			}
566
-			// Just in case $files is a single int like '1234'
567
-			if (!is_array($files_list)) {
568
-				$files_list = [$files_list];
569
-			}
570
-		}
571
-
572
-		if (!$this->validateShare($share)) {
573
-			throw new NotFoundException();
574
-		}
575
-
576
-		$userFolder = $this->rootFolder->getUserFolder($share->getShareOwner());
577
-		$originalSharePath = $userFolder->getRelativePath($share->getNode()->getPath());
578
-
579
-
580
-		// Single file share
581
-		if ($share->getNode() instanceof \OCP\Files\File) {
582
-			// Single file download
583
-			$this->singleFileDownloaded($share, $share->getNode());
584
-		}
585
-		// Directory share
586
-		else {
587
-			/** @var \OCP\Files\Folder $node */
588
-			$node = $share->getNode();
589
-
590
-			// Try to get the path
591
-			if ($path !== '') {
592
-				try {
593
-					$node = $node->get($path);
594
-				} catch (NotFoundException $e) {
595
-					$this->emitAccessShareHook($share, 404, 'Share not found');
596
-					return new NotFoundResponse();
597
-				}
598
-			}
599
-
600
-			$originalSharePath = $userFolder->getRelativePath($node->getPath());
601
-
602
-			if ($node instanceof \OCP\Files\File) {
603
-				// Single file download
604
-				$this->singleFileDownloaded($share, $share->getNode());
605
-			} else {
606
-				try {
607
-					if (!empty($files_list)) {
608
-						$this->fileListDownloaded($share, $files_list, $node);
609
-					} else {
610
-						// The folder is downloaded
611
-						$this->singleFileDownloaded($share, $share->getNode());
612
-					}
613
-				} catch (NotFoundException $e) {
614
-					return new NotFoundResponse();
615
-				}
616
-			}
617
-		}
618
-
619
-		/* FIXME: We should do this all nicely in OCP */
620
-		OC_Util::tearDownFS();
621
-		OC_Util::setupFS($share->getShareOwner());
622
-
623
-		/**
624
-		 * this sets a cookie to be able to recognize the start of the download
625
-		 * the content must not be longer than 32 characters and must only contain
626
-		 * alphanumeric characters
627
-		 */
628
-		if (!empty($downloadStartSecret)
629
-			&& !isset($downloadStartSecret[32])
630
-			&& preg_match('!^[a-zA-Z0-9]+$!', $downloadStartSecret) === 1) {
631
-
632
-			// FIXME: set on the response once we use an actual app framework response
633
-			setcookie('ocDownloadStarted', $downloadStartSecret, time() + 20, '/');
634
-		}
635
-
636
-		$this->emitAccessShareHook($share);
637
-
638
-		$server_params = [ 'head' => $this->request->getMethod() === 'HEAD' ];
639
-
640
-		/**
641
-		 * Http range requests support
642
-		 */
643
-		if (isset($_SERVER['HTTP_RANGE'])) {
644
-			$server_params['range'] = $this->request->getHeader('Range');
645
-		}
646
-
647
-		// download selected files
648
-		if (!is_null($files) && $files !== '') {
649
-			// FIXME: The exit is required here because otherwise the AppFramework is trying to add headers as well
650
-			// after dispatching the request which results in a "Cannot modify header information" notice.
651
-			OC_Files::get($originalSharePath, $files_list, $server_params);
652
-			exit();
653
-		} else {
654
-			// FIXME: The exit is required here because otherwise the AppFramework is trying to add headers as well
655
-			// after dispatching the request which results in a "Cannot modify header information" notice.
656
-			OC_Files::get(dirname($originalSharePath), basename($originalSharePath), $server_params);
657
-			exit();
658
-		}
659
-	}
660
-
661
-	/**
662
-	 * create activity for every downloaded file
663
-	 *
664
-	 * @param Share\IShare $share
665
-	 * @param array $files_list
666
-	 * @param \OCP\Files\Folder $node
667
-	 * @throws NotFoundException when trying to download a folder or multiple files of a "hide download" share
668
-	 */
669
-	protected function fileListDownloaded(Share\IShare $share, array $files_list, \OCP\Files\Folder $node) {
670
-		if ($share->getHideDownload() && count($files_list) > 1) {
671
-			throw new NotFoundException('Downloading more than 1 file');
672
-		}
673
-
674
-		foreach ($files_list as $file) {
675
-			$subNode = $node->get($file);
676
-			$this->singleFileDownloaded($share, $subNode);
677
-		}
678
-	}
679
-
680
-	/**
681
-	 * create activity if a single file was downloaded from a link share
682
-	 *
683
-	 * @param Share\IShare $share
684
-	 * @throws NotFoundException when trying to download a folder of a "hide download" share
685
-	 */
686
-	protected function singleFileDownloaded(Share\IShare $share, \OCP\Files\Node $node) {
687
-		if ($share->getHideDownload() && $node instanceof Folder) {
688
-			throw new NotFoundException('Downloading a folder');
689
-		}
690
-
691
-		$fileId = $node->getId();
692
-
693
-		$userFolder = $this->rootFolder->getUserFolder($share->getSharedBy());
694
-		$userNodeList = $userFolder->getById($fileId);
695
-		$userNode = $userNodeList[0];
696
-		$ownerFolder = $this->rootFolder->getUserFolder($share->getShareOwner());
697
-		$userPath = $userFolder->getRelativePath($userNode->getPath());
698
-		$ownerPath = $ownerFolder->getRelativePath($node->getPath());
699
-
700
-		$parameters = [$userPath];
701
-
702
-		if ($share->getShareType() === IShare::TYPE_EMAIL) {
703
-			if ($node instanceof \OCP\Files\File) {
704
-				$subject = Downloads::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED;
705
-			} else {
706
-				$subject = Downloads::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED;
707
-			}
708
-			$parameters[] = $share->getSharedWith();
709
-		} else {
710
-			if ($node instanceof \OCP\Files\File) {
711
-				$subject = Downloads::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED;
712
-			} else {
713
-				$subject = Downloads::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED;
714
-			}
715
-		}
716
-
717
-		$this->publishActivity($subject, $parameters, $share->getSharedBy(), $fileId, $userPath);
718
-
719
-		if ($share->getShareOwner() !== $share->getSharedBy()) {
720
-			$parameters[0] = $ownerPath;
721
-			$this->publishActivity($subject, $parameters, $share->getShareOwner(), $fileId, $ownerPath);
722
-		}
723
-	}
724
-
725
-	/**
726
-	 * publish activity
727
-	 *
728
-	 * @param string $subject
729
-	 * @param array $parameters
730
-	 * @param string $affectedUser
731
-	 * @param int $fileId
732
-	 * @param string $filePath
733
-	 */
734
-	protected function publishActivity($subject,
735
-										array $parameters,
736
-										$affectedUser,
737
-										$fileId,
738
-										$filePath) {
739
-		$event = $this->activityManager->generateEvent();
740
-		$event->setApp('files_sharing')
741
-			->setType('public_links')
742
-			->setSubject($subject, $parameters)
743
-			->setAffectedUser($affectedUser)
744
-			->setObject('files', $fileId, $filePath);
745
-		$this->activityManager->publish($event);
746
-	}
383
+            $freeSpace = $share->getNode()->getStorage()->free_space($share->getNode()->getInternalPath());
384
+            if ($freeSpace < \OCP\Files\FileInfo::SPACE_UNLIMITED) {
385
+                $freeSpace = max($freeSpace, 0);
386
+            } else {
387
+                $freeSpace = (INF > 0) ? INF: PHP_INT_MAX; // work around https://bugs.php.net/bug.php?id=69188
388
+            }
389
+
390
+            $hideFileList = !($share->getPermissions() & \OCP\Constants::PERMISSION_READ);
391
+            $maxUploadFilesize = $freeSpace;
392
+
393
+            $folder = new Template('files', 'list', '');
394
+
395
+            $folder->assign('dir', $shareNode->getRelativePath($folderNode->getPath()));
396
+            $folder->assign('dirToken', $this->getToken());
397
+            $folder->assign('permissions', \OCP\Constants::PERMISSION_READ);
398
+            $folder->assign('isPublic', true);
399
+            $folder->assign('hideFileList', $hideFileList);
400
+            $folder->assign('publicUploadEnabled', 'no');
401
+            // default to list view
402
+            $folder->assign('showgridview', false);
403
+            $folder->assign('uploadMaxFilesize', $maxUploadFilesize);
404
+            $folder->assign('uploadMaxHumanFilesize', \OCP\Util::humanFileSize($maxUploadFilesize));
405
+            $folder->assign('freeSpace', $freeSpace);
406
+            $folder->assign('usedSpacePercent', 0);
407
+            $folder->assign('trash', false);
408
+            $shareTmpl['folder'] = $folder->fetchPage();
409
+        } else {
410
+            $shareIsFolder = false;
411
+        }
412
+
413
+        // default to list view
414
+        $shareTmpl['showgridview'] = false;
415
+
416
+        $shareTmpl['hideFileList'] = $hideFileList;
417
+        $shareTmpl['downloadURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', ['token' => $this->getToken()]);
418
+        $shareTmpl['shareUrl'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $this->getToken()]);
419
+        $shareTmpl['maxSizeAnimateGif'] = $this->config->getSystemValue('max_filesize_animated_gifs_public_sharing', 10);
420
+        $shareTmpl['previewEnabled'] = $this->config->getSystemValue('enable_previews', true);
421
+        $shareTmpl['previewMaxX'] = $this->config->getSystemValue('preview_max_x', 1024);
422
+        $shareTmpl['previewMaxY'] = $this->config->getSystemValue('preview_max_y', 1024);
423
+        $shareTmpl['disclaimer'] = $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', null);
424
+        $shareTmpl['previewURL'] = $shareTmpl['downloadURL'];
425
+
426
+        if ($shareTmpl['previewSupported']) {
427
+            $shareTmpl['previewImage'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.PublicPreview.getPreview',
428
+                ['x' => 200, 'y' => 200, 'file' => $shareTmpl['directory_path'], 'token' => $shareTmpl['dirToken']]);
429
+            $ogPreview = $shareTmpl['previewImage'];
430
+
431
+            // We just have direct previews for image files
432
+            if ($shareNode->getMimePart() === 'image') {
433
+                $shareTmpl['previewURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.publicpreview.directLink', ['token' => $this->getToken()]);
434
+
435
+                $ogPreview = $shareTmpl['previewURL'];
436
+
437
+                //Whatapp is kind of picky about their size requirements
438
+                if ($this->request->isUserAgent(['/^WhatsApp/'])) {
439
+                    $ogPreview = $this->urlGenerator->linkToRouteAbsolute('files_sharing.PublicPreview.getPreview', [
440
+                        'token' => $this->getToken(),
441
+                        'x' => 256,
442
+                        'y' => 256,
443
+                        'a' => true,
444
+                    ]);
445
+                }
446
+            }
447
+        } else {
448
+            $shareTmpl['previewImage'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'favicon-fb.png'));
449
+            $ogPreview = $shareTmpl['previewImage'];
450
+        }
451
+
452
+        // Load files we need
453
+        \OCP\Util::addScript('files', 'semaphore');
454
+        \OCP\Util::addScript('files', 'file-upload');
455
+        \OCP\Util::addStyle('files_sharing', 'publicView');
456
+        \OCP\Util::addScript('files_sharing', 'public');
457
+        \OCP\Util::addScript('files_sharing', 'templates');
458
+        \OCP\Util::addScript('files', 'fileactions');
459
+        \OCP\Util::addScript('files', 'fileactionsmenu');
460
+        \OCP\Util::addScript('files', 'jquery.fileupload');
461
+        \OCP\Util::addScript('files_sharing', 'files_drop');
462
+
463
+        if (isset($shareTmpl['folder'])) {
464
+            // JS required for folders
465
+            \OCP\Util::addStyle('files', 'merged');
466
+            \OCP\Util::addScript('files', 'filesummary');
467
+            \OCP\Util::addScript('files', 'templates');
468
+            \OCP\Util::addScript('files', 'breadcrumb');
469
+            \OCP\Util::addScript('files', 'fileinfomodel');
470
+            \OCP\Util::addScript('files', 'newfilemenu');
471
+            \OCP\Util::addScript('files', 'files');
472
+            \OCP\Util::addScript('files', 'filemultiselectmenu');
473
+            \OCP\Util::addScript('files', 'filelist');
474
+            \OCP\Util::addScript('files', 'keyboardshortcuts');
475
+            \OCP\Util::addScript('files', 'operationprogressbar');
476
+
477
+            // Load Viewer scripts
478
+            if (class_exists(LoadViewer::class)) {
479
+                $this->eventDispatcher->dispatchTyped(new LoadViewer());
480
+            }
481
+        }
482
+
483
+        // OpenGraph Support: http://ogp.me/
484
+        \OCP\Util::addHeader('meta', ['property' => "og:title", 'content' => $shareTmpl['filename']]);
485
+        \OCP\Util::addHeader('meta', ['property' => "og:description", 'content' => $this->defaults->getName() . ($this->defaults->getSlogan() !== '' ? ' - ' . $this->defaults->getSlogan() : '')]);
486
+        \OCP\Util::addHeader('meta', ['property' => "og:site_name", 'content' => $this->defaults->getName()]);
487
+        \OCP\Util::addHeader('meta', ['property' => "og:url", 'content' => $shareTmpl['shareUrl']]);
488
+        \OCP\Util::addHeader('meta', ['property' => "og:type", 'content' => "object"]);
489
+        \OCP\Util::addHeader('meta', ['property' => "og:image", 'content' => $ogPreview]);
490
+
491
+        $this->eventDispatcher->dispatchTyped(new BeforeTemplateRenderedEvent($share));
492
+
493
+        $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
494
+        $csp->addAllowedFrameDomain('\'self\'');
495
+
496
+        $response = new PublicTemplateResponse($this->appName, 'public', $shareTmpl);
497
+        $response->setHeaderTitle($shareTmpl['filename']);
498
+        if ($shareTmpl['shareOwner'] !== '') {
499
+            $response->setHeaderDetails($this->l10n->t('shared by %s', [$shareTmpl['shareOwner']]));
500
+        }
501
+
502
+        $isNoneFileDropFolder = $shareIsFolder === false || $share->getPermissions() !== \OCP\Constants::PERMISSION_CREATE;
503
+
504
+        if ($isNoneFileDropFolder && !$share->getHideDownload()) {
505
+            \OCP\Util::addScript('files_sharing', 'public_note');
506
+
507
+            $downloadWhite = new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download-white', $shareTmpl['downloadURL'], 0);
508
+            $downloadAllWhite = new SimpleMenuAction('download', $this->l10n->t('Download all files'), 'icon-download-white', $shareTmpl['downloadURL'], 0);
509
+            $download = new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download', $shareTmpl['downloadURL'], 10, $shareTmpl['fileSize']);
510
+            $downloadAll = new SimpleMenuAction('download', $this->l10n->t('Download all files'), 'icon-download', $shareTmpl['downloadURL'], 10, $shareTmpl['fileSize']);
511
+            $directLink = new LinkMenuAction($this->l10n->t('Direct link'), 'icon-public', $shareTmpl['previewURL']);
512
+            $externalShare = new ExternalShareMenuAction($this->l10n->t('Add to your Nextcloud'), 'icon-external', $shareTmpl['owner'], $shareTmpl['shareOwner'], $shareTmpl['filename']);
513
+
514
+            $responseComposer = [];
515
+
516
+            if ($shareIsFolder) {
517
+                $responseComposer[] = $downloadAllWhite;
518
+                $responseComposer[] = $downloadAll;
519
+            } else {
520
+                $responseComposer[] = $downloadWhite;
521
+                $responseComposer[] = $download;
522
+            }
523
+            $responseComposer[] = $directLink;
524
+            if ($this->federatedShareProvider->isOutgoingServer2serverShareEnabled()) {
525
+                $responseComposer[] = $externalShare;
526
+            }
527
+
528
+            $response->setHeaderActions($responseComposer);
529
+        }
530
+
531
+        $response->setContentSecurityPolicy($csp);
532
+
533
+        $this->emitAccessShareHook($share);
534
+
535
+        return $response;
536
+    }
537
+
538
+    /**
539
+     * @PublicPage
540
+     * @NoCSRFRequired
541
+     * @NoSameSiteCookieRequired
542
+     *
543
+     * @param string $token
544
+     * @param string $files
545
+     * @param string $path
546
+     * @param string $downloadStartSecret
547
+     * @return void|\OCP\AppFramework\Http\Response
548
+     * @throws NotFoundException
549
+     */
550
+    public function downloadShare($token, $files = null, $path = '', $downloadStartSecret = '') {
551
+        \OC_User::setIncognitoMode(true);
552
+
553
+        $share = $this->shareManager->getShareByToken($token);
554
+
555
+        if (!($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) {
556
+            return new \OCP\AppFramework\Http\DataResponse('Share is read-only');
557
+        }
558
+
559
+        $files_list = null;
560
+        if (!is_null($files)) { // download selected files
561
+            $files_list = json_decode($files);
562
+            // in case we get only a single file
563
+            if ($files_list === null) {
564
+                $files_list = [$files];
565
+            }
566
+            // Just in case $files is a single int like '1234'
567
+            if (!is_array($files_list)) {
568
+                $files_list = [$files_list];
569
+            }
570
+        }
571
+
572
+        if (!$this->validateShare($share)) {
573
+            throw new NotFoundException();
574
+        }
575
+
576
+        $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner());
577
+        $originalSharePath = $userFolder->getRelativePath($share->getNode()->getPath());
578
+
579
+
580
+        // Single file share
581
+        if ($share->getNode() instanceof \OCP\Files\File) {
582
+            // Single file download
583
+            $this->singleFileDownloaded($share, $share->getNode());
584
+        }
585
+        // Directory share
586
+        else {
587
+            /** @var \OCP\Files\Folder $node */
588
+            $node = $share->getNode();
589
+
590
+            // Try to get the path
591
+            if ($path !== '') {
592
+                try {
593
+                    $node = $node->get($path);
594
+                } catch (NotFoundException $e) {
595
+                    $this->emitAccessShareHook($share, 404, 'Share not found');
596
+                    return new NotFoundResponse();
597
+                }
598
+            }
599
+
600
+            $originalSharePath = $userFolder->getRelativePath($node->getPath());
601
+
602
+            if ($node instanceof \OCP\Files\File) {
603
+                // Single file download
604
+                $this->singleFileDownloaded($share, $share->getNode());
605
+            } else {
606
+                try {
607
+                    if (!empty($files_list)) {
608
+                        $this->fileListDownloaded($share, $files_list, $node);
609
+                    } else {
610
+                        // The folder is downloaded
611
+                        $this->singleFileDownloaded($share, $share->getNode());
612
+                    }
613
+                } catch (NotFoundException $e) {
614
+                    return new NotFoundResponse();
615
+                }
616
+            }
617
+        }
618
+
619
+        /* FIXME: We should do this all nicely in OCP */
620
+        OC_Util::tearDownFS();
621
+        OC_Util::setupFS($share->getShareOwner());
622
+
623
+        /**
624
+         * this sets a cookie to be able to recognize the start of the download
625
+         * the content must not be longer than 32 characters and must only contain
626
+         * alphanumeric characters
627
+         */
628
+        if (!empty($downloadStartSecret)
629
+            && !isset($downloadStartSecret[32])
630
+            && preg_match('!^[a-zA-Z0-9]+$!', $downloadStartSecret) === 1) {
631
+
632
+            // FIXME: set on the response once we use an actual app framework response
633
+            setcookie('ocDownloadStarted', $downloadStartSecret, time() + 20, '/');
634
+        }
635
+
636
+        $this->emitAccessShareHook($share);
637
+
638
+        $server_params = [ 'head' => $this->request->getMethod() === 'HEAD' ];
639
+
640
+        /**
641
+         * Http range requests support
642
+         */
643
+        if (isset($_SERVER['HTTP_RANGE'])) {
644
+            $server_params['range'] = $this->request->getHeader('Range');
645
+        }
646
+
647
+        // download selected files
648
+        if (!is_null($files) && $files !== '') {
649
+            // FIXME: The exit is required here because otherwise the AppFramework is trying to add headers as well
650
+            // after dispatching the request which results in a "Cannot modify header information" notice.
651
+            OC_Files::get($originalSharePath, $files_list, $server_params);
652
+            exit();
653
+        } else {
654
+            // FIXME: The exit is required here because otherwise the AppFramework is trying to add headers as well
655
+            // after dispatching the request which results in a "Cannot modify header information" notice.
656
+            OC_Files::get(dirname($originalSharePath), basename($originalSharePath), $server_params);
657
+            exit();
658
+        }
659
+    }
660
+
661
+    /**
662
+     * create activity for every downloaded file
663
+     *
664
+     * @param Share\IShare $share
665
+     * @param array $files_list
666
+     * @param \OCP\Files\Folder $node
667
+     * @throws NotFoundException when trying to download a folder or multiple files of a "hide download" share
668
+     */
669
+    protected function fileListDownloaded(Share\IShare $share, array $files_list, \OCP\Files\Folder $node) {
670
+        if ($share->getHideDownload() && count($files_list) > 1) {
671
+            throw new NotFoundException('Downloading more than 1 file');
672
+        }
673
+
674
+        foreach ($files_list as $file) {
675
+            $subNode = $node->get($file);
676
+            $this->singleFileDownloaded($share, $subNode);
677
+        }
678
+    }
679
+
680
+    /**
681
+     * create activity if a single file was downloaded from a link share
682
+     *
683
+     * @param Share\IShare $share
684
+     * @throws NotFoundException when trying to download a folder of a "hide download" share
685
+     */
686
+    protected function singleFileDownloaded(Share\IShare $share, \OCP\Files\Node $node) {
687
+        if ($share->getHideDownload() && $node instanceof Folder) {
688
+            throw new NotFoundException('Downloading a folder');
689
+        }
690
+
691
+        $fileId = $node->getId();
692
+
693
+        $userFolder = $this->rootFolder->getUserFolder($share->getSharedBy());
694
+        $userNodeList = $userFolder->getById($fileId);
695
+        $userNode = $userNodeList[0];
696
+        $ownerFolder = $this->rootFolder->getUserFolder($share->getShareOwner());
697
+        $userPath = $userFolder->getRelativePath($userNode->getPath());
698
+        $ownerPath = $ownerFolder->getRelativePath($node->getPath());
699
+
700
+        $parameters = [$userPath];
701
+
702
+        if ($share->getShareType() === IShare::TYPE_EMAIL) {
703
+            if ($node instanceof \OCP\Files\File) {
704
+                $subject = Downloads::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED;
705
+            } else {
706
+                $subject = Downloads::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED;
707
+            }
708
+            $parameters[] = $share->getSharedWith();
709
+        } else {
710
+            if ($node instanceof \OCP\Files\File) {
711
+                $subject = Downloads::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED;
712
+            } else {
713
+                $subject = Downloads::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED;
714
+            }
715
+        }
716
+
717
+        $this->publishActivity($subject, $parameters, $share->getSharedBy(), $fileId, $userPath);
718
+
719
+        if ($share->getShareOwner() !== $share->getSharedBy()) {
720
+            $parameters[0] = $ownerPath;
721
+            $this->publishActivity($subject, $parameters, $share->getShareOwner(), $fileId, $ownerPath);
722
+        }
723
+    }
724
+
725
+    /**
726
+     * publish activity
727
+     *
728
+     * @param string $subject
729
+     * @param array $parameters
730
+     * @param string $affectedUser
731
+     * @param int $fileId
732
+     * @param string $filePath
733
+     */
734
+    protected function publishActivity($subject,
735
+                                        array $parameters,
736
+                                        $affectedUser,
737
+                                        $fileId,
738
+                                        $filePath) {
739
+        $event = $this->activityManager->generateEvent();
740
+        $event->setApp('files_sharing')
741
+            ->setType('public_links')
742
+            ->setSubject($subject, $parameters)
743
+            ->setAffectedUser($affectedUser)
744
+            ->setObject('files', $fileId, $filePath);
745
+        $this->activityManager->publish($event);
746
+    }
747 747
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Listener/LegacyBeforeTemplateRenderedListener.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -35,25 +35,25 @@
 block discarded – undo
35 35
 
36 36
 class LegacyBeforeTemplateRenderedListener implements IEventListener {
37 37
 
38
-	/** @var SymfonyAdapter */
39
-	private $dispatcher;
38
+    /** @var SymfonyAdapter */
39
+    private $dispatcher;
40 40
 
41
-	public function __construct(SymfonyAdapter $dispatcher) {
42
-		$this->dispatcher = $dispatcher;
43
-	}
41
+    public function __construct(SymfonyAdapter $dispatcher) {
42
+        $this->dispatcher = $dispatcher;
43
+    }
44 44
 
45
-	public function handle(Event $event): void {
46
-		if (!($event instanceof BeforeTemplateRenderedEvent)) {
47
-			return;
48
-		}
45
+    public function handle(Event $event): void {
46
+        if (!($event instanceof BeforeTemplateRenderedEvent)) {
47
+            return;
48
+        }
49 49
 
50
-		$eventName = 'OCA\Files_Sharing::loadAdditionalScripts';
50
+        $eventName = 'OCA\Files_Sharing::loadAdditionalScripts';
51 51
 
52
-		if ($event->getScope() !== null) {
53
-			$eventName .= '::' . $event->getScope();
54
-		}
52
+        if ($event->getScope() !== null) {
53
+            $eventName .= '::' . $event->getScope();
54
+        }
55 55
 
56
-		$legacyEvent = new GenericEvent(null, ['share' => $event->getShare()]);
57
-		$this->dispatcher->dispatch($eventName, $legacyEvent);
58
-	}
56
+        $legacyEvent = new GenericEvent(null, ['share' => $event->getShare()]);
57
+        $this->dispatcher->dispatch($eventName, $legacyEvent);
58
+    }
59 59
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 		$eventName = 'OCA\Files_Sharing::loadAdditionalScripts';
51 51
 
52 52
 		if ($event->getScope() !== null) {
53
-			$eventName .= '::' . $event->getScope();
53
+			$eventName .= '::'.$event->getScope();
54 54
 		}
55 55
 
56 56
 		$legacyEvent = new GenericEvent(null, ['share' => $event->getShare()]);
Please login to merge, or discard this patch.
apps/files_sharing/lib/AppInfo/Application.php 2 patches
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -60,179 +60,179 @@
 block discarded – undo
60 60
 use Symfony\Component\EventDispatcher\GenericEvent;
61 61
 
62 62
 class Application extends App {
63
-	public const APP_ID = 'files_sharing';
64
-
65
-	public function __construct(array $urlParams = []) {
66
-		parent::__construct(self::APP_ID, $urlParams);
67
-
68
-		$container = $this->getContainer();
69
-
70
-		/** @var IServerContainer $server */
71
-		$server = $container->getServer();
72
-
73
-		/** @var IEventDispatcher $dispatcher */
74
-		$dispatcher = $container->query(IEventDispatcher::class);
75
-		$mountProviderCollection = $server->getMountProviderCollection();
76
-		$notifications = $server->getNotificationManager();
77
-
78
-		/**
79
-		 * Core class wrappers
80
-		 */
81
-		$container->registerService(Manager::class, function (SimpleContainer $c) use ($server) {
82
-			$user = $server->getUserSession()->getUser();
83
-			$uid = $user ? $user->getUID() : null;
84
-			return new \OCA\Files_Sharing\External\Manager(
85
-				$server->getDatabaseConnection(),
86
-				\OC\Files\Filesystem::getMountManager(),
87
-				\OC\Files\Filesystem::getLoader(),
88
-				$server->getHTTPClientService(),
89
-				$server->getNotificationManager(),
90
-				$server->query(\OCP\OCS\IDiscoveryService::class),
91
-				$server->getCloudFederationProviderManager(),
92
-				$server->getCloudFederationFactory(),
93
-				$server->getGroupManager(),
94
-				$server->getUserManager(),
95
-				$uid
96
-			);
97
-		});
98
-
99
-		/**
100
-		 * Middleware
101
-		 */
102
-		$container->registerMiddleWare(SharingCheckMiddleware::class);
103
-		$container->registerMiddleWare(OCSShareAPIMiddleware::class);
104
-		$container->registerMiddleWare(ShareInfoMiddleware::class);
105
-
106
-		$container->registerService('ExternalMountProvider', function (IContainer $c) {
107
-			/** @var \OCP\IServerContainer $server */
108
-			$server = $c->query('ServerContainer');
109
-			return new \OCA\Files_Sharing\External\MountProvider(
110
-				$server->getDatabaseConnection(),
111
-				function () use ($c) {
112
-					return $c->query(Manager::class);
113
-				},
114
-				$server->getCloudIdManager()
115
-			);
116
-		});
117
-
118
-		/**
119
-		 * Register capabilities
120
-		 */
121
-		$container->registerCapability(Capabilities::class);
122
-
123
-		$notifications->registerNotifierService(Notifier::class);
124
-
125
-		$this->registerMountProviders($mountProviderCollection);
126
-		$this->registerEventsScripts($dispatcher);
127
-		$this->setupSharingMenus();
128
-
129
-		/**
130
-		 * Always add main sharing script
131
-		 */
132
-		Util::addScript(self::APP_ID, 'dist/main');
133
-	}
134
-
135
-	protected function registerMountProviders(IMountProviderCollection $mountProviderCollection) {
136
-		$mountProviderCollection->registerProvider($this->getContainer()->query(MountProvider::class));
137
-		$mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider'));
138
-	}
139
-
140
-	protected function registerEventsScripts(IEventDispatcher $dispatcher) {
141
-		// sidebar and files scripts
142
-		$dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class);
143
-		$dispatcher->addServiceListener(BeforeTemplateRenderedEvent::class, LegacyBeforeTemplateRenderedListener::class);
144
-		$dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class);
145
-		$dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class);
146
-		$dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () {
147
-			\OCP\Util::addScript('files_sharing', 'dist/collaboration');
148
-		});
149
-		$dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class);
150
-		$dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class);
151
-
152
-		// notifications api to accept incoming user shares
153
-		$dispatcher->addListener('OCP\Share::postShare', function (GenericEvent $event) {
154
-			/** @var Listener $listener */
155
-			$listener = $this->getContainer()->query(Listener::class);
156
-			$listener->shareNotification($event);
157
-		});
158
-		$dispatcher->addListener(IGroup::class . '::postAddUser', function (GenericEvent $event) {
159
-			/** @var Listener $listener */
160
-			$listener = $this->getContainer()->query(Listener::class);
161
-			$listener->userAddedToGroup($event);
162
-		});
163
-	}
164
-
165
-	protected function setupSharingMenus() {
166
-		$config = \OC::$server->getConfig();
167
-
168
-		if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') {
169
-			return;
170
-		}
171
-
172
-		// show_Quick_Access stored as string
173
-		\OCA\Files\App::getNavigationManager()->add(function () {
174
-			$config = \OC::$server->getConfig();
175
-			$l = \OC::$server->getL10N('files_sharing');
176
-
177
-			$sharingSublistArray = [];
178
-
179
-			if (\OCP\Util::isSharingDisabledForUser() === false) {
180
-				$sharingSublistArray[] = [
181
-					'id' => 'sharingout',
182
-					'appname' => 'files_sharing',
183
-					'script' => 'list.php',
184
-					'order' => 16,
185
-					'name' => $l->t('Shared with others'),
186
-				];
187
-			}
188
-
189
-			$sharingSublistArray[] = [
190
-				'id' => 'sharingin',
191
-				'appname' => 'files_sharing',
192
-				'script' => 'list.php',
193
-				'order' => 15,
194
-				'name' => $l->t('Shared with you'),
195
-			];
196
-
197
-			if (\OCP\Util::isSharingDisabledForUser() === false) {
198
-				// Check if sharing by link is enabled
199
-				if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
200
-					$sharingSublistArray[] = [
201
-						'id' => 'sharinglinks',
202
-						'appname' => 'files_sharing',
203
-						'script' => 'list.php',
204
-						'order' => 17,
205
-						'name' => $l->t('Shared by link'),
206
-					];
207
-				}
208
-			}
209
-
210
-			$sharingSublistArray[] = [
211
-				'id' => 'deletedshares',
212
-				'appname' => 'files_sharing',
213
-				'script' => 'list.php',
214
-				'order' => 19,
215
-				'name' => $l->t('Deleted shares'),
216
-			];
217
-
218
-			$sharingSublistArray[] = [
219
-				'id' => 'pendingshares',
220
-				'appname' => 'files_sharing',
221
-				'script' => 'list.php',
222
-				'order' => 19,
223
-				'name' => $l->t('Pending shares'),
224
-			];
225
-
226
-			return [
227
-				'id' => 'shareoverview',
228
-				'appname' => 'files_sharing',
229
-				'script' => 'list.php',
230
-				'order' => 18,
231
-				'name' => $l->t('Shares'),
232
-				'classes' => 'collapsible',
233
-				'sublist' => $sharingSublistArray,
234
-				'expandedState' => 'show_sharing_menu'
235
-			];
236
-		});
237
-	}
63
+    public const APP_ID = 'files_sharing';
64
+
65
+    public function __construct(array $urlParams = []) {
66
+        parent::__construct(self::APP_ID, $urlParams);
67
+
68
+        $container = $this->getContainer();
69
+
70
+        /** @var IServerContainer $server */
71
+        $server = $container->getServer();
72
+
73
+        /** @var IEventDispatcher $dispatcher */
74
+        $dispatcher = $container->query(IEventDispatcher::class);
75
+        $mountProviderCollection = $server->getMountProviderCollection();
76
+        $notifications = $server->getNotificationManager();
77
+
78
+        /**
79
+         * Core class wrappers
80
+         */
81
+        $container->registerService(Manager::class, function (SimpleContainer $c) use ($server) {
82
+            $user = $server->getUserSession()->getUser();
83
+            $uid = $user ? $user->getUID() : null;
84
+            return new \OCA\Files_Sharing\External\Manager(
85
+                $server->getDatabaseConnection(),
86
+                \OC\Files\Filesystem::getMountManager(),
87
+                \OC\Files\Filesystem::getLoader(),
88
+                $server->getHTTPClientService(),
89
+                $server->getNotificationManager(),
90
+                $server->query(\OCP\OCS\IDiscoveryService::class),
91
+                $server->getCloudFederationProviderManager(),
92
+                $server->getCloudFederationFactory(),
93
+                $server->getGroupManager(),
94
+                $server->getUserManager(),
95
+                $uid
96
+            );
97
+        });
98
+
99
+        /**
100
+         * Middleware
101
+         */
102
+        $container->registerMiddleWare(SharingCheckMiddleware::class);
103
+        $container->registerMiddleWare(OCSShareAPIMiddleware::class);
104
+        $container->registerMiddleWare(ShareInfoMiddleware::class);
105
+
106
+        $container->registerService('ExternalMountProvider', function (IContainer $c) {
107
+            /** @var \OCP\IServerContainer $server */
108
+            $server = $c->query('ServerContainer');
109
+            return new \OCA\Files_Sharing\External\MountProvider(
110
+                $server->getDatabaseConnection(),
111
+                function () use ($c) {
112
+                    return $c->query(Manager::class);
113
+                },
114
+                $server->getCloudIdManager()
115
+            );
116
+        });
117
+
118
+        /**
119
+         * Register capabilities
120
+         */
121
+        $container->registerCapability(Capabilities::class);
122
+
123
+        $notifications->registerNotifierService(Notifier::class);
124
+
125
+        $this->registerMountProviders($mountProviderCollection);
126
+        $this->registerEventsScripts($dispatcher);
127
+        $this->setupSharingMenus();
128
+
129
+        /**
130
+         * Always add main sharing script
131
+         */
132
+        Util::addScript(self::APP_ID, 'dist/main');
133
+    }
134
+
135
+    protected function registerMountProviders(IMountProviderCollection $mountProviderCollection) {
136
+        $mountProviderCollection->registerProvider($this->getContainer()->query(MountProvider::class));
137
+        $mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider'));
138
+    }
139
+
140
+    protected function registerEventsScripts(IEventDispatcher $dispatcher) {
141
+        // sidebar and files scripts
142
+        $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class);
143
+        $dispatcher->addServiceListener(BeforeTemplateRenderedEvent::class, LegacyBeforeTemplateRenderedListener::class);
144
+        $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class);
145
+        $dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class);
146
+        $dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () {
147
+            \OCP\Util::addScript('files_sharing', 'dist/collaboration');
148
+        });
149
+        $dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class);
150
+        $dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class);
151
+
152
+        // notifications api to accept incoming user shares
153
+        $dispatcher->addListener('OCP\Share::postShare', function (GenericEvent $event) {
154
+            /** @var Listener $listener */
155
+            $listener = $this->getContainer()->query(Listener::class);
156
+            $listener->shareNotification($event);
157
+        });
158
+        $dispatcher->addListener(IGroup::class . '::postAddUser', function (GenericEvent $event) {
159
+            /** @var Listener $listener */
160
+            $listener = $this->getContainer()->query(Listener::class);
161
+            $listener->userAddedToGroup($event);
162
+        });
163
+    }
164
+
165
+    protected function setupSharingMenus() {
166
+        $config = \OC::$server->getConfig();
167
+
168
+        if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') {
169
+            return;
170
+        }
171
+
172
+        // show_Quick_Access stored as string
173
+        \OCA\Files\App::getNavigationManager()->add(function () {
174
+            $config = \OC::$server->getConfig();
175
+            $l = \OC::$server->getL10N('files_sharing');
176
+
177
+            $sharingSublistArray = [];
178
+
179
+            if (\OCP\Util::isSharingDisabledForUser() === false) {
180
+                $sharingSublistArray[] = [
181
+                    'id' => 'sharingout',
182
+                    'appname' => 'files_sharing',
183
+                    'script' => 'list.php',
184
+                    'order' => 16,
185
+                    'name' => $l->t('Shared with others'),
186
+                ];
187
+            }
188
+
189
+            $sharingSublistArray[] = [
190
+                'id' => 'sharingin',
191
+                'appname' => 'files_sharing',
192
+                'script' => 'list.php',
193
+                'order' => 15,
194
+                'name' => $l->t('Shared with you'),
195
+            ];
196
+
197
+            if (\OCP\Util::isSharingDisabledForUser() === false) {
198
+                // Check if sharing by link is enabled
199
+                if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
200
+                    $sharingSublistArray[] = [
201
+                        'id' => 'sharinglinks',
202
+                        'appname' => 'files_sharing',
203
+                        'script' => 'list.php',
204
+                        'order' => 17,
205
+                        'name' => $l->t('Shared by link'),
206
+                    ];
207
+                }
208
+            }
209
+
210
+            $sharingSublistArray[] = [
211
+                'id' => 'deletedshares',
212
+                'appname' => 'files_sharing',
213
+                'script' => 'list.php',
214
+                'order' => 19,
215
+                'name' => $l->t('Deleted shares'),
216
+            ];
217
+
218
+            $sharingSublistArray[] = [
219
+                'id' => 'pendingshares',
220
+                'appname' => 'files_sharing',
221
+                'script' => 'list.php',
222
+                'order' => 19,
223
+                'name' => $l->t('Pending shares'),
224
+            ];
225
+
226
+            return [
227
+                'id' => 'shareoverview',
228
+                'appname' => 'files_sharing',
229
+                'script' => 'list.php',
230
+                'order' => 18,
231
+                'name' => $l->t('Shares'),
232
+                'classes' => 'collapsible',
233
+                'sublist' => $sharingSublistArray,
234
+                'expandedState' => 'show_sharing_menu'
235
+            ];
236
+        });
237
+    }
238 238
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		/**
79 79
 		 * Core class wrappers
80 80
 		 */
81
-		$container->registerService(Manager::class, function (SimpleContainer $c) use ($server) {
81
+		$container->registerService(Manager::class, function(SimpleContainer $c) use ($server) {
82 82
 			$user = $server->getUserSession()->getUser();
83 83
 			$uid = $user ? $user->getUID() : null;
84 84
 			return new \OCA\Files_Sharing\External\Manager(
@@ -103,12 +103,12 @@  discard block
 block discarded – undo
103 103
 		$container->registerMiddleWare(OCSShareAPIMiddleware::class);
104 104
 		$container->registerMiddleWare(ShareInfoMiddleware::class);
105 105
 
106
-		$container->registerService('ExternalMountProvider', function (IContainer $c) {
106
+		$container->registerService('ExternalMountProvider', function(IContainer $c) {
107 107
 			/** @var \OCP\IServerContainer $server */
108 108
 			$server = $c->query('ServerContainer');
109 109
 			return new \OCA\Files_Sharing\External\MountProvider(
110 110
 				$server->getDatabaseConnection(),
111
-				function () use ($c) {
111
+				function() use ($c) {
112 112
 					return $c->query(Manager::class);
113 113
 				},
114 114
 				$server->getCloudIdManager()
@@ -143,19 +143,19 @@  discard block
 block discarded – undo
143 143
 		$dispatcher->addServiceListener(BeforeTemplateRenderedEvent::class, LegacyBeforeTemplateRenderedListener::class);
144 144
 		$dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class);
145 145
 		$dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class);
146
-		$dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () {
146
+		$dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function() {
147 147
 			\OCP\Util::addScript('files_sharing', 'dist/collaboration');
148 148
 		});
149 149
 		$dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class);
150 150
 		$dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class);
151 151
 
152 152
 		// notifications api to accept incoming user shares
153
-		$dispatcher->addListener('OCP\Share::postShare', function (GenericEvent $event) {
153
+		$dispatcher->addListener('OCP\Share::postShare', function(GenericEvent $event) {
154 154
 			/** @var Listener $listener */
155 155
 			$listener = $this->getContainer()->query(Listener::class);
156 156
 			$listener->shareNotification($event);
157 157
 		});
158
-		$dispatcher->addListener(IGroup::class . '::postAddUser', function (GenericEvent $event) {
158
+		$dispatcher->addListener(IGroup::class.'::postAddUser', function(GenericEvent $event) {
159 159
 			/** @var Listener $listener */
160 160
 			$listener = $this->getContainer()->query(Listener::class);
161 161
 			$listener->userAddedToGroup($event);
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		}
171 171
 
172 172
 		// show_Quick_Access stored as string
173
-		\OCA\Files\App::getNavigationManager()->add(function () {
173
+		\OCA\Files\App::getNavigationManager()->add(function() {
174 174
 			$config = \OC::$server->getConfig();
175 175
 			$l = \OC::$server->getL10N('files_sharing');
176 176
 
Please login to merge, or discard this patch.
apps/files_sharing/lib/Event/BeforeTemplateRenderedEvent.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -30,25 +30,25 @@
 block discarded – undo
30 30
 use OCP\Share\IShare;
31 31
 
32 32
 class BeforeTemplateRenderedEvent extends Event {
33
-	public const SCOPE_PUBLIC_SHARE_AUTH = 'publicShareAuth';
33
+    public const SCOPE_PUBLIC_SHARE_AUTH = 'publicShareAuth';
34 34
 
35
-	/** @var IShare */
36
-	private $share;
37
-	/** @var string|null */
38
-	private $scope;
35
+    /** @var IShare */
36
+    private $share;
37
+    /** @var string|null */
38
+    private $scope;
39 39
 
40
-	public function __construct(IShare $share, ?string $scope = null) {
41
-		parent::__construct();
40
+    public function __construct(IShare $share, ?string $scope = null) {
41
+        parent::__construct();
42 42
 
43
-		$this->share = $share;
44
-		$this->scope = $scope;
45
-	}
43
+        $this->share = $share;
44
+        $this->scope = $scope;
45
+    }
46 46
 
47
-	public function getShare(): IShare {
48
-		return $this->share;
49
-	}
47
+    public function getShare(): IShare {
48
+        return $this->share;
49
+    }
50 50
 
51
-	public function getScope(): ?string {
52
-		return $this->scope;
53
-	}
51
+    public function getScope(): ?string {
52
+        return $this->scope;
53
+    }
54 54
 }
Please login to merge, or discard this patch.
apps/files_sharing/composer/composer/autoload_static.php 1 patch
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -6,91 +6,91 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInitFiles_Sharing
8 8
 {
9
-    public static $prefixLengthsPsr4 = array (
9
+    public static $prefixLengthsPsr4 = array(
10 10
         'O' => 
11
-        array (
11
+        array(
12 12
             'OCA\\Files_Sharing\\' => 18,
13 13
         ),
14 14
     );
15 15
 
16
-    public static $prefixDirsPsr4 = array (
16
+    public static $prefixDirsPsr4 = array(
17 17
         'OCA\\Files_Sharing\\' => 
18
-        array (
19
-            0 => __DIR__ . '/..' . '/../lib',
18
+        array(
19
+            0 => __DIR__.'/..'.'/../lib',
20 20
         ),
21 21
     );
22 22
 
23
-    public static $classMap = array (
24
-        'OCA\\Files_Sharing\\Activity\\Filter' => __DIR__ . '/..' . '/../lib/Activity/Filter.php',
25
-        'OCA\\Files_Sharing\\Activity\\Providers\\Base' => __DIR__ . '/..' . '/../lib/Activity/Providers/Base.php',
26
-        'OCA\\Files_Sharing\\Activity\\Providers\\Downloads' => __DIR__ . '/..' . '/../lib/Activity/Providers/Downloads.php',
27
-        'OCA\\Files_Sharing\\Activity\\Providers\\Groups' => __DIR__ . '/..' . '/../lib/Activity/Providers/Groups.php',
28
-        'OCA\\Files_Sharing\\Activity\\Providers\\PublicLinks' => __DIR__ . '/..' . '/../lib/Activity/Providers/PublicLinks.php',
29
-        'OCA\\Files_Sharing\\Activity\\Providers\\RemoteShares' => __DIR__ . '/..' . '/../lib/Activity/Providers/RemoteShares.php',
30
-        'OCA\\Files_Sharing\\Activity\\Providers\\Users' => __DIR__ . '/..' . '/../lib/Activity/Providers/Users.php',
31
-        'OCA\\Files_Sharing\\Activity\\Settings\\PublicLinks' => __DIR__ . '/..' . '/../lib/Activity/Settings/PublicLinks.php',
32
-        'OCA\\Files_Sharing\\Activity\\Settings\\RemoteShare' => __DIR__ . '/..' . '/../lib/Activity/Settings/RemoteShare.php',
33
-        'OCA\\Files_Sharing\\Activity\\Settings\\Shared' => __DIR__ . '/..' . '/../lib/Activity/Settings/Shared.php',
34
-        'OCA\\Files_Sharing\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
35
-        'OCA\\Files_Sharing\\BackgroundJob\\FederatedSharesDiscoverJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/FederatedSharesDiscoverJob.php',
36
-        'OCA\\Files_Sharing\\Cache' => __DIR__ . '/..' . '/../lib/Cache.php',
37
-        'OCA\\Files_Sharing\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
38
-        'OCA\\Files_Sharing\\Collaboration\\ShareRecipientSorter' => __DIR__ . '/..' . '/../lib/Collaboration/ShareRecipientSorter.php',
39
-        'OCA\\Files_Sharing\\Command\\CleanupRemoteStorages' => __DIR__ . '/..' . '/../lib/Command/CleanupRemoteStorages.php',
40
-        'OCA\\Files_Sharing\\Command\\ExiprationNotification' => __DIR__ . '/..' . '/../lib/Command/ExiprationNotification.php',
41
-        'OCA\\Files_Sharing\\Controller\\AcceptController' => __DIR__ . '/..' . '/../lib/Controller/AcceptController.php',
42
-        'OCA\\Files_Sharing\\Controller\\DeletedShareAPIController' => __DIR__ . '/..' . '/../lib/Controller/DeletedShareAPIController.php',
43
-        'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => __DIR__ . '/..' . '/../lib/Controller/ExternalSharesController.php',
44
-        'OCA\\Files_Sharing\\Controller\\PublicPreviewController' => __DIR__ . '/..' . '/../lib/Controller/PublicPreviewController.php',
45
-        'OCA\\Files_Sharing\\Controller\\RemoteController' => __DIR__ . '/..' . '/../lib/Controller/RemoteController.php',
46
-        'OCA\\Files_Sharing\\Controller\\SettingsController' => __DIR__ . '/..' . '/../lib/Controller/SettingsController.php',
47
-        'OCA\\Files_Sharing\\Controller\\ShareAPIController' => __DIR__ . '/..' . '/../lib/Controller/ShareAPIController.php',
48
-        'OCA\\Files_Sharing\\Controller\\ShareController' => __DIR__ . '/..' . '/../lib/Controller/ShareController.php',
49
-        'OCA\\Files_Sharing\\Controller\\ShareInfoController' => __DIR__ . '/..' . '/../lib/Controller/ShareInfoController.php',
50
-        'OCA\\Files_Sharing\\Controller\\ShareesAPIController' => __DIR__ . '/..' . '/../lib/Controller/ShareesAPIController.php',
51
-        'OCA\\Files_Sharing\\DeleteOrphanedSharesJob' => __DIR__ . '/..' . '/../lib/DeleteOrphanedSharesJob.php',
52
-        'OCA\\Files_Sharing\\Event\\BeforeTemplateRenderedEvent' => __DIR__ . '/..' . '/../lib/Event/BeforeTemplateRenderedEvent.php',
53
-        'OCA\\Files_Sharing\\Exceptions\\BrokenPath' => __DIR__ . '/..' . '/../lib/Exceptions/BrokenPath.php',
54
-        'OCA\\Files_Sharing\\Exceptions\\S2SException' => __DIR__ . '/..' . '/../lib/Exceptions/S2SException.php',
55
-        'OCA\\Files_Sharing\\Exceptions\\SharingRightsException' => __DIR__ . '/..' . '/../lib/Exceptions/SharingRightsException.php',
56
-        'OCA\\Files_Sharing\\ExpireSharesJob' => __DIR__ . '/..' . '/../lib/ExpireSharesJob.php',
57
-        'OCA\\Files_Sharing\\External\\Cache' => __DIR__ . '/..' . '/../lib/External/Cache.php',
58
-        'OCA\\Files_Sharing\\External\\Manager' => __DIR__ . '/..' . '/../lib/External/Manager.php',
59
-        'OCA\\Files_Sharing\\External\\Mount' => __DIR__ . '/..' . '/../lib/External/Mount.php',
60
-        'OCA\\Files_Sharing\\External\\MountProvider' => __DIR__ . '/..' . '/../lib/External/MountProvider.php',
61
-        'OCA\\Files_Sharing\\External\\Scanner' => __DIR__ . '/..' . '/../lib/External/Scanner.php',
62
-        'OCA\\Files_Sharing\\External\\Storage' => __DIR__ . '/..' . '/../lib/External/Storage.php',
63
-        'OCA\\Files_Sharing\\External\\Watcher' => __DIR__ . '/..' . '/../lib/External/Watcher.php',
64
-        'OCA\\Files_Sharing\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php',
65
-        'OCA\\Files_Sharing\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php',
66
-        'OCA\\Files_Sharing\\ISharedStorage' => __DIR__ . '/..' . '/../lib/ISharedStorage.php',
67
-        'OCA\\Files_Sharing\\Listener\\LegacyBeforeTemplateRenderedListener' => __DIR__ . '/..' . '/../lib/Listener/LegacyBeforeTemplateRenderedListener.php',
68
-        'OCA\\Files_Sharing\\Listener\\LoadAdditionalListener' => __DIR__ . '/..' . '/../lib/Listener/LoadAdditionalListener.php',
69
-        'OCA\\Files_Sharing\\Listener\\LoadSidebarListener' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarListener.php',
70
-        'OCA\\Files_Sharing\\Listener\\ShareInteractionListener' => __DIR__ . '/..' . '/../lib/Listener/ShareInteractionListener.php',
71
-        'OCA\\Files_Sharing\\Listener\\UserAddedToGroupListener' => __DIR__ . '/..' . '/../lib/Listener/UserAddedToGroupListener.php',
72
-        'OCA\\Files_Sharing\\Listener\\UserShareAcceptanceListener' => __DIR__ . '/..' . '/../lib/Listener/UserShareAcceptanceListener.php',
73
-        'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/OCSShareAPIMiddleware.php',
74
-        'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/ShareInfoMiddleware.php',
75
-        'OCA\\Files_Sharing\\Middleware\\SharingCheckMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/SharingCheckMiddleware.php',
76
-        'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => __DIR__ . '/..' . '/../lib/Migration/OwncloudGuestShareType.php',
77
-        'OCA\\Files_Sharing\\Migration\\SetAcceptedStatus' => __DIR__ . '/..' . '/../lib/Migration/SetAcceptedStatus.php',
78
-        'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => __DIR__ . '/..' . '/../lib/Migration/SetPasswordColumn.php',
79
-        'OCA\\Files_Sharing\\MountProvider' => __DIR__ . '/..' . '/../lib/MountProvider.php',
80
-        'OCA\\Files_Sharing\\Notification\\Listener' => __DIR__ . '/..' . '/../lib/Notification/Listener.php',
81
-        'OCA\\Files_Sharing\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php',
82
-        'OCA\\Files_Sharing\\Scanner' => __DIR__ . '/..' . '/../lib/Scanner.php',
83
-        'OCA\\Files_Sharing\\Settings\\Personal' => __DIR__ . '/..' . '/../lib/Settings/Personal.php',
84
-        'OCA\\Files_Sharing\\ShareBackend\\File' => __DIR__ . '/..' . '/../lib/ShareBackend/File.php',
85
-        'OCA\\Files_Sharing\\ShareBackend\\Folder' => __DIR__ . '/..' . '/../lib/ShareBackend/Folder.php',
86
-        'OCA\\Files_Sharing\\SharedMount' => __DIR__ . '/..' . '/../lib/SharedMount.php',
87
-        'OCA\\Files_Sharing\\SharedStorage' => __DIR__ . '/..' . '/../lib/SharedStorage.php',
88
-        'OCA\\Files_Sharing\\Updater' => __DIR__ . '/..' . '/../lib/Updater.php',
23
+    public static $classMap = array(
24
+        'OCA\\Files_Sharing\\Activity\\Filter' => __DIR__.'/..'.'/../lib/Activity/Filter.php',
25
+        'OCA\\Files_Sharing\\Activity\\Providers\\Base' => __DIR__.'/..'.'/../lib/Activity/Providers/Base.php',
26
+        'OCA\\Files_Sharing\\Activity\\Providers\\Downloads' => __DIR__.'/..'.'/../lib/Activity/Providers/Downloads.php',
27
+        'OCA\\Files_Sharing\\Activity\\Providers\\Groups' => __DIR__.'/..'.'/../lib/Activity/Providers/Groups.php',
28
+        'OCA\\Files_Sharing\\Activity\\Providers\\PublicLinks' => __DIR__.'/..'.'/../lib/Activity/Providers/PublicLinks.php',
29
+        'OCA\\Files_Sharing\\Activity\\Providers\\RemoteShares' => __DIR__.'/..'.'/../lib/Activity/Providers/RemoteShares.php',
30
+        'OCA\\Files_Sharing\\Activity\\Providers\\Users' => __DIR__.'/..'.'/../lib/Activity/Providers/Users.php',
31
+        'OCA\\Files_Sharing\\Activity\\Settings\\PublicLinks' => __DIR__.'/..'.'/../lib/Activity/Settings/PublicLinks.php',
32
+        'OCA\\Files_Sharing\\Activity\\Settings\\RemoteShare' => __DIR__.'/..'.'/../lib/Activity/Settings/RemoteShare.php',
33
+        'OCA\\Files_Sharing\\Activity\\Settings\\Shared' => __DIR__.'/..'.'/../lib/Activity/Settings/Shared.php',
34
+        'OCA\\Files_Sharing\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php',
35
+        'OCA\\Files_Sharing\\BackgroundJob\\FederatedSharesDiscoverJob' => __DIR__.'/..'.'/../lib/BackgroundJob/FederatedSharesDiscoverJob.php',
36
+        'OCA\\Files_Sharing\\Cache' => __DIR__.'/..'.'/../lib/Cache.php',
37
+        'OCA\\Files_Sharing\\Capabilities' => __DIR__.'/..'.'/../lib/Capabilities.php',
38
+        'OCA\\Files_Sharing\\Collaboration\\ShareRecipientSorter' => __DIR__.'/..'.'/../lib/Collaboration/ShareRecipientSorter.php',
39
+        'OCA\\Files_Sharing\\Command\\CleanupRemoteStorages' => __DIR__.'/..'.'/../lib/Command/CleanupRemoteStorages.php',
40
+        'OCA\\Files_Sharing\\Command\\ExiprationNotification' => __DIR__.'/..'.'/../lib/Command/ExiprationNotification.php',
41
+        'OCA\\Files_Sharing\\Controller\\AcceptController' => __DIR__.'/..'.'/../lib/Controller/AcceptController.php',
42
+        'OCA\\Files_Sharing\\Controller\\DeletedShareAPIController' => __DIR__.'/..'.'/../lib/Controller/DeletedShareAPIController.php',
43
+        'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => __DIR__.'/..'.'/../lib/Controller/ExternalSharesController.php',
44
+        'OCA\\Files_Sharing\\Controller\\PublicPreviewController' => __DIR__.'/..'.'/../lib/Controller/PublicPreviewController.php',
45
+        'OCA\\Files_Sharing\\Controller\\RemoteController' => __DIR__.'/..'.'/../lib/Controller/RemoteController.php',
46
+        'OCA\\Files_Sharing\\Controller\\SettingsController' => __DIR__.'/..'.'/../lib/Controller/SettingsController.php',
47
+        'OCA\\Files_Sharing\\Controller\\ShareAPIController' => __DIR__.'/..'.'/../lib/Controller/ShareAPIController.php',
48
+        'OCA\\Files_Sharing\\Controller\\ShareController' => __DIR__.'/..'.'/../lib/Controller/ShareController.php',
49
+        'OCA\\Files_Sharing\\Controller\\ShareInfoController' => __DIR__.'/..'.'/../lib/Controller/ShareInfoController.php',
50
+        'OCA\\Files_Sharing\\Controller\\ShareesAPIController' => __DIR__.'/..'.'/../lib/Controller/ShareesAPIController.php',
51
+        'OCA\\Files_Sharing\\DeleteOrphanedSharesJob' => __DIR__.'/..'.'/../lib/DeleteOrphanedSharesJob.php',
52
+        'OCA\\Files_Sharing\\Event\\BeforeTemplateRenderedEvent' => __DIR__.'/..'.'/../lib/Event/BeforeTemplateRenderedEvent.php',
53
+        'OCA\\Files_Sharing\\Exceptions\\BrokenPath' => __DIR__.'/..'.'/../lib/Exceptions/BrokenPath.php',
54
+        'OCA\\Files_Sharing\\Exceptions\\S2SException' => __DIR__.'/..'.'/../lib/Exceptions/S2SException.php',
55
+        'OCA\\Files_Sharing\\Exceptions\\SharingRightsException' => __DIR__.'/..'.'/../lib/Exceptions/SharingRightsException.php',
56
+        'OCA\\Files_Sharing\\ExpireSharesJob' => __DIR__.'/..'.'/../lib/ExpireSharesJob.php',
57
+        'OCA\\Files_Sharing\\External\\Cache' => __DIR__.'/..'.'/../lib/External/Cache.php',
58
+        'OCA\\Files_Sharing\\External\\Manager' => __DIR__.'/..'.'/../lib/External/Manager.php',
59
+        'OCA\\Files_Sharing\\External\\Mount' => __DIR__.'/..'.'/../lib/External/Mount.php',
60
+        'OCA\\Files_Sharing\\External\\MountProvider' => __DIR__.'/..'.'/../lib/External/MountProvider.php',
61
+        'OCA\\Files_Sharing\\External\\Scanner' => __DIR__.'/..'.'/../lib/External/Scanner.php',
62
+        'OCA\\Files_Sharing\\External\\Storage' => __DIR__.'/..'.'/../lib/External/Storage.php',
63
+        'OCA\\Files_Sharing\\External\\Watcher' => __DIR__.'/..'.'/../lib/External/Watcher.php',
64
+        'OCA\\Files_Sharing\\Helper' => __DIR__.'/..'.'/../lib/Helper.php',
65
+        'OCA\\Files_Sharing\\Hooks' => __DIR__.'/..'.'/../lib/Hooks.php',
66
+        'OCA\\Files_Sharing\\ISharedStorage' => __DIR__.'/..'.'/../lib/ISharedStorage.php',
67
+        'OCA\\Files_Sharing\\Listener\\LegacyBeforeTemplateRenderedListener' => __DIR__.'/..'.'/../lib/Listener/LegacyBeforeTemplateRenderedListener.php',
68
+        'OCA\\Files_Sharing\\Listener\\LoadAdditionalListener' => __DIR__.'/..'.'/../lib/Listener/LoadAdditionalListener.php',
69
+        'OCA\\Files_Sharing\\Listener\\LoadSidebarListener' => __DIR__.'/..'.'/../lib/Listener/LoadSidebarListener.php',
70
+        'OCA\\Files_Sharing\\Listener\\ShareInteractionListener' => __DIR__.'/..'.'/../lib/Listener/ShareInteractionListener.php',
71
+        'OCA\\Files_Sharing\\Listener\\UserAddedToGroupListener' => __DIR__.'/..'.'/../lib/Listener/UserAddedToGroupListener.php',
72
+        'OCA\\Files_Sharing\\Listener\\UserShareAcceptanceListener' => __DIR__.'/..'.'/../lib/Listener/UserShareAcceptanceListener.php',
73
+        'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => __DIR__.'/..'.'/../lib/Middleware/OCSShareAPIMiddleware.php',
74
+        'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => __DIR__.'/..'.'/../lib/Middleware/ShareInfoMiddleware.php',
75
+        'OCA\\Files_Sharing\\Middleware\\SharingCheckMiddleware' => __DIR__.'/..'.'/../lib/Middleware/SharingCheckMiddleware.php',
76
+        'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => __DIR__.'/..'.'/../lib/Migration/OwncloudGuestShareType.php',
77
+        'OCA\\Files_Sharing\\Migration\\SetAcceptedStatus' => __DIR__.'/..'.'/../lib/Migration/SetAcceptedStatus.php',
78
+        'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => __DIR__.'/..'.'/../lib/Migration/SetPasswordColumn.php',
79
+        'OCA\\Files_Sharing\\MountProvider' => __DIR__.'/..'.'/../lib/MountProvider.php',
80
+        'OCA\\Files_Sharing\\Notification\\Listener' => __DIR__.'/..'.'/../lib/Notification/Listener.php',
81
+        'OCA\\Files_Sharing\\Notification\\Notifier' => __DIR__.'/..'.'/../lib/Notification/Notifier.php',
82
+        'OCA\\Files_Sharing\\Scanner' => __DIR__.'/..'.'/../lib/Scanner.php',
83
+        'OCA\\Files_Sharing\\Settings\\Personal' => __DIR__.'/..'.'/../lib/Settings/Personal.php',
84
+        'OCA\\Files_Sharing\\ShareBackend\\File' => __DIR__.'/..'.'/../lib/ShareBackend/File.php',
85
+        'OCA\\Files_Sharing\\ShareBackend\\Folder' => __DIR__.'/..'.'/../lib/ShareBackend/Folder.php',
86
+        'OCA\\Files_Sharing\\SharedMount' => __DIR__.'/..'.'/../lib/SharedMount.php',
87
+        'OCA\\Files_Sharing\\SharedStorage' => __DIR__.'/..'.'/../lib/SharedStorage.php',
88
+        'OCA\\Files_Sharing\\Updater' => __DIR__.'/..'.'/../lib/Updater.php',
89 89
     );
90 90
 
91 91
     public static function getInitializer(ClassLoader $loader)
92 92
     {
93
-        return \Closure::bind(function () use ($loader) {
93
+        return \Closure::bind(function() use ($loader) {
94 94
             $loader->prefixLengthsPsr4 = ComposerStaticInitFiles_Sharing::$prefixLengthsPsr4;
95 95
             $loader->prefixDirsPsr4 = ComposerStaticInitFiles_Sharing::$prefixDirsPsr4;
96 96
             $loader->classMap = ComposerStaticInitFiles_Sharing::$classMap;
Please login to merge, or discard this patch.
apps/files_sharing/composer/composer/autoload_classmap.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -6,69 +6,69 @@
 block discarded – undo
6 6
 $baseDir = $vendorDir;
7 7
 
8 8
 return array(
9
-    'OCA\\Files_Sharing\\Activity\\Filter' => $baseDir . '/../lib/Activity/Filter.php',
10
-    'OCA\\Files_Sharing\\Activity\\Providers\\Base' => $baseDir . '/../lib/Activity/Providers/Base.php',
11
-    'OCA\\Files_Sharing\\Activity\\Providers\\Downloads' => $baseDir . '/../lib/Activity/Providers/Downloads.php',
12
-    'OCA\\Files_Sharing\\Activity\\Providers\\Groups' => $baseDir . '/../lib/Activity/Providers/Groups.php',
13
-    'OCA\\Files_Sharing\\Activity\\Providers\\PublicLinks' => $baseDir . '/../lib/Activity/Providers/PublicLinks.php',
14
-    'OCA\\Files_Sharing\\Activity\\Providers\\RemoteShares' => $baseDir . '/../lib/Activity/Providers/RemoteShares.php',
15
-    'OCA\\Files_Sharing\\Activity\\Providers\\Users' => $baseDir . '/../lib/Activity/Providers/Users.php',
16
-    'OCA\\Files_Sharing\\Activity\\Settings\\PublicLinks' => $baseDir . '/../lib/Activity/Settings/PublicLinks.php',
17
-    'OCA\\Files_Sharing\\Activity\\Settings\\RemoteShare' => $baseDir . '/../lib/Activity/Settings/RemoteShare.php',
18
-    'OCA\\Files_Sharing\\Activity\\Settings\\Shared' => $baseDir . '/../lib/Activity/Settings/Shared.php',
19
-    'OCA\\Files_Sharing\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
20
-    'OCA\\Files_Sharing\\BackgroundJob\\FederatedSharesDiscoverJob' => $baseDir . '/../lib/BackgroundJob/FederatedSharesDiscoverJob.php',
21
-    'OCA\\Files_Sharing\\Cache' => $baseDir . '/../lib/Cache.php',
22
-    'OCA\\Files_Sharing\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
23
-    'OCA\\Files_Sharing\\Collaboration\\ShareRecipientSorter' => $baseDir . '/../lib/Collaboration/ShareRecipientSorter.php',
24
-    'OCA\\Files_Sharing\\Command\\CleanupRemoteStorages' => $baseDir . '/../lib/Command/CleanupRemoteStorages.php',
25
-    'OCA\\Files_Sharing\\Command\\ExiprationNotification' => $baseDir . '/../lib/Command/ExiprationNotification.php',
26
-    'OCA\\Files_Sharing\\Controller\\AcceptController' => $baseDir . '/../lib/Controller/AcceptController.php',
27
-    'OCA\\Files_Sharing\\Controller\\DeletedShareAPIController' => $baseDir . '/../lib/Controller/DeletedShareAPIController.php',
28
-    'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => $baseDir . '/../lib/Controller/ExternalSharesController.php',
29
-    'OCA\\Files_Sharing\\Controller\\PublicPreviewController' => $baseDir . '/../lib/Controller/PublicPreviewController.php',
30
-    'OCA\\Files_Sharing\\Controller\\RemoteController' => $baseDir . '/../lib/Controller/RemoteController.php',
31
-    'OCA\\Files_Sharing\\Controller\\SettingsController' => $baseDir . '/../lib/Controller/SettingsController.php',
32
-    'OCA\\Files_Sharing\\Controller\\ShareAPIController' => $baseDir . '/../lib/Controller/ShareAPIController.php',
33
-    'OCA\\Files_Sharing\\Controller\\ShareController' => $baseDir . '/../lib/Controller/ShareController.php',
34
-    'OCA\\Files_Sharing\\Controller\\ShareInfoController' => $baseDir . '/../lib/Controller/ShareInfoController.php',
35
-    'OCA\\Files_Sharing\\Controller\\ShareesAPIController' => $baseDir . '/../lib/Controller/ShareesAPIController.php',
36
-    'OCA\\Files_Sharing\\DeleteOrphanedSharesJob' => $baseDir . '/../lib/DeleteOrphanedSharesJob.php',
37
-    'OCA\\Files_Sharing\\Event\\BeforeTemplateRenderedEvent' => $baseDir . '/../lib/Event/BeforeTemplateRenderedEvent.php',
38
-    'OCA\\Files_Sharing\\Exceptions\\BrokenPath' => $baseDir . '/../lib/Exceptions/BrokenPath.php',
39
-    'OCA\\Files_Sharing\\Exceptions\\S2SException' => $baseDir . '/../lib/Exceptions/S2SException.php',
40
-    'OCA\\Files_Sharing\\Exceptions\\SharingRightsException' => $baseDir . '/../lib/Exceptions/SharingRightsException.php',
41
-    'OCA\\Files_Sharing\\ExpireSharesJob' => $baseDir . '/../lib/ExpireSharesJob.php',
42
-    'OCA\\Files_Sharing\\External\\Cache' => $baseDir . '/../lib/External/Cache.php',
43
-    'OCA\\Files_Sharing\\External\\Manager' => $baseDir . '/../lib/External/Manager.php',
44
-    'OCA\\Files_Sharing\\External\\Mount' => $baseDir . '/../lib/External/Mount.php',
45
-    'OCA\\Files_Sharing\\External\\MountProvider' => $baseDir . '/../lib/External/MountProvider.php',
46
-    'OCA\\Files_Sharing\\External\\Scanner' => $baseDir . '/../lib/External/Scanner.php',
47
-    'OCA\\Files_Sharing\\External\\Storage' => $baseDir . '/../lib/External/Storage.php',
48
-    'OCA\\Files_Sharing\\External\\Watcher' => $baseDir . '/../lib/External/Watcher.php',
49
-    'OCA\\Files_Sharing\\Helper' => $baseDir . '/../lib/Helper.php',
50
-    'OCA\\Files_Sharing\\Hooks' => $baseDir . '/../lib/Hooks.php',
51
-    'OCA\\Files_Sharing\\ISharedStorage' => $baseDir . '/../lib/ISharedStorage.php',
52
-    'OCA\\Files_Sharing\\Listener\\LegacyBeforeTemplateRenderedListener' => $baseDir . '/../lib/Listener/LegacyBeforeTemplateRenderedListener.php',
53
-    'OCA\\Files_Sharing\\Listener\\LoadAdditionalListener' => $baseDir . '/../lib/Listener/LoadAdditionalListener.php',
54
-    'OCA\\Files_Sharing\\Listener\\LoadSidebarListener' => $baseDir . '/../lib/Listener/LoadSidebarListener.php',
55
-    'OCA\\Files_Sharing\\Listener\\ShareInteractionListener' => $baseDir . '/../lib/Listener/ShareInteractionListener.php',
56
-    'OCA\\Files_Sharing\\Listener\\UserAddedToGroupListener' => $baseDir . '/../lib/Listener/UserAddedToGroupListener.php',
57
-    'OCA\\Files_Sharing\\Listener\\UserShareAcceptanceListener' => $baseDir . '/../lib/Listener/UserShareAcceptanceListener.php',
58
-    'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => $baseDir . '/../lib/Middleware/OCSShareAPIMiddleware.php',
59
-    'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => $baseDir . '/../lib/Middleware/ShareInfoMiddleware.php',
60
-    'OCA\\Files_Sharing\\Middleware\\SharingCheckMiddleware' => $baseDir . '/../lib/Middleware/SharingCheckMiddleware.php',
61
-    'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => $baseDir . '/../lib/Migration/OwncloudGuestShareType.php',
62
-    'OCA\\Files_Sharing\\Migration\\SetAcceptedStatus' => $baseDir . '/../lib/Migration/SetAcceptedStatus.php',
63
-    'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => $baseDir . '/../lib/Migration/SetPasswordColumn.php',
64
-    'OCA\\Files_Sharing\\MountProvider' => $baseDir . '/../lib/MountProvider.php',
65
-    'OCA\\Files_Sharing\\Notification\\Listener' => $baseDir . '/../lib/Notification/Listener.php',
66
-    'OCA\\Files_Sharing\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php',
67
-    'OCA\\Files_Sharing\\Scanner' => $baseDir . '/../lib/Scanner.php',
68
-    'OCA\\Files_Sharing\\Settings\\Personal' => $baseDir . '/../lib/Settings/Personal.php',
69
-    'OCA\\Files_Sharing\\ShareBackend\\File' => $baseDir . '/../lib/ShareBackend/File.php',
70
-    'OCA\\Files_Sharing\\ShareBackend\\Folder' => $baseDir . '/../lib/ShareBackend/Folder.php',
71
-    'OCA\\Files_Sharing\\SharedMount' => $baseDir . '/../lib/SharedMount.php',
72
-    'OCA\\Files_Sharing\\SharedStorage' => $baseDir . '/../lib/SharedStorage.php',
73
-    'OCA\\Files_Sharing\\Updater' => $baseDir . '/../lib/Updater.php',
9
+    'OCA\\Files_Sharing\\Activity\\Filter' => $baseDir.'/../lib/Activity/Filter.php',
10
+    'OCA\\Files_Sharing\\Activity\\Providers\\Base' => $baseDir.'/../lib/Activity/Providers/Base.php',
11
+    'OCA\\Files_Sharing\\Activity\\Providers\\Downloads' => $baseDir.'/../lib/Activity/Providers/Downloads.php',
12
+    'OCA\\Files_Sharing\\Activity\\Providers\\Groups' => $baseDir.'/../lib/Activity/Providers/Groups.php',
13
+    'OCA\\Files_Sharing\\Activity\\Providers\\PublicLinks' => $baseDir.'/../lib/Activity/Providers/PublicLinks.php',
14
+    'OCA\\Files_Sharing\\Activity\\Providers\\RemoteShares' => $baseDir.'/../lib/Activity/Providers/RemoteShares.php',
15
+    'OCA\\Files_Sharing\\Activity\\Providers\\Users' => $baseDir.'/../lib/Activity/Providers/Users.php',
16
+    'OCA\\Files_Sharing\\Activity\\Settings\\PublicLinks' => $baseDir.'/../lib/Activity/Settings/PublicLinks.php',
17
+    'OCA\\Files_Sharing\\Activity\\Settings\\RemoteShare' => $baseDir.'/../lib/Activity/Settings/RemoteShare.php',
18
+    'OCA\\Files_Sharing\\Activity\\Settings\\Shared' => $baseDir.'/../lib/Activity/Settings/Shared.php',
19
+    'OCA\\Files_Sharing\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php',
20
+    'OCA\\Files_Sharing\\BackgroundJob\\FederatedSharesDiscoverJob' => $baseDir.'/../lib/BackgroundJob/FederatedSharesDiscoverJob.php',
21
+    'OCA\\Files_Sharing\\Cache' => $baseDir.'/../lib/Cache.php',
22
+    'OCA\\Files_Sharing\\Capabilities' => $baseDir.'/../lib/Capabilities.php',
23
+    'OCA\\Files_Sharing\\Collaboration\\ShareRecipientSorter' => $baseDir.'/../lib/Collaboration/ShareRecipientSorter.php',
24
+    'OCA\\Files_Sharing\\Command\\CleanupRemoteStorages' => $baseDir.'/../lib/Command/CleanupRemoteStorages.php',
25
+    'OCA\\Files_Sharing\\Command\\ExiprationNotification' => $baseDir.'/../lib/Command/ExiprationNotification.php',
26
+    'OCA\\Files_Sharing\\Controller\\AcceptController' => $baseDir.'/../lib/Controller/AcceptController.php',
27
+    'OCA\\Files_Sharing\\Controller\\DeletedShareAPIController' => $baseDir.'/../lib/Controller/DeletedShareAPIController.php',
28
+    'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => $baseDir.'/../lib/Controller/ExternalSharesController.php',
29
+    'OCA\\Files_Sharing\\Controller\\PublicPreviewController' => $baseDir.'/../lib/Controller/PublicPreviewController.php',
30
+    'OCA\\Files_Sharing\\Controller\\RemoteController' => $baseDir.'/../lib/Controller/RemoteController.php',
31
+    'OCA\\Files_Sharing\\Controller\\SettingsController' => $baseDir.'/../lib/Controller/SettingsController.php',
32
+    'OCA\\Files_Sharing\\Controller\\ShareAPIController' => $baseDir.'/../lib/Controller/ShareAPIController.php',
33
+    'OCA\\Files_Sharing\\Controller\\ShareController' => $baseDir.'/../lib/Controller/ShareController.php',
34
+    'OCA\\Files_Sharing\\Controller\\ShareInfoController' => $baseDir.'/../lib/Controller/ShareInfoController.php',
35
+    'OCA\\Files_Sharing\\Controller\\ShareesAPIController' => $baseDir.'/../lib/Controller/ShareesAPIController.php',
36
+    'OCA\\Files_Sharing\\DeleteOrphanedSharesJob' => $baseDir.'/../lib/DeleteOrphanedSharesJob.php',
37
+    'OCA\\Files_Sharing\\Event\\BeforeTemplateRenderedEvent' => $baseDir.'/../lib/Event/BeforeTemplateRenderedEvent.php',
38
+    'OCA\\Files_Sharing\\Exceptions\\BrokenPath' => $baseDir.'/../lib/Exceptions/BrokenPath.php',
39
+    'OCA\\Files_Sharing\\Exceptions\\S2SException' => $baseDir.'/../lib/Exceptions/S2SException.php',
40
+    'OCA\\Files_Sharing\\Exceptions\\SharingRightsException' => $baseDir.'/../lib/Exceptions/SharingRightsException.php',
41
+    'OCA\\Files_Sharing\\ExpireSharesJob' => $baseDir.'/../lib/ExpireSharesJob.php',
42
+    'OCA\\Files_Sharing\\External\\Cache' => $baseDir.'/../lib/External/Cache.php',
43
+    'OCA\\Files_Sharing\\External\\Manager' => $baseDir.'/../lib/External/Manager.php',
44
+    'OCA\\Files_Sharing\\External\\Mount' => $baseDir.'/../lib/External/Mount.php',
45
+    'OCA\\Files_Sharing\\External\\MountProvider' => $baseDir.'/../lib/External/MountProvider.php',
46
+    'OCA\\Files_Sharing\\External\\Scanner' => $baseDir.'/../lib/External/Scanner.php',
47
+    'OCA\\Files_Sharing\\External\\Storage' => $baseDir.'/../lib/External/Storage.php',
48
+    'OCA\\Files_Sharing\\External\\Watcher' => $baseDir.'/../lib/External/Watcher.php',
49
+    'OCA\\Files_Sharing\\Helper' => $baseDir.'/../lib/Helper.php',
50
+    'OCA\\Files_Sharing\\Hooks' => $baseDir.'/../lib/Hooks.php',
51
+    'OCA\\Files_Sharing\\ISharedStorage' => $baseDir.'/../lib/ISharedStorage.php',
52
+    'OCA\\Files_Sharing\\Listener\\LegacyBeforeTemplateRenderedListener' => $baseDir.'/../lib/Listener/LegacyBeforeTemplateRenderedListener.php',
53
+    'OCA\\Files_Sharing\\Listener\\LoadAdditionalListener' => $baseDir.'/../lib/Listener/LoadAdditionalListener.php',
54
+    'OCA\\Files_Sharing\\Listener\\LoadSidebarListener' => $baseDir.'/../lib/Listener/LoadSidebarListener.php',
55
+    'OCA\\Files_Sharing\\Listener\\ShareInteractionListener' => $baseDir.'/../lib/Listener/ShareInteractionListener.php',
56
+    'OCA\\Files_Sharing\\Listener\\UserAddedToGroupListener' => $baseDir.'/../lib/Listener/UserAddedToGroupListener.php',
57
+    'OCA\\Files_Sharing\\Listener\\UserShareAcceptanceListener' => $baseDir.'/../lib/Listener/UserShareAcceptanceListener.php',
58
+    'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => $baseDir.'/../lib/Middleware/OCSShareAPIMiddleware.php',
59
+    'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => $baseDir.'/../lib/Middleware/ShareInfoMiddleware.php',
60
+    'OCA\\Files_Sharing\\Middleware\\SharingCheckMiddleware' => $baseDir.'/../lib/Middleware/SharingCheckMiddleware.php',
61
+    'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => $baseDir.'/../lib/Migration/OwncloudGuestShareType.php',
62
+    'OCA\\Files_Sharing\\Migration\\SetAcceptedStatus' => $baseDir.'/../lib/Migration/SetAcceptedStatus.php',
63
+    'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => $baseDir.'/../lib/Migration/SetPasswordColumn.php',
64
+    'OCA\\Files_Sharing\\MountProvider' => $baseDir.'/../lib/MountProvider.php',
65
+    'OCA\\Files_Sharing\\Notification\\Listener' => $baseDir.'/../lib/Notification/Listener.php',
66
+    'OCA\\Files_Sharing\\Notification\\Notifier' => $baseDir.'/../lib/Notification/Notifier.php',
67
+    'OCA\\Files_Sharing\\Scanner' => $baseDir.'/../lib/Scanner.php',
68
+    'OCA\\Files_Sharing\\Settings\\Personal' => $baseDir.'/../lib/Settings/Personal.php',
69
+    'OCA\\Files_Sharing\\ShareBackend\\File' => $baseDir.'/../lib/ShareBackend/File.php',
70
+    'OCA\\Files_Sharing\\ShareBackend\\Folder' => $baseDir.'/../lib/ShareBackend/Folder.php',
71
+    'OCA\\Files_Sharing\\SharedMount' => $baseDir.'/../lib/SharedMount.php',
72
+    'OCA\\Files_Sharing\\SharedStorage' => $baseDir.'/../lib/SharedStorage.php',
73
+    'OCA\\Files_Sharing\\Updater' => $baseDir.'/../lib/Updater.php',
74 74
 );
Please login to merge, or discard this patch.