diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-10 18:56:22 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-10 18:56:22 -0400 |
commit | 7c908a0016db30c70271304c4d080383911645e3 (patch) | |
tree | cc14759d9476d18310901acb9e48ef7445cb3c8a /lib/files.php | |
parent | 1ad5e3e39f7e1c6d8279cf8e06781a8e6512b9fe (diff) | |
download | nextcloud-server-7c908a0016db30c70271304c4d080383911645e3.tar.gz nextcloud-server-7c908a0016db30c70271304c4d080383911645e3.zip |
Sharing files working using share API
Diffstat (limited to 'lib/files.php')
-rw-r--r-- | lib/files.php | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/lib/files.php b/lib/files.php index 2feae20afe6..4f58ff6782d 100644 --- a/lib/files.php +++ b/lib/files.php @@ -33,15 +33,30 @@ class OC_Files { * @param dir $directory path under datadirectory */ public static function getDirectoryContent($directory, $mimetype_filter = ''){ - $files=OC_FileCache::getFolderContent($directory, false, $mimetype_filter); - if ($directory == '') { - $files = array_merge($files, array()); - } else if (substr($directory, 7) == '/Shared') { - $files = array_merge($files, OCP\Share::getItemsSharedWith('file', $directory, OC_Share_Backend_File::FORMAT_FILE_APP)); + $files = array(); + if (substr($directory, 0, 7) == '/Shared') { + if ($directory == '/Shared') { + $files = OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP, array('mimetype_filter' => $mimetype_filter)); + } else { + $pos = strpos($directory, '/', 8); + // Get shared folder name + if ($pos !== false) { + $itemTarget = substr($directory, 0, $pos); + } else { + $itemTarget = $directory; + } + $files = OCP\Share::getItemSharedWith('folder', $itemTarget, OC_Share_Backend_File::FORMAT_FILE_APP, array('folder' => $directory, 'mimetype_filter' => $mimetype_filter)); + } + } else { + $files = OC_FileCache::getFolderContent($directory, false, $mimetype_filter); + if ($directory == '') { + // Add 'Shared' folder + $files = array_merge($files, OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP_ROOT)); + } } - foreach($files as &$file){ - $file['directory']=$directory; - $file['type']=($file['mimetype']=='httpd/unix-directory')?'dir':'file'; + foreach ($files as &$file) { + $file['directory'] = $directory; + $file['type'] = ($file['mimetype'] == 'httpd/unix-directory') ? 'dir' : 'file'; } usort($files, "fileCmp");//TODO: remove this once ajax is merged return $files; @@ -109,8 +124,7 @@ class OC_Files { header('Content-Type: application/zip'); header('Content-Length: ' . filesize($filename)); }else{ - $fileData=OC_FileCache::get($filename); - header('Content-Type: ' . $fileData['mimetype']); + header('Content-Type: '.OC_Filesystem::getMimeType($filename)); } }elseif($zip or !OC_Filesystem::file_exists($filename)){ header("HTTP/1.0 404 Not Found"); |