|
32 | 32 | use OC\Encryption\Exceptions\ModuleDoesNotExistsException; |
33 | 33 | use OC\Files\Filesystem; |
34 | 34 | use OC\Files\View; |
35 | | -use OCA\Files_External\Lib\StorageConfig; |
36 | | -use OCA\Files_External\Service\GlobalStoragesService; |
37 | | -use OCP\App\IAppManager; |
38 | 35 | use OCP\Encryption\IEncryptionModule; |
| 36 | +use OCP\Files\Mount\ISystemMountPoint; |
39 | 37 | use OCP\IConfig; |
40 | 38 | use OCP\IGroupManager; |
41 | 39 | use OCP\IUser; |
@@ -295,46 +293,9 @@ public function getUserWithAccessToMountPoint($users, $groups) { |
295 | 293 | * @param string $uid |
296 | 294 | * @return boolean |
297 | 295 | */ |
298 | | - public function isSystemWideMountPoint($path, $uid) { |
299 | | - // No DI here as this initialise the db too soon |
300 | | - if (\OCP\Server::get(IAppManager::class)->isEnabledForUser("files_external")) { |
301 | | - /** @var GlobalStoragesService $storageService */ |
302 | | - $storageService = \OC::$server->get(GlobalStoragesService::class); |
303 | | - $storages = $storageService->getAllStorages(); |
304 | | - foreach ($storages as $storage) { |
305 | | - if (strpos($path, '/files/' . ltrim($storage->getMountPoint(), '/')) === 0) { |
306 | | - if ($this->isMountPointApplicableToUser($storage, $uid)) { |
307 | | - return true; |
308 | | - } |
309 | | - } |
310 | | - } |
311 | | - } |
312 | | - return false; |
313 | | - } |
314 | | - |
315 | | - /** |
316 | | - * check if mount point is applicable to user |
317 | | - * |
318 | | - * @param StorageConfig $mount |
319 | | - * @param string $uid |
320 | | - * @return boolean |
321 | | - */ |
322 | | - private function isMountPointApplicableToUser(StorageConfig $mount, string $uid) { |
323 | | - if ($mount->getApplicableUsers() === [] && $mount->getApplicableGroups() === []) { |
324 | | - // applicable for everyone |
325 | | - return true; |
326 | | - } |
327 | | - // check if mount point is applicable for the user |
328 | | - if (array_search($uid, $mount->getApplicableUsers()) !== false) { |
329 | | - return true; |
330 | | - } |
331 | | - // check if mount point is applicable for group where the user is a member |
332 | | - foreach ($mount->getApplicableGroups() as $gid) { |
333 | | - if ($this->groupManager->isInGroup($uid, $gid)) { |
334 | | - return true; |
335 | | - } |
336 | | - } |
337 | | - return false; |
| 296 | + public function isSystemWideMountPoint(string $path, string $uid) { |
| 297 | + $mount = Filesystem::getMountManager()->find('/' . $uid . $path); |
| 298 | + return $mount instanceof ISystemMountPoint; |
338 | 299 | } |
339 | 300 |
|
340 | 301 | /** |
|
0 commit comments