diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e8d4b01..06e7cf99 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 17ad0f54..caef6e5f 100644 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -1,7 +1,7 @@ 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 @@ function() { $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 c455b88e..811ae8a8 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -6,7 +6,7 @@ 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. agpl Ascensio System SIA - 4.1.1 + 4.1.2 Onlyoffice diff --git a/appinfo/routes.php b/appinfo/routes.php index 5a8a894d..89c80423 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -1,7 +1,7 @@ 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 fd562578..adbca486 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -1,7 +1,7 @@ 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 @@ private function getWatermarkText($isPublic, $userId, $file, $canEdit, $canDownl } } } 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 a3117cb9..36c9f501 100644 --- a/controller/federationcontroller.php +++ b/controller/federationcontroller.php @@ -1,7 +1,7 @@ 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 01dc090e..364cdf1d 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 2dbc794d..dd06eebc 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 9960534b..12ba0cc0 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 73efbe39..5452422a 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 e29dabd9..9aa95dfd 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 ab9682a6..5cb0c46d 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); } diff --git a/js/main.js b/js/main.js index 5b388f5e..b2c7cfeb 100644 --- a/js/main.js +++ b/js/main.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/settings.js b/js/settings.js index 9723587f..a2f36334 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 9156b1e1..04cb230e 100644 --- a/lib/adminsection.php +++ b/lib/adminsection.php @@ -1,7 +1,7 @@ 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 bef5c048..1fbb7cf1 100644 --- a/lib/documentservice.php +++ b/lib/documentservice.php @@ -1,7 +1,7 @@