summaryrefslogtreecommitdiffstats
path: root/apps/theming/lib/Controller/UserThemeController.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/theming/lib/Controller/UserThemeController.php')
-rw-r--r--apps/theming/lib/Controller/UserThemeController.php25
1 files changed, 19 insertions, 6 deletions
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,
]);
}