From cedae7c6d74e11c8aaa59b09a38db04dbebc818d Mon Sep 17 00:00:00 2001 From: John Molakvoæ Date: Thu, 20 Oct 2022 13:18:06 +0200 Subject: Allow to remove the background and select a custom colour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- .../theming/lib/Controller/UserThemeController.php | 25 ++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'apps/theming/lib/Controller') diff --git a/apps/theming/lib/Controller/UserThemeController.php b/apps/theming/lib/Controller/UserThemeController.php index 635dad34736..888ab9a0ca8 100644 --- a/apps/theming/lib/Controller/UserThemeController.php +++ b/apps/theming/lib/Controller/UserThemeController.php @@ -155,21 +155,34 @@ class UserThemeController extends OCSController { /** * @NoAdminRequired */ - public function setBackground(string $type = 'default', string $value = ''): JSONResponse { + public function deleteBackground(): JSONResponse { + $currentVersion = (int)$this->config->getUserValue($this->userId, Application::APP_ID, 'userCacheBuster', '0'); + $this->backgroundService->deleteBackgroundImage(); + return new JSONResponse([ + 'backgroundImage' => null, + 'backgroundColor' => $this->themingDefaults->getColorPrimary(), + 'version' => $currentVersion, + ]); + } + + /** + * @NoAdminRequired + */ + public function setBackground(string $type = BackgroundService::BACKGROUND_DEFAULT, string $value = ''): JSONResponse { $currentVersion = (int)$this->config->getUserValue($this->userId, Application::APP_ID, 'userCacheBuster', '0'); try { switch ($type) { - case 'shipped': + case BackgroundService::BACKGROUND_SHIPPED: $this->backgroundService->setShippedBackground($value); break; - case 'custom': + case BackgroundService::BACKGROUND_CUSTOM: $this->backgroundService->setFileBackground($value); break; case 'color': $this->backgroundService->setColorBackground($value); break; - case 'default': + case BackgroundService::BACKGROUND_DEFAULT: $this->backgroundService->setDefaultBackground(); break; default: @@ -185,8 +198,8 @@ class UserThemeController extends OCSController { $this->config->setUserValue($this->userId, Application::APP_ID, 'userCacheBuster', (string)$currentVersion); return new JSONResponse([ - 'type' => $type, - 'value' => $value, + 'backgroundImage' => $this->config->getUserValue($this->userId, Application::APP_ID, 'background_image', BackgroundService::BACKGROUND_DEFAULT), + 'backgroundColor' => $this->themingDefaults->getColorPrimary(), 'version' => $currentVersion, ]); } -- cgit v1.2.3