diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2014-08-27 02:30:13 +0400 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2014-10-01 17:13:47 +0400 |
commit | df97d8299ad4d96d53807b871c6197e53d652e67 (patch) | |
tree | 7ce550fd78a2e9e03fb13a2b06c850866264dc1f /lib/private/share | |
parent | 97dba2e022aa1d2431b97efa01ec158bf3979040 (diff) |
fix add user to group to work with grouped shares
Diffstat (limited to 'lib/private/share')
-rw-r--r-- | lib/private/share/hooks.php | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/private/share/hooks.php b/lib/private/share/hooks.php index 9ac64d888ea..2be7dc85e3c 100644 --- a/lib/private/share/hooks.php +++ b/lib/private/share/hooks.php @@ -45,6 +45,7 @@ class Hooks extends \OC\Share\Constants { * @param array $arguments */ public static function post_addToGroup($arguments) { + // Find the group shares and check if the user needs a unique target $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `share_type` = ? AND `share_with` = ?'); $result = $query->execute(array(self::SHARE_TYPE_GROUP, $arguments['gid'])); @@ -52,18 +53,25 @@ class Hooks extends \OC\Share\Constants { .' `item_target`, `parent`, `share_type`, `share_with`, `uid_owner`, `permissions`,' .' `stime`, `file_source`, `file_target`) VALUES (?,?,?,?,?,?,?,?,?,?,?)'); while ($item = $result->fetchRow()) { - if ($item['item_type'] == 'file' || $item['item_type'] == 'file') { - $itemTarget = null; - } else { - $itemTarget = Helper::generateTarget($item['item_type'], $item['item_source'], self::SHARE_TYPE_USER, - $arguments['uid'], $item['uid_owner'], $item['item_target'], $item['id']); - } - if (isset($item['file_source'])) { - $fileTarget = Helper::generateTarget($item['item_type'], $item['item_source'], self::SHARE_TYPE_USER, - $arguments['uid'], $item['uid_owner'], $item['file_target'], $item['id']); + + $sourceExists = \OC\Share\Share::getItemSharedWithBySource($item['item_type'], $item['item_source'], self::FORMAT_NONE, null, true, $arguments['uid']); + + if ($sourceExists) { + $fileTarget = $sourceExists['file_target']; + $itemTarget = $sourceExists['item_target']; } else { - $fileTarget = null; + $itemTarget = Helper::generateTarget($item['item_type'], $item['item_source'], self::SHARE_TYPE_USER, $arguments['uid'], + $item['owner'], null, $item['parent']); + + // do we also need a file target + if ($item['item_type'] === 'file' || $item['item_type'] === 'folder') { + $fileTarget = Helper::generateTarget('file', $row['file_target'], self::SHARE_TYPE_USER, $arguments['uid'], + $item['owner'], null, $item['parent']); + } else { + $fileTarget = null; + } } + // Insert an extra row for the group share if the item or file target is unique for this user if ($itemTarget != $item['item_target'] || $fileTarget != $item['file_target']) { $query->execute(array($item['item_type'], $item['item_source'], $itemTarget, $item['id'], |