Skip to content

Commit

Permalink
Merge pull request #10 from ONLYOFFICE/develop
Browse files Browse the repository at this point in the history
Release/2.0.4
  • Loading branch information
LinneyS authored Sep 11, 2018
2 parents 038d9e7 + fcba6d7 commit 6738c68
Show file tree
Hide file tree
Showing 18 changed files with 179 additions and 108 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## 2.0.4
## Added
- opening for editing not OOXML

## Changed
- different keys for a file from different instances
- replace hash generator to JWT

## 2.0.2
## Changed
- deleted unsupported methods
Expand Down
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,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>2.0.2</version>
<version>2.0.4</version>
<namespace>Onlyoffice</namespace>
<types>
<filesystem/>
Expand All @@ -30,7 +30,7 @@
<screenshot>https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-nextcloud/master/screenshots/new.png</screenshot>
<screenshot>https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-nextcloud/master/screenshots/open.png</screenshot>
<dependencies>
<nextcloud min-version="12" max-version="14"/>
<nextcloud min-version="13" max-version="14"/>
</dependencies>
<settings>
<admin>OCA\Onlyoffice\AdminSettings</admin>
Expand Down
4 changes: 2 additions & 2 deletions controller/callbackcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,10 @@ public function track($doc, $users, $key, $status, $url) {
$key = DocumentService::GenerateRevisionId($fileId . $url);

try {
$this->logger->debug("GetConvertedUri from " . $downloadExt . " to " . $curExt . " " . $url, array("app" => $this->appName));
$this->logger->debug("Converted from " . $downloadExt . " to " . $curExt, array("app" => $this->appName));
$url = $documentService->GetConvertedUri($url, $downloadExt, $curExt, $key);
} catch (\Exception $e) {
$this->logger->error("GetConvertedUri on save error: " . $e->getMessage(), array("app" => $this->appName));
$this->logger->error("Converted on save error: " . $e->getMessage(), array("app" => $this->appName));
return new JSONResponse(["message" => $e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR);
}
}
Expand Down
41 changes: 25 additions & 16 deletions controller/editorcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ private function getTemplatePath($lang, $ext) {
public function convert($fileId) {
$this->logger->debug("Convert: " . $fileId, array("app" => $this->appName));

list ($file, $error) = $this->getFile($fileId);
$userId = $this->userSession->getUser()->getUID();
list ($file, $error) = $this->getFile($userId, $fileId);

if (isset($error)) {
$this->logger->error("Convertion: " . $fileId . " " . $error, array("app" => $this->appName));
Expand All @@ -253,13 +254,13 @@ public function convert($fileId) {

$fileName = $file->getName();
$ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
$format = $this->config->formats[$ext];
$format = $this->config->FormatsSetting()[$ext];
if (!isset($format)) {
$this->logger->info("Format for convertion not supported: " . $fileName, array("app" => $this->appName));
return ["error" => $this->trans->t("Format is not supported")];
}

if (!isset($format["conv"]) || $format["conv"] !== TRUE) {
if (!isset($format["conv"]) || $format["conv"] !== true) {
$this->logger->info("Conversion is not required: " . $fileName, array("app" => $this->appName));
return ["error" => $this->trans->t("Conversion is not required")];
}
Expand All @@ -286,7 +287,6 @@ public function convert($fileId) {
return ["error" => $e->getMessage()];
}

$userId = $this->userSession->getUser()->getUID();
$folder = $file->getParent();
if (!$folder->isCreatable()) {
$folder = $this->root->getUserFolder($userId);
Expand All @@ -299,7 +299,7 @@ public function convert($fileId) {

$newFilePath = $newFolderPath . DIRECTORY_SEPARATOR . $newFileName;

if (($newData = $documentService->Request($newFileUri)) === FALSE) {
if (($newData = $documentService->Request($newFileUri)) === false) {
$this->logger->error("Failed to download converted file: " . $newFileUri, array("app" => $this->appName));
return ["error" => $this->trans->t("Failed to download converted file")];
}
Expand Down Expand Up @@ -399,7 +399,13 @@ public function PublicPage($fileId, $token) {
*/
public function config($fileId, $token = NULL) {

list ($file, $error) = empty($token) ? $this->getFile($fileId) : $this->getFileByToken($fileId, $token);
$user = $this->userSession->getUser();
$userId = NULL;
if (!empty($user)) {
$userId = $user->getUID();
}

list ($file, $error) = empty($token) ? $this->getFile($userId, $fileId) : $this->getFileByToken($fileId, $token);

if (isset($error)) {
$this->logger->error("Config: " . $fileId . " " . $error, array("app" => $this->appName));
Expand All @@ -408,7 +414,7 @@ public function config($fileId, $token = NULL) {

$fileName = $file->getName();
$ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
$format = $this->config->formats[$ext];
$format = $this->config->FormatsSetting()[$ext];
if (!isset($format)) {
$this->logger->info("Format is not supported for editing: " . $fileName, array("app" => $this->appName));
return ["error" => $this->trans->t("Format is not supported")];
Expand Down Expand Up @@ -457,12 +463,6 @@ public function config($fileId, $token = NULL) {
$params["editorConfig"]["mode"] = "view";
}

$user = $this->userSession->getUser();
$userId = NULL;
if (!empty($user)) {
$userId = $user->getUID();
}

if (!empty($userId)) {
$params["editorConfig"]["user"] = [
"id" => $userId,
Expand Down Expand Up @@ -503,16 +503,23 @@ public function config($fileId, $token = NULL) {
/**
* Getting file by identifier
*
* @param integer $userId - user identifier
* @param integer $fileId - file identifier
*
* @return array
*/
private function getFile($fileId) {
private function getFile($userId, $fileId) {
if (empty($fileId)) {
return [NULL, $this->trans->t("FileId is empty")];
}

$files = $this->root->getById($fileId);
if ($userId !== NULL) {
$files = $this->root->getUserFolder($userId)->getById($fileId);
} else {
$this->logger->debug("getFile by unknown user: " . $fileId, array("app" => $this->appName));
$files = $this->root->getById($fileId);
}

if (empty($files)) {
return [NULL, $this->trans->t("File not found")];
}
Expand Down Expand Up @@ -600,9 +607,11 @@ private function getShare($token) {
* @return string
*/
private function getKey($file) {
$instanceId = $this->config->getSystemValue("instanceid", true);

$fileId = $file->getId();

$key = $fileId . "_" . $file->getMtime();
$key = $instanceId . "_" . $fileId . "_" . $file->getMtime();

return $key;
}
Expand Down
28 changes: 5 additions & 23 deletions controller/settingscontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function index() {
"storageUrl" => $this->config->GetStorageUrl(),
"secret" => $this->config->GetDocumentServerSecret(),
"currentServer" => $this->urlGenerator->getAbsoluteURL("/"),
"formats" => $this->formats(),
"formats" => $this->config->FormatsSetting(),
"sameTab" => $this->config->GetSameTab(),
"encryption" => $this->checkEncryptionModule()
];
Expand All @@ -142,6 +142,7 @@ public function SaveSettings($documentserver,
$storageUrl,
$secret,
$defFormats,
$editFormats,
$sameTab
) {
$this->config->SetDocumentServerUrl($documentserver);
Expand All @@ -158,6 +159,7 @@ public function SaveSettings($documentserver,
$this->config->DropSKey();

$this->config->SetDefaultFormats($defFormats);
$this->config->SetEditableFormats($editFormats);
$this->config->SetSameTab($sameTab);

if ($this->checkEncryptionModule()) {
Expand All @@ -183,32 +185,12 @@ public function SaveSettings($documentserver,
*/
public function GetSettings() {
$result = [
"formats" => $this->formats(),
"formats" => $this->config->FormatsSetting(),
"sameTab" => $this->config->GetSameTab()
];
return $result;
}

/**
* Get supported formats
*
* @return array
*
* @NoAdminRequired
*/
private function formats() {
$result = $this->config->formats;

$defFormats = $this->config->GetDefaultFormats();
foreach ($defFormats as $format => $setting) {
if (array_key_exists($format, $result)) {
$result[$format]["def"] = ($setting === true || $setting === "true");
}
}

return $result;
}


/**
* Checking document service location
Expand Down Expand Up @@ -285,7 +267,7 @@ private function checkDocServiceUrl() {
}

try {
if ($documentService->Request($convertedFileUri) === FALSE) {
if ($documentService->Request($convertedFileUri) === false) {
throw new \Exception($this->trans->t("Error occurred in the document service"));
}
} catch (\Exception $e) {
Expand Down
6 changes: 6 additions & 0 deletions js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
defFormats[this.name] = this.checked;
});

var editFormats = {};
$("input[id^=\"onlyofficeEditFormat\"]").each(function() {
editFormats[this.name] = this.checked;
});

var sameTab = $("#onlyofficeSameTab").is(":checked");

$.ajax({
Expand All @@ -78,6 +83,7 @@
storageUrl: onlyofficeStorageUrl,
secret: onlyofficeSecret,
defFormats: defFormats,
editFormats: editFormats,
sameTab: sameTab
},
success: function onSuccess(response) {
Expand Down
4 changes: 3 additions & 1 deletion l10n/de.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
OC.L10N.register(
OC.L10N.register(
"onlyoffice",
{
"Access deny" : "Zugriff verweigern",
Expand Down Expand Up @@ -42,6 +42,8 @@
"Secret key (leave blank to disable)" : "Geheimer Schlüssel (freilassen, um zu deaktivieren)",
"Open file in the same tab" : "Datei in der gleichen Registerkarte öffnen",
"The default application for opening the format" : "Die Standardanwendung zum Öffnen des Formats",
"Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Öffne die Datei zum Bearbeiten (aufgrund von Formateinschränkungen können die Daten beim Speichern in den Formaten aus der folgenden Liste verloren gehen)",
"View details" : "Details anzeigen",
"Save" : "Speichern",
"Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Mixed Active Content ist nicht möglich. HTTPS-Adresse für Document Server ist erforderlich."
},
Expand Down
4 changes: 3 additions & 1 deletion l10n/de.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ "translations": {
{ "translations": {
"Access deny" : "Zugriff verweigern",
"Invalid request" : "Ungültige Anfrage",
"Files not found" : "Dateien nicht gefunden",
Expand Down Expand Up @@ -40,6 +40,8 @@
"Secret key (leave blank to disable)" : "Geheimer Schlüssel (freilassen, um zu deaktivieren)",
"Open file in the same tab" : "Datei in der gleichen Registerkarte öffnen",
"The default application for opening the format" : "Die Standardanwendung zum Öffnen des Formats",
"Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Öffne die Datei zum Bearbeiten (aufgrund von Formateinschränkungen können die Daten beim Speichern in den Formaten aus der folgenden Liste verloren gehen)",
"View details" : "Details anzeigen",
"Save" : "Speichern",
"Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Mixed Active Content ist nicht möglich. HTTPS-Adresse für Document Server ist erforderlich."
},"pluralForm" :"nplurals=2; plural=(n != 1);"
Expand Down
2 changes: 2 additions & 0 deletions l10n/de_DE.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ OC.L10N.register(
"Secret key (leave blank to disable)" : "Geheimer Schlüssel (freilassen, um zu deaktivieren)",
"Open file in the same tab" : "Datei in der gleichen Registerkarte öffnen",
"The default application for opening the format" : "Die Standardanwendung zum Öffnen des Formats",
"Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Öffnen Sie die Datei zum Bearbeiten (aufgrund von Formateinschränkungen können die Daten beim Speichern in den Formaten aus der folgenden Liste verloren gehen)",
"View details" : "Details anzeigen",
"Save" : "Speichern",
"Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Mixed Active Content ist nicht möglich. HTTPS-Adresse für Document Server ist erforderlich."
},
Expand Down
2 changes: 2 additions & 0 deletions l10n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
"Secret key (leave blank to disable)" : "Geheimer Schlüssel (freilassen, um zu deaktivieren)",
"Open file in the same tab" : "Datei in der gleichen Registerkarte öffnen",
"The default application for opening the format" : "Die Standardanwendung zum Öffnen des Formats",
"Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Öffnen Sie die Datei zum Bearbeiten (aufgrund von Formateinschränkungen können die Daten beim Speichern in den Formaten aus der folgenden Liste verloren gehen)",
"View details" : "Details anzeigen",
"Save" : "Speichern",
"Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Mixed Active Content ist nicht möglich. HTTPS-Adresse für Document Server ist erforderlich."
},"pluralForm" :"nplurals=2; plural=(n != 1);"
Expand Down
2 changes: 2 additions & 0 deletions l10n/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ OC.L10N.register(
"Secret key (leave blank to disable)" : "Clave secreta (deje en blanco o desactive)",
"Open file in the same tab" : "Abrir archivo en la misma pestaña",
"The default application for opening the format" : "La aplicación predeterminada para abrir el formato",
"Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Abrir archivo para editar (debido a las restricciones de formato los datos podrían perderse al guardar en los formatos de la siguiente lista)",
"View details" : "Ver detalles",
"Save" : "Guardar",
"Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Contenido Mixto Activo no está permitido. Se requiere la dirección HTTPS para Servidor de Documentos."
},
Expand Down
2 changes: 2 additions & 0 deletions l10n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
"Secret key (leave blank to disable)" : "Clave secreta (deje en blanco o desactive)",
"Open file in the same tab" : "Abrir archivo en la misma pestaña",
"The default application for opening the format" : "La aplicación predeterminada para abrir el formato",
"Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Abrir archivo para editar (debido a las restricciones de formato los datos podrían perderse al guardar en los formatos de la siguiente lista)",
"View details" : "Ver detalles",
"Save" : "Guardar",
"Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Contenido Mixto Activo no está permitido. Se requiere la dirección HTTPS para Servidor de Documentos."
},"pluralForm" :"nplurals=2; plural=(n != 1);"
Expand Down
2 changes: 2 additions & 0 deletions l10n/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ OC.L10N.register(
"Secret key (leave blank to disable)" : "Секретный ключ (оставьте пустым для отключения)",
"Open file in the same tab" : "Открыть файл в той же вкладке",
"The default application for opening the format" : "Приложение по умолчанию для открытия формата",
"Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Открыть файл на редактирование (из-за ограничений формата данные могут быть утеряны при сохранении в форматы из списка ниже)",
"View details" : "Подробнее",
"Save" : "Сохранить",
"Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Смешанное активное содержимое запрещено. Для Сервера документов необходимо использовать HTTPS-адрес."
},
Expand Down
2 changes: 2 additions & 0 deletions l10n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
"Secret key (leave blank to disable)" : "Секретный ключ (оставьте пустым для отключения)",
"Open file in the same tab" : "Открыть файл в той же вкладке",
"The default application for opening the format" : "Приложение по умолчанию для открытия формата",
"Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Открыть файл на редактирование (из-за ограничений формата данные могут быть утеряны при сохранении в форматы из списка ниже)",
"View details" : "Подробнее",
"Save" : "Сохранить",
"Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Смешанное активное содержимое запрещено. Для Сервера документов необходимо использовать HTTPS-адрес."
},"pluralForm" :"nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);"
Expand Down
Loading

0 comments on commit 6738c68

Please sign in to comment.