From 8c8490b28eb0d6ce5b0405e620eb9a9660f8c542 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Wed, 24 Aug 2011 18:41:36 -0400 Subject: [PATCH] Show users shared with in the drop down for reshared files --- apps/files_sharing/ajax/getitem.php | 13 +++++++------ apps/files_sharing/ajax/share.php | 7 ++----- apps/files_sharing/lib_share.php | 9 ++++++++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/apps/files_sharing/ajax/getitem.php b/apps/files_sharing/ajax/getitem.php index cdb59b9cd1b..249af6cfa31 100644 --- a/apps/files_sharing/ajax/getitem.php +++ b/apps/files_sharing/ajax/getitem.php @@ -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) { diff --git a/apps/files_sharing/ajax/share.php b/apps/files_sharing/ajax/share.php index cff0acf3323..e672cf02403 100644 --- a/apps/files_sharing/ajax/share.php +++ b/apps/files_sharing/ajax/share.php @@ -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); diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php index c862f505e42..978847f4a8f 100644 --- a/apps/files_sharing/lib_share.php +++ b/apps/files_sharing/lib_share.php @@ -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; + } } /** -- 2.39.5