$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
$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
);
}
-
- /**
- * @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