]> source.dussan.org Git - nextcloud-server.git/commitdiff
check list of users with access to the file from the bottom to the top. This way...
authorBjörn Schießle <schiessle@owncloud.com>
Wed, 29 May 2013 11:10:26 +0000 (13:10 +0200)
committerFlorin Peter <github@florin-peter.de>
Fri, 31 May 2013 10:24:08 +0000 (12:24 +0200)
apps/files_encryption/lib/util.php
lib/public/share.php

index 5335007a68cba0f6204a7d6f5bd474116e851958..2c99d5d502db2bbd557dc656b041ebd570a6e39b 100644 (file)
@@ -1028,7 +1028,7 @@ class Util {
                if ($sharingEnabled) {
 
                        // Find out who, if anyone, is sharing the file
-                       $result = \OCP\Share::getUsersSharingFile($ownerPath, $owner, true, true, true);
+                       $result = \OCP\Share::getUsersSharingFile($ownerPath, $owner, true);
                        $userIds = $result['users'];
                        if ($result['public']) {
                                $userIds[] = $this->publicShareKeyId;
@@ -1459,7 +1459,7 @@ class Util {
 
                // Find out who, if anyone, is sharing the file
                if ($sharingEnabled) {
-                       $result = \OCP\Share::getUsersSharingFile($file, $this->userId, true, true, true);
+                       $result = \OCP\Share::getUsersSharingFile($file, $this->userId, true);
                        $userIds = $result['users'];
                        $userIds[] = $this->recoveryKeyId;
                        if ($result['public']) {
index d98b2678d6424aa93fa9635135fd9e142beb3e5c..c215df5c8ed7faa2f9f5d933886d86d54f264499 100644 (file)
@@ -134,17 +134,16 @@ class Share {
        * @note $path needs to be relative to user data dir, e.g. 'file.txt'
        *       not '/admin/data/file.txt'
        */
-       public static function getUsersSharingFile($path, $user, $includeOwner = false, $removeDuplicates = true) {
+       public static function getUsersSharingFile($path, $user, $includeOwner = false) {
 
-               $path_parts = explode(DIRECTORY_SEPARATOR, trim($path, DIRECTORY_SEPARATOR));
-               $path = '';
                $shares = array();
                $publicShare = false;
                $view = new \OC\Files\View('/' . $user . '/files/');
-               foreach ($path_parts as $p) {
-                       $path .= '/' . $p;
-                       $meta = $view->getFileInfo(\OC_Filesystem::normalizePath($path));
-                       $source = $meta['fileid'];
+               $meta = $view->getFileInfo(\OC_Filesystem::normalizePath($path));
+               $source = $meta['fileid'];
+               $cache = new \OC\Files\Cache\Cache($meta['storage']);
+               
+               while ($path !== 'files') {
 
                        // Fetch all shares of this file path from DB
                        $query = \OC_DB::prepare(
@@ -204,6 +203,13 @@ class Share {
                        if ($result->fetchRow()) {
                                $publicShare = true;
                        }
+
+                       // let's get the parent for the next round
+                       $meta = $cache->get((int)$source);
+                       $parent = $meta['parent'];
+                       $parentMeta = $cache->get((int)$parent);
+                       $path = $parentMeta['path'];
+                       $source = $parent;
                }
                // Include owner in list of users, if requested
                if ($includeOwner) {