From: Bjoern Schiessle Date: Mon, 16 Sep 2013 15:42:56 +0000 (+0200) Subject: return error if public upload is disabled X-Git-Tag: v6.0.0alpha2~95^2~28 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ef3307f0996f1025a75a697a549166b26576e670;p=nextcloud-server.git return error if public upload is disabled --- 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; } @@ -212,24 +221,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