diff options
author | Björn Schießle <schiessle@owncloud.com> | 2014-06-26 10:26:24 +0200 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2014-06-26 10:26:24 +0200 |
commit | 1822bba5e941862323117e2625361098ce729155 (patch) | |
tree | 02b92b819e18f569f0ec209482ff3a0f5d4fd1f3 /lib/private | |
parent | a5154450cf81878498e65bdff0fefb144fc27cf4 (diff) | |
parent | 38ff8173ab752a422a398be92b2050847154363b (diff) | |
download | nextcloud-server-1822bba5e941862323117e2625361098ce729155.tar.gz nextcloud-server-1822bba5e941862323117e2625361098ce729155.zip |
Merge pull request #9193 from owncloud/sharing_etag_propagation
make sure that the etags get propagated correctly
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/share/helper.php | 22 | ||||
-rw-r--r-- | lib/private/share/share.php | 60 |
2 files changed, 70 insertions, 12 deletions
diff --git a/lib/private/share/helper.php b/lib/private/share/helper.php index 71c6d8517a9..46e3c280488 100644 --- a/lib/private/share/helper.php +++ b/lib/private/share/helper.php @@ -149,17 +149,18 @@ class Helper extends \OC\Share\Constants { */ public static function delete($parent, $excludeParent = false, $uidOwner = null) { $ids = array($parent); + $deletedItems = array(); $parents = array($parent); while (!empty($parents)) { $parents = "'".implode("','", $parents)."'"; // Check the owner on the first search of reshares, useful for // finding and deleting the reshares by a single user of a group share if (count($ids) == 1 && isset($uidOwner)) { - $query = \OC_DB::prepare('SELECT `id`, `uid_owner`, `item_type`, `item_target`, `parent`' + $query = \OC_DB::prepare('SELECT `id`, `share_with`, `item_type`, `share_type`, `item_target`, `file_target`, `parent`' .' FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.') AND `uid_owner` = ?'); $result = $query->execute(array($uidOwner)); } else { - $query = \OC_DB::prepare('SELECT `id`, `item_type`, `item_target`, `parent`, `uid_owner`' + $query = \OC_DB::prepare('SELECT `id`, `share_with`, `item_type`, `share_type`, `item_target`, `file_target`, `parent`, `uid_owner`' .' FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.')'); $result = $query->execute(); } @@ -168,16 +169,29 @@ class Helper extends \OC\Share\Constants { while ($item = $result->fetchRow()) { $ids[] = $item['id']; $parents[] = $item['id']; + $tmpItem = array( + 'id' => $item['id'], + 'shareWith' => $item['share_with'], + 'itemTarget' => $item['item_target'], + 'itemType' => $item['item_type'], + 'shareType' => (int)$item['share_type'], + ); + if (isset($item['file_target'])) { + $tmpItem['fileTarget'] = $item['file_target']; + } + $deletedItems[] = $tmpItem; } } if ($excludeParent) { unset($ids[0]); } if (!empty($ids)) { - $ids = "'".implode("','", $ids)."'"; - $query = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `id` IN ('.$ids.')'); + $idList = "'".implode("','", $ids)."'"; + $query = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `id` IN ('.$idList.')'); $query->execute(); } + + return $deletedItems; } /** diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 26108a937ce..c06ea72c348 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -738,11 +738,24 @@ class Share extends \OC\Share\Constants { $shares = $result->fetchAll(); + $listOfUnsharedItems = array(); + $itemUnshared = false; foreach ($shares as $share) { if ((int)$share['share_type'] === \OCP\Share::SHARE_TYPE_USER && $share['share_with'] === $uid) { - Helper::delete($share['id']); + $deletedShares = Helper::delete($share['id']); + $shareTmp = array( + 'id' => $share['id'], + 'shareWith' => $share['share_with'], + 'itemTarget' => $share['item_target'], + 'itemType' => $share['item_type'], + 'shareType' => (int)$share['share_type'], + ); + if (isset($share['file_target'])) { + $shareTmp['fileTarget'] = $share['file_target']; + } + $listOfUnsharedItems = array_merge($listOfUnsharedItems, $deletedShares, array($shareTmp)); $itemUnshared = true; break; } elseif ((int)$share['share_type'] === \OCP\Share::SHARE_TYPE_GROUP) { @@ -764,13 +777,40 @@ class Share extends \OC\Share\Constants { $groupShare['id'], self::$shareTypeGroupUserUnique, \OC_User::getUser(), $groupShare['uid_owner'], 0, $groupShare['stime'], $groupShare['file_source'], $groupShare['file_target'])); + $shareTmp = array( + 'id' => $groupShare['id'], + 'shareWith' => $groupShare['share_with'], + 'itemTarget' => $groupShare['item_target'], + 'itemType' => $groupShare['item_type'], + 'shareType' => (int)$groupShare['share_type'], + ); + if (isset($groupShare['file_target'])) { + $shareTmp['fileTarget'] = $groupShare['file_target']; + } + $listOfUnsharedItems = array_merge($listOfUnsharedItems, array($groupShare)); $itemUnshared = true; } elseif (!$itemUnshared && isset($uniqueGroupShare)) { $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `permissions` = ? WHERE `id` = ?'); $query->execute(array(0, $uniqueGroupShare['id'])); + $shareTmp = array( + 'id' => $uniqueGroupShare['id'], + 'shareWith' => $uniqueGroupShare['share_with'], + 'itemTarget' => $uniqueGroupShare['item_target'], + 'itemType' => $uniqueGroupShare['item_type'], + 'shareType' => (int)$uniqueGroupShare['share_type'], + ); + if (isset($uniqueGroupShare['file_target'])) { + $shareTmp['fileTarget'] = $uniqueGroupShare['file_target']; + } + $listOfUnsharedItems = array_merge($listOfUnsharedItems, array($uniqueGroupShare)); $itemUnshared = true; } + if ($itemUnshared) { + \OC_Hook::emit('OCP\Share', 'post_unshareFromSelf', + array('unsharedItems' => $listOfUnsharedItems, 'itemType' => $itemType)); + } + return $itemUnshared; } @@ -967,19 +1007,23 @@ class Share extends \OC\Share\Constants { protected static function unshareItem(array $item) { // Pass all the vars we have for now, they may be useful $hookParams = array( + 'id' => $item['id'], 'itemType' => $item['item_type'], 'itemSource' => $item['item_source'], - 'fileSource' => $item['file_source'], - 'shareType' => $item['share_type'], + 'shareType' => (int)$item['share_type'], 'shareWith' => $item['share_with'], 'itemParent' => $item['parent'], 'uidOwner' => $item['uid_owner'], ); + if($item['item_type'] === 'file' || $item['item_type'] === 'folder') { + $hookParams['fileSource'] = $item['file_source']; + $hookParams['fileTarget'] = $item['file_target']; + } - \OC_Hook::emit('OCP\Share', 'pre_unshare', $hookParams + array( - 'fileSource' => $item['file_source'], - )); - Helper::delete($item['id']); + \OC_Hook::emit('OCP\Share', 'pre_unshare', $hookParams); + $deletedShares = Helper::delete($item['id']); + $deletedShares[] = $hookParams; + $hookParams['deletedShares'] = $deletedShares; \OC_Hook::emit('OCP\Share', 'post_unshare', $hookParams); } @@ -1788,7 +1832,7 @@ class Share extends \OC\Share\Constants { if (isset($uidOwner)) { if ($fileDependent) { $select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `*PREFIX*share`.`parent`,' - . ' `share_type`, `share_with`, `file_source`, `path`, `*PREFIX*share`.`permissions`, `stime`,' + . ' `share_type`, `share_with`, `file_source`, `file_target`, `path`, `*PREFIX*share`.`permissions`, `stime`,' . ' `expiration`, `token`, `storage`, `mail_send`, `uid_owner`'; } else { $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `*PREFIX*share`.`permissions`,' |