]> source.dussan.org Git - nextcloud-server.git/commitdiff
return error if public upload is disabled
authorBjoern Schiessle <schiessle@owncloud.com>
Mon, 16 Sep 2013 15:42:56 +0000 (17:42 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Mon, 16 Sep 2013 15:42:56 +0000 (17:42 +0200)
apps/files_sharing/lib/api.php

index ba186094311e8898be1829d926e3dbe47d5542ac..f641623ac10da0fee0500ee36a0efecf97bf0ed3 100644 (file)
@@ -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