summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-01-22 10:40:29 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-01-22 10:40:29 +0100
commitb5b491d1bb12a869ddae7878e8aa441109419a00 (patch)
tree5e5c8eb7e023fdc1c0131b88f91611079815be96 /lib
parent5f3c6a97b2e41fc6255cc602a863805e3dfa3671 (diff)
parent9f137ac25991da89425f6140dc5e078bd0f7d21d (diff)
downloadnextcloud-server-b5b491d1bb12a869ddae7878e8aa441109419a00.tar.gz
nextcloud-server-b5b491d1bb12a869ddae7878e8aa441109419a00.zip
Merge pull request #13509 from owncloud/share-deletechildrenwhenunsharefromgroup
Fix reshare permission change to not impair other deletion code
Diffstat (limited to 'lib')
-rw-r--r--lib/private/share/helper.php27
-rw-r--r--lib/private/share/share.php3
2 files changed, 21 insertions, 9 deletions
diff --git a/lib/private/share/helper.php b/lib/private/share/helper.php
index 5b27f0e6f50..6059af0196d 100644
--- a/lib/private/share/helper.php
+++ b/lib/private/share/helper.php
@@ -79,13 +79,14 @@ class Helper extends \OC\Share\Constants {
}
/**
- * Delete all reshares of an item
+ * Delete all reshares and group share children of an item
* @param int $parent Id of item to delete
* @param bool $excludeParent If true, exclude the parent from the delete (optional)
* @param string $uidOwner The user that the parent was shared with (optional)
* @param int $newParent new parent for the childrens
+ * @param bool $excludeGroupChildren exclude group children elements
*/
- public static function delete($parent, $excludeParent = false, $uidOwner = null, $newParent = null) {
+ public static function delete($parent, $excludeParent = false, $uidOwner = null, $newParent = null, $excludeGroupChildren = false) {
$ids = array($parent);
$deletedItems = array();
$changeParent = array();
@@ -94,15 +95,25 @@ class Helper extends \OC\Share\Constants {
$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
+ $params = array();
if (count($ids) == 1 && isset($uidOwner)) {
- $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` = ? AND `share_type` != ?');
- $result = $query->execute(array($uidOwner, self::$shareTypeGroupUserUnique));
+ // FIXME: don't concat $parents, use Docrine's PARAM_INT_ARRAY approach
+ $queryString = 'SELECT `id`, `share_with`, `item_type`, `share_type`, ' .
+ '`item_target`, `file_target`, `parent` ' .
+ 'FROM `*PREFIX*share` ' .
+ 'WHERE `parent` IN ('.$parents.') AND `uid_owner` = ? ';
+ $params[] = $uidOwner;
} else {
- $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.') AND `share_type` != ?');
- $result = $query->execute(array(self::$shareTypeGroupUserUnique));
+ $queryString = 'SELECT `id`, `share_with`, `item_type`, `share_type`, ' .
+ '`item_target`, `file_target`, `parent`, `uid_owner` ' .
+ 'FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.') ';
}
+ if ($excludeGroupChildren) {
+ $queryString .= ' AND `share_type` != ?';
+ $params[] = self::$shareTypeGroupUserUnique;
+ }
+ $query = \OC_DB::prepare($queryString);
+ $result = $query->execute($params);
// Reset parents array, only go through loop again if items are found
$parents = array();
while ($item = $result->fetchRow()) {
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index e85f9f06ed3..e5f350a24fb 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -971,7 +971,8 @@ class Share extends \OC\Share\Constants {
if ($item['permissions'] & ~$permissions) {
// If share permission is removed all reshares must be deleted
if (($item['permissions'] & \OCP\Constants::PERMISSION_SHARE) && (~$permissions & \OCP\Constants::PERMISSION_SHARE)) {
- Helper::delete($item['id'], true);
+ // delete all shares, keep parent and group children
+ Helper::delete($item['id'], true, null, null, true);
} else {
$ids = array();
$parents = array($item['id']);