summaryrefslogtreecommitdiffstats
path: root/lib/private/share/hooks.php
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-08-27 00:30:13 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-09-24 14:02:01 +0200
commit9f7b15582ac11a7f6706cfb0c20b1a9e508ee217 (patch)
tree4cf7d50a63270d01d1c4f769c2cbdf77f7600b5d /lib/private/share/hooks.php
parentbd268c35f523dc861f315fc476f2416eaa605b5e (diff)
downloadnextcloud-server-9f7b15582ac11a7f6706cfb0c20b1a9e508ee217.tar.gz
nextcloud-server-9f7b15582ac11a7f6706cfb0c20b1a9e508ee217.zip
fix add user to group to work with grouped shares
Diffstat (limited to 'lib/private/share/hooks.php')
-rw-r--r--lib/private/share/hooks.php28
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'],