mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-02-04 13:06:53 +00:00
Make timezone an attribute
Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
This commit is contained in:
parent
f030abcafd
commit
9df3a7b231
4 changed files with 22 additions and 22 deletions
|
|
@ -117,7 +117,7 @@ $app->get('/containers', function (Request $request, Response $response, array $
|
|||
'borg_restore_password' => $configurationManager->borg_restore_password,
|
||||
'daily_backup_time' => $configurationManager->GetDailyBackupTime(),
|
||||
'is_daily_backup_running' => $configurationManager->isDailyBackupRunning(),
|
||||
'timezone' => $configurationManager->GetTimezone(),
|
||||
'timezone' => $configurationManager->timezone,
|
||||
'skip_domain_validation' => $configurationManager->shouldDomainValidationBeSkipped($skip_domain_validation),
|
||||
'talk_port' => $configurationManager->GetTalkPort(),
|
||||
'collabora_dictionaries' => $configurationManager->GetCollaboraDictionaries(),
|
||||
|
|
|
|||
|
|
@ -67,12 +67,12 @@ readonly class ConfigurationController {
|
|||
}
|
||||
|
||||
if (isset($request->getParsedBody()['delete_timezone'])) {
|
||||
$this->configurationManager->DeleteTimezone();
|
||||
$this->configurationManager->deleteTimezone();
|
||||
}
|
||||
|
||||
if (isset($request->getParsedBody()['timezone'])) {
|
||||
$timezone = $request->getParsedBody()['timezone'] ?? '';
|
||||
$this->configurationManager->SetTimezone($timezone);
|
||||
$this->configurationManager->timezone = $timezone;
|
||||
}
|
||||
|
||||
if (isset($request->getParsedBody()['options-form'])) {
|
||||
|
|
|
|||
|
|
@ -124,6 +124,18 @@ class ConfigurationManager
|
|||
set { $this->set('borg_restore_password', $value); }
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidSettingConfigurationException
|
||||
*/
|
||||
public string $timezone {
|
||||
get => $this->get('timezone', '');
|
||||
set {
|
||||
// This throws an exception if the validation fails.
|
||||
$this->validateTimezone($value);
|
||||
$this->set('timezone', $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function GetConfig() : array
|
||||
{
|
||||
if ($this->config === [] && file_exists(DataConst::GetConfigFile()))
|
||||
|
|
@ -784,19 +796,10 @@ class ConfigurationManager
|
|||
return false;
|
||||
}
|
||||
|
||||
public function GetTimezone() : string {
|
||||
$config = $this->GetConfig();
|
||||
if(!isset($config['timezone'])) {
|
||||
$config['timezone'] = '';
|
||||
}
|
||||
|
||||
return $config['timezone'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidSettingConfigurationException
|
||||
*/
|
||||
public function SetTimezone(string $timezone) : void {
|
||||
private function validateTimezone(string $timezone) : void {
|
||||
if ($timezone === "") {
|
||||
throw new InvalidSettingConfigurationException("The timezone must not be empty!");
|
||||
}
|
||||
|
|
@ -804,16 +807,13 @@ class ConfigurationManager
|
|||
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);
|
||||
/**
|
||||
* Provide an extra method since our `timezone` attribute setter prevents setting an empty timezone.
|
||||
*/
|
||||
public function deleteTimezone() : void {
|
||||
$this->set('timezone', '');
|
||||
}
|
||||
|
||||
public function shouldDomainValidationBeSkipped(bool $skipDomainValidation) : bool {
|
||||
|
|
|
|||
|
|
@ -577,7 +577,7 @@ readonly class DockerActionManager {
|
|||
'COLLABORA_ENABLED' => $this->configurationManager->isCollaboraEnabled ? 'yes' : '',
|
||||
'TALK_ENABLED' => $this->configurationManager->isTalkEnabled ? 'yes' : '',
|
||||
'UPDATE_NEXTCLOUD_APPS' => ($this->configurationManager->isDailyBackupRunning() && $this->configurationManager->areAutomaticUpdatesEnabled()) ? 'yes' : '',
|
||||
'TIMEZONE' => $this->configurationManager->GetTimezone() === '' ? 'Etc/UTC' : $this->configurationManager->GetTimezone(),
|
||||
'TIMEZONE' => $this->configurationManager->timezone === '' ? 'Etc/UTC' : $this->configurationManager->timezone,
|
||||
'COLLABORA_DICTIONARIES' => $this->configurationManager->GetCollaboraDictionaries() === '' ? 'de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru' : $this->configurationManager->GetCollaboraDictionaries(),
|
||||
'IMAGINARY_ENABLED' => $this->configurationManager->isImaginaryEnabled ? 'yes' : '',
|
||||
'FULLTEXTSEARCH_ENABLED' => $this->configurationManager->isFulltextsearchEnabled ? 'yes' : '',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue