Merge pull request #19589 from nextcloud/bug/19162/reindex-quota-preset

Make sure quota_preset is using numerical indexes
This commit is contained in:
John Molakvoæ 2020-02-26 14:29:52 +01:00 committed by GitHub
commit e85d3ae3f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 6 deletions

View File

@ -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');
@ -247,6 +242,19 @@ class UsersController extends Controller {
return new TemplateResponse('settings', 'settings-vue', ['serverData' => $serverData]);
}
/**
* 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
*