[Pkg-owncloud-commits] [owncloud] 158/258: fix add user to group to work with grouped shares
David Prévot
taffit at moszumanska.debian.org
Sat Oct 11 17:22:31 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit df97d8299ad4d96d53807b871c6197e53d652e67
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date: Wed Aug 27 00:30:13 2014 +0200
fix add user to group to work with grouped shares
---
lib/private/share/hooks.php | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/lib/private/share/hooks.php b/lib/private/share/hooks.php
index 9ac64d8..2be7dc8 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'],
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list