summaryrefslogtreecommitdiffstats
path: root/apps/accessibility/lib/Controller/ConfigController.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/accessibility/lib/Controller/ConfigController.php')
-rw-r--r--apps/accessibility/lib/Controller/ConfigController.php38
1 files changed, 28 insertions, 10 deletions
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);
+ }
+
}