allow to change the timezone

Signed-off-by: szaimen <szaimen@e.mail.de>
This commit is contained in:
szaimen 2022-05-18 18:36:51 +02:00
parent 1cf5cf5509
commit 3e019d25f2
10 changed files with 102 additions and 10 deletions

View file

@ -52,6 +52,15 @@ class ConfigurationController
$this->configurationManager->DeleteDailyBackupTime();
}
if (isset($request->getParsedBody()['delete_timezone'])) {
$this->configurationManager->DeleteTimezone();
}
if (isset($request->getParsedBody()['timezone'])) {
$timezone = $request->getParsedBody()['timezone'] ?? '';
$this->configurationManager->SetTimezone($timezone);
}
if (isset($request->getParsedBody()['options-form'])) {
if (isset($request->getParsedBody()['collabora']) && isset($request->getParsedBody()['onlyoffice'])) {
throw new InvalidSettingConfigurationException("Collabora and Onlyoffice are not allowed to be enabled at the same time!");

View file

@ -479,4 +479,33 @@ class ConfigurationManager
}
return false;
}
public function GetTimezone() : string {
$config = $this->GetConfig();
if(!isset($config['timezone'])) {
$config['timezone'] = '';
}
return $config['timezone'];
}
public function SetTimezone(string $timezone) : void {
if ($timezone === "") {
throw new InvalidSettingConfigurationException("The timezone must not be empty!");
}
if (!preg_match("#[a-zA-Z0-9_-/+]+$#", $timezone)) {
throw new InvalidSettingConfigurationException("The entered timezone does not seem to be a valid timezone!");
}
$config = $this->GetConfig();
$config['timezone'] = $timezone;
$this->WriteConfig($config);
}
public function DeleteTimezone() : void {
$config = $this->GetConfig();
$config['timezone'] = '';
$this->WriteConfig($config);
}
}

View file

@ -280,6 +280,8 @@ class DockerActionManager
} else {
$replacements[1] = '';
}
} elseif ($out[1] === 'TIMEZONE') {
$replacements[1] = $this->configurationManager->GetTimezone();
} else {
$replacements[1] = $this->configurationManager->GetSecret($out[1]);
}