summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2020-02-26 14:29:52 +0100
committerGitHub <noreply@github.com>2020-02-26 14:29:52 +0100
commite85d3ae3f87559313fa913aa3ba2305e4518f2fd (patch)
tree5bf4b86b4ae1735b92aca15ba4359e480ee02375 /apps
parent0e7163c7c108711d1b968406a7492803b62badba (diff)
parent8e8e912015309700fc2d5ee021cd171e18c27b47 (diff)
downloadnextcloud-server-e85d3ae3f87559313fa913aa3ba2305e4518f2fd.tar.gz
nextcloud-server-e85d3ae3f87559313fa913aa3ba2305e4518f2fd.zip
Merge pull request #19589 from nextcloud/bug/19162/reindex-quota-preset
Make sure quota_preset is using numerical indexes
Diffstat (limited to 'apps')
-rw-r--r--apps/settings/lib/Controller/UsersController.php20
1 files changed, 14 insertions, 6 deletions
diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php
index 2c7c17bced2..2c20ce36caa 100644
--- a/apps/settings/lib/Controller/UsersController.php
+++ b/apps/settings/lib/Controller/UsersController.php
@@ -214,12 +214,7 @@ class UsersController extends Controller {
];
/* QUOTAS PRESETS */
- $quotaPreset = $this->config->getAppValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB');
- $quotaPreset = explode(',', $quotaPreset);
- foreach ($quotaPreset as &$preset) {
- $preset = trim($preset);
- }
- $quotaPreset = array_diff($quotaPreset, array('default', 'none'));
+ $quotaPreset = $this->parseQuotaPreset($this->config->getAppValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB'));
$defaultQuota = $this->config->getAppValue('files', 'default_quota', 'none');
\OC::$server->getEventDispatcher()->dispatch('OC\Settings\Users::loadAdditionalScripts');
@@ -248,6 +243,19 @@ class UsersController extends Controller {
}
/**
+ * Parse the app value for quota_present
+ *
+ * @param string $quotaPreset
+ * @return array
+ */
+ protected function parseQuotaPreset(string $quotaPreset): array {
+ // 1 GB, 5 GB, 10 GB => [1 GB, 5 GB, 10 GB]
+ $presets = array_filter(array_map('trim', explode(',', $quotaPreset)));
+ // Drop default and none, Make array indexes numerically
+ return array_values(array_diff($presets, ['default', 'none']));
+ }
+
+ /**
* check if the admin can change the users password
*
* The admin can change the passwords if: