add onlyoffice and allow to disable talk and collabora

Signed-off-by: szaimen <szaimen@e.mail.de>
This commit is contained in:
szaimen 2022-03-17 10:13:21 +01:00
parent 68ac85e60b
commit 1b86445b6a
15 changed files with 250 additions and 24 deletions

View file

@ -53,6 +53,18 @@ class ContainerDefinitionFetcher
if (!$this->configurationManager->isClamavEnabled()) {
continue;
}
} elseif ($entry['identifier'] === 'nextcloud-aio-onlyoffice') {
if (!$this->configurationManager->isOnlyofficeEnabled()) {
continue;
}
} elseif ($entry['identifier'] === 'nextcloud-aio-collabora') {
if (!$this->configurationManager->isCollaboraEnabled()) {
continue;
}
} elseif ($entry['identifier'] === 'nextcloud-aio-talk') {
if (!$this->configurationManager->isTalkEnabled()) {
continue;
}
}
$ports = new ContainerPorts();
@ -111,6 +123,18 @@ class ContainerDefinitionFetcher
if (!$this->configurationManager->isClamavEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-onlyoffice') {
if (!$this->configurationManager->isOnlyofficeEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-collabora') {
if (!$this->configurationManager->isCollaboraEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-talk') {
if (!$this->configurationManager->isTalkEnabled()) {
continue;
}
}
$dependsOn[] = $value;
}

View file

@ -36,11 +36,29 @@ class ConfigurationController
}
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!");
}
if (isset($request->getParsedBody()['clamav'])) {
$this->configurationManager->SetClamavEnabledState(1);
} else {
$this->configurationManager->SetClamavEnabledState(0);
}
if (isset($request->getParsedBody()['onlyoffice'])) {
$this->configurationManager->SetOnlyofficeEnabledState(1);
} else {
$this->configurationManager->SetOnlyofficeEnabledState(0);
}
if (isset($request->getParsedBody()['collabora'])) {
$this->configurationManager->SetCollaboraEnabledState(1);
} else {
$this->configurationManager->SetCollaboraEnabledState(0);
}
if (isset($request->getParsedBody()['talk'])) {
$this->configurationManager->SetTalkEnabledState(1);
} else {
$this->configurationManager->SetTalkEnabledState(0);
}
}
return $response->withStatus(201)->withHeader('Location', '/');

View file

@ -139,6 +139,51 @@ class ConfigurationManager
$this->WriteConfig($config);
}
public function isOnlyofficeEnabled() : bool {
$config = $this->GetConfig();
if (isset($config['isOnlyofficeEnabled']) && $config['isOnlyofficeEnabled'] === 1) {
return true;
} else {
return false;
}
}
public function SetOnlyofficeEnabledState(int $value) : void {
$config = $this->GetConfig();
$config['isOnlyofficeEnabled'] = $value;
$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) {
return false;
} else {
return true;
}
}
public function SetTalkEnabledState(int $value) : void {
$config = $this->GetConfig();
$config['isTalkEnabled'] = $value;
$this->WriteConfig($config);
}
/**
* @throws InvalidSettingConfigurationException
*/

View file

@ -247,6 +247,24 @@ class DockerActionManager
} else {
$replacements[1] = '';
}
} elseif ($out[1] === 'ONLYOFFICE_ENABLED') {
if ($this->configurationManager->isOnlyofficeEnabled()) {
$replacements[1] = 'yes';
} else {
$replacements[1] = '';
}
} elseif ($out[1] === 'COLLABORA_ENABLED') {
if ($this->configurationManager->isCollaboraEnabled()) {
$replacements[1] = 'yes';
} else {
$replacements[1] = '';
}
} elseif ($out[1] === 'TALK_ENABLED') {
if ($this->configurationManager->isTalkEnabled()) {
$replacements[1] = 'yes';
} else {
$replacements[1] = '';
}
} else {
$replacements[1] = $this->configurationManager->GetSecret($out[1]);
}