Add support for files inside of shared folders having different names than the source file
This commit is contained in:
parent
73bab46758
commit
010920ad08
|
@ -174,6 +174,18 @@ class OC_SHARE {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the files within a shared folder that have their own entry for the purpose of name, location, or permissions that differ from the folder itself
|
||||
* @param $sourceFolder The source folder of the files to look for
|
||||
* @return array An array of the files if any
|
||||
*/
|
||||
public static function getSharedFilesIn($sourceFolder) {
|
||||
// Append '/' in order to filter out the folder itself
|
||||
$sourceFolder = $sourceFolder."/";
|
||||
$query = OC_DB::prepare("SELECT source, target FROM *PREFIX*sharing WHERE source COLLATE latin1_bin LIKE ? AND uid_shared_with = ?");
|
||||
return $query->execute(array($sourceFolder."%", $_SESSION['user_id']))->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the target location to a new value
|
||||
* @param $oldTarget The current target location
|
||||
|
|
|
@ -74,7 +74,6 @@ class OC_FILESTORAGE_SHARED extends OC_FILESTORAGE {
|
|||
OC_SHARE::unshareFromSelf($target);
|
||||
}
|
||||
|
||||
// TODO Change files within shared folders that are renamed
|
||||
public function opendir($path) {
|
||||
if ($path == "" || $path == "/") {
|
||||
global $FAKEDIRS;
|
||||
|
@ -88,7 +87,28 @@ class OC_FILESTORAGE_SHARED extends OC_FILESTORAGE {
|
|||
$source = $this->getSource($path);
|
||||
if ($source) {
|
||||
$storage = OC_FILESYSTEM::getStorage($source);
|
||||
return $storage->opendir($this->getInternalPath($source));
|
||||
$dh = $storage->opendir($this->getInternalPath($source));
|
||||
$modifiedItems = OC_SHARE::getSharedFilesIn($source);
|
||||
if ($modifiedItems && $dh) {
|
||||
global $FAKEDIRS;
|
||||
$sources = array();
|
||||
$targets = array();
|
||||
foreach ($modifiedItems as $item) {
|
||||
$sources[] = basename($item['source']);
|
||||
$targets[] = basename($item['target']);
|
||||
}
|
||||
while (($filename = readdir($dh)) !== false) {
|
||||
if (!in_array($filename, $sources)) {
|
||||
$files[] = $filename;
|
||||
} else {
|
||||
$files[] = $targets[array_search($filename, $sources)];
|
||||
}
|
||||
}
|
||||
$FAKEDIRS['shared'] = $files;
|
||||
return opendir('fakedir://shared');
|
||||
} else {
|
||||
return $dh;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue