From d429f472c30eb2164a508c6515d6c7380635b66b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 9 Aug 2016 14:05:02 +0200 Subject: [PATCH 1/8] hide global credentials in personal when a user cant add mounts --- apps/files_external/css/settings.css | 5 ++++ apps/files_external/templates/settings.php | 35 ++++++++++++---------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/apps/files_external/css/settings.css b/apps/files_external/css/settings.css index 4d5dc69a4e789..d09ab3ed427be 100644 --- a/apps/files_external/css/settings.css +++ b/apps/files_external/css/settings.css @@ -1,3 +1,8 @@ +#files_external { + margin-bottom: 0; + padding-bottom: 0; +} + #externalStorage td.status { /* overwrite conflicting core styles */ display: table-cell; diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php index 6fb2a0185479e..640604c14c580 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -84,24 +84,9 @@ function writeParameterInput($parameter, $options, $classes = []) { } } ?> -
-

t('External Storage')); ?>

-

t('Global Credentials')); ?>

- - - - -
+

t('External Storage')); ?>

'')) print_unescaped(''.$_['dependencies'].''); ?> '> @@ -200,3 +185,21 @@ function writeParameterInput($parameter, $options, $classes = []) {

+ + + +

t('Global Credentials')); ?>

+ + + + + + From d2edd381557c9d1493625f30011068db1db6bfc8 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 9 Aug 2016 14:09:53 +0200 Subject: [PATCH 2/8] don't show dependency info if we cant create new mounts --- apps/files_external/css/settings.css | 5 ++--- apps/files_external/templates/settings.php | 8 +++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/files_external/css/settings.css b/apps/files_external/css/settings.css index d09ab3ed427be..43bbb080d7e07 100644 --- a/apps/files_external/css/settings.css +++ b/apps/files_external/css/settings.css @@ -1,6 +1,5 @@ -#files_external { - margin-bottom: 0; - padding-bottom: 0; +#global_credentials { + padding-top: 0; } #externalStorage td.status { diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php index 640604c14c580..47230f98bd36a 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -4,6 +4,8 @@ use \OCA\Files_External\Lib\DefinitionParameter; use \OCA\Files_External\Service\BackendService; + $canCreateMounts = $_['visibilityType'] === BackendService::VISIBILITY_ADMIN || $_['allowUserMounting']; + $l->t("Enable encryption"); $l->t("Enable previews"); $l->t("Enable sharing"); @@ -87,7 +89,7 @@ function writeParameterInput($parameter, $options, $classes = []) {

t('External Storage')); ?>

- '')) print_unescaped(''.$_['dependencies'].''); ?> + '') and $canCreateMounts) print_unescaped(''.$_['dependencies'].''); ?>
'> @@ -103,7 +105,7 @@ function writeParameterInput($parameter, $options, $classes = []) { + style="display: none;" > @@ -186,7 +188,7 @@ function writeParameterInput($parameter, $options, $classes = []) { - +

t('Global Credentials')); ?>

From cc422e556b63de89aa5407932de01d96e18656cc Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 9 Aug 2016 14:19:15 +0200 Subject: [PATCH 3/8] hide files external in personal settings if it's empty --- apps/files_external/js/settings.js | 5 +++++ apps/files_external/templates/settings.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js index fc6edefc64808..da3e2397b7ea9 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -945,6 +945,11 @@ MountConfigListView.prototype = _.extend({ $tr.find('.configuration').text(t('files_external', 'Admin defined')); } }); + var mainForm = $('#files_external'); + if (result.length === 0 && mainForm.attr('data-can-create') === 'false') { + mainForm.hide(); + $('a[href="#external-storage"]').parent().hide(); + } onCompletion.resolve(); } }); diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php index 47230f98bd36a..2581259c4caab 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -87,7 +87,7 @@ function writeParameterInput($parameter, $options, $classes = []) { } ?> - +

t('External Storage')); ?>

'') and $canCreateMounts) print_unescaped(''.$_['dependencies'].''); ?>
'> From 8ffbe757d2ef46fb75bf662bdcc6db867907909e Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 10 Aug 2016 01:01:39 +0200 Subject: [PATCH 4/8] layout refinements --- apps/files_external/css/settings.css | 11 ++++++++++- apps/files_external/lib/config.php | 12 ++++++------ apps/files_external/templates/settings.php | 2 -- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/apps/files_external/css/settings.css b/apps/files_external/css/settings.css index 43bbb080d7e07..38e497eebe69c 100644 --- a/apps/files_external/css/settings.css +++ b/apps/files_external/css/settings.css @@ -1,5 +1,14 @@ #global_credentials { - padding-top: 0; + padding: 0 30px; + margin-bottom: 0px; +} + +#files_external { + margin-bottom: 0px; +} + +#externalStorage { + margin: 15px 0 20px 0; } #externalStorage td.status { diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index cd3b4d9f3cb43..7a10d4bbc242a 100644 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -285,7 +285,7 @@ public static function dependencyMessage($backends) { foreach ($backends as $backend) { foreach ($backend->checkDependencies() as $dependency) { if ($message = $dependency->getMessage()) { - $message .= '
' . $l->t('Note: ') . $message; + $message .= '

' . $message . '

'; } else { $dependencyGroups[$dependency->getDependency()][] = $backend; } @@ -294,9 +294,9 @@ public static function dependencyMessage($backends) { foreach ($dependencyGroups as $module => $dependants) { $backends = implode(', ', array_map(function($backend) { - return '' . $backend->getText() . ''; + return '"' . $backend->getText() . '"'; }, $dependants)); - $message .= '
' . OC_Mount_Config::getSingleDependencyMessage($l, $module, $backends); + $message .= '

' . OC_Mount_Config::getSingleDependencyMessage($l, $module, $backends) . '

'; } return $message; @@ -313,11 +313,11 @@ public static function dependencyMessage($backends) { private static function getSingleDependencyMessage(\OCP\IL10N $l, $module, $backend) { switch (strtolower($module)) { case 'curl': - return (string)$l->t('Note: The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it.', $backend); + return (string)$l->t('The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it.', $backend); case 'ftp': - return (string)$l->t('Note: The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it.', $backend); + return (string)$l->t('The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it.', $backend); default: - return (string)$l->t('Note: "%s" is not installed. Mounting of %s is not possible. Please ask your system administrator to install it.', array($module, $backend)); + return (string)$l->t('"%s" is not installed. Mounting of %s is not possible. Please ask your system administrator to install it.', array($module, $backend)); } } diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php index 2581259c4caab..636877e1fa07e 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -160,10 +160,8 @@ function writeParameterInput($parameter, $options, $classes = []) {
-
-
/> From 263c73c685f69188f4be5316c16f5413026db628 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 10 Aug 2016 01:04:35 +0200 Subject: [PATCH 5/8] Fix casing of external storage app --- apps/files_external/appinfo/info.xml | 4 ++-- apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php | 2 +- apps/files_external/templates/settings.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/files_external/appinfo/info.xml b/apps/files_external/appinfo/info.xml index ba12d1ff676dd..39b669fcc927d 100644 --- a/apps/files_external/appinfo/info.xml +++ b/apps/files_external/appinfo/info.xml @@ -3,9 +3,9 @@ files_external External storage support - This application enables administrators to configure connections to external storage providers, such as FTP servers, S3 or SWIFT object stores, Google Drive, Dropbox, other ownCloud servers, WebDAV servers, and more. Administrators can choose which types of storage to enable and can mount these storage locations for a user, a group, or the entire system. Users will see a new folder appear in their root ownCloud directory, which they can access and use like any other ownCloud folder. External Storage also allows users to share files stored in these external locations. In these cases, the credentials for the owner of the file are used when the recipient requests the file from external storage, thereby ensuring that the recipient can access the shared file. + This application enables administrators to configure connections to external storage providers, such as FTP servers, S3 or SWIFT object stores, Google Drive, Dropbox, other ownCloud servers, WebDAV servers, and more. Administrators can choose which types of storage to enable and can mount these storage locations for a user, a group, or the entire system. Users will see a new folder appear in their root ownCloud directory, which they can access and use like any other ownCloud folder. External storage also allows users to share files stored in these external locations. In these cases, the credentials for the owner of the file are used when the recipient requests the file from external storage, thereby ensuring that the recipient can access the shared file. - External Storage can be configured using the GUI or at the command line. This second option provides the advanced user with more flexibility for configuring bulk external storage mounts and setting mount priorities. More information is available in the External Storage GUI documentation and the External Storage Configuration File documentation. + External storage can be configured using the GUI or at the command line. This second option provides the advanced user with more flexibility for configuring bulk external storage mounts and setting mount priorities. More information is available in the external storage GUI documentation and the external storage Configuration File documentation. AGPL Robin Appelman, Michael Gapczynski, Vincent Petry diff --git a/apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php b/apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php index 502024be4f201..c0ece745aa4bf 100644 --- a/apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php +++ b/apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php @@ -48,7 +48,7 @@ public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { ->setIdentifier('password::global') ->setVisibility(BackendService::VISIBILITY_DEFAULT) ->setScheme(self::SCHEME_PASSWORD) - ->setText($l->t('Global Credentials')); + ->setText($l->t('Global credentials')); } public function getAuth($uid) { diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php index 636877e1fa07e..53d2412425c22 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -88,7 +88,7 @@ function writeParameterInput($parameter, $options, $classes = []) { ?> -

t('External Storage')); ?>

+

t('External storage')); ?>

'') and $canCreateMounts) print_unescaped(''.$_['dependencies'].''); ?> '> @@ -189,7 +189,7 @@ function writeParameterInput($parameter, $options, $classes = []) { -

t('Global Credentials')); ?>

+

t('Global credentials')); ?>

Date: Mon, 15 Aug 2016 15:32:22 +0200 Subject: [PATCH 6/8] dont register personal files_external setting if it's empty --- apps/files_external/lib/AppInfo/Application.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/files_external/lib/AppInfo/Application.php b/apps/files_external/lib/AppInfo/Application.php index 06c163419f060..8e76ffd335288 100644 --- a/apps/files_external/lib/AppInfo/Application.php +++ b/apps/files_external/lib/AppInfo/Application.php @@ -68,7 +68,14 @@ public function __construct(array $urlParams = array()) { * Register settings templates */ public function registerSettings() { - \OCP\App::registerPersonal('files_external', 'personal'); + $container = $this->getContainer(); + $backendService = $container->query('OCA\\Files_External\\Service\\BackendService'); + + /** @var \OCA\Files_External\Service\UserGlobalStoragesService $userGlobalStoragesService */ + $userGlobalStoragesService = $container->query('OCA\Files_External\Service\UserGlobalStoragesService'); + if (count($userGlobalStoragesService->getStorages()) > 0 || $backendService->isUserMountingAllowed()) { + \OCP\App::registerPersonal('files_external', 'personal'); + } } /** From bead6c9307df8bddc2603a87f4b7772bf713abb7 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 15 Aug 2016 16:13:23 +0200 Subject: [PATCH 7/8] change remote cloud naming to Nextcloud --- apps/files_external/lib/Lib/Backend/OwnCloud.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_external/lib/Lib/Backend/OwnCloud.php b/apps/files_external/lib/Lib/Backend/OwnCloud.php index 59d1b2cec52b6..1304b09c87c06 100644 --- a/apps/files_external/lib/Lib/Backend/OwnCloud.php +++ b/apps/files_external/lib/Lib/Backend/OwnCloud.php @@ -37,7 +37,7 @@ public function __construct(IL10N $l, Password $legacyAuth) { ->setIdentifier('owncloud') ->addIdentifierAlias('\OC\Files\Storage\OwnCloud') // legacy compat ->setStorageClass('\OCA\Files_External\Lib\Storage\OwnCloud') - ->setText($l->t('ownCloud')) + ->setText($l->t('Nextcloud')) ->addParameters([ (new DefinitionParameter('host', $l->t('URL'))), (new DefinitionParameter('root', $l->t('Remote subfolder'))) From e286e0492a43f2c18938d4de334fded608a569e1 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 18 Aug 2016 16:06:25 +0200 Subject: [PATCH 8/8] fix error when not logged in --- apps/files_external/lib/AppInfo/Application.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/files_external/lib/AppInfo/Application.php b/apps/files_external/lib/AppInfo/Application.php index 8e76ffd335288..fcf10adb3755b 100644 --- a/apps/files_external/lib/AppInfo/Application.php +++ b/apps/files_external/lib/AppInfo/Application.php @@ -69,6 +69,10 @@ public function __construct(array $urlParams = array()) { */ public function registerSettings() { $container = $this->getContainer(); + $userSession = $container->getServer()->getUserSession(); + if (!$userSession->isLoggedIn()) { + return; + } $backendService = $container->query('OCA\\Files_External\\Service\\BackendService'); /** @var \OCA\Files_External\Service\UserGlobalStoragesService $userGlobalStoragesService */