diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-25 16:33:08 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-25 16:33:08 -0400 |
commit | 4d17ed2f71c8cbb0d34c039aa7953b2427ce5c78 (patch) | |
tree | 136a050983c8feaa993805ffff53d5aad86f9cff /lib/files.php | |
parent | 6f58eca5349d8c82f7bba3a7c0f92c0caa8e3749 (diff) | |
download | nextcloud-server-4d17ed2f71c8cbb0d34c039aa7953b2427ce5c78.tar.gz nextcloud-server-4d17ed2f71c8cbb0d34c039aa7953b2427ce5c78.zip |
Make file actions permissions aware
Diffstat (limited to 'lib/files.php')
-rw-r--r-- | lib/files.php | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/files.php b/lib/files.php index f7a7aecc167..fee71b777b3 100644 --- a/lib/files.php +++ b/lib/files.php @@ -36,7 +36,7 @@ class OC_Files { $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)); + $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 @@ -49,15 +49,23 @@ class OC_Files { } } 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)); } } - 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; } |