summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-11-02 23:26:49 +0100
committerLukas Reschke <lukas@statuscode.ch>2016-11-02 23:26:49 +0100
commit6920e609c02814d03a5dc83792de12d05f1da854 (patch)
tree03b2e78c3f5ccd670cd22cd5f4c6390dc867fe73 /lib
parent68cebef64ca38ea93bc1006d667726f42d7f9805 (diff)
downloadnextcloud-server-6920e609c02814d03a5dc83792de12d05f1da854.tar.gz
nextcloud-server-6920e609c02814d03a5dc83792de12d05f1da854.zip
Adjust tests and DI for Share.php
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Share/Share.php24
-rw-r--r--lib/public/Share.php10
2 files changed, 30 insertions, 4 deletions
diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php
index b9accda728c..f6da19f3bb8 100644
--- a/lib/private/Share/Share.php
+++ b/lib/private/Share/Share.php
@@ -45,6 +45,8 @@ namespace OC\Share;
use OC\Files\Filesystem;
use OCA\FederatedFileSharing\DiscoveryManager;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\ILogger;
+use OCP\IUserManager;
use OCP\IUserSession;
use OCP\IDBConnection;
use OCP\IConfig;
@@ -128,19 +130,35 @@ class Share extends Constants {
* Find which users can access a shared item
* @param string $path to the file
* @param string $ownerUser owner of the file
+ * @param IUserManager $userManager
+ * @param ILogger $logger
* @param boolean $includeOwner include owner to the list of users with access to the file
* @param boolean $returnUserPaths Return an array with the user => path map
* @param boolean $recursive take all parent folders into account (default true)
* @return array
* @note $path needs to be relative to user data dir, e.g. 'file.txt'
* not '/admin/data/file.txt'
+ * @throws \OC\User\NoUserException
*/
- public static function getUsersSharingFile($path, $ownerUser, $includeOwner = false, $returnUserPaths = false, $recursive = true) {
- $userManager = \OC::$server->getUserManager();
+ public static function getUsersSharingFile($path,
+ $ownerUser,
+ IUserManager $userManager,
+ ILogger $logger,
+ $includeOwner = false,
+ $returnUserPaths = false,
+ $recursive = true) {
$userObject = $userManager->get($ownerUser);
if (is_null($userObject)) {
- \OCP\Util::writeLog('files', ' Backends provided no user object for ' . $ownerUser, \OCP\Util::ERROR);
+ $logger->error(
+ sprintf(
+ 'Backends provided no user object for %s',
+ $ownerUser
+ ),
+ [
+ 'app' => 'files',
+ ]
+ );
throw new \OC\User\NoUserException('Backends provided no user object');
}
diff --git a/lib/public/Share.php b/lib/public/Share.php
index bc7aa828f62..ec3a7c8db1b 100644
--- a/lib/public/Share.php
+++ b/lib/public/Share.php
@@ -89,7 +89,15 @@ class Share extends \OC\Share\Constants {
* @since 5.0.0 - $recursive was added in 9.0.0
*/
public static function getUsersSharingFile($path, $ownerUser, $includeOwner = false, $returnUserPaths = false, $recursive = true) {
- return \OC\Share\Share::getUsersSharingFile($path, $ownerUser, $includeOwner, $returnUserPaths, $recursive);
+ return \OC\Share\Share::getUsersSharingFile(
+ $path,
+ $ownerUser,
+ \OC::$server->getUserManager(),
+ \OC::$server->getLogger(),
+ $includeOwner,
+ $returnUserPaths,
+ $recursive
+ );
}
/**