Skip to content

Commit

Permalink
Merge pull request #285 from ONLYOFFICE/develop
Browse files Browse the repository at this point in the history
Release/3.0.1
  • Loading branch information
LinneyS authored Sep 11, 2019
2 parents 5a55a72 + d5e902d commit bcd4d31
Show file tree
Hide file tree
Showing 81 changed files with 651 additions and 142 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log

## 3.0.1
## Added
- "save as" to the folder
- inserting images from the folder
- Mail Merge
- connection to the demo server

## Changed
- updated files for compatibility with MS Office v2016

## 2.3.1
## Added
- editor customization
Expand Down
2 changes: 1 addition & 1 deletion appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* For details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 17-2 Elijas street, Riga, Latvia, EU, LV-1021.
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions of the Program
* must display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
Expand Down
2 changes: 1 addition & 1 deletion appinfo/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* For details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 17-2 Elijas street, Riga, Latvia, EU, LV-1021.
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions of the Program
* must display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
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>Ascensio System SIA</author>
<version>2.3.1</version>
<version>3.0.1</version>
<namespace>Onlyoffice</namespace>
<types>
<filesystem/>
Expand Down
4 changes: 3 additions & 1 deletion appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* For details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 17-2 Elijas street, Riga, Latvia, EU, LV-1021.
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions of the Program
* must display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
Expand All @@ -37,6 +37,8 @@
["name" => "editor#config", "url" => "/ajax/config/{fileId}", "verb" => "GET"],
["name" => "editor#create", "url" => "/ajax/new", "verb" => "POST"],
["name" => "editor#convert", "url" => "/ajax/convert", "verb" => "POST"],
["name" => "editor#save", "url" => "/ajax/save", "verb" => "POST"],
["name" => "editor#url", "url" => "/ajax/url", "verb" => "GET"],
["name" => "settings#save_address", "url" => "/ajax/settings/address", "verb" => "PUT"],
["name" => "settings#save_common", "url" => "/ajax/settings/common", "verb" => "PUT"],
["name" => "settings#get_settings", "url" => "/ajax/settings", "verb" => "GET"],
Expand Down
Binary file modified assets/bg_BG/new.docx
Binary file not shown.
Binary file modified assets/bg_BG/new.pptx
Binary file not shown.
Binary file modified assets/bg_BG/new.xlsx
Binary file not shown.
Binary file modified assets/cs/new.docx
Binary file not shown.
Binary file modified assets/cs/new.pptx
Binary file not shown.
Binary file modified assets/de/new.docx
Binary file not shown.
Binary file modified assets/de/new.pptx
Binary file not shown.
Binary file modified assets/de_DE/new.docx
Binary file not shown.
Binary file modified assets/de_DE/new.pptx
Binary file not shown.
Binary file modified assets/el/new.docx
Binary file not shown.
Binary file modified assets/el/new.pptx
Binary file not shown.
Binary file modified assets/en/new.docx
Binary file not shown.
Binary file modified assets/en/new.pptx
Binary file not shown.
Binary file modified assets/en/new.xlsx
Binary file not shown.
Binary file modified assets/es/new.docx
Binary file not shown.
Binary file modified assets/es/new.pptx
Binary file not shown.
Binary file modified assets/fr/new.docx
Binary file not shown.
Binary file modified assets/fr/new.pptx
Binary file not shown.
Binary file modified assets/it/new.docx
Binary file not shown.
Binary file modified assets/it/new.pptx
Binary file not shown.
Binary file modified assets/ko/new.docx
Binary file not shown.
Binary file modified assets/ko/new.pptx
Binary file not shown.
Binary file modified assets/nl/new.docx
Binary file not shown.
Binary file modified assets/nl/new.pptx
Binary file not shown.
Binary file modified assets/nl/new.xlsx
Binary file not shown.
Binary file modified assets/pl/new.docx
Binary file not shown.
Binary file modified assets/pl/new.pptx
Binary file not shown.
Binary file modified assets/pt_BR/new.docx
Binary file not shown.
Binary file modified assets/pt_BR/new.pptx
Binary file not shown.
Binary file modified assets/pt_PT/new.docx
Binary file not shown.
Binary file modified assets/pt_PT/new.pptx
Binary file not shown.
Binary file modified assets/ru/new.docx
Binary file not shown.
Binary file modified assets/ru/new.pptx
Binary file not shown.
Binary file modified assets/sv/new.docx
Binary file not shown.
Binary file modified assets/sv/new.pptx
Binary file not shown.
Binary file modified assets/sv/new.xlsx
Binary file not shown.
Binary file modified assets/zh_CN/new.docx
Binary file not shown.
Binary file modified assets/zh_CN/new.pptx
Binary file not shown.
23 changes: 4 additions & 19 deletions controller/callbackcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* For details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 17-2 Elijas street, Riga, Latvia, EU, LV-1021.
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions of the Program
* must display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
Expand Down Expand Up @@ -346,7 +346,6 @@ public function track($doc, $users, $key, $status, $url, $token) {

try {
$decodedHeader = \Firebase\JWT\JWT::decode($header, $this->config->GetDocumentServerSecret(), array("HS256"));
$this->logger->debug("Track HEADER : " . json_encode($decodedHeader), array("app" => $this->appName));

$payload = $decodedHeader->payload;
} catch (\UnexpectedValueException $e) {
Expand Down Expand Up @@ -400,25 +399,11 @@ public function track($doc, $users, $key, $status, $url, $token) {
list ($file, $error) = !empty($ownerId) ? $this->getFile($ownerId, $fileId) : $this->getFileByToken($fileId, $token);

if (isset($error)) {
$this->logger->error("track error" . $fileId ." " . $error, array("app" => $this->appName));
$this->logger->error("track error" . $fileId ." " . json_encode($error->getData()), array("app" => $this->appName));
return $error;
}

$documentServerUrl = $this->config->GetDocumentServerInternalUrl(true);
if (!empty($documentServerUrl)) {
$from = $this->config->GetDocumentServerUrl();

if (!preg_match("/^https?:\/\//i", $from)) {
$parsedUrl = parse_url($url);
$from = $parsedUrl["scheme"] . "://" . $parsedUrl["host"] . (array_key_exists("port", $parsedUrl) ? (":" . $parsedUrl["port"]) : "") . $from;
}

if ($from !== $documentServerUrl)
{
$this->logger->debug("Replace in track from " . $from . " to " . $documentServerUrl, array("app" => $this->appName));
$url = str_replace($from, $documentServerUrl, $url);
}
}
$url = $this->config->ReplaceDocumentServerUrlToInternal($url);

$fileName = $file->getName();
$curExt = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
Expand Down Expand Up @@ -453,7 +438,7 @@ public function track($doc, $users, $key, $status, $url, $token) {
break;
}

$this->logger->debug("Track: " . $fileId . " status " . $status . " result " . $error, array("app" => $this->appName));
$this->logger->debug("Track: " . $fileId . " status " . $status . " result " . $result, array("app" => $this->appName));

return new JSONResponse(["error" => $result], Http::STATUS_OK);
}
Expand Down
130 changes: 121 additions & 9 deletions controller/editorcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* For details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 17-2 Elijas street, Riga, Latvia, EU, LV-1021.
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions of the Program
* must display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
Expand Down Expand Up @@ -221,7 +221,7 @@ public function create($name, $dir, $token = NULL) {

$ext = strtolower("." . pathinfo($name, PATHINFO_EXTENSION));

$lang = \OC::$server->getL10NFactory("")->get("")->getLanguageCode();
$lang = $this->trans->getLanguageCode();

$templatePath = $this->getTemplatePath($lang, $ext);
if (!file_exists($templatePath)) {
Expand Down Expand Up @@ -365,6 +365,114 @@ public function convert($fileId, $token = NULL) {
return $result;
}

/**
* Save file to folder
*
* @param string $name - file name
* @param string $dir - folder path
* @param string $url - file url
*
* @return array
*
* @NoAdminRequired
* @PublicPage
*/
public function save($name, $dir, $url) {
$this->logger->debug("Save: " . $name, array("app" => $this->appName));

if (!$this->config->isUserAllowedToUse()) {
return ["error" => $this->trans->t("Not permitted")];
}

$userId = $this->userSession->getUser()->getUID();
$userFolder = $this->root->getUserFolder($userId);

$folder = $userFolder->get($dir);

if ($folder === NULL) {
$this->logger->error("Folder for saving file was not found: " . $dir, array("app" => $this->appName));
return ["error" => $this->trans->t("The required folder was not found")];
}
if (!$folder->isCreatable()) {
$this->logger->error("Folder for saving file without permission: " . $dir, array("app" => $this->appName));
return ["error" => $this->trans->t("You don't have enough permission to create")];
}

$url = $this->config->ReplaceDocumentServerUrlToInternal($url);

try {
$documentService = new DocumentService($this->trans, $this->config);
$newData = $documentService->Request($url);
} catch (\Exception $e) {
$this->logger->error("Failed to download file for saving: " . $url . " " . $e->getMessage(), array("app" => $this->appName));
return ["error" => $this->trans->t("Download failed")];
}

$name = $folder->getNonExistingName($name);

try {
$file = $folder->newFile($name);

$file->putContent($newData);
} catch (NotPermittedException $e) {
$this->logger->error("Can't save file: " . $name, array("app" => $this->appName));
return ["error" => $this->trans->t("Can't create file")];
}

$fileInfo = $file->getFileInfo();

$result = Helper::formatFileInfo($fileInfo);
return $result;
}

/**
* Get presigned url to file
*
* @param string $filePath - file path
*
* @return array
*
* @NoAdminRequired
*/
public function url($filePath) {
$this->logger->debug("Save: " . $name, array("app" => $this->appName));

if (!$this->config->isUserAllowedToUse()) {
return ["error" => $this->trans->t("Not permitted")];
}

$userId = $this->userSession->getUser()->getUID();
$userFolder = $this->root->getUserFolder($userId);

$file = $userFolder->get($filePath);

if ($file === NULL) {
$this->logger->error("File for generate presigned url was not found: " . $dir, array("app" => $this->appName));
return ["error" => $this->trans->t("File not found")];
}
if (!$file->isReadable()) {
$this->logger->error("Folder for saving file without permission: " . $dir, array("app" => $this->appName));
return ["error" => $this->trans->t("You do not have enough permissions to view the file")];
}

$fileName = $file->getName();
$ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
$fileId = $file->getId();
$fileUrl = $this->getUrl($fileId);

$result = [
"fileType" => $ext,
"url" => $fileUrl
];

if (!empty($this->config->GetDocumentServerSecret())) {
$token = \Firebase\JWT\JWT::encode($result, $this->config->GetDocumentServerSecret());
$result["token"] = $token;
}

return $result;
}

/**
* Print editor section
*
Expand Down Expand Up @@ -491,7 +599,7 @@ public function config($fileId, $filePath = NULL, $token = NULL, $desktop = fals
],
"documentType" => $format["type"],
"editorConfig" => [
"lang" => str_replace("_", "-", \OC::$server->getL10NFactory("")->get("")->getLanguageCode())
"lang" => str_replace("_", "-", $this->trans->getLanguageCode())
]
];

Expand Down Expand Up @@ -617,6 +725,10 @@ public function config($fileId, $filePath = NULL, $token = NULL, $desktop = fals

$params = $this->setCustomization($params);

if ($this->config->UseDemo()) {
$params["editorConfig"]["tenant"] = $this->config->GetSystemValue("instanceid", true);
}

if (!empty($this->config->GetDocumentServerSecret())) {
$token = \Firebase\JWT\JWT::encode($params, $this->config->GetDocumentServerSecret());
$params["token"] = $token;
Expand Down Expand Up @@ -765,7 +877,7 @@ private function getShare($token) {
* @return string
*/
private function getKey($file) {
$instanceId = $this->config->getSystemValue("instanceid", true);
$instanceId = $this->config->GetSystemValue("instanceid", true);

$fileId = $file->getId();

Expand Down Expand Up @@ -837,27 +949,27 @@ private function setCustomization($params) {

/* from system config */

$customer = $this->config->getSystemValue($this->config->_customization_customer);
$customer = $this->config->GetSystemValue($this->config->_customization_customer);
if (isset($customer)) {
$params["editorConfig"]["customization"]["customer"] = $customer;
}

$feedback = $this->config->getSystemValue($this->config->_customization_feedback);
$feedback = $this->config->GetSystemValue($this->config->_customization_feedback);
if (isset($feedback)) {
$params["editorConfig"]["customization"]["feedback"] = $feedback;
}

$loaderLogo = $this->config->getSystemValue($this->config->_customization_loaderLogo);
$loaderLogo = $this->config->GetSystemValue($this->config->_customization_loaderLogo);
if (isset($loaderLogo)) {
$params["editorConfig"]["customization"]["loaderLogo"] = $loaderLogo;
}

$loaderName = $this->config->getSystemValue($this->config->_customization_loaderName);
$loaderName = $this->config->GetSystemValue($this->config->_customization_loaderName);
if (isset($loaderName)) {
$params["editorConfig"]["customization"]["loaderName"] = $loaderName;
}

$logo = $this->config->getSystemValue($this->config->_customization_logo);
$logo = $this->config->GetSystemValue($this->config->_customization_logo);
if (isset($logo)) {
$params["editorConfig"]["customization"]["logo"] = $logo;
}
Expand Down
47 changes: 26 additions & 21 deletions controller/settingscontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* For details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 17-2 Elijas street, Riga, Latvia, EU, LV-1021.
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions of the Program
* must display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
Expand Down Expand Up @@ -113,10 +113,11 @@ public function __construct($AppName,
*/
public function index() {
$data = [
"documentserver" => $this->config->GetDocumentServerUrl(),
"documentserver" => $this->config->GetDocumentServerUrl(true),
"documentserverInternal" => $this->config->GetDocumentServerInternalUrl(true),
"storageUrl" => $this->config->GetStorageUrl(),
"secret" => $this->config->GetDocumentServerSecret(),
"secret" => $this->config->GetDocumentServerSecret(true),
"demo" => $this->config->GetDemoData(),
"currentServer" => $this->urlGenerator->getAbsoluteURL("/"),
"formats" => $this->config->FormatsSetting(),
"sameTab" => $this->config->GetSameTab(),
Expand All @@ -139,39 +140,43 @@ public function index() {
* @param string $documentserverInternal - document service address available from ownCloud
* @param string $storageUrl - ownCloud address available from document server
* @param string $secret - secret key for signature
* @param array $defFormats - formats array with default action
* @param array $editFormats - editable formats array
* @param bool $sameTab - open in same tab
* @param array $limitGroups - list of groups
* @param bool $demo - use demo server
*
* @return array
*/
public function SaveAddress($documentserver,
$documentserverInternal,
$storageUrl,
$secret
$secret,
$demo
) {
$this->config->SetDocumentServerUrl($documentserver);
$this->config->SetDocumentServerInternalUrl($documentserverInternal);
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.");
}
if ($demo !== true) {
$this->config->SetDocumentServerUrl($documentserver);
$this->config->SetDocumentServerInternalUrl($documentserverInternal);
$this->config->SetDocumentServerSecret($secret);
}
$this->config->SetStorageUrl($storageUrl);
$this->config->SetDocumentServerSecret($secret);

$documentserver = $this->config->GetDocumentServerUrl();
$error = NULL;
if (!empty($documentserver)) {
$error = $this->checkDocServiceUrl();
$this->config->SetSettingsError($error);
}
if (empty($error)) {
$documentserver = $this->config->GetDocumentServerUrl();
if (!empty($documentserver)) {
$error = $this->checkDocServiceUrl();
$this->config->SetSettingsError($error);
}

if ($this->config->checkEncryptionModule() === true) {
$this->logger->info("SaveSettings when encryption is enabled", array("app" => $this->appName));
if ($this->config->checkEncryptionModule() === true) {
$this->logger->info("SaveSettings when encryption is enabled", array("app" => $this->appName));
}
}

return [
"documentserver" => $this->config->GetDocumentServerUrl(),
"documentserver" => $this->config->GetDocumentServerUrl(true),
"documentserverInternal" => $this->config->GetDocumentServerInternalUrl(true),
"storageUrl" => $this->config->GetStorageUrl(),
"secret" => $this->config->GetDocumentServerSecret(),
"secret" => $this->config->GetDocumentServerSecret(true),
"error" => $error
];
}
Expand Down
Loading

0 comments on commit bcd4d31

Please sign in to comment.