diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/AppFramework/DependencyInjection/DIContainer.php | 5 | ||||
-rw-r--r-- | lib/private/Encryption/File.php | 2 | ||||
-rw-r--r-- | lib/private/Server.php | 8 | ||||
-rw-r--r-- | lib/public/Share/IManager.php | 5 | ||||
-rw-r--r-- | lib/public/Share/IShareHelper.php | 44 |
5 files changed, 61 insertions, 3 deletions
diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index 4fb13b09ae0..45a971f1257 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -57,6 +57,7 @@ use OCP\IRequest; use OCP\IServerContainer; use OCP\IUserSession; use OCP\RichObjectStrings\IValidator; +use OCP\Share\IShareHelper; use OCP\Util; class DIContainer extends SimpleContainer implements IAppContainer { @@ -169,6 +170,10 @@ class DIContainer extends SimpleContainer implements IAppContainer { ); }); + $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 329fb12b839..3b6a87ef516 100644 --- a/lib/private/Encryption/File.php +++ b/lib/private/Encryption/File.php @@ -101,7 +101,7 @@ class File implements \OCP\Encryption\IFile { // 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 c38675934c3..068c89dd8e2 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -93,6 +93,7 @@ use OC\Security\CredentialsManager; 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\App\IAppManager; @@ -106,6 +107,7 @@ use OCP\IServerContainer; use OCP\ITempManager; use OCP\RichObjectStrings\IValidator; use OCP\Security\IContentSecurityPolicyManager; +use OCP\Share\IShareHelper; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -977,6 +979,12 @@ class Server extends ServerContainer implements IServerContainer { $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { return $c->query(\OCP\IUserSession::class)->getSession(); }); + + $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 45e0e9d80c2..26c3f2b42e6 100644 --- a/lib/public/Share/IManager.php +++ b/lib/public/Share/IManager.php @@ -216,10 +216,11 @@ interface IManager { * * @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 00000000000..5e99f86832d --- /dev/null +++ b/lib/public/Share/IShareHelper.php @@ -0,0 +1,44 @@ +<?php +/** + * @copyright 2017, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ +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); +} |