summaryrefslogtreecommitdiffstats
path: root/apps/theming/lib/Controller
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2022-10-20 13:18:06 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2022-11-29 11:22:13 +0100
commitcedae7c6d74e11c8aaa59b09a38db04dbebc818d (patch)
treeb95c77675542e0654084dd41f5d1f07a413b4db7 /apps/theming/lib/Controller
parenta884f311b78341612adeb6d62f707dda1bae39e7 (diff)
downloadnextcloud-server-cedae7c6d74e11c8aaa59b09a38db04dbebc818d.tar.gz
nextcloud-server-cedae7c6d74e11c8aaa59b09a38db04dbebc818d.zip
Allow to remove the background and select a custom colour
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/theming/lib/Controller')
-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,
]);
}