Skip to content

Commit

Permalink
Merge pull request #226 from ONLYOFFICE/develop
Browse files Browse the repository at this point in the history
Release/4.1.2
  • Loading branch information
LinneyS authored Jan 24, 2020
2 parents c8fc3c8 + 8a85f32 commit a7d640b
Show file tree
Hide file tree
Showing 28 changed files with 106 additions and 64 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion appinfo/app.php
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 6 additions & 3 deletions appinfo/application.php
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -80,7 +80,8 @@ function() {

$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");
}
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]" homepage="https://www.onlyoffice.com/">Ascensio System SIA</author>
<version>4.1.1</version>
<version>4.1.2</version>
<namespace>Onlyoffice</namespace>
<types>
<filesystem/>
Expand Down
2 changes: 1 addition & 1 deletion appinfo/routes.php
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 5 additions & 1 deletion controller/callbackcontroller.php
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -393,6 +393,10 @@ public function track($doc, $users, $key, $status, $url, $token) {
$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
Expand Down
45 changes: 28 additions & 17 deletions controller/editorcontroller.php
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -554,25 +554,35 @@ public function PublicPage($fileId, $shareToken, $inframe = false) {
*/
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)) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion controller/federationcontroller.php
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion controller/settingscontroller.php
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -152,6 +152,7 @@ public function SaveAddress($documentserver,
$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.");
}
Expand Down
2 changes: 1 addition & 1 deletion css/editor.css
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion css/main.css
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion css/settings.css
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion js/desktop.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion js/directeditor.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
51 changes: 33 additions & 18 deletions js/editor.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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."));
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -170,7 +179,8 @@
window.parent.postMessage({
method: "editorRequestSaveAs",
param: saveData
});
},
"*");
} else {
OC.dialogs.filepicker(t(OCA.Onlyoffice.AppName, "Save as"),
function (fileDir) {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -277,13 +289,15 @@

window.parent.postMessage({
method: "editorRequestClose"
});
},
"*");
};

OCA.Onlyoffice.onRequestSharingSettings = function() {
window.parent.postMessage({
method: "editorRequestSharingSettings"
});
},
"*");
};

OCA.Onlyoffice.onRequestCompareFile = function() {
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion js/main.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion js/settings.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/adminsection.php
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/adminsettings.php
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/appconfig.php
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/crypt.php
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading

0 comments on commit a7d640b

Please sign in to comment.