From 99fbb8e1d695bfa4da0de036587d9335f1d5bf3b Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Sun, 2 Sep 2018 10:55:00 +0300 Subject: fix encoding (Fixed #8) --- l10n/de.js | 2 +- l10n/de.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/l10n/de.js b/l10n/de.js index 99905c9..b35d318 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -1,4 +1,4 @@ -OC.L10N.register( +OC.L10N.register( "onlyoffice", { "Access deny" : "Zugriff verweigern", diff --git a/l10n/de.json b/l10n/de.json index bf6bd41..d5e4500 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -1,4 +1,4 @@ -{ "translations": { +{ "translations": { "Access deny" : "Zugriff verweigern", "Invalid request" : "Ungültige Anfrage", "Files not found" : "Dateien nicht gefunden", -- cgit v1.2.3 From add5c738c5a01b61a196f4c34e15f5a9f117c9ea Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 4 Sep 2018 10:34:35 +0300 Subject: boolean to lower case --- controller/editorcontroller.php | 4 ++-- controller/settingscontroller.php | 2 +- lib/appconfig.php | 2 +- lib/documentservice.php | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index de03e26..4a860a0 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -259,7 +259,7 @@ class EditorController extends Controller { 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")]; } @@ -299,7 +299,7 @@ class EditorController extends Controller { $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")]; } diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php index 44a78f6..881b3eb 100644 --- a/controller/settingscontroller.php +++ b/controller/settingscontroller.php @@ -285,7 +285,7 @@ class SettingsController extends Controller { } 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) { diff --git a/lib/appconfig.php b/lib/appconfig.php index c585ec8..75c8016 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -397,7 +397,7 @@ class AppConfig { */ public function TurnOffVerification() { $turnOff = $this->getSystemValue($this->_verification); - return $turnOff === TRUE; + return $turnOff === true; } /** diff --git a/lib/documentservice.php b/lib/documentservice.php index 621b02c..558bd79 100644 --- a/lib/documentservice.php +++ b/lib/documentservice.php @@ -90,7 +90,7 @@ class DocumentService { * @return string */ function GetConvertedUri($document_uri, $from_extension, $to_extension, $document_revision_id) { - $responceFromConvertService = $this->SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, FALSE); + $responceFromConvertService = $this->SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, false); $errorElement = $responceFromConvertService->Error; if ($errorElement->count() > 0) { @@ -268,7 +268,7 @@ class DocumentService { ) ); - if (($response = $this->Request($urlHealthcheck, $opts)) === FALSE) { + if (($response = $this->Request($urlHealthcheck, $opts)) === false) { throw new \Exception ($this->trans->t("Bad Request or timeout error")); } @@ -314,7 +314,7 @@ class DocumentService { $opts["http"]["header"] = $opts["http"]["header"] . $this->config->JwtHeader() . ": Bearer " . $token . "\r\n"; } - if (($response = $this->Request($urlCommand, $opts)) === FALSE) { + if (($response = $this->Request($urlCommand, $opts)) === false) { throw new \Exception ($this->trans->t("Bad Request or timeout error")); } @@ -371,13 +371,13 @@ class DocumentService { if (substr($url, 0, strlen("https")) === "https" && $this->config->TurnOffVerification()) { $opts["ssl"] = array( - "verify_peer" => FALSE, - "verify_peer_name" => FALSE + "verify_peer" => false, + "verify_peer_name" => false ); } $context = stream_context_create($opts); - return file_get_contents($url, FALSE, $context); + return file_get_contents($url, false, $context); } } -- cgit v1.2.3 From 94db5c292d36275ab58699860e8b3e6c9486f852 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 4 Sep 2018 11:09:45 +0300 Subject: instanceid in document key --- controller/editorcontroller.php | 4 +++- lib/appconfig.php | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 4a860a0..04f5d7a 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -600,9 +600,11 @@ class EditorController extends Controller { * @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; } diff --git a/lib/appconfig.php b/lib/appconfig.php index 75c8016..efc6668 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -178,12 +178,16 @@ class AppConfig { /** * Get value from the system configuration - * + * * @param string $key - key configuration + * @param string $system - get from root or from app section * * @return string */ - public function GetSystemValue($key) { + public function GetSystemValue($key, $system = false) { + if ($system) { + return $this->config->getSystemValue($key); + } if (!empty($this->config->getSystemValue($this->appName)) && array_key_exists($key, $this->config->getSystemValue($this->appName))) { return $this->config->getSystemValue($this->appName)[$key]; -- cgit v1.2.3 From 0f8280025e51b6a513166976e8e7eec3b3efabb8 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 4 Sep 2018 13:47:57 +0300 Subject: replace hash generator to JWT --- lib/crypt.php | 51 +++++++++++---------------------------------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/lib/crypt.php b/lib/crypt.php index b7790ff..4605df0 100644 --- a/lib/crypt.php +++ b/lib/crypt.php @@ -32,7 +32,7 @@ namespace OCA\Onlyoffice; use OCA\Onlyoffice\AppConfig; /** - * Hash generator + * Token generator * * @package OCA\Onlyoffice */ @@ -53,63 +53,34 @@ class Crypt { } /** - * Generate base64 hash for the object + * Generate token for the object * - * @param array $object - object to signature hash + * @param array $object - object to signature * * @return string */ public function GetHash($object) { - $primaryKey = json_encode($object); - $hash = $this->SignatureCreate($primaryKey); - return $hash; + return \Firebase\JWT\JWT::encode($object, $this->skey); } /** - * Create an object from the base64 hash + * Create an object from the token * - * @param string $hash - base64 hash + * @param string $token - token * * @return array */ - public function ReadHash($hash) { + public function ReadHash($token) { $result = NULL; $error = NULL; - if ($hash === NULL) { - return [$result, "hash is empty"]; + if ($token === NULL) { + return [$result, "token is empty"]; } try { - $payload = base64_decode($hash); - $payloadParts = explode("?", $payload, 2); - - if (count($payloadParts) === 2) { - $encode = base64_encode( hash( "sha256", ($payloadParts[1] . $this->skey), true ) ); - - if ($payloadParts[0] === $encode) { - $result = json_decode($payloadParts[1]); - } else { - $error = "hash not equal"; - } - } else { - $error = "incorrect hash"; - } - } catch (\Exception $e) { + $result = \Firebase\JWT\JWT::decode($token, $this->skey, array("HS256")); + } catch (\UnexpectedValueException $e) { $error = $e->getMessage(); } return [$result, $error]; } - - /** - * Generate base64 hash for the object - * - * @param string $primary_key - string to the signature hash - * - * @return string - */ - private function SignatureCreate($primary_key) { - $payload = base64_encode( hash( "sha256", ($primary_key . $this->skey), true ) ) . "?" . $primary_key; - $base64Str = base64_encode($payload); - - return $base64Str; - } } -- cgit v1.2.3 From df0a4c894d69642f5c16e11bba8aaf55621322ba Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 4 Sep 2018 15:45:34 +0300 Subject: get file from user folder (ONLYOFFICE/onlyoffice-owncloud#210) --- controller/editorcontroller.php | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 04f5d7a..98bcadc 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -244,7 +244,8 @@ class EditorController extends Controller { 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)); @@ -286,7 +287,6 @@ class EditorController extends Controller { return ["error" => $e->getMessage()]; } - $userId = $this->userSession->getUser()->getUID(); $folder = $file->getParent(); if (!$folder->isCreatable()) { $folder = $this->root->getUserFolder($userId); @@ -399,7 +399,13 @@ class EditorController extends Controller { */ 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)); @@ -457,12 +463,6 @@ class EditorController extends Controller { $params["editorConfig"]["mode"] = "view"; } - $user = $this->userSession->getUser(); - $userId = NULL; - if (!empty($user)) { - $userId = $user->getUID(); - } - if (!empty($userId)) { $params["editorConfig"]["user"] = [ "id" => $userId, @@ -503,16 +503,23 @@ class EditorController extends Controller { /** * 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")]; } -- cgit v1.2.3 From 75f8c8910376c9757729c07f04807642b0a40511 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Thu, 6 Sep 2018 13:24:03 +0300 Subject: remove url from log --- controller/callbackcontroller.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index 14ce9f3..014a487 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -398,10 +398,10 @@ class CallbackController extends Controller { $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); } } -- cgit v1.2.3 From c8ac2d9387e95d22ae75c6b8d2478915a1d838c4 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Thu, 6 Sep 2018 13:32:40 +0300 Subject: move FormatsSetting to config --- controller/editorcontroller.php | 4 ++-- controller/settingscontroller.php | 24 ++---------------------- lib/appconfig.php | 28 ++++++++++++++++++++++++---- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 98bcadc..80d653b 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -254,7 +254,7 @@ class EditorController extends Controller { $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")]; @@ -414,7 +414,7 @@ class EditorController extends Controller { $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")]; diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php index 881b3eb..9011ab0 100644 --- a/controller/settingscontroller.php +++ b/controller/settingscontroller.php @@ -119,7 +119,7 @@ class SettingsController extends Controller { "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() ]; @@ -183,32 +183,12 @@ class SettingsController extends Controller { */ 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 diff --git a/lib/appconfig.php b/lib/appconfig.php index efc6668..bf8356a 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -350,7 +350,7 @@ class AppConfig { } /** - * Save the formats array with default action + * Save an array of formats with default action * * @param array $formats - formats with status */ @@ -362,11 +362,11 @@ class AppConfig { } /** - * Get the formats array with default action + * Get an array of formats with default action * * @return array */ - public function GetDefaultFormats() { + private function GetDefaultFormats() { $value = $this->config->getAppValue($this->appName, $this->_defFormats, ""); if (empty($value)) { return array(); @@ -435,13 +435,33 @@ class AppConfig { return empty($this->config->getAppValue($this->appName, $this->_settingsError, "")); } + /** + * Get supported formats + * + * @return array + * + * @NoAdminRequired + */ + public function FormatsSetting() { + $result = $this->formats; + + $defFormats = $this->GetDefaultFormats(); + foreach ($defFormats as $format => $setting) { + if (array_key_exists($format, $result)) { + $result[$format]["def"] = ($setting === true || $setting === "true"); + } + } + + return $result; + } + /** * Additional data about formats * * @var array */ - public $formats = [ + private $formats = [ "csv" => [ "mime" => "text/csv", "type" => "spreadsheet", "edit" => true ], "doc" => [ "mime" => "application/msword", "type" => "text", "conv" => true ], "docm" => [ "mime" => "application/vnd.ms-word.document.macroEnabled.12", "type" => "text", "conv" => true ], -- cgit v1.2.3 From b6f7888cb919cdb5528074dc9f6484c3c07eb58d Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Thu, 6 Sep 2018 13:37:03 +0300 Subject: opening for editing not OOXML (#6) --- controller/settingscontroller.php | 2 ++ js/settings.js | 6 +++++ l10n/de.js | 2 ++ l10n/de.json | 2 ++ l10n/de_DE.js | 2 ++ l10n/de_DE.json | 2 ++ l10n/es.js | 2 ++ l10n/es.json | 2 ++ l10n/ru.js | 2 ++ l10n/ru.json | 2 ++ lib/appconfig.php | 51 ++++++++++++++++++++++++++++++++++----- templates/settings.php | 24 +++++++++++++++--- 12 files changed, 89 insertions(+), 10 deletions(-) diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php index 9011ab0..1a056ce 100644 --- a/controller/settingscontroller.php +++ b/controller/settingscontroller.php @@ -142,6 +142,7 @@ class SettingsController extends Controller { $storageUrl, $secret, $defFormats, + $editFormats, $sameTab ) { $this->config->SetDocumentServerUrl($documentserver); @@ -158,6 +159,7 @@ class SettingsController extends Controller { $this->config->DropSKey(); $this->config->SetDefaultFormats($defFormats); + $this->config->SetEditableFormats($editFormats); $this->config->SetSameTab($sameTab); if ($this->checkEncryptionModule()) { diff --git a/js/settings.js b/js/settings.js index 3bcc1bb..4c51540 100644 --- a/js/settings.js +++ b/js/settings.js @@ -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({ @@ -78,6 +83,7 @@ storageUrl: onlyofficeStorageUrl, secret: onlyofficeSecret, defFormats: defFormats, + editFormats: editFormats, sameTab: sameTab }, success: function onSuccess(response) { diff --git a/l10n/de.js b/l10n/de.js index b35d318..0fd00d3 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -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)" : "Ö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." }, diff --git a/l10n/de.json b/l10n/de.json index d5e4500..dddb082 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -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);" diff --git a/l10n/de_DE.js b/l10n/de_DE.js index 5538e9e..ac193ac 100644 --- a/l10n/de_DE.js +++ b/l10n/de_DE.js @@ -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." }, diff --git a/l10n/de_DE.json b/l10n/de_DE.json index 3f12625..3578e30 100644 --- a/l10n/de_DE.json +++ b/l10n/de_DE.json @@ -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);" diff --git a/l10n/es.js b/l10n/es.js index ce0b556..0c60054 100644 --- a/l10n/es.js +++ b/l10n/es.js @@ -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." }, diff --git a/l10n/es.json b/l10n/es.json index 3ac89ad..b7cfa50 100644 --- a/l10n/es.json +++ b/l10n/es.json @@ -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);" diff --git a/l10n/ru.js b/l10n/ru.js index 1289d5f..9ba1ec6 100644 --- a/l10n/ru.js +++ b/l10n/ru.js @@ -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-адрес." }, diff --git a/l10n/ru.json b/l10n/ru.json index dd931cf..a923702 100644 --- a/l10n/ru.json +++ b/l10n/ru.json @@ -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);" diff --git a/lib/appconfig.php b/lib/appconfig.php index bf8356a..d0a719a 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -95,6 +95,13 @@ class AppConfig { */ private $_defFormats = "defFormats"; + /** + * The config key for the editable formats + * + * @var string + */ + private $_editFormats = "editFormats"; + /** * The config key for the setting same tab * @@ -374,6 +381,31 @@ class AppConfig { return json_decode($value, true); } + /** + * Save an array of formats that is opened for editing + * + * @param array $formats - formats with status + */ + public function SetEditableFormats($formats) { + $value = json_encode($formats); + $this->logger->info("Set editing formats: " . $value, array("app" => $this->appName)); + + $this->config->setAppValue($this->appName, $this->_editFormats, $value); + } + + /** + * Get an array of formats opening for editing + * + * @return array + */ + private function GetEditableFormats() { + $value = $this->config->getAppValue($this->appName, $this->_editFormats, ""); + if (empty($value)) { + return array(); + } + return json_decode($value, true); + } + /** * Save the opening setting in a same tab * @@ -452,6 +484,13 @@ class AppConfig { } } + $editFormats = $this->GetEditableFormats(); + foreach ($editFormats as $format => $setting) { + if (array_key_exists($format, $result)) { + $result[$format]["edit"] = ($setting === true || $setting === "true"); + } + } + return $result; } @@ -462,7 +501,7 @@ class AppConfig { * @var array */ private $formats = [ - "csv" => [ "mime" => "text/csv", "type" => "spreadsheet", "edit" => true ], + "csv" => [ "mime" => "text/csv", "type" => "spreadsheet", "edit" => true, "editable" => true ], "doc" => [ "mime" => "application/msword", "type" => "text", "conv" => true ], "docm" => [ "mime" => "application/vnd.ms-word.document.macroEnabled.12", "type" => "text", "conv" => true ], "docx" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "type" => "text", "edit" => true, "def" => true ], @@ -471,9 +510,9 @@ class AppConfig { "epub" => [ "mime" => "application/epub+zip", "type" => "text", "conv" => true ], "htm" => [ "type" => "text", "conv" => true ], "html" => [ "mime" => "text/html", "type" => "text", "conv" => true ], - "odp" => [ "mime" => "application/vnd.oasis.opendocument.presentation", "type" => "presentation", "conv" => true ], - "ods" => [ "mime" => "application/vnd.oasis.opendocument.spreadsheet", "type" => "spreadsheet", "conv" => true ], - "odt" => [ "mime" => "application/vnd.oasis.opendocument.text", "type" => "text", "conv" => true ], + "odp" => [ "mime" => "application/vnd.oasis.opendocument.presentation", "type" => "presentation", "conv" => true, "editable" => true ], + "ods" => [ "mime" => "application/vnd.oasis.opendocument.spreadsheet", "type" => "spreadsheet", "conv" => true, "editable" => true ], + "odt" => [ "mime" => "application/vnd.oasis.opendocument.text", "type" => "text", "conv" => true, "editable" => true ], "pdf" => [ "mime" => "application/pdf", "type" => "text" ], "pot" => [ "type" => "presentation", "conv" => true ], "potm" => [ "mime" => "application/vnd.ms-powerpoint.template.macroEnabled.12", "type" => "presentation", "conv" => true ], @@ -484,8 +523,8 @@ class AppConfig { "ppt" => [ "mime" => "application/vnd.ms-powerpoint", "type" => "presentation", "conv" => true ], "pptm" => [ "mime" => "application/vnd.ms-powerpoint.presentation.macroEnabled.12", "type" => "presentation", "conv" => true ], "pptx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.presentation", "type" => "presentation", "edit" => true, "def" => true ], - "rtf" => [ "mime" => "text/rtf", "type" => "text", "conv" => true ], - "txt" => [ "mime" => "text/plain", "type" => "text", "edit" => true ], + "rtf" => [ "mime" => "text/rtf", "type" => "text", "conv" => true, "editable" => true ], + "txt" => [ "mime" => "text/plain", "type" => "text", "edit" => true, "editable" => true ], "xls" => [ "mime" => "application/vnd.ms-excel", "type" => "spreadsheet", "conv" => true ], "xlsm" => [ "mime" => "application/vnd.ms-excel.sheet.macroEnabled.12", "type" => "spreadsheet", "conv" => true ], "xlsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "type" => "spreadsheet", "edit" => true, "def" => true ], diff --git a/templates/settings.php b/templates/settings.php index 650ddd8..07976d3 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -68,8 +68,8 @@

t("The default application for opening the format")) ?>

- $setting) { - if (array_key_exists("mime", $setting)) { ?> + $setting) { ?> +
checked="checked" />
- + + +
+ +

t("Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)")) ?>

+ "> +
+ $setting) { ?> + +
+ checked="checked" /> + +
+ +
t("Save")) ?> -- cgit v1.2.3 From fcba6d7d179573ed96bdfc4e9e2b68526abfbd08 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 11 Sep 2018 13:44:07 +0300 Subject: 2.0.4 --- CHANGELOG.md | 8 ++++++++ appinfo/info.xml | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca4e2b4..98a6a29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/appinfo/info.xml b/appinfo/info.xml index e052996..e16d21a 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -7,7 +7,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 - 2.0.2 + 2.0.4 Onlyoffice @@ -30,7 +30,7 @@ https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-nextcloud/master/screenshots/new.png https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-nextcloud/master/screenshots/open.png - + OCA\Onlyoffice\AdminSettings -- cgit v1.2.3