]> source.dussan.org Git - nextcloud-server.git/commitdiff
remove util::getPaths(), this function was broken and is replaced my util::getAllFile...
authorBjörn Schießle <schiessle@owncloud.com>
Mon, 22 Apr 2013 10:22:07 +0000 (12:22 +0200)
committerBjörn Schießle <schiessle@owncloud.com>
Mon, 22 Apr 2013 10:22:07 +0000 (12:22 +0200)
apps/files_encryption/hooks/hooks.php
apps/files_encryption/lib/util.php

index 13cf352b4ed604c84a92839b6976bf8032948649..e3861e7cc5a9797132c0efb2f24d19307aa400f2 100644 (file)
@@ -196,7 +196,6 @@ class Hooks {
                        $sharingEnabled = \OCP\Share::isEnabled();\r
 \r
                        if ($params['itemType'] === 'folder') {\r
-                               //list($owner, $ownerPath) = $util->getUidAndFilename($filePath);\r
                                $allFiles = $util->getAllFiles($path);\r
                        } else {\r
                                $allFiles = array($path);\r
@@ -250,13 +249,21 @@ class Hooks {
                                $userIds = array($params['shareWith']);\r
                        }\r
 \r
-                       // If path is a folder, get all children\r
-                       $allPaths = $util->getPaths( $path );\r
-                       \r
-                       foreach ( $allPaths as $path ) {\r
+                       if ($params['itemType'] === 'folder') {\r
+                               $allFiles = $util->getAllFiles($path);\r
+                       } else {\r
+                               $allFiles = array($path);\r
+                       }\r
+\r
                        \r
-                               // Unshare each child path\r
-                               if ( ! Keymanager::delShareKey( $view, $userIds, $path ) ) {\r
+                       foreach ( $allFiles as $path ) {\r
+\r
+                               // check if the user still has access to the file, otherwise delete share key\r
+                               $sharingUsers = $util->getSharingUsersArray(true, $path);\r
+\r
+                               // Unshare every user who no longer has access to the file\r
+                               $delUsers = array_diff($userIds, $sharingUsers);\r
+                               if ( ! Keymanager::delShareKey( $view, $delUsers, $path ) ) {\r
                                \r
                                        $failed[] = $path;\r
                                        \r
index b3df7f0db03882872c71af8d3eeacd2f4b604f4b..de63e0ff9f4c0ca97116aa328f0105b5a482a35a 100644 (file)
@@ -693,58 +693,7 @@ class Util {
                );
                
        }
-       
-       /**
-        * @brief Expand given path to all sub files & folders
-        * @param string $path path which needs to be updated
-        * @return array $pathsArray all found file paths
-        * @note Paths of directories excluded, only *file* paths are returned
-        */
-       public function getPaths( $path ) {
                
-               // Default return value is success
-               $result = true;
-       
-               // Make path include 'files' dir for OC_FSV operations
-               $fPath = 'files' . $path;
-               
-               // If we're handling a single file
-               if ( ! $this->view->is_dir( $fPath ) ) {
-                       
-                       $pathsArray[] = $path;
-                       
-               // If we're handling a folder (recursively)
-               } else {
-               
-                       $subFiles = $this->view->getDirectoryContent( $fPath );
-                       
-                       foreach ( $subFiles as $file ) {
-                       
-                               $filePath = substr( $file['path'], 5 );
-                               
-                               // If this is a nested file
-                               if ( ! $this->view->is_dir( $fPath ) ) {
-                                       
-                                       // Add the file path to array
-                                       $pathsArray[] = $path;
-                                       
-                               } else {
-                               
-                                       // If this is a nested folder
-                                       $dirPaths = $this->getPaths( $filePath );
-                                       
-                                       // Add all subfiles & folders to the array
-                                       $pathsArray = array_merge( $dirPaths, $pathsArray );
-                                       
-                               }
-                       }
-                       
-               }
-               
-               return $pathsArray;
-
-       }
-       
        /**
         * @brief Decrypt a keyfile without knowing how it was encrypted
         * @param string $filePath