diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index f1c6b460a9277..2ce883ee2383d 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -53,6 +53,7 @@ use OCP\Files\IAppData; use OCP\Files\Mount\IMountManager; use OCP\RichObjectStrings\IValidator; +use OCP\Share\IShareHelper; use OCP\Util; class DIContainer extends SimpleContainer implements IAppContainer { @@ -363,6 +364,10 @@ public function __construct($appName, $urlParams = array()){ ); }); + $this->registerService(IShareHelper::class, function (SimpleContainer $c) { + return $c->query(IShareHelper::class); + }); + /** * App Framework APIs diff --git a/lib/private/Encryption/File.php b/lib/private/Encryption/File.php index 329fb12b83938..3b6a87ef516bd 100644 --- a/lib/private/Encryption/File.php +++ b/lib/private/Encryption/File.php @@ -101,7 +101,7 @@ public function getAccessList($path) { // Find out who, if anyone, is sharing the file if ($file !== null) { $resultForFile = $this->shareManager->getAccessList($file, false); - $userIds = \array_merge($userIds, $resultForFile['users']); + $userIds = array_merge($userIds, $resultForFile['users']); $public = $resultForFile['public'] || $resultForFile['remote'] || $public; } diff --git a/lib/private/Server.php b/lib/private/Server.php index f4ffd88504498..64935f94ff263 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -89,6 +89,7 @@ use OC\Security\SecureRandom; use OC\Security\TrustedDomainHelper; use OC\Session\CryptoWrapper; +use OC\Share20\ShareHelper; use OC\Tagging\TagMapper; use OCA\Theming\ThemingDefaults; use OCP\Federation\ICloudIdManager; @@ -97,6 +98,7 @@ use OCP\IServerContainer; use OCP\RichObjectStrings\IValidator; use OCP\Security\IContentSecurityPolicyManager; +use OCP\Share\IShareHelper; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -845,6 +847,12 @@ public function __construct($webRoot, \OC\Config $config) { new TimeFactory() ); }); + + $this->registerService(IShareHelper::class, function(Server $c) { + return new ShareHelper( + $c->getLazyRootFolder() + ); + }); } /** diff --git a/lib/public/Share/IManager.php b/lib/public/Share/IManager.php index 45e0e9d80c25b..26c3f2b42e633 100644 --- a/lib/public/Share/IManager.php +++ b/lib/public/Share/IManager.php @@ -216,10 +216,11 @@ public function userDeletedFromGroup($uid, $gid); * * @param \OCP\Files\Node $path * @param bool $recursive Should we check all parent folders as well + * @param bool $currentAccess Should the user have currently access to the file * @return array - * @since 9.2.0 + * @since 12 */ - public function getAccessList(\OCP\Files\Node $path, $recursive = true); + public function getAccessList(\OCP\Files\Node $path, $recursive = true, $currentAccess = false); /** * Instantiates a new share object. This is to be passed to diff --git a/lib/public/Share/IShareHelper.php b/lib/public/Share/IShareHelper.php new file mode 100644 index 0000000000000..5e99f86832d60 --- /dev/null +++ b/lib/public/Share/IShareHelper.php @@ -0,0 +1,44 @@ + + * + * @author Roeland Jago Douma + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +namespace OCP\Share; + +use OCP\Files\Node; + +/** + * Interface IShareHelper + * + * @package OCP\Share + * @since 12 + */ +interface IShareHelper { + + /** + * If a user has access to a file + * + * @param Node $node + * @param array $users Array of userIds + * @return array Mapping $uid to an array of nodes + * @since 12 + */ + public function getPathsForAccessList(Node $node, $users); +}