summaryrefslogtreecommitdiffstats
path: root/apps/files/ajax
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2014-12-12 08:34:28 +0100
committerMorris Jobke <hey@morrisjobke.de>2014-12-12 08:34:28 +0100
commite969fe6b1222467349929523ea92192ca23f92d5 (patch)
tree67bbf63fbf671b19d18d4fe17517cc299a653c61 /apps/files/ajax
parent68932b30fd3347761ca75dd8b7289848b2d6b42e (diff)
parentc615b3527f7c472afbc93d3293c7f467a99cbd0b (diff)
downloadnextcloud-server-e969fe6b1222467349929523ea92192ca23f92d5.tar.gz
nextcloud-server-e969fe6b1222467349929523ea92192ca23f92d5.zip
Merge pull request #12698 from owncloud/handle_readonly_shared_files
Handle readonly shared files
Diffstat (limited to 'apps/files/ajax')
-rw-r--r--apps/files/ajax/upload.php24
1 files changed, 18 insertions, 6 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index eb99d0644f7..fcee0166da6 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -117,6 +117,12 @@ if (strpos($dir, '..') === false) {
$fileCount = count($files['name']);
for ($i = 0; $i < $fileCount; $i++) {
+ if (isset($_POST['resolution'])) {
+ $resolution = $_POST['resolution'];
+ } else {
+ $resolution = null;
+ }
+
// target directory for when uploading folders
$relativePath = '';
if(!empty($_POST['file_directory'])) {
@@ -124,7 +130,7 @@ if (strpos($dir, '..') === false) {
}
// $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder
- if (isset($_POST['resolution']) && $_POST['resolution']==='autorename') {
+ if ($resolution === 'autorename') {
// append a number in brackets like 'filename (2).ext'
$target = OCP\Files::buildNotExistingFileName(stripslashes($dir . $relativePath), $files['name'][$i]);
} else {
@@ -141,9 +147,12 @@ if (strpos($dir, '..') === false) {
}
$returnedDir = \OC\Files\Filesystem::normalizePath($returnedDir);
- if ( ! \OC\Files\Filesystem::file_exists($target)
- || (isset($_POST['resolution']) && $_POST['resolution']==='replace')
- ) {
+
+ $exists = \OC\Files\Filesystem::file_exists($target);
+ if ($exists) {
+ $updatable = \OC\Files\Filesystem::isUpdatable($target);
+ }
+ if ( ! $exists || ($updatable && $resolution === 'replace' ) ) {
// upload and overwrite file
try
{
@@ -181,8 +190,11 @@ if (strpos($dir, '..') === false) {
$error = $l->t('Upload failed. Could not get file info.');
} else {
$data = \OCA\Files\Helper::formatFileInfo($meta);
- $data['permissions'] = $data['permissions'] & $allowedPermissions;
- $data['status'] = 'existserror';
+ if ($updatable) {
+ $data['status'] = 'existserror';
+ } else {
+ $data['status'] = 'readonly';
+ }
$data['originalname'] = $files['tmp_name'][$i];
$data['uploadMaxFilesize'] = $maxUploadFileSize;
$data['maxHumanFilesize'] = $maxHumanFileSize;