diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-14 11:53:02 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-14 11:53:02 -0400 |
commit | 82dea705d48f192cdeae942753141f3ea7770721 (patch) | |
tree | dacd8c5902412ecd101961518b99c727d341cc8d /lib | |
parent | 0e9ab5cf2a0705124a32d7f66298de72e35d1595 (diff) | |
download | nextcloud-server-82dea705d48f192cdeae942753141f3ea7770721.tar.gz nextcloud-server-82dea705d48f192cdeae942753141f3ea7770721.zip |
Add option to delete() to check the owner of the first search of reshares
Diffstat (limited to 'lib')
-rw-r--r-- | lib/public/share.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/public/share.php b/lib/public/share.php index 445bd52164f..50f2ff1c8a2 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -707,15 +707,22 @@ class Share { /** * @brief Delete all reshares of an item * @param int Id of item to delete - * @param bool If true, exclude the parent from the delete + * @param bool If true, exclude the parent from the delete (optional) + * @param string The user that the parent was shared with (optinal) */ - private static function delete($parent, $excludeParent = false) { + private static function delete($parent, $excludeParent = false, $uidOwner = null) { $ids = array($parent); $parents = array($parent); while (!empty($parents)) { $parents = "'".implode("','", $parents)."'"; - $query = \OC_DB::prepare('SELECT id FROM *PREFIX*share WHERE parent IN ('.$parents.')'); - $result = $query->execute(); + // 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 FROM *PREFIX*share WHERE parent IN ('.$parents.') AND uid_owner = ?'); + $result = $query->execute(array($uidOwner)); + } else { + $query = \OC_DB::prepare('SELECT id FROM *PREFIX*share WHERE parent IN ('.$parents.')'); + $result = $query->execute(); + } // Reset parents array, only go through loop again if items are found $parents = array(); while ($item = $result->fetchRow()) { |