From a0980163a0a7fcdb6cb47b20fb330fa8dfdb1ef5 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Wed, 25 Sep 2019 12:47:10 +0300 Subject: [PATCH 01/21] Update README.md --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index aee82bda..aee1828a 100644 --- a/README.md +++ b/README.md @@ -51,15 +51,15 @@ The table below will help you to make the right choice. | Simultaneous connections | up to 20 maximum | As in chosen pricing plan | | Number of users | up to 20 recommended | As in chosen pricing plan | | License | GNU AGPL v.3 | Proprietary | -| **Support** | **Community Edition** | **Integration Edition** | +| **Support** | **Community Edition** | **Integration Edition** | | Documentation | [Help Center](https://helpcenter.onlyoffice.com/server/docker/opensource/index.aspx) | [Help Center](https://helpcenter.onlyoffice.com/server/integration-edition/index.aspx) | | Standard support | [GitHub](https://github.com/ONLYOFFICE/DocumentServer/issues) or paid | One year support included | | Premium support | [Buy Now](https://www.onlyoffice.com/support.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubNextcloud) | [Buy Now](https://www.onlyoffice.com/support.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubNextcloud) | -| **Services** | **Community Edition** | **Integration Edition** | -| Conversion Service | + | + | -| Document Builder Service | - | + | +| **Services** | **Community Edition** | **Integration Edition** | +| Conversion Service | + | + | +| Document Builder Service | + | + | | **Interface** | **Community Edition** | **Integration Edition** | -| Tabbed interface | - | + | +| Tabbed interface | + | + | | White Label | - | - | | Integrated test example (node.js)* | - | + | | **Plugins & Macros** | **Community Edition** | **Integration Edition** | @@ -70,27 +70,27 @@ The table below will help you to make the right choice. | Comments | + | + | | Built-in chat | + | + | | Review and tracking changes | + | + | -| Display modes of tracking changes | - | + | +| Display modes of tracking changes | + | + | | Version history | + | + | | **Document Editor features** | **Community Edition** | **Integration Edition** | | Font and paragraph formatting | + | + | | Object insertion | + | + | -| Content control | - | + | +| Content control | + | + | | Layout tools | + | + | | Table of contents | + | + | -| Navigation panel | - | + | +| Navigation panel | + | + | | Mail Merge | + | + | | **Spreadsheet Editor features** | **Community Edition** | **Integration Edition** | | Font and paragraph formatting | + | + | | Object insertion | + | + | | Functions, formulas, equations | + | + | | Table templates | + | + | -| Pivot tables | - | +** | +| Pivot tables | +** | +** | | **Presentation Editor features** | **Community Edition** | **Integration Edition** | | Font and paragraph formatting | + | + | | Object insertion | + | + | | Animations | + | + | -| Presenter mode | - | + | +| Presenter mode | + | + | | Notes | + | + | | | [Get it now](https://www.onlyoffice.com/download.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubNextcloud) | [Start Free Trial](https://www.onlyoffice.com/connectors-request.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubNextcloud) | From 25795ce9097bce35b83665b099c6d5a7f1493ef7 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Wed, 25 Sep 2019 13:44:05 +0300 Subject: [PATCH 02/21] Fix missing check for shared files --- controller/editorcontroller.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 01f0e914..65cc3461 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -689,7 +689,7 @@ public function config($fileId, $filePath = NULL, $token = NULL, $desktop = fals $params = $this->setCustomization($params); - $params = $this->setWatermark($params, !empty($token), $userId, $fileId); + $params = $this->setWatermark($params, !empty($token), $userId, $file); if ($this->config->UseDemo()) { $params["editorConfig"]["tenant"] = $this->config->GetSystemValue("instanceid", true); @@ -949,12 +949,12 @@ private function setCustomization($params) { * @param array params - file parameters * @param bool isPublic - with access token * @param string userId - user identifier - * @param string fileId - file identifier + * @param string file - file * * @return array */ - private function setWatermark($params, $isPublic, $userId, $fileId) { - $watermarkTemplate = $this->getWatermarkText($isPublic, $userId, $fileId, + private function setWatermark($params, $isPublic, $userId, $file) { + $watermarkTemplate = $this->getWatermarkText($isPublic, $userId, $file, $params["document"]["permissions"]["edit"] !== false, $params["document"]["permissions"]["download"] !== false); @@ -993,15 +993,22 @@ private function setWatermark($params, $isPublic, $userId, $fileId) { /** * Should watermark * + * @param bool isPublic - with access token + * @param string userId - user identifier + * @param string file - file + * @param bool canEdit - edit permission + * @param bool canDownload - download permission + * * @return bool|string */ - private function getWatermarkText($isPublic, $userId, $fileId, $canEdit, $canDownload) { + private function getWatermarkText($isPublic, $userId, $file, $canEdit, $canDownload) { $watermarkSettings = $this->config->GetWatermarkSettings(); if (!$watermarkSettings["enabled"]) { return false; } $watermarkText = $watermarkSettings["text"]; + $fileId = $file->getId(); if ($isPublic) { if ($watermarkSettings["linkAll"]) { @@ -1023,7 +1030,7 @@ private function getWatermarkText($isPublic, $userId, $fileId, $canEdit, $canDow } } } else { - if ($watermarkSettings["shareAll"]) { + if ($watermarkSettings["shareAll"] && $file->getOwner()->getUID() !== $userId) { return $watermarkText; } if ($watermarkSettings["shareRead"] && !$canEdit) { From 83a1181e59281251612ecf9574d8d4ded2331506 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Fri, 30 Aug 2019 16:01:13 +0300 Subject: [PATCH 03/21] replace space --- l10n/bg.js | 4 ++-- l10n/bg.json | 4 ++-- l10n/de.js | 4 ++-- l10n/de.json | 4 ++-- l10n/de_DE.js | 4 ++-- l10n/de_DE.json | 4 ++-- l10n/es.js | 10 +++++----- l10n/es.json | 10 +++++----- l10n/ru.js | 4 ++-- l10n/ru.json | 4 ++-- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/l10n/bg.js b/l10n/bg.js index d583834e..7760c4fe 100644 --- a/l10n/bg.js +++ b/l10n/bg.js @@ -23,7 +23,7 @@ OC.L10N.register( "Loading, please wait." : "Зареждане. Моля, изчакайте.", "File created" : "Файлът е създаден", "Open in ONLYOFFICE" : "Отвори в ONLYOFFICE", - "Convert with ONLYOFFICE" : "Конвертирай с ONLYOFFICE", + "Convert with ONLYOFFICE" : "Конвертирай с ONLYOFFICE", "Document" : "Документ", "Spreadsheet" : "Електронна таблица", "Presentation" : "Презентация", @@ -40,7 +40,7 @@ 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)" : "Отваряне на файла за редактиране (според ограниченята на формата данните могат да бъдат загубени при запис във формати от списъка по-долу)", + "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/bg.json b/l10n/bg.json index 925e0bad..b81ed5b5 100644 --- a/l10n/bg.json +++ b/l10n/bg.json @@ -21,7 +21,7 @@ "Loading, please wait." : "Зареждане. Моля, изчакайте.", "File created" : "Файлът е създаден", "Open in ONLYOFFICE" : "Отвори в ONLYOFFICE", - "Convert with ONLYOFFICE" : "Конвертирай с ONLYOFFICE", + "Convert with ONLYOFFICE" : "Конвертирай с ONLYOFFICE", "Document" : "Документ", "Spreadsheet" : "Електронна таблица", "Presentation" : "Презентация", @@ -38,7 +38,7 @@ "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)" : "Отваряне на файла за редактиране (според ограниченята на формата данните могат да бъдат загубени при запис във формати от списъка по-долу)", + "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/de.js b/l10n/de.js index 1fcb97c8..4a1cd1a7 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -43,7 +43,7 @@ OC.L10N.register( "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.", + "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.", "Restrict access to editors to following groups" : "Den Zugriff auf Editoren auf folgende Gruppen gewähren", "Server settings" : "Servereinstellungen", "Common settings" : "Allgemeine Einstellungen", @@ -51,7 +51,7 @@ OC.L10N.register( "The customization section allows personalizing the editor interface" : "Die Anpassungssektion ermöglicht die Anpassung der Editoroberfläche", "Display Chat menu button" : "Chat-Taste anzeigen", "Display the header more compact" : "Kompakten Header anzeigen", - "Display Feedback & Support menu button" : "Feedback-& Support-Taste anzeigen", + "Display Feedback & Support menu button" : "Feedback-& Support-Taste anzeigen", "Display Help menu button" : "Hilfetaste anzeigen", "Display toolbar tabs" : "Symbolleiste-Registerkarten anzeigen", "Save as" : "Speichern als", diff --git a/l10n/de.json b/l10n/de.json index 23919147..d8ecbe36 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -41,7 +41,7 @@ "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.", + "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.", "Restrict access to editors to following groups" : "Den Zugriff auf Editoren auf folgende Gruppen gewähren", "Server settings" : "Servereinstellungen", "Common settings" : "Allgemeine Einstellungen", @@ -49,7 +49,7 @@ "The customization section allows personalizing the editor interface" : "Die Anpassungssektion ermöglicht die Anpassung der Editoroberfläche", "Display Chat menu button" : "Chat-Taste anzeigen", "Display the header more compact" : "Kompakten Header anzeigen", - "Display Feedback & Support menu button" : "Feedback-& Support-Taste anzeigen", + "Display Feedback & Support menu button" : "Feedback-& Support-Taste anzeigen", "Display Help menu button" : "Hilfetaste anzeigen", "Display toolbar tabs" : "Symbolleiste-Registerkarten anzeigen", "Save as" : "Speichern als", diff --git a/l10n/de_DE.js b/l10n/de_DE.js index fae5de40..fc2ac6dc 100644 --- a/l10n/de_DE.js +++ b/l10n/de_DE.js @@ -43,7 +43,7 @@ OC.L10N.register( "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.", + "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.", "Restrict access to editors to following groups" : "Den Zugriff auf Editoren auf folgende Gruppen gewähren", "Server settings" : "Servereinstellungen", "Common settings" : "Allgemeine Einstellungen", @@ -51,7 +51,7 @@ OC.L10N.register( "The customization section allows personalizing the editor interface" : "Die Anpassungssektion ermöglicht die Anpassung der Editoroberfläche", "Display Chat menu button" : "Chat-Taste anzeigen", "Display the header more compact" : "Kompakten Header anzeigen", - "Display Feedback & Support menu button" : "Feedback-& Support-Taste anzeigen", + "Display Feedback & Support menu button" : "Feedback-& Support-Taste anzeigen", "Display Help menu button" : "Hilfetaste anzeigen", "Display toolbar tabs" : "Symbolleiste-Registerkarten anzeigen", "Save as" : "Speichern als", diff --git a/l10n/de_DE.json b/l10n/de_DE.json index 1903bf70..39ece953 100644 --- a/l10n/de_DE.json +++ b/l10n/de_DE.json @@ -41,7 +41,7 @@ "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.", + "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.", "Restrict access to editors to following groups" : "Den Zugriff auf Editoren auf folgende Gruppen gewähren", "Server settings" : "Servereinstellungen", "Common settings" : "Allgemeine Einstellungen", @@ -49,7 +49,7 @@ "The customization section allows personalizing the editor interface" : "Die Anpassungssektion ermöglicht die Anpassung der Editoroberfläche", "Display Chat menu button" : "Chat-Taste anzeigen", "Display the header more compact" : "Kompakten Header anzeigen", - "Display Feedback & Support menu button" : "Feedback-& Support-Taste anzeigen", + "Display Feedback & Support menu button" : "Feedback-& Support-Taste anzeigen", "Display Help menu button" : "Hilfetaste anzeigen", "Display toolbar tabs" : "Symbolleiste-Registerkarten anzeigen", "Save as" : "Speichern als", diff --git a/l10n/es.js b/l10n/es.js index a87062bf..be0601c6 100644 --- a/l10n/es.js +++ b/l10n/es.js @@ -23,7 +23,7 @@ OC.L10N.register( "Loading, please wait." : "Cargando, espere, por favor.", "File created" : "Archivo creado", "Open in ONLYOFFICE" : "Abrir en ONLYOFFICE", - "Convert with ONLYOFFICE" : "Convertir con ONLYOFFICE", + "Convert with ONLYOFFICE" : "Convertir con ONLYOFFICE", "Document" : "Documento", "Spreadsheet" : "Hoja de cálculo", "Presentation" : "Presentación", @@ -43,14 +43,14 @@ OC.L10N.register( "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.", - "Restrict access to editors to following groups" : "Restringir el acceso a editores a siguientes grupos", + "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.", + "Restrict access to editors to following groups" : "Restringir el acceso a editores a siguientes grupos", "Server settings" : "Ajustes de servidor", "Common settings" : "Ajustes comunes", "Editor customization settings" : "Ajustes del editor", - "The customization section allows personalizing the editor interface" : "La sección de personalización permite customizar la interfaz del editor", + "The customization section allows personalizing the editor interface" : "La sección de personalización permite customizar la interfaz del editor", "Display Chat menu button" : "Mostrar el botón de Chat", - "Display the header more compact" : "Mostrar el encabezado más compacto", + "Display the header more compact" : "Mostrar el encabezado más compacto", "Display Feedback & Support menu button" : "Mostrar el botón de Feedback y Soporte", "Display Help menu button" : "Mostrar el botón de Ayuda", "Display toolbar tabs" : "Mostrar pestañas de barra de herramientas", diff --git a/l10n/es.json b/l10n/es.json index 76cc28aa..7c3b5358 100644 --- a/l10n/es.json +++ b/l10n/es.json @@ -21,7 +21,7 @@ "Loading, please wait." : "Cargando, espere, por favor.", "File created" : "Archivo creado", "Open in ONLYOFFICE" : "Abrir en ONLYOFFICE", - "Convert with ONLYOFFICE" : "Convertir con ONLYOFFICE", + "Convert with ONLYOFFICE" : "Convertir con ONLYOFFICE", "Document" : "Documento", "Spreadsheet" : "Hoja de cálculo", "Presentation" : "Presentación", @@ -41,14 +41,14 @@ "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.", - "Restrict access to editors to following groups" : "Restringir el acceso a editores a siguientes grupos", + "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.", + "Restrict access to editors to following groups" : "Restringir el acceso a editores a siguientes grupos", "Server settings" : "Ajustes de servidor", "Common settings" : "Ajustes comunes", "Editor customization settings" : "Ajustes del editor", - "The customization section allows personalizing the editor interface" : "La sección de personalización permite customizar la interfaz del editor", + "The customization section allows personalizing the editor interface" : "La sección de personalización permite customizar la interfaz del editor", "Display Chat menu button" : "Mostrar el botón de Chat", - "Display the header more compact" : "Mostrar el encabezado más compacto", + "Display the header more compact" : "Mostrar el encabezado más compacto", "Display Feedback & Support menu button" : "Mostrar el botón de Feedback y Soporte", "Display Help menu button" : "Mostrar el botón de Ayuda", "Display toolbar tabs" : "Mostrar pestañas de barra de herramientas", diff --git a/l10n/ru.js b/l10n/ru.js index 555cc401..1a00377d 100644 --- a/l10n/ru.js +++ b/l10n/ru.js @@ -23,7 +23,7 @@ OC.L10N.register( "Loading, please wait." : "Загрузка. Пожалуйста, подождите.", "File created" : "Файл создан", "Open in ONLYOFFICE" : "Открыть в ONLYOFFICE", - "Convert with ONLYOFFICE" : "Конвертировать в ONLYOFFICE", + "Convert with ONLYOFFICE" : "Конвертировать в ONLYOFFICE", "Document" : "Документ", "Spreadsheet" : "Электронная таблица", "Presentation" : "Презентация", @@ -40,7 +40,7 @@ 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)" : "Открыть файл на редактирование (из-за ограничений формата данные могут быть утеряны при сохранении в форматы из списка ниже)", + "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 f5ffd27c..70d8be7b 100644 --- a/l10n/ru.json +++ b/l10n/ru.json @@ -21,7 +21,7 @@ "Loading, please wait." : "Загрузка. Пожалуйста, подождите.", "File created" : "Файл создан", "Open in ONLYOFFICE" : "Открыть в ONLYOFFICE", - "Convert with ONLYOFFICE" : "Конвертировать в ONLYOFFICE", + "Convert with ONLYOFFICE" : "Конвертировать в ONLYOFFICE", "Document" : "Документ", "Spreadsheet" : "Электронная таблица", "Presentation" : "Презентация", @@ -38,7 +38,7 @@ "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)" : "Открыть файл на редактирование (из-за ограничений формата данные могут быть утеряны при сохранении в форматы из списка ниже)", + "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-адрес.", From 520894477bfb777f377fa0f11e780d153a21c461 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Fri, 30 Aug 2019 16:56:10 +0300 Subject: [PATCH 04/21] change getUrl param --- controller/editorcontroller.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 65cc3461..cc2f3712 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -326,12 +326,11 @@ public function convert($fileId, $token = NULL) { $newFileUri; $documentService = new DocumentService($this->trans, $this->config); $key = $this->getKey($file); - $fileId = $file->getId(); - $fileUrl = $this->getUrl($fileId, $token); + $fileUrl = $this->getUrl($file, $token); try { $newFileUri = $documentService->GetConvertedUri($fileUrl, $ext, $internalExtension, $key); } catch (\Exception $e) { - $this->logger->error("GetConvertedUri: " . $fileId . " " . $e->getMessage(), array("app" => $this->appName)); + $this->logger->error("GetConvertedUri: " . $file->getId() . " " . $e->getMessage(), array("app" => $this->appName)); return ["error" => $e->getMessage()]; } @@ -456,8 +455,7 @@ public function url($filePath) { $fileName = $file->getName(); $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); - $fileId = $file->getId(); - $fileUrl = $this->getUrl($fileId); + $fileUrl = $this->getUrl($file); $result = [ "fileType" => $ext, @@ -584,8 +582,7 @@ public function config($fileId, $filePath = NULL, $token = NULL, $desktop = fals return ["error" => $this->trans->t("Format is not supported")]; } - $fileId = $file->getId(); - $fileUrl = $this->getUrl($fileId, $token); + $fileUrl = $this->getUrl($file, $token); $key = $this->getKey($file); $params = [ @@ -619,7 +616,7 @@ public function config($fileId, $filePath = NULL, $token = NULL, $desktop = fals $ownerId = $owner->getUID(); } - $hashCallback = $this->crypt->GetHash(["fileId" => $fileId, "ownerId" => $ownerId, "token" => $token, "action" => "track"]); + $hashCallback = $this->crypt->GetHash(["fileId" => $file->getId(), "ownerId" => $ownerId, "token" => $token, "action" => "track"]); $callback = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.track", ["doc" => $hashCallback]); if (!empty($this->config->GetStorageUrl())) { @@ -855,12 +852,12 @@ private function getKey($file) { /** * Generate secure link to download document * - * @param integer $fileId - file identifier + * @param integer $file - file * @param string $token - access token * * @return string */ - private function getUrl($fileId, $token = NULL) { + private function getUrl($file, $token = NULL) { $user = $this->userSession->getUser(); $userId = NULL; @@ -868,7 +865,7 @@ private function getUrl($fileId, $token = NULL) { $userId = $user->getUID(); } - $hashUrl = $this->crypt->GetHash(["fileId" => $fileId, "userId" => $userId, "token" => $token, "action" => "download"]); + $hashUrl = $this->crypt->GetHash(["fileId" => $file->getId(), "userId" => $userId, "token" => $token, "action" => "download"]); $fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.download", ["doc" => $hashUrl]); From 3497e9d319ada730188d07bffc9594f4047b844b Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Fri, 30 Aug 2019 16:59:30 +0300 Subject: [PATCH 05/21] ownerId to download url --- controller/callbackcontroller.php | 11 ++++++++++- controller/editorcontroller.php | 8 +++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index 476d8412..624f5334 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -212,7 +212,16 @@ public function download($doc) { if ($this->userSession->isLoggedIn()) { $userId = $this->userSession->getUser()->getUID(); } else { - $userId = $hashData->userId; + $userId = $hashData->ownerId; + + if (empty($this->userManager->get($userId))) { + $userId = $hashData->userId; + } + + \OC_Util::tearDownFS(); + if (!empty($userId)) { + \OC_Util::setupFS($userId); + } } $token = isset($hashData->token) ? $hashData->token : NULL; diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index cc2f3712..dd7bcbd6 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -865,7 +865,13 @@ private function getUrl($file, $token = NULL) { $userId = $user->getUID(); } - $hashUrl = $this->crypt->GetHash(["fileId" => $file->getId(), "userId" => $userId, "token" => $token, "action" => "download"]); + $ownerId = NULL; + $owner = $file->getOwner(); + if (!empty($owner)) { + $ownerId = $owner->getUID(); + } + + $hashUrl = $this->crypt->GetHash(["fileId" => $file->getId(), "userId" => $userId, "ownerId" => $ownerId, "token" => $token, "action" => "download"]); $fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.download", ["doc" => $hashUrl]); From b4fd878b81f652666a53a0fe3183996091a5b6e3 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Fri, 30 Aug 2019 17:00:30 +0300 Subject: [PATCH 06/21] without ownerId for public url --- controller/editorcontroller.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index dd7bcbd6..cc18bed3 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -866,9 +866,11 @@ private function getUrl($file, $token = NULL) { } $ownerId = NULL; - $owner = $file->getOwner(); - if (!empty($owner)) { - $ownerId = $owner->getUID(); + if (empty($token)) { + $owner = $file->getOwner(); + if (!empty($owner)) { + $ownerId = $owner->getUID(); + } } $hashUrl = $this->crypt->GetHash(["fileId" => $file->getId(), "userId" => $userId, "ownerId" => $ownerId, "token" => $token, "action" => "download"]); From 574a12876e790cbfde7c93e165ffdcf835776737 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Wed, 25 Sep 2019 13:56:01 +0300 Subject: [PATCH 07/21] Revert "save after deleting pulbic link" This reverts commit 72d5851bc4371919b4d983e3211ff65f7aba0943. --- controller/callbackcontroller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index 624f5334..74a58e08 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -401,7 +401,7 @@ public function track($doc, $users, $key, $status, $url, $token) { \OC_Util::setupFS($ownerId); } - list ($file, $error) = !empty($ownerId) ? $this->getFile($ownerId, $fileId) : $this->getFileByToken($fileId, $token); + list ($file, $error) = empty($token) ? $this->getFile($ownerId, $fileId) : $this->getFileByToken($fileId, $token); if (isset($error)) { $this->logger->error("track error" . $fileId ." " . json_encode($error->getData()), array("app" => $this->appName)); From 6caa965ac32d53362068882c8dd2c23cc3f07c4f Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Wed, 25 Sep 2019 13:59:41 +0300 Subject: [PATCH 08/21] owner exists check --- controller/callbackcontroller.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index 74a58e08..54ec9214 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -377,31 +377,36 @@ public function track($doc, $users, $key, $status, $url, $token) { case "Corrupted": if (empty($url)) { $this->logger->error("Track without url: " . $fileId . " status " . $trackerStatus, array("app" => $this->appName)); - return new JSONResponse(["message" => $this->trans->t("Url not found")], Http::STATUS_BAD_REQUEST); + return new JSONResponse(["message" => "Url not found"], Http::STATUS_BAD_REQUEST); } try { - $ownerId = $hashData->ownerId; $token = isset($hashData->token) ? $hashData->token : NULL; - if (empty($ownerId) && empty($token)) { - $this->logger->error("Track without owner: " . $fileId . " status " . $trackerStatus, array("app" => $this->appName)); - return new JSONResponse(["message" => $this->trans->t("File owner is empty")], Http::STATUS_BAD_REQUEST); - } $userId = $users[0]; $user = $this->userManager->get($userId); if (!empty($user)) { $this->userSession->setUser($user); } else { + if (empty($token)) { + $this->logger->error("Track without access: " . $fileId . " status " . $trackerStatus, array("app" => $this->appName)); + return new JSONResponse(["message" => "User and token is empty"], Http::STATUS_BAD_REQUEST); + } + $this->logger->debug("Track by anonymous " . $userId, array("app" => $this->appName)); } + $ownerId = $hashData->ownerId; + if (!empty($this->userManager->get($ownerId))) { + $userId = $ownerId; + } + \OC_Util::tearDownFS(); - if (!empty($ownerId)) { - \OC_Util::setupFS($ownerId); + if (!empty($userId)) { + \OC_Util::setupFS($userId); } - list ($file, $error) = empty($token) ? $this->getFile($ownerId, $fileId) : $this->getFileByToken($fileId, $token); + list ($file, $error) = empty($token) ? $this->getFile($userId, $fileId) : $this->getFileByToken($fileId, $token); if (isset($error)) { $this->logger->error("track error" . $fileId ." " . json_encode($error->getData()), array("app" => $this->appName)); From 5ea2eff8ed9f60ef2b61b166253ea2ac4a1e1730 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Wed, 25 Sep 2019 14:01:48 +0300 Subject: [PATCH 09/21] exception if the federated file is deleted --- controller/callbackcontroller.php | 14 ++++++++++++-- controller/editorcontroller.php | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index 54ec9214..37d90f9a 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -467,7 +467,12 @@ private function getFile($userId, $fileId) { return [NULL, new JSONResponse(["message" => $this->trans->t("FileId is empty")], Http::STATUS_BAD_REQUEST)]; } - $files = $this->root->getUserFolder($userId)->getById($fileId); + try { + $files = $this->root->getUserFolder($userId)->getById($fileId); + } catch (\Exception $e) { + $this->logger->error("getFile: " . $fileId . " " . $e->getMessage(), array("app" => $this->appName)); + return [NULL, new JSONResponse(["message" => $this->trans->t("Invalid request")], Http::STATUS_BAD_REQUEST)]; + } if (empty($files)) { $this->logger->error("Files not found: " . $fileId, array("app" => $this->appName)); @@ -506,7 +511,12 @@ private function getFileByToken($fileId, $token) { } if ($node instanceof Folder) { - $files = $node->getById($fileId); + try { + $files = $node->getById($fileId); + } catch (\Exception $e) { + $this->logger->error("getFileByToken: " . $fileId . " " . $e->getMessage(), array("app" => $this->appName)); + return [NULL, new JSONResponse(["message" => $this->trans->t("Invalid request")], Http::STATUS_NOT_FOUND)]; + } if (empty($files)) { return [NULL, new JSONResponse(["message" => $this->trans->t("File not found")], Http::STATUS_NOT_FOUND)]; diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index cc18bed3..1491af0a 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -716,7 +716,12 @@ private function getFile($userId, $fileId, $filePath = NULL) { return [NULL, $this->trans->t("FileId is empty"), NULL]; } - $files = $this->root->getUserFolder($userId)->getById($fileId); + try { + $files = $this->root->getUserFolder($userId)->getById($fileId); + } catch (\Exception $e) { + $this->logger->error("getFile: " . $fileId . " " . $e->getMessage(), array("app" => $this->appName)); + return [NULL, $this->trans->t("Invalid request"), NULL]; + } if (empty($files)) { $this->logger->info("Files not found: " . $fileId, array("app" => $this->appName)); @@ -757,7 +762,12 @@ private function getFileByToken($fileId, $token) { } if ($node instanceof Folder) { - $files = $node->getById($fileId); + try { + $files = $node->getById($fileId); + } catch (\Exception $e) { + $this->logger->error("getFileByToken: " . $fileId . " " . $e->getMessage(), array("app" => $this->appName)); + return [NULL, $this->trans->t("Invalid request"), NULL]; + } if (empty($files)) { $this->logger->info("Files not found: " . $fileId, array("app" => $this->appName)); From 486fe1ca10d4a7539eff3daba6af9ddec09b59be Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Wed, 25 Sep 2019 14:37:52 +0300 Subject: [PATCH 10/21] Revert "get language" (Fix #139) This reverts commit 71272075663d1ff1e940e3c25c27f8a1f3bbe13e. # Conflicts: # controller/editorcontroller.php --- controller/editorcontroller.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 1491af0a..4f3abdce 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -221,7 +221,7 @@ public function create($name, $dir, $token = NULL) { $ext = strtolower("." . pathinfo($name, PATHINFO_EXTENSION)); - $lang = $this->trans->getLanguageCode(); + $lang = \OC::$server->getL10NFactory("")->get("")->getLanguageCode(); $templatePath = $this->getTemplatePath($lang, $ext); if (!file_exists($templatePath)) { @@ -595,7 +595,7 @@ public function config($fileId, $filePath = NULL, $token = NULL, $desktop = fals ], "documentType" => $format["type"], "editorConfig" => [ - "lang" => str_replace("_", "-", $this->trans->getLanguageCode()), + "lang" => str_replace("_", "-", \OC::$server->getL10NFactory("")->get("")->getLanguageCode()), "region" => str_replace("_", "-", \OC::$server->getL10NFactory("")->findLocale()) ] ]; From c918f27e4425225de06bfcd63b726fa7874c33b4 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Wed, 25 Sep 2019 15:18:00 +0300 Subject: [PATCH 11/21] sv --- l10n/sv.js | 21 +++++++++++++++++++-- l10n/sv.json | 21 +++++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/l10n/sv.js b/l10n/sv.js index 245b1425..e5afc85e 100644 --- a/l10n/sv.js +++ b/l10n/sv.js @@ -58,7 +58,24 @@ OC.L10N.register( "File saved" : "Filen har sparats", "Insert image" : "Infoga bild", "Select recipients" : "Välj mottagare", - "Secure view enables you to secure documents by embedding a watermark" : "Med säker vy kan du säkra dokument genom att bädda in ett vattenstämpel", - "Supported placeholders" : "Platshållare som stöds" + "Connect to demo ONLYOFFICE Document Server" : "Anslut till demo ONLYOFFICE Dokumentserver", + "This is a public test server, please do not use it for private sensitive data. The server will be available during a 30-day period." : "Detta är en offentlig testserver, använd den inte för privat känslig information. Servern kommer att finnas tillgänglig under en 30-dagarsperiod.", + "The 30-day test period is over, you can no longer connect to demo ONLYOFFICE Document Server." : "När 30-dagars testperioden är över, kan du inte längre ansluta till demo ONLYOFFICE Dokumentserver.", + "You are using public demo ONLYOFFICE Document Server. Please do not store private sensitive data." : "Du använder en offentlig demo ONLYOFFICE Dokumentserver. Lagra inte privat känslig information.", + "Secure view settings" : "Säkra vyinställningar", + "Secure view enables you to secure documents by embedding a watermark" : "Med säker vy kan du säkra dokument genom att bädda in en vattenstämpel", + "Enable watermarking" : "Aktivera vattenstämpel", + "Watermark text" : "Text för vattenmärke", + "DO NOT SHARE THIS" : "DELA INTE DETTA", + "Show watermark on tagged files" : "Visa vattenstämpel på taggade filer", + "Show watermark for users of groups" : "Visa vattenstämpel för användare i grupper", + "Supported placeholders" : "Platshållare som stöds", + "Show watermark for all shares" : "Visa vattenstämpel för alla delningar", + "Show watermark for read only shares" : "Visa vattenmärke för skrivskyddade delningar", + "Link shares" : "Länkdelningar", + "Show watermark for all link shares" : "Visa vattenstämpel för alla länkdelningar", + "Show watermark for download hidden shares" : "Visa vattenstämpel för delningar med gömd nedladdning", + "Show watermark for read only link shares" : "Visa vattenmärke för skrivskyddade länkdelningar", + "Show watermark on link shares with specific system tags" : "Visa vattenmärke för länkdelningar med specifika systemtaggar" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/sv.json b/l10n/sv.json index e73f2f5e..7d623dc9 100644 --- a/l10n/sv.json +++ b/l10n/sv.json @@ -56,7 +56,24 @@ "File saved" : "Filen har sparats", "Insert image" : "Infoga bild", "Select recipients" : "Välj mottagare", - "Secure view enables you to secure documents by embedding a watermark" : "Med säker vy kan du säkra dokument genom att bädda in ett vattenstämpel", - "Supported placeholders" : "Platshållare som stöds" + "Connect to demo ONLYOFFICE Document Server" : "Anslut till demo ONLYOFFICE Dokumentserver", + "This is a public test server, please do not use it for private sensitive data. The server will be available during a 30-day period." : "Detta är en offentlig testserver, använd den inte för privat känslig information. Servern kommer att finnas tillgänglig under en 30-dagarsperiod.", + "The 30-day test period is over, you can no longer connect to demo ONLYOFFICE Document Server." : "När 30-dagars testperioden är över, kan du inte längre ansluta till demo ONLYOFFICE Dokumentserver.", + "You are using public demo ONLYOFFICE Document Server. Please do not store private sensitive data." : "Du använder en offentlig demo ONLYOFFICE Dokumentserver. Lagra inte privat känslig information.", + "Secure view settings" : "Säkra vyinställningar", + "Secure view enables you to secure documents by embedding a watermark" : "Med säker vy kan du säkra dokument genom att bädda in en vattenstämpel", + "Enable watermarking" : "Aktivera vattenstämpel", + "Watermark text" : "Text för vattenmärke", + "DO NOT SHARE THIS" : "DELA INTE DETTA", + "Show watermark on tagged files" : "Visa vattenstämpel på taggade filer", + "Show watermark for users of groups" : "Visa vattenstämpel för användare i grupper", + "Supported placeholders" : "Platshållare som stöds", + "Show watermark for all shares" : "Visa vattenstämpel för alla delningar", + "Show watermark for read only shares" : "Visa vattenmärke för skrivskyddade delningar", + "Link shares" : "Länkdelningar", + "Show watermark for all link shares" : "Visa vattenstämpel för alla länkdelningar", + "Show watermark for download hidden shares" : "Visa vattenstämpel för delningar med gömd nedladdning", + "Show watermark for read only link shares" : "Visa vattenmärke för skrivskyddade länkdelningar", + "Show watermark on link shares with specific system tags" : "Visa vattenmärke för länkdelningar med specifika systemtaggar" },"pluralForm" :"nplurals=2; plural=(n != 1);" } \ No newline at end of file From b12e4552276702514b957b0d57c2f96853d5ed0c Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Wed, 25 Sep 2019 15:55:03 +0300 Subject: [PATCH 12/21] rename access token param to "shareToken" --- appinfo/routes.php | 2 +- controller/callbackcontroller.php | 26 ++++----- controller/editorcontroller.php | 88 +++++++++++++++---------------- js/editor.js | 8 +-- js/main.js | 8 +-- templates/editor.php | 2 +- 6 files changed, 67 insertions(+), 67 deletions(-) diff --git a/appinfo/routes.php b/appinfo/routes.php index e67f92fd..80f769c4 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -33,7 +33,7 @@ ["name" => "callback#emptyfile", "url" => "/empty", "verb" => "GET"], ["name" => "callback#track", "url" => "/track", "verb" => "POST"], ["name" => "editor#index", "url" => "/{fileId}", "verb" => "GET"], - ["name" => "editor#public_page", "url" => "/s/{token}", "verb" => "GET"], + ["name" => "editor#public_page", "url" => "/s/{shareToken}", "verb" => "GET"], ["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"], diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index 37d90f9a..671b077e 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -224,8 +224,8 @@ public function download($doc) { } } - $token = isset($hashData->token) ? $hashData->token : NULL; - list ($file, $error) = empty($token) ? $this->getFile($userId, $fileId) : $this->getFileByToken($fileId, $token); + $shareToken = isset($hashData->shareToken) ? $hashData->shareToken : NULL; + list ($file, $error) = empty($shareToken) ? $this->getFile($userId, $fileId) : $this->getFileByToken($fileId, $shareToken); if (isset($error)) { return $error; @@ -312,7 +312,7 @@ public function emptyfile($doc) { * @param string $key - the edited document identifier * @param integer $status - the edited status * @param string $url - the link to the edited document to be saved - * @param string $token - access token + * @param string $token - request signature * * @return array * @@ -381,14 +381,14 @@ public function track($doc, $users, $key, $status, $url, $token) { } try { - $token = isset($hashData->token) ? $hashData->token : NULL; + $shareToken = isset($hashData->shareToken) ? $hashData->shareToken : NULL; $userId = $users[0]; $user = $this->userManager->get($userId); if (!empty($user)) { $this->userSession->setUser($user); } else { - if (empty($token)) { + if (empty($shareToken)) { $this->logger->error("Track without access: " . $fileId . " status " . $trackerStatus, array("app" => $this->appName)); return new JSONResponse(["message" => "User and token is empty"], Http::STATUS_BAD_REQUEST); } @@ -406,7 +406,7 @@ public function track($doc, $users, $key, $status, $url, $token) { \OC_Util::setupFS($userId); } - list ($file, $error) = empty($token) ? $this->getFile($userId, $fileId) : $this->getFileByToken($fileId, $token); + list ($file, $error) = empty($shareToken) ? $this->getFile($userId, $fileId) : $this->getFileByToken($fileId, $shareToken); if (isset($error)) { $this->logger->error("track error" . $fileId ." " . json_encode($error->getData()), array("app" => $this->appName)); @@ -492,12 +492,12 @@ private function getFile($userId, $fileId) { * Getting file by token * * @param integer $fileId - file identifier - * @param string $token - access token + * @param string $shareToken - access token * * @return array */ - private function getFileByToken($fileId, $token) { - list ($share, $error) = $this->getShare($token); + private function getFileByToken($fileId, $shareToken) { + list ($share, $error) = $this->getShare($shareToken); if (isset($error)) { return [NULL, $error]; @@ -532,18 +532,18 @@ private function getFileByToken($fileId, $token) { /** * Getting share by token * - * @param string $token - access token + * @param string $shareToken - access token * * @return array */ - private function getShare($token) { - if (empty($token)) { + private function getShare($shareToken) { + if (empty($shareToken)) { return [NULL, new JSONResponse(["message" => $this->trans->t("FileId is empty")], Http::STATUS_BAD_REQUEST)]; } $share; try { - $share = $this->shareManager->getShareByToken($token); + $share = $this->shareManager->getShareByToken($shareToken); } catch (ShareNotFound $e) { $this->logger->error("getShare error: " . $e->getMessage(), array("app" => $this->appName)); $share = NULL; diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 4f3abdce..6eeadb9b 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -173,25 +173,25 @@ public function __construct($AppName, * * @param string $name - file name * @param string $dir - folder path - * @param string $token - access token + * @param string $shareToken - access token * * @return array * * @NoAdminRequired * @PublicPage */ - public function create($name, $dir, $token = NULL) { + public function create($name, $dir, $shareToken = NULL) { $this->logger->debug("Create: " . $name, array("app" => $this->appName)); - if (empty($token) && !$this->config->isUserAllowedToUse()) { + if (empty($shareToken) && !$this->config->isUserAllowedToUse()) { return ["error" => $this->trans->t("Not permitted")]; } - if (empty($token)) { + if (empty($shareToken)) { $userId = $this->userSession->getUser()->getUID(); $userFolder = $this->root->getUserFolder($userId); } else { - list ($userFolder, $error, $share) = $this->getNodeByToken($token); + list ($userFolder, $error, $share) = $this->getNodeByToken($shareToken); if (isset($error)) { $this->logger->error("Create: " . $error, array("app" => $this->appName)); @@ -202,7 +202,7 @@ public function create($name, $dir, $token = NULL) { return ["error" => $this->trans->t("You don't have enough permission to create")]; } - if (!empty($token) && ($share->getPermissions() & Constants::PERMISSION_CREATE) === 0) { + if (!empty($shareToken) && ($share->getPermissions() & Constants::PERMISSION_CREATE) === 0) { $this->logger->error("Create in public folder without access: " . $fileId, array("app" => $this->appName)); return ["error" => $this->trans->t("You do not have enough permissions to view the file")]; } @@ -268,17 +268,17 @@ private function getTemplatePath($lang, $ext) { * Conversion file to Office Open XML format * * @param integer $fileId - file identifier - * @param string $token - access token + * @param string $shareToken - access token * * @return array * * @NoAdminRequired * @PublicPage */ - public function convert($fileId, $token = NULL) { + public function convert($fileId, $shareToken = NULL) { $this->logger->debug("Convert: " . $fileId, array("app" => $this->appName)); - if (empty($token) && !$this->config->isUserAllowedToUse()) { + if (empty($shareToken) && !$this->config->isUserAllowedToUse()) { return ["error" => $this->trans->t("Not permitted")]; } @@ -288,14 +288,14 @@ public function convert($fileId, $token = NULL) { $userId = $user->getUID(); } - list ($file, $error, $share) = empty($token) ? $this->getFile($userId, $fileId) : $this->getFileByToken($fileId, $token); + list ($file, $error, $share) = empty($shareToken) ? $this->getFile($userId, $fileId) : $this->getFileByToken($fileId, $shareToken); if (isset($error)) { $this->logger->error("Convertion: " . $fileId . " " . $error, array("app" => $this->appName)); return ["error" => $error]; } - if (!empty($token) && ($share->getPermissions() & Constants::PERMISSION_CREATE) === 0) { + if (!empty($shareToken) && ($share->getPermissions() & Constants::PERMISSION_CREATE) === 0) { $this->logger->error("Convertion in public folder without access: " . $fileId, array("app" => $this->appName)); return ["error" => $this->trans->t("You do not have enough permissions to view the file")]; } @@ -326,7 +326,7 @@ public function convert($fileId, $token = NULL) { $newFileUri; $documentService = new DocumentService($this->trans, $this->config); $key = $this->getKey($file); - $fileUrl = $this->getUrl($file, $token); + $fileUrl = $this->getUrl($file, $shareToken); try { $newFileUri = $documentService->GetConvertedUri($fileUrl, $ext, $internalExtension, $key); } catch (\Exception $e) { @@ -474,7 +474,7 @@ public function url($filePath) { * Print editor section * * @param integer $fileId - file identifier - * @param string $token - access token + * @param string $shareToken - access token * @param string $filePath - file path * * @return TemplateResponse|RedirectResponse @@ -482,17 +482,17 @@ public function url($filePath) { * @NoAdminRequired * @NoCSRFRequired */ - public function index($fileId, $token = NULL, $filePath = NULL) { + public function index($fileId, $shareToken = NULL, $filePath = NULL) { $this->logger->debug("Open: " . $fileId . " " . $filePath, array("app" => $this->appName)); - if (empty($token) && !$this->userSession->isLoggedIn()) { + if (empty($shareToken) && !$this->userSession->isLoggedIn()) { $redirectUrl = $this->urlGenerator->linkToRoute("core.login.showLoginForm", [ "redirect_url" => $this->request->getRequestUri() ]); return new RedirectResponse($redirectUrl); } - if (empty($token) && !$this->config->isUserAllowedToUse()) { + if (empty($shareToken) && !$this->config->isUserAllowedToUse()) { return $this->renderError($this->trans->t("Not permitted")); } @@ -507,7 +507,7 @@ public function index($fileId, $token = NULL, $filePath = NULL) { "documentServerUrl" => $documentServerUrl, "fileId" => $fileId, "filePath" => $filePath, - "token" => $token + "shareToken" => $shareToken ]; $response = new TemplateResponse($this->appName, "editor", $params); @@ -530,7 +530,7 @@ public function index($fileId, $token = NULL, $filePath = NULL) { * Print public editor section * * @param integer $fileId - file identifier - * @param string $token - access token + * @param string $shareToken - access token * * @return TemplateResponse * @@ -538,8 +538,8 @@ public function index($fileId, $token = NULL, $filePath = NULL) { * @NoCSRFRequired * @PublicPage */ - public function PublicPage($fileId, $token) { - return $this->index($fileId, $token); + public function PublicPage($fileId, $shareToken) { + return $this->index($fileId, $shareToken); } /** @@ -547,7 +547,7 @@ public function PublicPage($fileId, $token) { * * @param integer $fileId - file identifier * @param string $filePath - file path - * @param string $token - access token + * @param string $shareToken - access token * @param bool $desktop - desktop label * * @return array @@ -555,9 +555,9 @@ public function PublicPage($fileId, $token) { * @NoAdminRequired * @PublicPage */ - public function config($fileId, $filePath = NULL, $token = NULL, $desktop = false) { + public function config($fileId, $filePath = NULL, $shareToken = NULL, $desktop = false) { - if (empty($token) && !$this->config->isUserAllowedToUse()) { + if (empty($shareToken) && !$this->config->isUserAllowedToUse()) { return ["error" => $this->trans->t("Not permitted")]; } @@ -567,7 +567,7 @@ public function config($fileId, $filePath = NULL, $token = NULL, $desktop = fals $userId = $user->getUID(); } - list ($file, $error, $share) = empty($token) ? $this->getFile($userId, $fileId, $filePath) : $this->getFileByToken($fileId, $token); + list ($file, $error, $share) = empty($shareToken) ? $this->getFile($userId, $fileId, $filePath) : $this->getFileByToken($fileId, $shareToken); if (isset($error)) { $this->logger->error("Config: " . $fileId . " " . $error, array("app" => $this->appName)); @@ -582,7 +582,7 @@ public function config($fileId, $filePath = NULL, $token = NULL, $desktop = fals return ["error" => $this->trans->t("Format is not supported")]; } - $fileUrl = $this->getUrl($file, $token); + $fileUrl = $this->getUrl($file, $shareToken); $key = $this->getKey($file); $params = [ @@ -607,7 +607,7 @@ public function config($fileId, $filePath = NULL, $token = NULL, $desktop = fals $canEdit = isset($format["edit"]) && $format["edit"]; $editable = $file->isUpdateable() - && (empty($token) || ($share->getPermissions() & Constants::PERMISSION_UPDATE) === Constants::PERMISSION_UPDATE); + && (empty($shareToken) || ($share->getPermissions() & Constants::PERMISSION_UPDATE) === Constants::PERMISSION_UPDATE); $params["document"]["permissions"]["edit"] = $editable; if ($editable && $canEdit) { $ownerId = NULL; @@ -616,7 +616,7 @@ public function config($fileId, $filePath = NULL, $token = NULL, $desktop = fals $ownerId = $owner->getUID(); } - $hashCallback = $this->crypt->GetHash(["fileId" => $file->getId(), "ownerId" => $ownerId, "token" => $token, "action" => "track"]); + $hashCallback = $this->crypt->GetHash(["fileId" => $file->getId(), "ownerId" => $ownerId, "shareToken" => $shareToken, "action" => "track"]); $callback = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.track", ["doc" => $hashCallback]); if (!empty($this->config->GetStorageUrl())) { @@ -641,7 +641,7 @@ public function config($fileId, $filePath = NULL, $token = NULL, $desktop = fals $folderLink = NULL; - if (!empty($token)) { + if (!empty($shareToken)) { if (method_exists($share, "getHideDownload") && $share->getHideDownload()) { $params["document"]["permissions"]["download"] = false; $params["document"]["permissions"]["print"] = false; @@ -655,7 +655,7 @@ public function config($fileId, $filePath = NULL, $token = NULL, $desktop = fals $linkAttr = [ "path" => $folderPath, "scrollto" => $file->getName(), - "token" => $token + "token" => $shareToken ]; $folderLink = $this->urlGenerator->linkToRouteAbsolute("files_sharing.sharecontroller.showShare", $linkAttr); } @@ -686,7 +686,7 @@ public function config($fileId, $filePath = NULL, $token = NULL, $desktop = fals $params = $this->setCustomization($params); - $params = $this->setWatermark($params, !empty($token), $userId, $file); + $params = $this->setWatermark($params, !empty($shareToken), $userId, $file); if ($this->config->UseDemo()) { $params["editorConfig"]["tenant"] = $this->config->GetSystemValue("instanceid", true); @@ -750,12 +750,12 @@ private function getFile($userId, $fileId, $filePath = NULL) { * Getting file by token * * @param integer $fileId - file identifier - * @param string $token - access token + * @param string $shareToken - access token * * @return array */ - private function getFileByToken($fileId, $token) { - list ($node, $error, $share) = $this->getNodeByToken($token); + private function getFileByToken($fileId, $shareToken) { + list ($node, $error, $share) = $this->getNodeByToken($shareToken); if (isset($error)) { return [NULL, $error, NULL]; @@ -784,12 +784,12 @@ private function getFileByToken($fileId, $token) { /** * Getting file by token * - * @param string $token - access token + * @param string $shareToken - access token * * @return array */ - private function getNodeByToken($token) { - list ($share, $error) = $this->getShare($token); + private function getNodeByToken($shareToken) { + list ($share, $error) = $this->getShare($shareToken); if (isset($error)) { return [NULL, $error, NULL]; @@ -812,18 +812,18 @@ private function getNodeByToken($token) { /** * Getting share by token * - * @param string $token - access token + * @param string $shareToken - access token * * @return array */ - private function getShare($token) { - if (empty($token)) { + private function getShare($shareToken) { + if (empty($shareToken)) { return [NULL, $this->trans->t("FileId is empty")]; } $share; try { - $share = $this->shareManager->getShareByToken($token); + $share = $this->shareManager->getShareByToken($shareToken); } catch (ShareNotFound $e) { $this->logger->error("getShare error: " . $e->getMessage(), array("app" => $this->appName)); $share = NULL; @@ -863,11 +863,11 @@ private function getKey($file) { * Generate secure link to download document * * @param integer $file - file - * @param string $token - access token + * @param string $shareToken - access token * * @return string */ - private function getUrl($file, $token = NULL) { + private function getUrl($file, $shareToken = NULL) { $user = $this->userSession->getUser(); $userId = NULL; @@ -876,14 +876,14 @@ private function getUrl($file, $token = NULL) { } $ownerId = NULL; - if (empty($token)) { + if (empty($shareToken)) { $owner = $file->getOwner(); if (!empty($owner)) { $ownerId = $owner->getUID(); } } - $hashUrl = $this->crypt->GetHash(["fileId" => $file->getId(), "userId" => $userId, "ownerId" => $ownerId, "token" => $token, "action" => "download"]); + $hashUrl = $this->crypt->GetHash(["fileId" => $file->getId(), "userId" => $userId, "ownerId" => $ownerId, "shareToken" => $shareToken, "action" => "download"]); $fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.download", ["doc" => $hashUrl]); diff --git a/js/editor.js b/js/editor.js index 6024646d..c4b3d0f8 100644 --- a/js/editor.js +++ b/js/editor.js @@ -41,8 +41,8 @@ var fileId = $("#iframeEditor").data("id"); var filePath = $("#iframeEditor").data("path"); - var fileToken = $("#iframeEditor").data("token"); - if (!fileId && !fileToken) { + var shareToken = $("#iframeEditor").data("shareToken"); + if (!fileId && !shareToken) { displayError(t(OCA.Onlyoffice.AppName, "FileId is empty")); return; } @@ -61,8 +61,8 @@ if (filePath) { params.push("filePath=" + encodeURIComponent(filePath)); } - if (fileToken) { - params.push("token=" + encodeURIComponent(fileToken)); + if (shareToken) { + params.push("shareToken=" + encodeURIComponent(shareToken)); } if (OCA.Onlyoffice.Desktop) { params.push("desktop=true"); diff --git a/js/main.js b/js/main.js index 8db38f63..5bd4d3e4 100644 --- a/js/main.js +++ b/js/main.js @@ -51,7 +51,7 @@ }; if ($("#isPublic").val()) { - createData.token = encodeURIComponent($("#sharingToken").val()); + createData.shareToken = encodeURIComponent($("#sharingToken").val()); } $.post(OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/ajax/new"), @@ -87,9 +87,9 @@ }); if ($("#isPublic").val()) { - url = OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/s/{token}?fileId={fileId}", + url = OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/s/{shareToken}?fileId={fileId}", { - token: encodeURIComponent($("#sharingToken").val()), + shareToken: encodeURIComponent($("#sharingToken").val()), fileId: fileId }); } @@ -117,7 +117,7 @@ }; if ($("#isPublic").val()) { - convertData.token = encodeURIComponent($("#sharingToken").val()); + convertData.shareToken = encodeURIComponent($("#sharingToken").val()); } $.post(OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/ajax/convert"), diff --git a/templates/editor.php b/templates/editor.php index f20186d3..f8911422 100644 --- a/templates/editor.php +++ b/templates/editor.php @@ -34,7 +34,7 @@
-
" data-path="" data-token="">
+
" data-path="" data-shareToken="">