From 836e7305d02d718673848c2ea35fe194fd81142c Mon Sep 17 00:00:00 2001 From: "John Molakvoæ (skjnldsv)" Date: Mon, 18 Nov 2019 22:13:38 +0100 Subject: Fix accessibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- .../lib/Controller/ConfigController.php | 38 ++++++++++++++++------ 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'apps/accessibility/lib/Controller/ConfigController.php') diff --git a/apps/accessibility/lib/Controller/ConfigController.php b/apps/accessibility/lib/Controller/ConfigController.php index d98ba231fa8..589861163f1 100644 --- a/apps/accessibility/lib/Controller/ConfigController.php +++ b/apps/accessibility/lib/Controller/ConfigController.php @@ -102,16 +102,8 @@ class ConfigController extends OCSController { public function setConfig(string $key, $value): DataResponse { if ($key === 'theme' || $key === 'font' || $key === 'highcontrast') { - if ($value === false) { - $this->config->deleteUserValue($this->userId, $this->appName, $key); - $userValues = $this->config->getUserKeys($this->userId, $this->appName); - - // remove hash if no settings selected - if (count($userValues) === 1 && $userValues[0] === 'icons-css') { - $this->config->deleteUserValue($this->userId, $this->appName, 'icons-css'); - } - - return new DataResponse(); + if ($value === false || $value === '') { + throw new OCSBadRequestException('Invalid value: ' . $value); } $themes = $this->accessibilityProvider->getThemes(); @@ -133,4 +125,30 @@ class ConfigController extends OCSController { throw new OCSBadRequestException('Invalid key: ' . $key); } + /** + * @NoAdminRequired + * + * Unset theme or font config + * + * @param string $key theme or font + * @return DataResponse + * @throws Exception + */ + public function deleteConfig(string $key): DataResponse { + if ($key === 'theme' || $key === 'font' || $key === 'highcontrast') { + + $this->config->deleteUserValue($this->userId, $this->appName, $key); + $userValues = $this->config->getUserKeys($this->userId, $this->appName); + + // remove hash if no settings selected + if (count($userValues) === 1 && $userValues[0] === 'icons-css') { + $this->config->deleteUserValue($this->userId, $this->appName, 'icons-css'); + } + + return new DataResponse(); + } + + throw new OCSBadRequestException('Invalid key: ' . $key); + } + } -- cgit v1.2.3