From ac3a68c9dd32970fd9d3f90cb18bec51c8b2c5f4 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Thu, 1 Jul 2021 17:46:15 +0300 Subject: [PATCH] getting onlyoffice address from the app --- .../lib/Controller/FilesController.php | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/packages/web-integration-oc10/lib/Controller/FilesController.php b/packages/web-integration-oc10/lib/Controller/FilesController.php index f041ec9ad73..5b022d9a23a 100644 --- a/packages/web-integration-oc10/lib/Controller/FilesController.php +++ b/packages/web-integration-oc10/lib/Controller/FilesController.php @@ -141,29 +141,16 @@ private function applyCSPOnlyOffice(ContentSecurityPolicy $csp): ContentSecurity } /** - * Extracts the onlyoffice document server URL from the app-config or system-config, in the same manner - * like the onlyoffice connector app: - * - https://github.com/ONLYOFFICE/onlyoffice-owncloud/blob/34f69c833ee4b00880d538aed1ecc48025ac8791/lib/appconfig.php#L379 - * - https://github.com/ONLYOFFICE/onlyoffice-owncloud/blob/34f69c833ee4b00880d538aed1ecc48025ac8791/lib/appconfig.php#L278 + * Extracts the onlyoffice document server URL from the app * * @return string */ private function getOnlyOfficeDocumentServerUrl(): string { - $appName = 'onlyoffice'; - $documentServerKey = 'DocumentServerUrl'; - $documentServerUrl = $this->config->getAppValue($appName, $documentServerKey); - if (!empty($documentServerUrl)) { - return $documentServerUrl; - } - $documentServerUrl = $this->config->getSystemValue($documentServerKey); - if (!empty($documentServerUrl)) { - return $documentServerUrl; - } - $onlyOfficeConfig = $this->config->getSystemValue($appName); - if (\is_array($onlyOfficeConfig) && \array_key_exists($documentServerKey, $onlyOfficeConfig)) { - return $onlyOfficeConfig[$documentServerKey]; + if (!class_exists("\OCA\Onlyoffice\AppConfig")) { + return ""; } - return ""; + $onlyofficeConfig = new \OCA\Onlyoffice\AppConfig("onlyoffice"); + return $onlyofficeConfig->GetDocumentServerUrl(); } private function applyCSPRichDocuments(ContentSecurityPolicy $csp): ContentSecurityPolicy {