From fc2d5383119f548f58b5000ebb94422b7feb08a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 12 Jul 2013 17:03:51 +0200 Subject: [PATCH 1/5] new admin setting added which allows to turn off anonymous uploads --- apps/files/index.php | 1 + apps/files/templates/index.php | 2 +- core/js/share.js | 7 ++++++- settings/admin.php | 3 ++- settings/templates/admin.php | 10 +++++++++- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/apps/files/index.php b/apps/files/index.php index 2338cf439e..892f75a351 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -138,5 +138,6 @@ if ($needUpgrade) { $tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $tmpl->assign('usedSpacePercent', (int)$storageInfo['relative']); $tmpl->assign('isPublic', false); + $tmpl->assign('publicUploadEnabled', \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes')); $tmpl->printPage(); } diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 7d679bc4bf..dacd2be0b3 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -61,7 +61,7 @@
t('Nothing in here. Upload something!'))?>
- +
+ + + From 79d23463f82d70fc7b3aff176d0de8154720f480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sun, 14 Jul 2013 21:58:08 +0200 Subject: [PATCH 5/5] No admin option to enable public upload in case encryption is enabled No upload on pubic page if public upload is disabled --- apps/files_sharing/public.php | 5 ++++- settings/templates/admin.php | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 695c00e554..3f8e29345a 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -137,6 +137,9 @@ if (isset($path)) { if (\OCP\App::isEnabled('files_encryption')) { $allowPublicUploadEnabled = false; } + if (OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes') === 'no') { + $allowPublicUploadEnabled = false; + } if ($linkItem['item_type'] !== 'folder') { $allowPublicUploadEnabled = false; } @@ -202,7 +205,7 @@ if (isset($path)) { $folder->assign('isCreatable', false); $folder->assign('permissions', OCP\PERMISSION_READ); $folder->assign('isPublic',true); - $folder->assign('publicUploadEnabled', true); + $folder->assign('publicUploadEnabled', 'no'); $folder->assign('files', $files); $folder->assign('uploadMaxFilesize', $maxUploadFilesize); $folder->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); diff --git a/settings/templates/admin.php b/settings/templates/admin.php index 9f16db0948..6c4fddd375 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -145,6 +145,7 @@ if (!$_['internetconnectionworking']) { t('Allow users to share items to the public with links')); ?> + +
diff --git a/core/js/share.js b/core/js/share.js index 21e352ee1c..4c8fd87410 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -161,7 +161,12 @@ OC.Share={ // respective checkbox should be checked or // not. + var publicUploadEnabled = $('#filestable').data('allow-public-upload'); + if (typeof publicUploadEnabled == 'undefined') { + publicUploadEnabled = 'no'; + } var allowPublicUploadStatus = false; + $.each(data.shares, function(key, value) { if (allowPublicUploadStatus) { return true; @@ -181,7 +186,7 @@ OC.Share={ html += '
'; html += ''; html += '
'; - if (itemType === 'folder' && (possiblePermissions & OC.PERMISSION_CREATE)) { + if (itemType === 'folder' && (possiblePermissions & OC.PERMISSION_CREATE) && publicUploadEnabled === 'yes') { html += '
> /> + value="1" />
t('Allow users to share items to the public with links')); ?>
> + /> +
+ t('Allow users to enable others to anonymously upload into their publicly shared folders')); ?> +
> Date: Fri, 12 Jul 2013 17:05:58 +0200 Subject: [PATCH 2/5] in case the encryption app is enabled we cannot yet allow anonymous upload --- apps/files/index.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/files/index.php b/apps/files/index.php index 892f75a351..2f00539150 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -121,6 +121,10 @@ if ($needUpgrade) { // information about storage capacities $storageInfo=OC_Helper::getStorageInfo(); $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir); + $publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes'); + if (OC_App::isEnabled('files_encryption')) { + $publicUploadEnabled = 'no'; + } OCP\Util::addscript('files', 'fileactions'); OCP\Util::addscript('files', 'files'); @@ -138,6 +142,6 @@ if ($needUpgrade) { $tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $tmpl->assign('usedSpacePercent', (int)$storageInfo['relative']); $tmpl->assign('isPublic', false); - $tmpl->assign('publicUploadEnabled', \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes')); + $tmpl->assign('publicUploadEnabled', $publicUploadEnabled); $tmpl->printPage(); } From c3e16a73883c967934abfa8dd5565b862df3489c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 12 Jul 2013 17:51:01 +0200 Subject: [PATCH 3/5] fixing Undefined index: publicUploadEnabled --- apps/files_sharing/public.php | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 9462844a82..695c00e554 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -202,6 +202,7 @@ if (isset($path)) { $folder->assign('isCreatable', false); $folder->assign('permissions', OCP\PERMISSION_READ); $folder->assign('isPublic',true); + $folder->assign('publicUploadEnabled', true); $folder->assign('files', $files); $folder->assign('uploadMaxFilesize', $maxUploadFilesize); $folder->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); From 7a44d4571487f6a5c63c75658fbe2ca3de7e900d Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 12 Jul 2013 21:34:38 +0200 Subject: [PATCH 4/5] change anonymous to public --- settings/templates/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/settings/templates/admin.php b/settings/templates/admin.php index 9f16db0948..397616a0a0 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -149,8 +149,8 @@ if (!$_['internetconnectionworking']) { > /> -
- t('Allow users to enable others to anonymously upload into their publicly shared folders')); ?> +
+ t('Allow users to enable others to upload into their publicly shared folders')); ?>
> t('Allow users to enable others to anonymously upload into their publicly shared folders')); ?>
>