Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ONLYOFFICE/onlyoffice-nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Linnik <sergey.linnik@onlyoffice.com>2018-09-11 13:49:27 +0300
committerGitHub <noreply@github.com>2018-09-11 13:49:27 +0300
commit6738c68df43e46b9062dfbbb3f6359a2781f49d3 (patch)
treef3938e115d2bc08dd05f6ed4345dd8ee893f18d7
parent038d9e72ddf1cfa6c529cbf3bcec392f3a50b882 (diff)
parentfcba6d7d179573ed96bdfc4e9e2b68526abfbd08 (diff)
Merge pull request #10 from ONLYOFFICE/developv2.0.4
Release/2.0.4
-rw-r--r--CHANGELOG.md8
-rw-r--r--appinfo/info.xml4
-rw-r--r--controller/callbackcontroller.php4
-rw-r--r--controller/editorcontroller.php41
-rw-r--r--controller/settingscontroller.php28
-rw-r--r--js/settings.js6
-rw-r--r--l10n/de.js4
-rw-r--r--l10n/de.json4
-rw-r--r--l10n/de_DE.js2
-rw-r--r--l10n/de_DE.json2
-rw-r--r--l10n/es.js2
-rw-r--r--l10n/es.json2
-rw-r--r--l10n/ru.js2
-rw-r--r--l10n/ru.json2
-rw-r--r--lib/appconfig.php89
-rw-r--r--lib/crypt.php51
-rw-r--r--lib/documentservice.php12
-rw-r--r--templates/settings.php24
18 files changed, 179 insertions, 108 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 @@
<description>ONLYOFFICE connector enables you to edit Office documents within ONLYOFFICE from the familiar web interface. This will create a new Open in ONLYOFFICE action within the document library for Office documents. This allows multiple users to collaborate in real time and to save back those changes to your file storage.</description>
<licence>agpl</licence>
<author mail="dev@onlyoffice.com" homepage="https://www.onlyoffice.com/">Ascensio System SIA</author>
- <version>2.0.2</version>
+ <version>2.0.4</version>
<namespace>Onlyoffice</namespace>
<types>
<filesystem/>
@@ -30,7 +30,7 @@
<screenshot>https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-nextcloud/master/screenshots/new.png</screenshot>
<screenshot>https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-nextcloud/master/screenshots/open.png</screenshot>
<dependencies>
- <nextcloud min-version="12" max-version="14"/>
+ <nextcloud min-version="13" max-version="14"/>
</dependencies>
<settings>
<admin>OCA\Onlyoffice\AdminSettings</admin>
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);
}
}
diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php
index de03e26..80d653b 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));
@@ -253,13 +254,13 @@ 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")];
}
- 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")];
}
@@ -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);
@@ -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")];
}
@@ -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));
@@ -408,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")];
@@ -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")];
}
@@ -600,9 +607,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/controller/settingscontroller.php b/controller/settingscontroller.php
index 44a78f6..1a056ce 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()
];
@@ -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()) {
@@ -183,32 +185,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
@@ -285,7 +267,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/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 99905c9..0fd00d3 100644
--- a/l10n/de.js
+++ b/l10n/de.js
@@ -1,4 +1,4 @@
-OC.L10N.register(
+OC.L10N.register(
"onlyoffice",
{
"Access deny" : "Zugriff verweigern",
@@ -42,6 +42,8 @@
"Secret key (leave blank to disable)" : "Geheimer Schlüssel (freilassen, um zu deaktivieren)",
"Open file in the same tab" : "Datei in der gleichen Registerkarte öffnen",
"The default application for opening the format" : "Die Standardanwendung zum Öffnen des Formats",
+ "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Öffne die Datei zum Bearbeiten (aufgrund von Formateinschränkungen können die Daten beim Speichern in den Formaten aus der folgenden Liste verloren gehen)",
+ "View details" : "Details anzeigen",
"Save" : "Speichern",
"Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Mixed Active Content ist nicht möglich. HTTPS-Adresse für Document Server ist erforderlich."
},
diff --git a/l10n/de.json b/l10n/de.json
index bf6bd41..dddb082 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",
@@ -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 c585ec8..d0a719a 100644
--- a/lib/appconfig.php
+++ b/lib/appconfig.php
@@ -96,6 +96,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
*
* @var string
@@ -178,12 +185,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];
@@ -346,7 +357,7 @@ class AppConfig {
}
/**
- * Save the formats array with default action
+ * Save an array of formats with default action
*
* @param array $formats - formats with status
*/
@@ -358,11 +369,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();
@@ -371,6 +382,31 @@ class AppConfig {
}
/**
+ * 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
*
* @param boolean $value - same tab
@@ -397,7 +433,7 @@ class AppConfig {
*/
public function TurnOffVerification() {
$turnOff = $this->getSystemValue($this->_verification);
- return $turnOff === TRUE;
+ return $turnOff === true;
}
/**
@@ -431,14 +467,41 @@ 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");
+ }
+ }
+
+ $editFormats = $this->GetEditableFormats();
+ foreach ($editFormats as $format => $setting) {
+ if (array_key_exists($format, $result)) {
+ $result[$format]["edit"] = ($setting === true || $setting === "true");
+ }
+ }
+
+ return $result;
+ }
+
/**
* Additional data about formats
*
* @var array
*/
- public $formats = [
- "csv" => [ "mime" => "text/csv", "type" => "spreadsheet", "edit" => true ],
+ private $formats = [
+ "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 ],
@@ -447,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 ],
@@ -460,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/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;
- }
}
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);
}
}
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 @@
<h3 class="onlyoffice-header"><?php p($l->t("The default application for opening the format")) ?></h3>
<div class="onlyoffice-exts">
- <?php foreach ($_["formats"] as $format => $setting) {
- if (array_key_exists("mime", $setting)) { ?>
+ <?php foreach ($_["formats"] as $format => $setting) { ?>
+ <?php if (array_key_exists("mime", $setting)) { ?>
<div>
<input type="checkbox" class="checkbox"
id="onlyofficeDefFormat<?php p($format) ?>"
@@ -77,8 +77,24 @@
<?php if ($setting["def"]) { ?>checked="checked"<?php } ?> />
<label for="onlyofficeDefFormat<?php p($format) ?>"><?php p($format) ?></label>
</div>
- <?php }
- } ?>
+ <?php } ?>
+ <?php } ?>
+ </div>
+
+ <h3 class="onlyoffice-header"><?php p($l->t("Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)")) ?></h3>
+ <a target="_blank" class="icon-info svg" title="" href="https://api.onlyoffice.com/editors/owncloud#editable" data-original-title="<?php p($l->t("View details")) ?>"></a>
+ <div class="onlyoffice-exts">
+ <?php foreach ($_["formats"] as $format => $setting) { ?>
+ <?php if (array_key_exists("editable", $setting)) { ?>
+ <div>
+ <input type="checkbox" class="checkbox"
+ id="onlyofficeEditFormat<?php p($format) ?>"
+ name="<?php p($format) ?>"
+ <?php if ($setting["edit"]) { ?>checked="checked"<?php } ?> />
+ <label for="onlyofficeEditFormat<?php p($format) ?>"><?php p($format) ?></label>
+ </div>
+ <?php } ?>
+ <?php } ?>
</div>
<a id="onlyofficeSave" class="button onlyoffice-header"><?php p($l->t("Save")) ?></a>