Make isCollaboraEnabled an attribute

Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
This commit is contained in:
Pablo Zmdl 2026-01-19 12:03:12 +01:00
parent 0c3d919618
commit cd1c2276e5
6 changed files with 13 additions and 23 deletions

View file

@ -112,7 +112,7 @@ $app->get('/containers', function (Request $request, Response $response, array $
'current_channel' => $dockerActionManager->GetCurrentChannel(),
'is_clamav_enabled' => $configurationManager->isClamavEnabled,
'is_onlyoffice_enabled' => $configurationManager->isOnlyofficeEnabled,
'is_collabora_enabled' => $configurationManager->isCollaboraEnabled(),
'is_collabora_enabled' => $configurationManager->isCollaboraEnabled,
'is_talk_enabled' => $configurationManager->isTalkEnabled(),
'borg_restore_password' => $configurationManager->GetBorgRestorePassword(),
'daily_backup_time' => $configurationManager->GetDailyBackupTime(),

View file

@ -64,7 +64,7 @@ readonly class ContainerDefinitionFetcher {
continue;
}
} elseif ($entry['container_name'] === 'nextcloud-aio-collabora') {
if (!$this->configurationManager->isCollaboraEnabled()) {
if (!$this->configurationManager->isCollaboraEnabled) {
continue;
}
if ($this->configurationManager->isCollaboraSubscriptionEnabled()) {
@ -176,7 +176,7 @@ readonly class ContainerDefinitionFetcher {
continue;
}
} elseif ($value === 'nextcloud-aio-collabora') {
if (!$this->configurationManager->isCollaboraEnabled()) {
if (!$this->configurationManager->isCollaboraEnabled) {
continue;
}
} elseif ($value === 'nextcloud-aio-talk') {

View file

@ -79,13 +79,13 @@ readonly class ConfigurationController {
$officeSuiteChoice = $request->getParsedBody()['office_suite_choice'] ?? '';
if ($officeSuiteChoice === 'collabora') {
$this->configurationManager->SetCollaboraEnabledState(1);
$this->configurationManager->isCollaboraEnabled = true;
$this->configurationManager->isOnlyofficeEnabled = false;
} elseif ($officeSuiteChoice === 'onlyoffice') {
$this->configurationManager->SetCollaboraEnabledState(0);
$this->configurationManager->isCollaboraEnabled = false;
$this->configurationManager->isOnlyofficeEnabled = true;
} else {
$this->configurationManager->SetCollaboraEnabledState(0);
$this->configurationManager->isCollaboraEnabled = false;
$this->configurationManager->isOnlyofficeEnabled = false;
}
$this->configurationManager->isClamavEnabled = isset($request->getParsedBody()['clamav']);

View file

@ -224,7 +224,7 @@ readonly class DockerController {
// This is a hack but no better solution was found for the meantime
// Stop Collabora first to make sure it force-saves
// See https://github.com/nextcloud/richdocuments/issues/3799
if ($id === self::TOP_CONTAINER && $this->configurationManager->isCollaboraEnabled()) {
if ($id === self::TOP_CONTAINER && $this->configurationManager->isCollaboraEnabled) {
$this->PerformRecursiveContainerStop('nextcloud-aio-collabora');
}

View file

@ -78,6 +78,11 @@ class ConfigurationManager
set { $this->set('isOnlyofficeEnabled', $value); }
}
public bool $isCollaboraEnabled {
get => $this->get('isCollaboraEnabled', true);
set { $this->set('isCollaboraEnabled', $value); }
}
public function GetConfig() : array
{
if ($this->config === [] && file_exists(DataConst::GetConfigFile()))
@ -248,21 +253,6 @@ class ConfigurationManager
$this->WriteConfig($config);
}
public function isCollaboraEnabled() : bool {
$config = $this->GetConfig();
if (isset($config['isCollaboraEnabled']) && $config['isCollaboraEnabled'] === 0) {
return false;
} else {
return true;
}
}
public function SetCollaboraEnabledState(int $value) : void {
$config = $this->GetConfig();
$config['isCollaboraEnabled'] = $value;
$this->WriteConfig($config);
}
public function isTalkEnabled() : bool {
$config = $this->GetConfig();
if (isset($config['isTalkEnabled']) && $config['isTalkEnabled'] === 0) {

View file

@ -574,7 +574,7 @@ readonly class DockerActionManager {
'CLAMAV_ENABLED' => $this->configurationManager->isClamavEnabled ? 'yes' : '',
'TALK_RECORDING_ENABLED' => $this->configurationManager->isTalkRecordingEnabled() ? 'yes' : '',
'ONLYOFFICE_ENABLED' => $this->configurationManager->isOnlyofficeEnabled ? 'yes' : '',
'COLLABORA_ENABLED' => $this->configurationManager->isCollaboraEnabled() ? 'yes' : '',
'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(),