diff options
-rw-r--r-- | CHANGELOG.md | 6 | ||||
-rw-r--r-- | appinfo/app.php | 2 | ||||
-rw-r--r-- | appinfo/application.php | 9 | ||||
-rw-r--r-- | appinfo/info.xml | 2 | ||||
-rw-r--r-- | appinfo/routes.php | 2 | ||||
-rw-r--r-- | controller/callbackcontroller.php | 6 | ||||
-rw-r--r-- | controller/editorcontroller.php | 45 | ||||
-rw-r--r-- | controller/federationcontroller.php | 2 | ||||
-rw-r--r-- | controller/settingscontroller.php | 3 | ||||
-rw-r--r-- | css/editor.css | 2 | ||||
-rw-r--r-- | css/main.css | 2 | ||||
-rw-r--r-- | css/settings.css | 2 | ||||
-rw-r--r-- | js/desktop.js | 2 | ||||
-rw-r--r-- | js/directeditor.js | 2 | ||||
-rw-r--r-- | js/editor.js | 51 | ||||
-rw-r--r-- | js/main.js | 2 | ||||
-rw-r--r-- | js/settings.js | 2 | ||||
-rw-r--r-- | lib/adminsection.php | 2 | ||||
-rw-r--r-- | lib/adminsettings.php | 2 | ||||
-rw-r--r-- | lib/appconfig.php | 2 | ||||
-rw-r--r-- | lib/crypt.php | 2 | ||||
-rw-r--r-- | lib/directeditor.php | 8 | ||||
-rw-r--r-- | lib/documentservice.php | 2 | ||||
-rw-r--r-- | lib/filecreator.php | 2 | ||||
-rw-r--r-- | lib/fileutility.php | 2 | ||||
-rw-r--r-- | lib/templatemanager.php | 2 | ||||
-rw-r--r-- | templates/editor.php | 2 | ||||
-rw-r--r-- | templates/settings.php | 2 |
28 files changed, 106 insertions, 64 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e8d4b0..06e7cf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 4.1.2 +## Changed +- fix file opening with a sidebar +- fix file opening in Nextcloud Android mobile application +- fix file opening the federated file when watermark is enabled + ## 4.1.1 ## Changed - compatible with Nextcloud 16-17 diff --git a/appinfo/app.php b/appinfo/app.php index 17ad0f5..caef6e5 100644 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/appinfo/application.php b/appinfo/application.php index 8b178c6..8e7375e 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License @@ -80,7 +80,8 @@ class Application extends App { $eventDispatcher->addListener("OCA\Files_Sharing::loadAdditionalScripts", function() { - if (!empty($this->appConfig->GetDocumentServerUrl()) && $this->appConfig->SettingsAreSuccessful()) { + if (!empty($this->appConfig->GetDocumentServerUrl()) + && $this->appConfig->SettingsAreSuccessful()) { Util::addScript("onlyoffice", "main"); Util::addStyle("onlyoffice", "main"); } @@ -131,7 +132,9 @@ class Application extends App { $eventDispatcher->addListener(RegisterDirectEditorEvent::class, function (RegisterDirectEditorEvent $event) use ($container) { - if (!empty($this->appConfig->GetDocumentServerUrl()) && $this->appConfig->SettingsAreSuccessful()) { + if (!empty($this->appConfig->GetDocumentServerUrl()) + && $this->appConfig->SettingsAreSuccessful() + && $this->appConfig->isUserAllowedToUse()) { $editor = $container->query("DirectEditor"); $event->register($editor); } diff --git a/appinfo/info.xml b/appinfo/info.xml index c455b88..811ae8a 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -6,7 +6,7 @@ <description>ONLYOFFICE connector enables you to edit Office documents within ONLYOFFICE from the familiar web interface. This will create a new Open in ONLYOFFICE action within the document library for Office documents. This allows multiple users to collaborate in real time and to save back those changes to your file storage.</description> <licence>agpl</licence> <author mail="dev@onlyoffice.com" homepage="https://www.onlyoffice.com/">Ascensio System SIA</author> - <version>4.1.1</version> + <version>4.1.2</version> <namespace>Onlyoffice</namespace> <types> <filesystem/> diff --git a/appinfo/routes.php b/appinfo/routes.php index 5a8a894..89c8042 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index 4034752..6cfd234 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License @@ -393,6 +393,10 @@ class CallbackController extends Controller { $user = $this->userManager->get($userId); if (!empty($user)) { \OC_Util::setupFS($userId); + + if ($userId === $hashData->userId) { + $filePath = $hashData->filePath; + } } else { if (empty($shareToken)) { // author of the callback link diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index fd56257..adbca48 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License @@ -554,25 +554,35 @@ class EditorController extends Controller { */ public function config($fileId, $filePath = NULL, $shareToken = NULL, $directToken = null, $inframe = 0, $desktop = false) { - if (empty($shareToken) && !$this->config->isUserAllowedToUse()) { - if (empty($directToken)) { + if (!empty($directToken)) { + list ($directData, $error) = $this->crypt->ReadHash($directToken); + if ($directData === NULL) { + $this->logger->error("Config for directEditor with empty or not correct hash: $error", array("app" => $this->appName)); return ["error" => $this->trans->t("Not permitted")]; - } else { - list ($directData, $error) = $this->crypt->ReadHash($directToken); - if ($directData === NULL) { - $this->logger->error("Config for directEditor with empty or not correct hash: $error", array("app" => $this->appName)); - return ["error" => $this->trans->t("Not permitted")]; - } - if ($directData->action !== "direct") { - $this->logger->error("Config for directEditor with other data", array("app" => $this->appName)); - return ["error" => $this->trans->t("Invalid request")]; - } + } + if ($directData->action !== "direct") { + $this->logger->error("Config for directEditor with other data", array("app" => $this->appName)); + return ["error" => $this->trans->t("Invalid request")]; + } - $fileId = $directData->fileId; - $userId = $directData->userId; - $user = $this->userManager->get($userId); + $fileId = $directData->fileId; + $userId = $directData->userId; + if ($this->userSession->isLoggedIn() + && $userId === $this->userSession->getUser()->getUID()) { + $redirectUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".editor.index", + [ + "fileId" => $fileId, + "filePath" => $filePath + ]); + return ["redirectUrl" => $redirectUrl]; } + + $user = $this->userManager->get($userId); } else { + if (empty($shareToken) && !$this->config->isUserAllowedToUse()) { + return ["error" => $this->trans->t("Not permitted")]; + } + $user = $this->userSession->getUser(); $userId = NULL; if (!empty($user)) { @@ -962,7 +972,8 @@ class EditorController extends Controller { } } } else { - if ($watermarkSettings["shareAll"] && $file->getOwner()->getUID() !== $userId) { + if ($watermarkSettings["shareAll"] + && ($file->getOwner() === null || $file->getOwner()->getUID() !== $userId)) { return $watermarkText; } if ($watermarkSettings["shareRead"] && !$canEdit) { diff --git a/controller/federationcontroller.php b/controller/federationcontroller.php index a3117cb..36c9f50 100644 --- a/controller/federationcontroller.php +++ b/controller/federationcontroller.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php index 4c70947..7292ce6 100644 --- a/controller/settingscontroller.php +++ b/controller/settingscontroller.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License @@ -152,6 +152,7 @@ class SettingsController extends Controller { $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 Document Server."); } diff --git a/css/editor.css b/css/editor.css index 01dc090..364cdf1 100644 --- a/css/editor.css +++ b/css/editor.css @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/css/main.css b/css/main.css index 2dbc794..dd06eeb 100644 --- a/css/main.css +++ b/css/main.css @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/css/settings.css b/css/settings.css index 9960534..12ba0cc 100644 --- a/css/settings.css +++ b/css/settings.css @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/js/desktop.js b/js/desktop.js index 73efbe3..5452422 100644 --- a/js/desktop.js +++ b/js/desktop.js @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/js/directeditor.js b/js/directeditor.js index e29dabd..9aa95df 100644 --- a/js/directeditor.js +++ b/js/directeditor.js @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/js/editor.js b/js/editor.js index ab9682a..5cb0c46 100644 --- a/js/editor.js +++ b/js/editor.js @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License @@ -72,17 +72,20 @@ params.push("directToken=" + encodeURIComponent(directToken)); } - var dsVersion = DocsAPI.DocEditor.version(); - var versionArray = dsVersion.split("."); - if (versionArray[0] < 5 || versionArray[1] < 5) { - if (OCA.Onlyoffice.inframe) { - window.parent.postMessage({ - method: "editorShowHeaderButton" - }); + if (OCA.Onlyoffice.inframe || directToken) { + var dsVersion = DocsAPI.DocEditor.version(); + var versionArray = dsVersion.split("."); + if (versionArray[0] < 5 || versionArray[0] == 5 && versionArray[1] < 5) { + if (OCA.Onlyoffice.inframe) { + window.parent.postMessage({ + method: "editorShowHeaderButton" + }, + "*"); + } + params.push("inframe=2"); + } else { + params.push("inframe=1"); } - params.push("inframe=2"); - } else if (OCA.Onlyoffice.inframe) { - params.push("inframe=1"); } if (OCA.Onlyoffice.Desktop) { @@ -101,6 +104,11 @@ return; } + if (config.redirectUrl) { + location.href = config.redirectUrl; + return; + } + if (config.editorConfig.tenant) { displayError(t(OCA.Onlyoffice.AppName, "You are using public demo ONLYOFFICE Document Server. Please do not store private sensitive data.")); } @@ -130,7 +138,8 @@ "onDocumentStateChange": setPageTitle, }; - if (OCA.Onlyoffice.inframe || OC.currentUser) { + if (OCA.Onlyoffice.inframe && !shareToken + || OC.currentUser) { config.events.onRequestSaveAs = OCA.Onlyoffice.onRequestSaveAs; config.events.onRequestInsertImage = OCA.Onlyoffice.onRequestInsertImage; config.events.onRequestMailMergeRecipients = OCA.Onlyoffice.onRequestMailMergeRecipients; @@ -170,7 +179,8 @@ window.parent.postMessage({ method: "editorRequestSaveAs", param: saveData - }); + }, + "*"); } else { OC.dialogs.filepicker(t(OCA.Onlyoffice.AppName, "Save as"), function (fileDir) { @@ -212,7 +222,8 @@ window.parent.postMessage({ method: "editorRequestInsertImage", param: imageMimes - }); + }, + "*"); } else { OC.dialogs.filepicker(t(OCA.Onlyoffice.AppName, "Insert image"), OCA.Onlyoffice.editorInsertImage, false, imageMimes); } @@ -245,7 +256,8 @@ window.parent.postMessage({ method: "editorRequestMailMergeRecipients", param: recipientMimes - }); + }, + "*"); } else { OC.dialogs.filepicker(t(OCA.Onlyoffice.AppName, "Select recipients"), OCA.Onlyoffice.editorSetRecipient, false, recipientMimes); } @@ -277,13 +289,15 @@ window.parent.postMessage({ method: "editorRequestClose" - }); + }, + "*"); }; OCA.Onlyoffice.onRequestSharingSettings = function() { window.parent.postMessage({ method: "editorRequestSharingSettings" - }); + }, + "*"); }; OCA.Onlyoffice.onRequestCompareFile = function() { @@ -295,7 +309,8 @@ window.parent.postMessage({ method: "editorRequestCompareFile", param: revisedMimes - }); + }, + "*"); } else { OC.dialogs.filepicker(t(OCA.Onlyoffice.AppName, "Select file to compare"), OCA.Onlyoffice.editorSetRevised, false, revisedMimes); } @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/js/settings.js b/js/settings.js index 9723587..a2f3633 100644 --- a/js/settings.js +++ b/js/settings.js @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/lib/adminsection.php b/lib/adminsection.php index 9156b1e..04cb230 100644 --- a/lib/adminsection.php +++ b/lib/adminsection.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/lib/adminsettings.php b/lib/adminsettings.php index 7d84c14..7d6155b 100644 --- a/lib/adminsettings.php +++ b/lib/adminsettings.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/lib/appconfig.php b/lib/appconfig.php index 2560b6f..88a101e 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/lib/crypt.php b/lib/crypt.php index 5ee6fe2..ccece98 100644 --- a/lib/crypt.php +++ b/lib/crypt.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/lib/directeditor.php b/lib/directeditor.php index 7d73ff7..601e71a 100644 --- a/lib/directeditor.php +++ b/lib/directeditor.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License @@ -225,13 +225,15 @@ class DirectEditor implements IEditor { ]); $filePath = $file->getPath(); - $filePath = preg_replace("/^" . $userId . "/", "", $filePath); + $filePath = preg_replace("/^\/" . $userId . "\/files/", "", $filePath); + $params = [ "documentServerUrl" => $documentServerUrl, "fileId" => null, "filePath" => $filePath, "shareToken" => null, - "directToken" => $directToken + "directToken" => $directToken, + "inframe" => false ]; $response = new TemplateResponse($this->appName, "editor", $params, "base"); diff --git a/lib/documentservice.php b/lib/documentservice.php index bef5c04..1fbb7cf 100644 --- a/lib/documentservice.php +++ b/lib/documentservice.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/lib/filecreator.php b/lib/filecreator.php index 85c0a69..31c18e8 100644 --- a/lib/filecreator.php +++ b/lib/filecreator.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/lib/fileutility.php b/lib/fileutility.php index 36cee28..75606b1 100644 --- a/lib/fileutility.php +++ b/lib/fileutility.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/lib/templatemanager.php b/lib/templatemanager.php index 71ad53d..b9c0911 100644 --- a/lib/templatemanager.php +++ b/lib/templatemanager.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/templates/editor.php b/templates/editor.php index a9642dd..17fac75 100644 --- a/templates/editor.php +++ b/templates/editor.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License diff --git a/templates/settings.php b/templates/settings.php index fe1032c..ba816e1 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -1,7 +1,7 @@ <?php /** * - * (c) Copyright Ascensio System SIA 2019 + * (c) Copyright Ascensio System SIA 2020 * * This program is a free software product. * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License |