diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-08-19 22:29:01 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-08-19 22:29:01 -0400 |
commit | 82d81e8d39ce69211ec6b29fe3f803c57714b8dd (patch) | |
tree | 09dbd675480a02fd626f6634e083f3d6a01b4404 /lib/files.php | |
parent | f893d21660695d1d1cd594c102e2bcba6919dee3 (diff) | |
parent | 5eca531f99f9615d1a09bbb0b03dda2063901aa7 (diff) | |
download | nextcloud-server-82d81e8d39ce69211ec6b29fe3f803c57714b8dd.tar.gz nextcloud-server-82d81e8d39ce69211ec6b29fe3f803c57714b8dd.zip |
Merge branch 'share_api'
Conflicts:
apps/contacts/lib/vcard.php
apps/files/index.php
lib/files.php
Diffstat (limited to 'lib/files.php')
-rw-r--r-- | lib/files.php | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/lib/files.php b/lib/files.php index b9c2ead9443..ce7cf2c4466 100644 --- a/lib/files.php +++ b/lib/files.php @@ -37,10 +37,38 @@ class OC_Files { if($directory=='/'){ $directory=''; } - $files=OC_FileCache::getFolderContent($directory, false, $mimetype_filter); - foreach($files as &$file){ - $file['directory']=$directory; - $file['type']=($file['mimetype']=='httpd/unix-directory')?'dir':'file'; + $files = array(); + if (substr($directory, 0, 7) == '/Shared') { + if ($directory == '/Shared') { + $files = OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP, array('folder' => $directory, 'mimetype_filter' => $mimetype_filter)); + } else { + $pos = strpos($directory, '/', 8); + // Get shared folder name + if ($pos !== false) { + $itemTarget = substr($directory, 7, $pos - 7); + } else { + $itemTarget = substr($directory, 7); + } + $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); + foreach ($files as &$file) { + $file['directory'] = $directory; + $file['type'] = ($file['mimetype'] == 'httpd/unix-directory') ? 'dir' : 'file'; + $permissions = OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_SHARE; + if ($file['type'] == 'dir' && $file['writable']) { + $permissions |= OCP\Share::PERMISSION_CREATE; + } + if ($file['writable']) { + $permissions |= OCP\Share::PERMISSION_UPDATE | OCP\Share::PERMISSION_DELETE; + } + $file['permissions'] = $permissions; + } + if ($directory == '') { + // Add 'Shared' folder + $files = array_merge($files, OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP_ROOT)); + } } usort($files, "fileCmp");//TODO: remove this once ajax is merged return $files; @@ -108,8 +136,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"); |