diff options
author | Jan-Christoph Borchardt <hey@jancborchardt.net> | 2014-03-05 14:41:36 +0100 |
---|---|---|
committer | Jan-Christoph Borchardt <hey@jancborchardt.net> | 2014-03-05 14:41:36 +0100 |
commit | bd866427471ec178602959afdce8851979501c45 (patch) | |
tree | d1d059b9ce00ca7b9b3409bf253cb4ebc29c4f62 /apps/files_external/lib | |
parent | 36d7c0b6a7ed79ec1c578476a797648715b3b000 (diff) | |
parent | 932c4ee927f278f4ef5275a9582bca8822310738 (diff) | |
download | nextcloud-server-bd866427471ec178602959afdce8851979501c45.tar.gz nextcloud-server-bd866427471ec178602959afdce8851979501c45.zip |
Merge pull request #7261 from owncloud/issue/6793
Allow admins to disable certain external storages for users
Diffstat (limited to 'apps/files_external/lib')
-rwxr-xr-x | apps/files_external/lib/config.php | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 8456b81d255..1069e2b42eb 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -156,6 +156,35 @@ class OC_Mount_Config { } /** + * Get details on each of the external storage backends, used for the mount config UI + * Some backends are not available as a personal backend, f.e. Local and such that have + * been disabled by the admin. + * + * If a custom UI is needed, add the key 'custom' and a javascript file with that name will be loaded + * If the configuration parameter should be secret, add a '*' to the beginning of the value + * If the configuration parameter is a boolean, add a '!' to the beginning of the value + * If the configuration parameter is optional, add a '&' to the beginning of the value + * If the configuration parameter is hidden, add a '#' to the beginning of the value + * @return array + */ + public static function getPersonalBackends() { + + $backends = self::getBackends(); + + // Remove local storage and other disabled storages + unset($backends['\OC\Files\Storage\Local']); + + $allowed_backends = explode(',', OCP\Config::getAppValue('files_external', 'user_mounting_backends', '')); + foreach ($backends as $backend => $null) { + if (!in_array($backend, $allowed_backends)) { + unset($backends[$backend]); + } + } + + return $backends; + } + + /** * Get the system mount points * The returned array is not in the same format as getUserMountPoints() * @return array @@ -287,11 +316,12 @@ class OC_Mount_Config { if (!isset($backends[$class])) { // invalid backend return false; - } + } if ($isPersonal) { // Verify that the mount point applies for the current user - // Prevent non-admin users from mounting local storage - if ($applicable !== OCP\User::getUser() || strtolower($class) === '\oc\files\storage\local') { + // Prevent non-admin users from mounting local storage and other disabled backends + $allowed_backends = self::getPersonalBackends(); + if ($applicable != OCP\User::getUser() || !in_array($class, $allowed_backends)) { return false; } $mountPoint = '/'.$applicable.'/files/'.ltrim($mountPoint, '/'); |