From bcb2e87846407959a1826b3c38d6956d180e3468 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Mon, 22 Apr 2013 14:13:59 +0200 Subject: [PATCH] check if the item source was shared to me to decide if it is a re-share or not. Re-sharing of encrypted files should work now, we might still need to test some corner cases --- apps/files_encryption/hooks/hooks.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index e3861e7cc5a..88ec64b492d 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -193,8 +193,18 @@ class Hooks { $util = new Util($view, $userId); $path = $util->fileIdToPath($params['itemSource']); + //check if this is a reshare action, that's true if the item source is already shared with me + $sharedItem = \OCP\Share::getItemSharedWithBySource($params['itemType'], $params['itemSource']); + if ($sharedItem) { + // if it is a re-share than the file is located in my Shared folder + $path = '/Shared'.$sharedItem['file_target']; + } else { + $path = $util->fileIdToPath($params['itemSource']); + } + $sharingEnabled = \OCP\Share::isEnabled(); + // if a folder was shared, get a list if all (sub-)folders if ($params['itemType'] === 'folder') { $allFiles = $util->getAllFiles($path); } else { @@ -243,12 +253,14 @@ class Hooks { $util = new Util( $view, $userId ); $path = $util->fileIdToPath( $params['itemSource'] ); + // for group shares get a list of the group members if ($params['shareType'] == \OCP\Share::SHARE_TYPE_GROUP) { $userIds = \OC_Group::usersInGroup($params['shareWith']); } else { $userIds = array($params['shareWith']); } + // if we unshare a folder we need a list of all (sub-)files if ($params['itemType'] === 'folder') { $allFiles = $util->getAllFiles($path); } else { -- 2.39.5