urlGenerator = $urlGenerator; $this->trans = $trans; $this->logger = $logger; $this->config = $config; $this->crypt = $crypt; } /** * Print config section * * @return TemplateResponse */ public function index() { $data = [ "documentserver" => $this->config->GetDocumentServerUrl(true), "documentserverInternal" => $this->config->GetDocumentServerInternalUrl(true), "storageUrl" => $this->config->GetStorageUrl(), "verifyPeerOff" => $this->config->GetVerifyPeerOff(), "secret" => $this->config->GetDocumentServerSecret(true), "demo" => $this->config->GetDemoData(), "currentServer" => $this->urlGenerator->getAbsoluteURL("/"), "formats" => $this->config->FormatsSetting(), "sameTab" => $this->config->GetSameTab(), "preview" => $this->config->GetPreview(), "versionHistory" => $this->config->GetVersionHistory(), "limitGroups" => $this->config->GetLimitGroups(), "chat" => $this->config->GetCustomizationChat(), "compactHeader" => $this->config->GetCustomizationCompactHeader(), "feedback" => $this->config->GetCustomizationFeedback(), "forcesave" => $this->config->GetCustomizationForcesave(), "help" => $this->config->GetCustomizationHelp(), "toolbarNoTabs" => $this->config->GetCustomizationToolbarNoTabs(), "successful" => $this->config->SettingsAreSuccessful(), "watermark" => $this->config->GetWatermarkSettings(), "tagsEnabled" => App::isEnabled("systemtags"), "reviewDisplay" => $this->config->GetCustomizationReviewDisplay(), "templates" => $this->GetGlobalTemplates() ]; return new TemplateResponse($this->appName, "settings", $data, "blank"); } /** * Save address settings * * @param string $documentserver - document service address * @param string $documentserverInternal - document service address available from Nextcloud * @param string $storageUrl - Nextcloud address available from document server * @param bool $verifyPeerOff - parameter verification setting * @param string $secret - secret key for signature * @param bool $demo - use demo server * * @return array */ public function SaveAddress($documentserver, $documentserverInternal, $storageUrl, $verifyPeerOff, $secret, $demo ) { $error = null; if (!$this->config->SelectDemo($demo === true)) { $error = $this->trans->t("The 30-day test period is over, you can no longer connect to demo ONLYOFFICE Docs server."); } if ($demo !== true) { $this->config->SetDocumentServerUrl($documentserver); $this->config->SetVerifyPeerOff($verifyPeerOff); $this->config->SetDocumentServerInternalUrl($documentserverInternal); $this->config->SetDocumentServerSecret($secret); } $this->config->SetStorageUrl($storageUrl); $version = null; if (empty($error)) { $documentserver = $this->config->GetDocumentServerUrl(); if (!empty($documentserver)) { $documentService = new DocumentService($this->trans, $this->config); list ($error, $version) = $documentService->checkDocServiceUrl($this->urlGenerator, $this->crypt); $this->config->SetSettingsError($error); } } return [ "documentserver" => $this->config->GetDocumentServerUrl(true), "verifyPeerOff" => $this->config->GetVerifyPeerOff(), "documentserverInternal" => $this->config->GetDocumentServerInternalUrl(true), "storageUrl" => $this->config->GetStorageUrl(), "secret" => $this->config->GetDocumentServerSecret(true), "error" => $error, "version" => $version, ]; } /** * Save common settings * * @param array $defFormats - formats array with default action * @param array $editFormats - editable formats array * @param bool $sameTab - open in the same tab * @param bool $preview - generate preview files * @param bool $versionHistory - keep version history * @param array $limitGroups - list of groups * @param bool $chat - display chat * @param bool $compactHeader - display compact header * @param bool $feedback - display feedback * @param bool $forcesave - forcesave * @param bool $help - display help * @param bool $toolbarNoTabs - display toolbar tab * @param string $reviewDisplay - review viewing mode * * @return array */ public function SaveCommon($defFormats, $editFormats, $sameTab, $preview, $versionHistory, $limitGroups, $chat, $compactHeader, $feedback, $forcesave, $help, $toolbarNoTabs, $reviewDisplay ) { $this->config->SetDefaultFormats($defFormats); $this->config->SetEditableFormats($editFormats); $this->config->SetSameTab($sameTab); $this->config->SetPreview($preview); $this->config->SetVersionHistory($versionHistory); $this->config->SetLimitGroups($limitGroups); $this->config->SetCustomizationChat($chat); $this->config->SetCustomizationCompactHeader($compactHeader); $this->config->SetCustomizationFeedback($feedback); $this->config->SetCustomizationForcesave($forcesave); $this->config->SetCustomizationHelp($help); $this->config->SetCustomizationToolbarNoTabs($toolbarNoTabs); $this->config->SetCustomizationReviewDisplay($reviewDisplay); return [ ]; } /** * Save watermark settings * * @param array $settings - watermark settings * * @return array */ public function SaveWatermark($settings) { if ($settings["enabled"] === "true") { $settings["text"] = trim($settings["text"]); if (empty($settings["text"])) { $settings["text"] = $this->trans->t("DO NOT SHARE THIS") . " {userId} {date}"; } } $this->config->SetWatermarkSettings($settings); return [ ]; } /** * Clear all version history * * @return array */ public function ClearHistory() { FileVersions::clearHistory(); return [ ]; } /** * Get app settings * * @return array * * @NoAdminRequired * @PublicPage */ public function GetSettings() { $result = [ "formats" => $this->config->FormatsSetting(), "sameTab" => $this->config->GetSameTab() ]; return $result; } /** * Get global templates * * @return array */ private function GetGlobalTemplates() { $templates = []; $templatesList = TemplateManager::GetGlobalTemplates(); foreach ($templatesList as $templatesItem) { $template = [ "id" => $templatesItem->getId(), "name" => $templatesItem->getName(), "type" => TemplateManager::GetTypeTemplate($templatesItem->getMimeType()) ]; array_push($templates, $template); } return $templates; } }