diff options
author | Michael Kuhn <suraia@ikkoku.de> | 2014-07-26 02:00:49 +0200 |
---|---|---|
committer | Michael Kuhn <suraia@ikkoku.de> | 2014-07-26 02:00:49 +0200 |
commit | ecdd04374a4cabdf682e427b59619ef2e42d2997 (patch) | |
tree | ef5187cc0e3f1e017fdea74193842ad6d4c79051 /lib | |
parent | acafb4a4268f2b6a7bce6aa05a056e6cedc62ac7 (diff) | |
download | nextcloud-server-ecdd04374a4cabdf682e427b59619ef2e42d2997.tar.gz nextcloud-server-ecdd04374a4cabdf682e427b59619ef2e42d2997.zip |
Allow specifying the item source in unshareFromSelf().
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/share/share.php | 13 | ||||
-rw-r--r-- | lib/public/share.php | 4 |
2 files changed, 9 insertions, 8 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 673c0dc383a..80389625c61 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -718,23 +718,24 @@ class Share extends \OC\Share\Constants { /** * Unshare an item shared with the current user * @param string $itemType - * @param string $itemTarget + * @param string $itemOrigin Item target or source + * @param boolean $originIsSource true if $itemOrigin is the source, false if $itemOrigin is the target (optional) * @return boolean true on success or false on failure * * Unsharing from self is not allowed for items inside collections */ - public static function unshareFromSelf($itemType, $itemTarget) { - + public static function unshareFromSelf($itemType, $itemOrigin, $originIsSource = false) { + $originType = ($originIsSource) ? 'source' : 'target'; $uid = \OCP\User::getUser(); if ($itemType === 'file' || $itemType === 'folder') { - $statement = 'SELECT * FROM `*PREFIX*share` WHERE `item_type` = ? and `file_target` = ?'; + $statement = 'SELECT * FROM `*PREFIX*share` WHERE `item_type` = ? and `file_' . $originType . '` = ?'; } else { - $statement = 'SELECT * FROM `*PREFIX*share` WHERE `item_type` = ? and `item_target` = ?'; + $statement = 'SELECT * FROM `*PREFIX*share` WHERE `item_type` = ? and `item_' . $originType . '` = ?'; } $query = \OCP\DB::prepare($statement); - $result = $query->execute(array($itemType, $itemTarget)); + $result = $query->execute(array($itemType, $itemOrigin)); $shares = $result->fetchAll(); diff --git a/lib/public/share.php b/lib/public/share.php index 8566a38c61e..3a08fd59b72 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -265,8 +265,8 @@ class Share extends \OC\Share\Constants { * * Unsharing from self is not allowed for items inside collections */ - public static function unshareFromSelf($itemType, $itemTarget) { - return \OC\Share\Share::unshareFromSelf($itemType, $itemTarget); + public static function unshareFromSelf($itemType, $itemOrigin, $originIsSource = false) { + return \OC\Share\Share::unshareFromSelf($itemType, $itemOrigin, $originIsSource); } /** |