summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-04-09 17:51:54 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-04-23 12:54:25 +0200
commit4c840cb61d560ae567e3e9aaa7bd411cac917e48 (patch)
tree845593970f083c0fee8af387faa807873e607850
parented981294f11bd59733e0d121cbf737e16275b666 (diff)
downloadnextcloud-server-4c840cb61d560ae567e3e9aaa7bd411cac917e48.tar.gz
nextcloud-server-4c840cb61d560ae567e3e9aaa7bd411cac917e48.zip
fix target generation for group shares
-rw-r--r--lib/private/share/share.php28
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index 24e2a150640..7af68d1b253 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -1395,8 +1395,8 @@ class Share extends \OC\Share\Constants {
}
}
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`item_type`, `item_source`, `item_target`,'
- .' `parent`, `share_type`, `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`,'
- .' `file_target`, `token`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)');
+ .' `share_type`, `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`,'
+ .' `file_target`, `token`, `parent`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)');
// Share with a group
if ($shareType == self::SHARE_TYPE_GROUP) {
$groupItemTarget = Helper::generateTarget($itemType, $itemSource, $shareType, $shareWith['group'],
@@ -1440,10 +1440,9 @@ class Share extends \OC\Share\Constants {
} else {
$groupFileTarget = null;
}
- $query->execute(array($itemType, $itemSource, $groupItemTarget, $parent, $shareType,
- $shareWith['group'], $uidOwner, $permissions, time(), $fileSource, $groupFileTarget, $token));
- // Save this id, any extra rows for this group share will need to reference it
- $parent = \OC_DB::insertid('*PREFIX*share');
+ $queriesToExecute = array();
+ $queriesToExecute['groupShare'] = array($itemType, $itemSource, $groupItemTarget, $shareType,
+ $shareWith['group'], $uidOwner, $permissions, time(), $fileSource, $groupFileTarget, $token, $parent);
// Loop through all users of this group in case we need to add an extra row
foreach ($shareWith['users'] as $uid) {
$itemTarget = Helper::generateTarget($itemType, $itemSource, self::SHARE_TYPE_USER, $uid,
@@ -1469,12 +1468,21 @@ class Share extends \OC\Share\Constants {
}
// Insert an extra row for the group share if the item or file target is unique for this user
if ($itemTarget != $groupItemTarget || (isset($fileSource) && $fileTarget != $groupFileTarget)) {
- $query->execute(array($itemType, $itemSource, $itemTarget, $parent,
+ $queriesToExecute[] = array($itemType, $itemSource, $itemTarget,
self::$shareTypeGroupUserUnique, $uid, $uidOwner, $permissions, time(),
- $fileSource, $fileTarget, $token));
+ $fileSource, $fileTarget, $token);
$id = \OC_DB::insertid('*PREFIX*share');
}
}
+ $query->execute($queriesToExecute['groupShare']);
+ // Save this id, any extra rows for this group share will need to reference it
+ $parent = \OC_DB::insertid('*PREFIX*share');
+ unset($queriesToExecute['groupShare']);
+ foreach ($queriesToExecute as $qe) {
+ $qe[] = $parent;
+ $query->execute($qe);
+ }
+
\OC_Hook::emit('OCP\Share', 'post_shared', array(
'itemType' => $itemType,
'itemSource' => $itemSource,
@@ -1534,8 +1542,8 @@ class Share extends \OC\Share\Constants {
} else {
$fileTarget = null;
}
- $query->execute(array($itemType, $itemSource, $itemTarget, $parent, $shareType, $shareWith, $uidOwner,
- $permissions, time(), $fileSource, $fileTarget, $token));
+ $query->execute(array($itemType, $itemSource, $itemTarget, $shareType, $shareWith, $uidOwner,
+ $permissions, time(), $fileSource, $fileTarget, $token, $parent));
$id = \OC_DB::insertid('*PREFIX*share');
\OC_Hook::emit('OCP\Share', 'post_shared', array(
'itemType' => $itemType,