Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>tags/v12.0.0beta1
@@ -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 |
@@ -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; | |||
} | |||
@@ -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() | |||
); | |||
}); | |||
} | |||
/** |
@@ -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 |
@@ -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); | |||
} |