diff options
author | Morris Jobke <hey@morrisjobke.de> | 2021-06-16 17:12:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-16 17:12:14 +0200 |
commit | 4c93249514783181115be8bb040de701bffdba10 (patch) | |
tree | 50045595d92b2f71383e0061e6a41c8ff7fba75d /lib | |
parent | cebfe4ba0e834dca11632b1e70c0398030e1ead0 (diff) | |
parent | 47a8d0d5e0c587bed693f5988d764ac6d50d43c4 (diff) | |
download | nextcloud-server-4c93249514783181115be8bb040de701bffdba10.tar.gz nextcloud-server-4c93249514783181115be8bb040de701bffdba10.zip |
Merge pull request #26319 from nextcloud/files_external_app.php
Move files_external to IBootstrap and remove some deprecated stuff in the process
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Encryption/File.php | 11 | ||||
-rw-r--r-- | lib/private/Encryption/Util.php | 28 |
2 files changed, 24 insertions, 15 deletions
diff --git a/lib/private/Encryption/File.php b/lib/private/Encryption/File.php index 76d8900a40e..2c486dfade6 100644 --- a/lib/private/Encryption/File.php +++ b/lib/private/Encryption/File.php @@ -28,6 +28,7 @@ namespace OC\Encryption; use OC\Cache\CappedMemoryCache; +use OCA\Files_External\Service\GlobalStoragesService; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\Share\IManager; @@ -110,10 +111,12 @@ class File implements \OCP\Encryption\IFile { // check if it is a group mount if (\OCP\App::isEnabled("files_external")) { - $mounts = \OCA\Files_External\MountConfig::getSystemMountPoints(); - foreach ($mounts as $mount) { - if ($mount['mountpoint'] == substr($ownerPath, 1, strlen($mount['mountpoint']))) { - $mountedFor = $this->util->getUserWithAccessToMountPoint($mount['applicable']['users'], $mount['applicable']['groups']); + /** @var GlobalStoragesService $storageService */ + $storageService = \OC::$server->get(GlobalStoragesService::class); + $storages = $storageService->getAllStorages(); + foreach ($storages as $storage) { + if ($storage->getMountPoint() == substr($ownerPath, 0, strlen($storage->getMountPoint()))) { + $mountedFor = $this->util->getUserWithAccessToMountPoint($storage->getApplicableUsers(), $storage->getApplicableGroups()); $userIds = array_merge($userIds, $mountedFor); } } diff --git a/lib/private/Encryption/Util.php b/lib/private/Encryption/Util.php index e1f03e2fff1..dc878ba8fc1 100644 --- a/lib/private/Encryption/Util.php +++ b/lib/private/Encryption/Util.php @@ -32,6 +32,8 @@ use OC\Encryption\Exceptions\EncryptionHeaderToLargeException; use OC\Encryption\Exceptions\ModuleDoesNotExistsException; use OC\Files\Filesystem; use OC\Files\View; +use OCA\Files_External\Lib\StorageConfig; +use OCA\Files_External\Service\GlobalStoragesService; use OCP\Encryption\IEncryptionModule; use OCP\IConfig; use OCP\IUser; @@ -265,7 +267,7 @@ class Util { public function getUserWithAccessToMountPoint($users, $groups) { $result = []; - if (in_array('all', $users)) { + if ($users === [] && $groups === []) { $users = $this->userManager->search('', null, null); $result = array_map(function (IUser $user) { return $user->getUID(); @@ -298,10 +300,12 @@ class Util { */ public function isSystemWideMountPoint($path, $uid) { if (\OCP\App::isEnabled("files_external")) { - $mounts = \OCA\Files_External\MountConfig::getSystemMountPoints(); - foreach ($mounts as $mount) { - if (strpos($path, '/files/' . $mount['mountpoint']) === 0) { - if ($this->isMountPointApplicableToUser($mount, $uid)) { + /** @var GlobalStoragesService $storageService */ + $storageService = \OC::$server->get(GlobalStoragesService::class); + $storages = $storageService->getAllStorages(); + foreach ($storages as $storage) { + if (strpos($path, '/files/' . $storage->getMountPoint()) === 0) { + if ($this->isMountPointApplicableToUser($storage, $uid)) { return true; } } @@ -313,19 +317,21 @@ class Util { /** * check if mount point is applicable to user * - * @param array $mount contains $mount['applicable']['users'], $mount['applicable']['groups'] + * @param StorageConfig $mount * @param string $uid * @return boolean */ - private function isMountPointApplicableToUser($mount, $uid) { - $acceptedUids = ['all', $uid]; + private function isMountPointApplicableToUser(StorageConfig $mount, string $uid) { + if ($mount->getApplicableUsers() === [] && $mount->getApplicableGroups() === []) { + // applicable for everyone + return true; + } // check if mount point is applicable for the user - $intersection = array_intersect($acceptedUids, $mount['applicable']['users']); - if (!empty($intersection)) { + if (array_search($uid, $mount->getApplicableUsers()) !== false) { return true; } // check if mount point is applicable for group where the user is a member - foreach ($mount['applicable']['groups'] as $gid) { + foreach ($mount->getApplicableGroups() as $gid) { if ($this->groupManager->isInGroup($uid, $gid)) { return true; } |