]> source.dussan.org Git - nextcloud-server.git/commitdiff
proper fix for getting the shared item if no user is logged in
authorThomas Müller <thomas.mueller@tmit.eu>
Fri, 5 Jul 2013 11:45:21 +0000 (13:45 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Fri, 5 Jul 2013 11:45:21 +0000 (13:45 +0200)
apps/files/ajax/upload.php
lib/public/share.php

index 733ed95974fed99bd79e2def45871baf64ca9202..54604d105631a51a515822c03213c93023f037fb 100644 (file)
@@ -26,15 +26,18 @@ if (empty($_POST['dirToken'])) {
        if (!($linkItem['permissions'] & OCP\PERMISSION_CREATE)) {
                OCP\JSON::checkLoggedIn();
        } else {
+               // Setup FS with owner
+               OC_Util::tearDownFS();
+               OC_Util::setupFS($linkItem['uid_owner']);
+
                // translate linkItem to the real folder name on the file system
-               $sharedItem = OCP\Share::getItemShared($linkItem['item_type'], $linkItem['item_source']);
+               $sharedItem = OCP\Share::getSharedItem($linkItem['item_type'], $linkItem['item_source'], $linkItem['uid_owner']);
                if (!$sharedItem || empty($sharedItem) || $sharedItem === false) {
                        OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Unable to set upload directory.')))));
                        die();
                }
 
                // The token defines the target directory (security reasons)
-               $sharedItem = array_pop($sharedItem);
                $dir = sprintf(
                        "/%s/%s",
                        $sharedItem['path'],
@@ -45,8 +48,6 @@ if (empty($_POST['dirToken'])) {
                        OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Unable to set upload directory.')))));
                        die();
                }
-               // Setup FS with owner
-               OC_Util::setupFS($linkItem['uid_owner']);
        }
 }
 
index de7025d7b15ad841cf5dfa4517c38dc837452480..28878c2c8683bd74dbb7f5131bbebaa75e3a34ac 100644 (file)
@@ -312,11 +312,22 @@ class Share {
        * @return Return depends on format
        */
        public static function getItemShared($itemType, $itemSource, $format = self::FORMAT_NONE,
-               $parameters = null, $includeCollections = false) {
+                                            $parameters = null, $includeCollections = false) {
                return self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), $format,
                        $parameters, -1, $includeCollections);
        }
 
+       /**
+        * @param $itemType
+        * @param $itemSource
+        * @param $uid_owner
+        * @return mixed
+        */
+       public static function getSharedItem($itemType, $itemSource, $uid_owner) {
+               return self::getItems($itemType, $itemSource, null, null, $uid_owner, self::FORMAT_NONE,
+                       null, 1, false);
+       }
+
        /**
        * Get all users an item is shared with
        * @param string Item type