]> source.dussan.org Git - nextcloud-server.git/commitdiff
Merge branch 'master' into type-hinting-sharing
authorBart Visscher <bartv@thisnet.nl>
Mon, 28 Apr 2014 15:59:41 +0000 (17:59 +0200)
committerBart Visscher <bartv@thisnet.nl>
Mon, 28 Apr 2014 15:59:41 +0000 (17:59 +0200)
Conflicts:
apps/files_sharing/lib/share/file.php
apps/files_sharing/tests/api.php
lib/private/share/share.php

1  2 
apps/files_sharing/lib/cache.php
apps/files_sharing/lib/helper.php
apps/files_sharing/lib/share/file.php
lib/private/share/share.php
lib/public/share.php

Simple merge
Simple merge
index c375579b1a23d97c37e669d995da3574d10460fb,c0c9e0c107eda3fd543af9cf3a1ba41a65c042ee..2c59bd3bf9206de8fbab768f5a7979f56d9b406c
@@@ -147,44 -152,49 +152,54 @@@ class OC_Share_Backend_File implements 
        }
  
        /**
-        * @param string $target
+        * @brief resolve reshares to return the correct source item
+        * @param array $source
+        * @return array source item
         */
-       public static function getSource($target) {
-               if ($target == '') {
-                       return false;
+       protected static function resolveReshares($source) {
+               if (isset($source['parent'])) {
+                       $parent = $source['parent'];
+                       while (isset($parent)) {
+                               $query = \OC_DB::prepare('SELECT `parent`, `uid_owner` FROM `*PREFIX*share` WHERE `id` = ?', 1);
+                               $item = $query->execute(array($parent))->fetchRow();
+                               if (isset($item['parent'])) {
+                                       $parent = $item['parent'];
+                               } else {
+                                       $fileOwner = $item['uid_owner'];
+                                       break;
+                               }
+                       }
+               } else {
+                       $fileOwner = $source['uid_owner'];
                }
-               $target = '/'.$target;
-               $target = rtrim($target, '/');
-               $pos = strpos($target, '/', 1);
-               // Get shared folder name
-               if ($pos !== false) {
-                       $folder = substr($target, 0, $pos);
-                       $source = \OCP\Share::getItemSharedWith('folder', $folder, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
-                       if ($source) {
-                               $source['path'] = $source['path'].substr($target, strlen($folder));
+               if (isset($fileOwner)) {
+                       $source['fileOwner'] = $fileOwner;
+               } else {
+                       \OCP\Util::writeLog('files_sharing', "No owner found for reshare", \OCP\Util::ERROR);
+               }
+               return $source;
+       }
++      /**
++       * @param string $target
++       * @param string $mountPoint
++       * @param string $itemType
++       * @return array|false source item
++       */
+       public static function getSource($target, $mountPoint, $itemType) {
 -
+               if ($itemType === 'folder') {
+                       $source = \OCP\Share::getItemSharedWith('folder', $mountPoint, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
+                       if ($source && $target !== '') {
+                               $source['path'] = $source['path'].'/'.$target;
                        }
                } else {
-                       $source = \OCP\Share::getItemSharedWith('file', $target, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
+                       $source = \OCP\Share::getItemSharedWith('file', $mountPoint, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
                }
                if ($source) {
-                       if (isset($source['parent'])) {
-                               $parent = $source['parent'];
-                               while (isset($parent)) {
-                                       $query = \OC_DB::prepare('SELECT `parent`, `uid_owner` FROM `*PREFIX*share` WHERE `id` = ?', 1);
-                                       $item = $query->execute(array($parent))->fetchRow();
-                                       if (isset($item['parent'])) {
-                                               $parent = $item['parent'];
-                                       } else {
-                                               $fileOwner = $item['uid_owner'];
-                                               break;
-                                       }
-                               }
-                       } else {
-                               $fileOwner = $source['uid_owner'];
-                       }
-                       $source['fileOwner'] = $fileOwner;
-                       return $source;
+                       return self::resolveReshares($source);
                }
                \OCP\Util::writeLog('files_sharing', 'File source not found for: '.$target, \OCP\Util::DEBUG);
                return false;
        }
index d9425b793c9e5e7ff4925b120c17272911b12d09,c0ce3a1d8af357e96f7ef3282f105577936bc8ed..21876bba8315c2d56418f540689259f501b1fd36
@@@ -668,14 -751,15 +752,15 @@@ class Share extends \OC\Share\Constant
  
        /**
         * Set the permissions of an item for a specific user or group
 -       * @param string Item type
 -       * @param string Item source
 -       * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
 -       * @param string User or group the item is being shared with
 -       * @param int CRUDS permissions
 -       * @return Returns true on success or false on failure
 +       * @param string $itemType
 +       * @param string $itemSource
 +       * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
 +       * @param string $shareWith User or group the item is being shared with
 +       * @param int $permissions CRUDS permissions
 +       * @return boolean true on success or false on failure
         */
        public static function setPermissions($itemType, $itemSource, $shareType, $shareWith, $permissions) {
+               $l = \OC_L10N::get('lib');
                if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith,
                        \OC_User::getUser(), self::FORMAT_NONE, null, 1, false)) {
                        // Check if this item is a reshare and verify that the permissions
Simple merge