summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-07-25 16:33:08 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2012-07-25 16:33:08 -0400
commit4d17ed2f71c8cbb0d34c039aa7953b2427ce5c78 (patch)
tree136a050983c8feaa993805ffff53d5aad86f9cff /apps/files_sharing
parent6f58eca5349d8c82f7bba3a7c0f92c0caa8e3749 (diff)
downloadnextcloud-server-4d17ed2f71c8cbb0d34c039aa7953b2427ce5c78.tar.gz
nextcloud-server-4d17ed2f71c8cbb0d34c039aa7953b2427ce5c78.zip
Make file actions permissions aware
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/share/file.php11
-rw-r--r--apps/files_sharing/lib/share/folder.php13
2 files changed, 21 insertions, 3 deletions
diff --git a/apps/files_sharing/lib/share/file.php b/apps/files_sharing/lib/share/file.php
index 658c42ee327..dd63539cdfe 100644
--- a/apps/files_sharing/lib/share/file.php
+++ b/apps/files_sharing/lib/share/file.php
@@ -70,7 +70,14 @@ class OC_Share_Backend_File extends OCP\Share_Backend {
// Set target path
$file['path'] = $shares[$file['id']]['file_target'];
$file['name'] = basename($file['path']);
- // TODO Set permissions: $file['writable']
+ $file['directory'] = $parameters['folder'];
+ $file['type'] = ($file['mimetype'] == 'httpd/unix-directory') ? 'dir' : 'file';
+ $permissions = $shares[$file['id']]['permissions'];
+ if ($file['type'] == 'file') {
+ // Remove Create permission if type is file
+ $permissions &= ~OCP\Share::PERMISSION_CREATE;
+ }
+ $file['permissions'] = $permissions;
$files[] = $file;
}
return $files;
@@ -85,7 +92,7 @@ class OC_Share_Backend_File extends OCP\Share_Backend {
}
$size += $file['size'];
}
- return array(0 => array('name' => 'Shared', 'mtime' => $mtime, 'mimetype' => 'httpd/unix-directory', 'size' => $size, 'writable' => false));
+ return array(0 => array('name' => 'Shared', 'mtime' => $mtime, 'mimetype' => 'httpd/unix-directory', 'size' => $size, 'writable' => false, 'type' => 'dir', 'directory' => '', 'permissions' => OCP\Share::PERMISSION_READ));
}
}
return array();
diff --git a/apps/files_sharing/lib/share/folder.php b/apps/files_sharing/lib/share/folder.php
index 033e2ba9667..a43ce2b2caf 100644
--- a/apps/files_sharing/lib/share/folder.php
+++ b/apps/files_sharing/lib/share/folder.php
@@ -43,7 +43,18 @@ class OC_Share_Backend_Folder extends OC_Share_Backend_File {
$pos = strpos($result['path'], $folder['item']);
$path = substr($result['path'], $pos).substr($parameters['folder'], strlen($folder['file_target']));
$root = substr($result['path'], 0, $pos);
- return OC_FileCache::getFolderContent($path, $root, $mimetype_filter);
+ $files = OC_FileCache::getFolderContent($path, $root, $mimetype_filter);
+ foreach ($files as &$file) {
+ $file['directory'] = $parameters['folder'];
+ $file['type'] = ($file['mimetype'] == 'httpd/unix-directory') ? 'dir' : 'file';
+ $permissions = $folder['permissions'];
+ if ($file['type'] == 'file') {
+ // Remove Create permission if type is file
+ $permissions &= ~OCP\Share::PERMISSION_CREATE;
+ }
+ $file['permissions'] = $permissions;
+ }
+ return $files;
}
}/* else if ($format == self::FORMAT_OPENDIR_ROOT) {
$query = OCP\DB::prepare('SELECT name FROM *PREFIX*fscache WHERE id IN ('.$ids.')');