]> source.dussan.org Git - nextcloud-server.git/commitdiff
check if the item source was shared to me to decide if it is a re-share or not. Re...
authorBjörn Schießle <schiessle@owncloud.com>
Mon, 22 Apr 2013 12:13:59 +0000 (14:13 +0200)
committerBjörn Schießle <schiessle@owncloud.com>
Mon, 22 Apr 2013 12:13:59 +0000 (14:13 +0200)
apps/files_encryption/hooks/hooks.php

index e3861e7cc5a9797132c0efb2f24d19307aa400f2..88ec64b492d9bc4f487928eb98c3be1b277bab09 100644 (file)
@@ -193,8 +193,18 @@ class Hooks {
                        $util = new Util($view, $userId);\r
                        $path = $util->fileIdToPath($params['itemSource']);\r
 \r
+                       //check if this is a reshare action, that's true if the item source is already shared with me\r
+                       $sharedItem = \OCP\Share::getItemSharedWithBySource($params['itemType'], $params['itemSource']);\r
+                       if ($sharedItem) {\r
+                               // if it is a re-share than the file is located in my Shared folder\r
+                               $path = '/Shared'.$sharedItem['file_target'];\r
+                       } else {\r
+                               $path = $util->fileIdToPath($params['itemSource']);\r
+                       }\r
+\r
                        $sharingEnabled = \OCP\Share::isEnabled();\r
 \r
+                       // if a folder was shared, get a list if all (sub-)folders\r
                        if ($params['itemType'] === 'folder') {\r
                                $allFiles = $util->getAllFiles($path);\r
                        } else {\r
@@ -243,12 +253,14 @@ class Hooks {
                        $util = new Util( $view, $userId );\r
                        $path = $util->fileIdToPath( $params['itemSource'] );\r
 \r
+                       // for group shares get a list of the group members\r
                        if ($params['shareType'] == \OCP\Share::SHARE_TYPE_GROUP) {\r
                                $userIds = \OC_Group::usersInGroup($params['shareWith']);\r
                        } else {\r
                                $userIds = array($params['shareWith']);\r
                        }\r
 \r
+                       // if we unshare a folder we need a list of all (sub-)files\r
                        if ($params['itemType'] === 'folder') {\r
                                $allFiles = $util->getAllFiles($path);\r
                        } else {\r