$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) {
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);
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;
+ }
}
/**