summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-09-16 17:42:56 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2013-09-16 17:42:56 +0200
commitef3307f0996f1025a75a697a549166b26576e670 (patch)
tree3c092e77210237ba436fe3d6a08619286c1cd0a1 /apps
parent7aed24fa6c3df13d553f5b83b7de57e89f119d15 (diff)
downloadnextcloud-server-ef3307f0996f1025a75a697a549166b26576e670.tar.gz
nextcloud-server-ef3307f0996f1025a75a697a549166b26576e670.zip
return error if public upload is disabled
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/api.php29
1 files changed, 10 insertions, 19 deletions
diff --git a/apps/files_sharing/lib/api.php b/apps/files_sharing/lib/api.php
index ba186094311..f641623ac10 100644
--- a/apps/files_sharing/lib/api.php
+++ b/apps/files_sharing/lib/api.php
@@ -77,8 +77,17 @@ class Api {
case \OCP\Share::SHARE_TYPE_LINK:
//allow password protection
$shareWith = isset($_POST['password']) ? $_POST['password'] : null;
+ //check public link share
+ $publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes');
+ $encryptionEnabled = \OC_App::isEnabled('files_encryption');
+ if(isset($_POST['publicUpload']) &&
+ ($encryptionEnabled || $publicUploadEnabled !== 'yes')) {
+ return new \OC_OCS_Result(null, 404, "public upload disabled by the administrator");
+ }
$publicUpload = isset($_POST['publicUpload']) ? $_POST['publicUpload'] : 'no';
- $permission = self::getPublicLinkSharePermissions($publicUpload);
+ // read, create, update (7) if public upload is enabled or
+ // read (1) if public upload is disabled
+ $permission = $publicUpload === 'yes' ? 7 : 1;
break;
}
@@ -213,24 +222,6 @@ class Api {
}
/**
- * @brief get public link share permissions to allow/forbid public uploads
- * @param string $publicUpload 'yes' or 'no'
- * @return int permissions read (1) or create,update,read (7)
- */
- private static function getPublicLinkSharePermissions($publicUpload) {
-
- $publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes');
-
- if(\OC_App::isEnabled('files_encryption') ||
- $publicUploadEnabled !== 'yes' ||
- $publicUpload === 'no') {
- return 1; // read
- } else {
- return 7; // create, update, read
- }
- }
-
- /**
* @brief get file ID from a given path
* @param string $path
* @return string fileID or null