]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow specifying the item source in unshareFromSelf().
authorMichael Kuhn <suraia@ikkoku.de>
Sat, 26 Jul 2014 00:00:49 +0000 (02:00 +0200)
committerMichael Kuhn <suraia@ikkoku.de>
Sat, 26 Jul 2014 00:00:49 +0000 (02:00 +0200)
lib/private/share/share.php
lib/public/share.php

index 673c0dc383a4d4e1b592a7a60b48100b466657d0..80389625c61010eb78efade677b283e366b32a82 100644 (file)
@@ -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();
 
index 8566a38c61ef8eb3256e5ff61ec84f0f93340cb2..3a08fd59b7291f99ba0c59f8c4aef9b4f456a723 100644 (file)
@@ -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);
        }
 
        /**