Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ONLYOFFICE/onlyoffice-nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Linnik <sergey.linnik@onlyoffice.com>2017-04-28 17:53:44 +0300
committerSergey Linnik <sergey.linnik@onlyoffice.com>2017-05-02 13:55:16 +0300
commitefe40e50afad5f1668da1f9de9b941777962ffe2 (patch)
tree2ce86346ae31c50b4857b3836df9c06697164821
parenta78f156d8acbd8a13a697c136bfd9401355178d1 (diff)
saving storage url
-rw-r--r--appinfo/application.php1
-rw-r--r--controller/settingscontroller.php19
-rw-r--r--js/settings.js10
-rw-r--r--lib/appconfig.php46
-rw-r--r--templates/settings.php3
5 files changed, 72 insertions, 7 deletions
diff --git a/appinfo/application.php b/appinfo/application.php
index 23e2fd0..ed2a5ab 100644
--- a/appinfo/application.php
+++ b/appinfo/application.php
@@ -99,6 +99,7 @@ class Application extends App {
return new SettingsController(
$c->query("AppName"),
$c->query("Request"),
+ $c->query("ServerContainer")->getURLGenerator(),
$c->query("L10N"),
$c->query("Logger"),
$this->appConfig
diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php
index 2e57169..f3ed79d 100644
--- a/controller/settingscontroller.php
+++ b/controller/settingscontroller.php
@@ -31,6 +31,7 @@ use OCP\AppFramework\Http\TemplateResponse;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
+use OCP\IURLGenerator;
use OCA\Onlyoffice\AppConfig;
use OCA\Onlyoffice\DocumentService;
@@ -62,20 +63,30 @@ class SettingsController extends Controller {
private $config;
/**
+ * Url generator service
+ *
+ * @var IURLGenerator
+ */
+ private $urlGenerator;
+
+ /**
* @param string $AppName - application name
* @param IRequest $request - request object
+ * @param IURLGenerator $urlGenerator - url generator service
* @param IL10N $trans - l10n service
* @param ILogger $logger - logger
* @param OCA\Onlyoffice\AppConfig $config - application configuration
*/
public function __construct($AppName,
IRequest $request,
+ IURLGenerator $urlGenerator,
IL10N $trans,
ILogger $logger,
AppConfig $config
) {
parent::__construct($AppName, $request);
+ $this->urlGenerator = $urlGenerator;
$this->trans = $trans;
$this->logger = $logger;
$this->config = $config;
@@ -90,7 +101,9 @@ class SettingsController extends Controller {
$data = [
"documentserver" => $this->config->GetDocumentServerUrl(),
"documentserverInternal" => $this->config->GetDocumentServerInternalUrl(true),
- "secret" => $this->config->GetDocumentServerSecret()
+ "storageUrl" => $this->config->GetStorageUrl(),
+ "secret" => $this->config->GetDocumentServerSecret(),
+ "currentServer" => $this->urlGenerator->getAbsoluteURL("/")
];
return new TemplateResponse($this->appName, "settings", $data, "blank");
}
@@ -103,9 +116,10 @@ class SettingsController extends Controller {
*
* @return array
*/
- public function settings($documentserver, $documentserverInternal, $secret) {
+ public function settings($documentserver, $documentserverInternal, $storageUrl, $secret) {
$this->config->SetDocumentServerUrl($documentserver);
$this->config->SetDocumentServerInternalUrl($documentserverInternal);
+ $this->config->SetStorageUrl($storageUrl);
$this->config->SetDocumentServerSecret($secret);
$documentserver = $this->config->GetDocumentServerUrl();
@@ -116,6 +130,7 @@ class SettingsController extends Controller {
return [
"documentserver" => $this->config->GetDocumentServerUrl(),
"documentserverInternal" => $this->config->GetDocumentServerInternalUrl(true),
+ "storageUrl" => $this->config->GetStorageUrl(),
"secret" => $this->config->GetDocumentServerSecret(),
"error" => $error
];
diff --git a/js/settings.js b/js/settings.js
index 759e480..0effabc 100644
--- a/js/settings.js
+++ b/js/settings.js
@@ -39,7 +39,8 @@
};
if ($("#onlyofficeInternalUrl").val().length
- || $("#onlyofficeSecret").val().length) {
+ || $("#onlyofficeSecret").val().length
+ || $("#onlyofficeStorageUrl").val().length) {
advToogle(false);
}
@@ -51,11 +52,12 @@
var onlyofficeUrl = $("#onlyofficeUrl").val().trim();
if (!onlyofficeUrl.length) {
- $("#onlyofficeInternalUrl, #onlyofficeSecret").val("");
+ $("#onlyofficeInternalUrl, #onlyofficeStorageUrl, #onlyofficeSecret").val("");
}
- var onlyofficeSecret = $("#onlyofficeSecret:visible").val() || "";
var onlyofficeInternalUrl = ($("#onlyofficeInternalUrl:visible").val() || "").trim();
+ var onlyofficeStorageUrl = ($("#onlyofficeStorageUrl:visible").val() || "").trim();
+ var onlyofficeSecret = $("#onlyofficeSecret:visible").val() || "";
$.ajax({
method: "PUT",
@@ -63,12 +65,14 @@
data: {
documentserver: onlyofficeUrl,
documentserverInternal: onlyofficeInternalUrl,
+ storageUrl: onlyofficeStorageUrl,
secret: onlyofficeSecret
},
success: function onSuccess(response) {
if (response && response.documentserver != null) {
$("#onlyofficeUrl").val(response.documentserver);
$("#onlyofficeInternalUrl").val(response.documentserverInternal);
+ $("#onlyofficeStorageUrl").val(response.storageUrl);
$("#onlyofficeSecret").val(response.secret);
var message =
diff --git a/lib/appconfig.php b/lib/appconfig.php
index 6523057..dc579b0 100644
--- a/lib/appconfig.php
+++ b/lib/appconfig.php
@@ -51,6 +51,13 @@ class AppConfig {
private $predefDocumentServerInternalUrl = "";
/**
+ * Definition url on server to ownCloud
+ *
+ * @var string
+ */
+ private $predefStorageUrl = "";
+
+ /**
* Definition url on server
*
* @var string
@@ -87,13 +94,20 @@ class AppConfig {
private $_documentserver = "DocumentServerUrl";
/**
- * The config key for the document server address from ownCloud
+ * The config key for the document server address available from ownCloud
*
* @var string
*/
private $_documentserverInternal = "DocumentServerInternalUrl";
/**
+ * The config key for the ownCloud address available from document server
+ *
+ * @var string
+ */
+ private $_storageUrl = "StorageUrl";
+
+ /**
* The config key for the secret key in jwt
*
* @var string
@@ -162,7 +176,6 @@ class AppConfig {
$this->logger->info("SetDocumentServerInternalUrl: " . $documentServerInternal, array("app" => $this->appName));
$this->config->setAppValue($this->appName, $this->_documentserverInternal, $documentServerInternal);
- $this->DropSKey();
}
/**
@@ -182,6 +195,35 @@ class AppConfig {
}
/**
+ * Save the document service address available from ownCloud to the application configuration
+ *
+ * @param string $documentServer - document service address
+ */
+ public function SetStorageUrl($storageUrl) {
+ $storageUrl = strtolower(rtrim(trim($storageUrl), "/")) . "/";
+ if (strlen($storageUrl) > 0 && !preg_match("/^https?:\/\//i", $storageUrl)) {
+ $storageUrl = "http://" . $storageUrl;
+ }
+
+ $this->logger->info("SetStorageUrl: " . $storageUrl, array("app" => $this->appName));
+
+ $this->config->setAppValue($this->appName, $this->_storageUrl, $storageUrl);
+ }
+
+ /**
+ * Get the document service address available from ownCloud from the application configuration
+ *
+ * @return string
+ */
+ public function GetStorageUrl() {
+ $url = $this->config->getAppValue($this->appName, $this->_storageUrl, "");
+ if (empty($url)) {
+ $url = $this->predefStorageUrl;
+ }
+ return $url;
+ }
+
+ /**
* Save the document service secret key to the application configuration
*
* @param string $secret - secret key
diff --git a/templates/settings.php b/templates/settings.php
index aabacbe..6bbeb8b 100644
--- a/templates/settings.php
+++ b/templates/settings.php
@@ -41,6 +41,9 @@
<p class="onlyoffice-header"><?php p($l->t("Document Editing Service Address for internal requests from the server")) ?></p>
<input id="onlyofficeInternalUrl" value="<?php p($_["documentserverInternal"]) ?>" placeholder="https://<documentserver>" type="text">
+ <p class="onlyoffice-header"><?php p($l->t("Server Address for internal requests from the Document Editing Service")) ?></p>
+ <input id="onlyofficeStorageUrl" value="<?php p($_["storageUrl"]) ?>" placeholder="<?php p($_["currentServer"]) ?>" type="text">
+
<p class="onlyoffice-header"><?php p($l->t("Secret key (leave blank to disable)")) ?></p>
<input id="onlyofficeSecret" value="<?php p($_["secret"]) ?>" placeholder="secret" type="text">
</div>