]> source.dussan.org Git - nextcloud-server.git/commitdiff
Show users shared with in the drop down for reshared files
authorMichael Gapczynski <GapczynskiM@gmail.com>
Wed, 24 Aug 2011 22:41:36 +0000 (18:41 -0400)
committerMichael Gapczynski <GapczynskiM@gmail.com>
Wed, 24 Aug 2011 22:41:36 +0000 (18:41 -0400)
apps/files_sharing/ajax/getitem.php
apps/files_sharing/ajax/share.php
apps/files_sharing/lib_share.php

index cdb59b9cd1b9ab2a51ad060d401c0383ade21312..249af6cfa31b803c29808cea1bf8399936c4e5c7 100644 (file)
@@ -6,17 +6,18 @@ require_once('../lib_share.php');
 
 $userDirectory = "/".OC_User::getUser()."/files";
 $source = $userDirectory.$_GET['source'];
-$users = OC_Share::getMySharedItem($source);
 $path = $source;
-for ($i = 0; $i < count($users); $i++) {
-       if ($users[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) {
-               $users[$i]['token'] = OC_Share::getTokenFromSource($source);
+if ($users = OC_Share::getMySharedItem($source)) {
+       for ($i = 0; $i < count($users); $i++) {
+               if ($users[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) {
+                       $users[$i]['token'] = OC_Share::getTokenFromSource($source);
+               }
        }
 }
 $source = dirname($source);
 while ($source != "" && $source != "/" && $source != "." && $source != $userDirectory) {
-       $values = array_values(OC_Share::getMySharedItem($source));
-       if (count($values) > 0) {
+       if ($values = OC_Share::getMySharedItem($source)) {
+               $values = array_values($values);
                $parentUsers = array();
                for ($i = 0; $i < count($values); $i++) {
                        if ($values[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) {
index cff0acf3323d12ccf18339fecec70d54f188689e..e672cf0240342e5903205cf52b9a00eb7ec2f672 100644 (file)
@@ -13,11 +13,8 @@ foreach ($sources as $source) {
        if ($source && OC_FILESYSTEM::file_exists($source) && OC_FILESYSTEM::is_readable($source)) {
                $source = $userDirectory.$source;
        // If the file doesn't exist, it may be shared with the current user
-       } else {
-               $source = OC_Share::getSource($userDirectory.$source);
-               if (!$source) {
-                       echo "false";
-               }
+       } else if (!$source = OC_Share::getSource($userDirectory.$source)) {
+               echo "false";
        }
        try {
                $shared = new OC_Share($source, $uid_shared_with, $permissions);
index c862f505e4221a16b1d1e36bb7e0b612c6d38fe2..978847f4a8f8ec3f514b1cd965bbe43ed241866f 100644 (file)
@@ -176,7 +176,14 @@ class OC_Share {
        public static function getMySharedItem($source) {
                $source = self::cleanPath($source);
                $query = OC_DB::prepare("SELECT uid_shared_with, permissions FROM *PREFIX*sharing WHERE source = ? AND uid_owner = ?");
-               return $query->execute(array($source, OC_User::getUser()))->fetchAll();
+               $result = $query->execute(array($source, OC_User::getUser()))->fetchAll();
+               if (count($result) > 0) {
+                       return $result;
+               } else if ($originalSource = self::getSource($source)) {
+                       return $query->execute(array($originalSource, OC_User::getUser()))->fetchAll();
+               } else {
+                       return false;
+               }
        }
 
        /**