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:
-rw-r--r--CHANGELOG.md11
-rw-r--r--appinfo/app.php2
-rw-r--r--appinfo/application.php13
-rw-r--r--appinfo/info.xml5
-rw-r--r--appinfo/routes.php3
-rw-r--r--assets/cs/new.docxbin8468 -> 7040 bytes
-rw-r--r--assets/cs/new.pptxbin35685 -> 34054 bytes
-rw-r--r--assets/de/new.docxbin8467 -> 7038 bytes
-rw-r--r--assets/de/new.pptxbin35672 -> 33551 bytes
-rw-r--r--assets/de_DE/new.docxbin8467 -> 7038 bytes
-rw-r--r--assets/de_DE/new.pptxbin35672 -> 33551 bytes
-rw-r--r--assets/el/new.docxbin8467 -> 7037 bytes
-rw-r--r--assets/en/new.docxbin8463 -> 7034 bytes
-rw-r--r--assets/es/new.docxbin8466 -> 7037 bytes
-rw-r--r--assets/fr/new.docxbin8467 -> 7038 bytes
-rw-r--r--assets/it/new.docxbin8466 -> 7038 bytes
-rw-r--r--assets/ko/new.docxbin8458 -> 7031 bytes
-rw-r--r--assets/pl/new.docxbin8466 -> 7038 bytes
-rw-r--r--assets/pt_BR/new.docxbin9710 -> 8551 bytes
-rw-r--r--assets/pt_PT/new.docxbin8466 -> 7038 bytes
-rw-r--r--assets/pt_PT/new.pptxbin35674 -> 35671 bytes
-rw-r--r--assets/ru/new.docxbin8467 -> 7038 bytes
-rw-r--r--assets/ru/new.pptxbin35680 -> 34591 bytes
-rw-r--r--assets/zh_CN/new.docxbin8468 -> 7038 bytes
-rw-r--r--controller/callbackcontroller.php148
-rw-r--r--controller/editorcontroller.php279
-rw-r--r--controller/settingscontroller.php6
-rw-r--r--css/editor.css3
-rw-r--r--css/main.css2
-rw-r--r--css/settings.css2
-rw-r--r--img/app-dark.svg (renamed from img/btn-edit.svg)0
-rw-r--r--js/editor.js9
-rw-r--r--js/main.js108
-rw-r--r--js/settings.js2
-rw-r--r--lib/adminsection.php83
-rw-r--r--lib/adminsettings.php4
-rw-r--r--lib/appconfig.php98
-rw-r--r--lib/crypt.php2
-rw-r--r--lib/documentservice.php2
-rw-r--r--lib/hookhandler.php47
-rw-r--r--settings.php2
-rw-r--r--templates/editor.php15
-rw-r--r--templates/settings.php2
43 files changed, 656 insertions, 192 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index df230fe..a79cf80 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,16 @@
# Change Log
+## 1.3.0
+## Added
+- add macro-enabled and template formats
+- support shared link for document
+- customization editor
+
+## Changed
+- update template empty files
+- fix collaboration editing
+- view without converting
+
## 1.2.0
## Added
- disabling for incorrect settings
diff --git a/appinfo/app.php b/appinfo/app.php
index c7ce9b0..f4cbcc0 100644
--- a/appinfo/app.php
+++ b/appinfo/app.php
@@ -1,7 +1,7 @@
<?php
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
diff --git a/appinfo/application.php b/appinfo/application.php
index 4b7ba89..907764f 100644
--- a/appinfo/application.php
+++ b/appinfo/application.php
@@ -1,7 +1,7 @@
<?php
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
@@ -27,6 +27,7 @@
namespace OCA\Onlyoffice\AppInfo;
use OCP\AppFramework\App;
+use OCP\Share\IManager;
use OCP\Util;
use OCA\Onlyoffice\AppConfig;
@@ -34,6 +35,7 @@ use OCA\Onlyoffice\Controller\CallbackController;
use OCA\Onlyoffice\Controller\EditorController;
use OCA\Onlyoffice\Controller\SettingsController;
use OCA\Onlyoffice\Crypt;
+use OCA\Onlyoffice\Hookhandler;
class Application extends App {
@@ -69,6 +71,8 @@ class Application extends App {
}
});
+ Util::connectHook("OCP\Share", "share_link_access", Hookhandler::class, "PublicPage");
+
require_once __DIR__ . "/../3rdparty/jwt/BeforeValidException.php";
require_once __DIR__ . "/../3rdparty/jwt/ExpiredException.php";
require_once __DIR__ . "/../3rdparty/jwt/SignatureInvalidException.php";
@@ -120,7 +124,9 @@ class Application extends App {
$c->query("L10N"),
$c->query("Logger"),
$this->appConfig,
- $this->crypt
+ $this->crypt,
+ $c->query("IManager"),
+ $c->query("Session")
);
});
@@ -134,7 +140,8 @@ class Application extends App {
$c->query("L10N"),
$c->query("Logger"),
$this->appConfig,
- $this->crypt
+ $this->crypt,
+ $c->query("IManager")
);
});
}
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 274b00b..e3025e4 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>Ascensio System SIA</author>
- <version>1.2.0</version>
+ <version>1.3.0</version>
<namespace>Onlyoffice</namespace>
<types>
<filesystem/>
@@ -29,9 +29,10 @@
<screenshot>https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-owncloud/master/screenshots/settings.png</screenshot>
<dependencies>
<owncloud min-version="9.0" max-version="10.0" />
- <nextcloud min-version="11" max-version="13"/>
+ <nextcloud min-version="12" max-version="13"/>
</dependencies>
<settings>
<admin>OCA\Onlyoffice\AdminSettings</admin>
+ <admin-section>OCA\Onlyoffice\AdminSection</admin-section>
</settings>
</info> \ No newline at end of file
diff --git a/appinfo/routes.php b/appinfo/routes.php
index 125bcac..5355622 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -1,7 +1,7 @@
<?php
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
@@ -30,6 +30,7 @@ return [
["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#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/assets/cs/new.docx b/assets/cs/new.docx
index c55264b..863bb2e 100644
--- a/assets/cs/new.docx
+++ b/assets/cs/new.docx
Binary files differ
diff --git a/assets/cs/new.pptx b/assets/cs/new.pptx
index 825dd3b..7e678b4 100644
--- a/assets/cs/new.pptx
+++ b/assets/cs/new.pptx
Binary files differ
diff --git a/assets/de/new.docx b/assets/de/new.docx
index 0c83b58..7697bab 100644
--- a/assets/de/new.docx
+++ b/assets/de/new.docx
Binary files differ
diff --git a/assets/de/new.pptx b/assets/de/new.pptx
index 914a6cc..a44d78a 100644
--- a/assets/de/new.pptx
+++ b/assets/de/new.pptx
Binary files differ
diff --git a/assets/de_DE/new.docx b/assets/de_DE/new.docx
index 0c83b58..7697bab 100644
--- a/assets/de_DE/new.docx
+++ b/assets/de_DE/new.docx
Binary files differ
diff --git a/assets/de_DE/new.pptx b/assets/de_DE/new.pptx
index 914a6cc..a44d78a 100644
--- a/assets/de_DE/new.pptx
+++ b/assets/de_DE/new.pptx
Binary files differ
diff --git a/assets/el/new.docx b/assets/el/new.docx
index b66945d..b697181 100644
--- a/assets/el/new.docx
+++ b/assets/el/new.docx
Binary files differ
diff --git a/assets/en/new.docx b/assets/en/new.docx
index 56831d5..3433b6e 100644
--- a/assets/en/new.docx
+++ b/assets/en/new.docx
Binary files differ
diff --git a/assets/es/new.docx b/assets/es/new.docx
index feb0bc8..5354fac 100644
--- a/assets/es/new.docx
+++ b/assets/es/new.docx
Binary files differ
diff --git a/assets/fr/new.docx b/assets/fr/new.docx
index 0836cb2..04cf5f9 100644
--- a/assets/fr/new.docx
+++ b/assets/fr/new.docx
Binary files differ
diff --git a/assets/it/new.docx b/assets/it/new.docx
index 3c903a3..e84d795 100644
--- a/assets/it/new.docx
+++ b/assets/it/new.docx
Binary files differ
diff --git a/assets/ko/new.docx b/assets/ko/new.docx
index c2130ce..6f331d4 100644
--- a/assets/ko/new.docx
+++ b/assets/ko/new.docx
Binary files differ
diff --git a/assets/pl/new.docx b/assets/pl/new.docx
index f526604..e97de5c 100644
--- a/assets/pl/new.docx
+++ b/assets/pl/new.docx
Binary files differ
diff --git a/assets/pt_BR/new.docx b/assets/pt_BR/new.docx
index 1339e2f..a924ff6 100644
--- a/assets/pt_BR/new.docx
+++ b/assets/pt_BR/new.docx
Binary files differ
diff --git a/assets/pt_PT/new.docx b/assets/pt_PT/new.docx
index bf7b7af..700f7e3 100644
--- a/assets/pt_PT/new.docx
+++ b/assets/pt_PT/new.docx
Binary files differ
diff --git a/assets/pt_PT/new.pptx b/assets/pt_PT/new.pptx
index 988986e..0f18234 100644
--- a/assets/pt_PT/new.pptx
+++ b/assets/pt_PT/new.pptx
Binary files differ
diff --git a/assets/ru/new.docx b/assets/ru/new.docx
index 4ce057b..875dad5 100644
--- a/assets/ru/new.docx
+++ b/assets/ru/new.docx
Binary files differ
diff --git a/assets/ru/new.pptx b/assets/ru/new.pptx
index c8b074e..0848cb7 100644
--- a/assets/ru/new.pptx
+++ b/assets/ru/new.pptx
Binary files differ
diff --git a/assets/zh_CN/new.docx b/assets/zh_CN/new.docx
index 7dc9fd7..d0262e2 100644
--- a/assets/zh_CN/new.docx
+++ b/assets/zh_CN/new.docx
Binary files differ
diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php
index 08b80c2..284e7d8 100644
--- a/controller/callbackcontroller.php
+++ b/controller/callbackcontroller.php
@@ -1,7 +1,7 @@
<?php
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
@@ -30,13 +30,17 @@ use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataDownloadResponse;
use OCP\AppFramework\Http\JSONResponse;
+use OCP\Constants;
use OCP\Files\File;
+use OCP\Files\Folder;
use OCP\Files\IRootFolder;
+use OCP\Files\NotPermittedException;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\Share\IManager;
use OCA\Onlyoffice\AppConfig;
use OCA\Onlyoffice\Crypt;
@@ -99,6 +103,13 @@ class CallbackController extends Controller {
private $crypt;
/**
+ * Share manager
+ *
+ * @var OCP\Share\IManager
+ */
+ private $shareManager;
+
+ /**
* Status of the document
*
* @var Array
@@ -121,6 +132,7 @@ class CallbackController extends Controller {
* @param ILogger $logger - logger
* @param OCA\Onlyoffice\AppConfig $config - application configuration
* @param OCA\Onlyoffice\Crypt $crypt - hash generator
+ * @param IManager $shareManager - Share manager
*/
public function __construct($AppName,
IRequest $request,
@@ -130,7 +142,8 @@ class CallbackController extends Controller {
IL10N $trans,
ILogger $logger,
AppConfig $config,
- Crypt $crypt
+ Crypt $crypt,
+ IManager $shareManager
) {
parent::__construct($AppName, $request);
@@ -141,6 +154,7 @@ class CallbackController extends Controller {
$this->logger = $logger;
$this->config = $config;
$this->crypt = $crypt;
+ $this->shareManager = $shareManager;
}
@@ -190,21 +204,16 @@ class CallbackController extends Controller {
$userId = $hashData->userId;
- $files = $this->root->getUserFolder($userId)->getById($fileId);
- if (empty($files)) {
- $this->logger->info("Files for download not found: " . $fileId, array("app" => $this->appName));
- return new JSONResponse(["message" => $this->trans->t("Files not found")], Http::STATUS_NOT_FOUND);
- }
- $file = $files[0];
+ $token = $hashData->token;
+ list ($file, $error) = empty($token) ? $this->getFile($userId, $fileId) : $this->getFileByToken($fileId, $token);
- if (! $file instanceof File) {
- $this->logger->info("File for download not found: " . $fileId, array("app" => $this->appName));
- return new JSONResponse(["message" => $this->trans->t("File not found")], Http::STATUS_NOT_FOUND);
+ if (isset($error)) {
+ return $error;
}
try {
return new DataDownloadResponse($file->getContent(), $file->getName(), $file->getMimeType());
- } catch (\OCP\Files\NotPermittedException $e) {
+ } catch (NotPermittedException $e) {
$this->logger->info("Download Not permitted: " . $fileId . " " . $e->getMessage(), array("app" => $this->appName));
return new JSONResponse(["message" => $this->trans->t("Not permitted")], Http::STATUS_FORBIDDEN);
}
@@ -263,7 +272,7 @@ class CallbackController extends Controller {
try {
return new DataDownloadResponse($template, "new.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
- } catch (\OCP\Files\NotPermittedException $e) {
+ } catch (NotPermittedException $e) {
$this->logger->info("Download Not permitted: " . $fileId . " " . $e->getMessage(), array("app" => $this->appName));
return new JSONResponse(["message" => $this->trans->t("Not permitted")], Http::STATUS_FORBIDDEN);
}
@@ -335,21 +344,26 @@ class CallbackController extends Controller {
return new JSONResponse(["message" => $this->trans->t("Url not found")], Http::STATUS_BAD_REQUEST);
}
- $userId = $hashData->userId;
+ $userId = $users[0];
+ $user = $this->userManager->get($userId);
+ if (!empty($user)) {
+ $this->logger->info("setupFS " . $userId, array("app" => $this->appName));
+ \OC_Util::tearDownFS();
+ \OC_Util::setupFS($userId);
- \OC_Util::tearDownFS();
- \OC_Util::setupFS($userId);
+ $this->userSession->setUser($user);
+ } else {
+ $ownerId = $hashData->ownerId;
- $files = $this->root->getUserFolder($userId)->getById($fileId);
- if (empty($files)) {
- $this->logger->info("Files for track not found: " . $fileId, array("app" => $this->appName));
- return new JSONResponse(["message" => $this->trans->t("Files not found")], Http::STATUS_NOT_FOUND);
+ \OC_Util::tearDownFS();
+ \OC_Util::setupFS($ownerId);
}
- $file = $files[0];
- if (! $file instanceof File) {
- $this->logger->info("File for track not found: " . $fileId, array("app" => $this->appName));
- return new JSONResponse(["message" => $this->trans->t("File not found")], Http::STATUS_NOT_FOUND);
+ $token = $hashData->token;
+ list ($file, $error) = empty($token) ? $this->getFile($userId, $fileId) : $this->getFileByToken($fileId, $token);
+
+ if (isset($error)) {
+ return $error;
}
$fileName = $file->getName();
@@ -374,7 +388,7 @@ class CallbackController extends Controller {
if (!preg_match("/^https?:\/\//i", $from)) {
$parsedUrl = parse_url($url);
- $from = $parsedUrl["scheme"] . "://" . $parsedUrl["host"] . (array_key_exists("port", $parsedUrl) ? (":" . $parsedUrl["port"]) : "") . "/";
+ $from = $parsedUrl["scheme"] . "://" . $parsedUrl["host"] . (array_key_exists("port", $parsedUrl) ? (":" . $parsedUrl["port"]) : "") . $from;
}
if ($from !== $documentServerUrl)
@@ -384,13 +398,6 @@ class CallbackController extends Controller {
}
}
- $this->userSession->setUser($this->userManager->get($users[0]));
-
- if (!$file->isUpdateable()) {
- $this->logger->error("Save error. File is not updateable: " . $fileId, array("app" => $this->appName));
- return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN);
- }
-
if (($newData = $documentService->Request($url))) {
$file->putContent($newData);
$error = 0;
@@ -403,6 +410,81 @@ class CallbackController extends Controller {
break;
}
- return new JSONResponse(["error" => $error], ($error === 0 ? Http::STATUS_OK : Http::STATUS_BAD_REQUEST));
+ return new JSONResponse(["error" => $error], Http::STATUS_OK);
+ }
+
+
+ /**
+ * Getting file by identifier
+ *
+ * @param integer $userId - user identifier
+ * @param integer $fileId - file identifier
+ *
+ * @return array
+ */
+ private function getFile($userId, $fileId) {
+ if (empty($fileId)) {
+ return [NULL, $this->trans->t("FileId is empty")];
+ }
+
+ $files = $this->root->getUserFolder($userId)->getById($fileId);
+ if (empty($files)) {
+ $this->logger->info("Files not found: " . $fileId, array("app" => $this->appName));
+ return new JSONResponse(["message" => $this->trans->t("Files not found")], Http::STATUS_NOT_FOUND);
+ }
+ $file = $files[0];
+
+ if (! $file instanceof File) {
+ $this->logger->info("File not found: " . $fileId, array("app" => $this->appName));
+ return new JSONResponse(["message" => $this->trans->t("File not found")], Http::STATUS_NOT_FOUND);
+ }
+
+ return [$file, NULL];
+ }
+
+ /**
+ * Getting file by token
+ *
+ * @param integer $fileId - file identifier
+ * @param string $token - access token
+ *
+ * @return array
+ */
+ private function getFileByToken($fileId, $token) {
+ list ($share, $error) = $this->getShare($token);
+
+ if (isset($error)) {
+ return [NULL, $error];
+ }
+
+ $node = $share->getNode();
+
+ if ($node instanceof Folder) {
+ $file = $node->getById($fileId)[0];
+ } else {
+ $file = $node;
+ }
+
+ return [$file, NULL];
+ }
+
+ /**
+ * Getting share by token
+ *
+ * @param string $token - access token
+ *
+ * @return array
+ */
+ private function getShare($token) {
+ if (empty($token)) {
+ return [NULL, $this->trans->t("FileId is empty")];
+ }
+
+ $share = $this->shareManager->getShareByToken($token);
+ if ($share === NULL || $share === false) {
+ return [NULL, $this->trans->t("You do not have enough permissions to view the file")];
+ }
+
+ return [$share, NULL];
}
} \ No newline at end of file
diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php
index e0ffd9f..d5a28bc 100644
--- a/controller/editorcontroller.php
+++ b/controller/editorcontroller.php
@@ -1,7 +1,7 @@
<?php
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
@@ -26,25 +26,25 @@
namespace OCA\Onlyoffice\Controller;
-use OCP\App;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Controller;
use OCP\AutoloadNotAllowedException;
+use OCP\Constants;
use OCP\Files\FileInfo;
+use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
+use OCP\ISession;
use OCP\IURLGenerator;
use OCP\IUserSession;
+use OCP\Share\IManager;
use OC\Files\Filesystem;
-use OC\Files\View;
-use OC\User\NoUserException;
use OCA\Files\Helper;
-use OCA\Files_Versions\Storage;
use OCA\Onlyoffice\AppConfig;
use OCA\Onlyoffice\Crypt;
@@ -105,6 +105,20 @@ class EditorController extends Controller {
private $crypt;
/**
+ * Share manager
+ *
+ * @var IManager
+ */
+ private $shareManager;
+
+ /**
+ * Session
+ *
+ * @var ISession
+ */
+ private $session;
+
+ /**
* Mobile regex from https://github.com/ONLYOFFICE/CommunityServer/blob/v9.1.1/web/studio/ASC.Web.Studio/web.appsettings.config#L35
*/
const USER_AGENT_MOBILE = "/android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i";
@@ -119,6 +133,8 @@ class EditorController extends Controller {
* @param ILogger $logger - logger
* @param OCA\Onlyoffice\AppConfig $config - application configuration
* @param OCA\Onlyoffice\Crypt $crypt - hash generator
+ * @param IManager $shareManager - Share manager
+ * @param IManager $ISession - Session
*/
public function __construct($AppName,
IRequest $request,
@@ -128,7 +144,9 @@ class EditorController extends Controller {
IL10N $trans,
ILogger $logger,
AppConfig $config,
- Crypt $crypt
+ Crypt $crypt,
+ IManager $shareManager,
+ ISession $session
) {
parent::__construct($AppName, $request);
@@ -139,6 +157,8 @@ class EditorController extends Controller {
$this->logger = $logger;
$this->config = $config;
$this->crypt = $crypt;
+ $this->shareManager = $shareManager;
+ $this->session = $session;
}
/**
@@ -251,7 +271,8 @@ class EditorController extends Controller {
$newFileUri;
$documentService = new DocumentService($this->trans, $this->config);
$key = $this->getKey($file);
- $fileUrl = $this->getUrl($file);
+ $fileId = $file->getId();
+ $fileUrl = $this->getUrl($fileId);
try {
$newFileUri = $documentService->GetConvertedUri($fileUrl, $ext, $internalExtension, $key);
} catch (\Exception $e) {
@@ -298,13 +319,15 @@ class EditorController extends Controller {
* Print editor section
*
* @param integer $fileId - file identifier
+ * @param string $token - access token
*
* @return TemplateResponse
*
* @NoAdminRequired
* @NoCSRFRequired
+ * @PublicPage
*/
- public function index($fileId) {
+ public function index($fileId, $token = NULL) {
$this->logger->debug("Open: " . $fileId, array("app" => $this->appName));
$documentServerUrl = $this->config->GetDocumentServerUrl();
@@ -316,7 +339,8 @@ class EditorController extends Controller {
$params = [
"documentServerUrl" => $documentServerUrl,
- "fileId" => $fileId
+ "fileId" => $fileId,
+ "token" => $token
];
$response = new TemplateResponse($this->appName, "editor", $params);
@@ -336,20 +360,37 @@ class EditorController extends Controller {
}
/**
+ * Print public editor section
+ *
+ * @param string $token - access token
+ *
+ * @return TemplateResponse
+ *
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @PublicPage
+ */
+ public function PublicPage($token) {
+ return $this->index(0, $token);
+ }
+
+ /**
* Collecting the file parameters for the document service
*
* @param integer $fileId - file identifier
+ * @param string $token - access token
*
* @return array
*
* @NoAdminRequired
+ * @PublicPage
*/
- public function config($fileId) {
+ public function config($fileId, $token = NULL) {
- list ($file, $error) = $this->getFile($fileId);
+ list ($file, $error) = empty($token) ? $this->getFile($fileId) : $this->getFileByToken($fileId, $token);
if (isset($error)) {
- $this->logger->error("Convertion: " . $fileId . " " . $error, array("app" => $this->appName));
+ $this->logger->error("Config: " . $fileId . " " . $error, array("app" => $this->appName));
return ["error" => $error];
}
@@ -361,31 +402,10 @@ class EditorController extends Controller {
return ["error" => $this->trans->t("Format is not supported")];
}
- $userId = $this->userSession->getUser()->getUID();
- $userFolder = $this->root->getUserFolder($userId);
- $folderPath = $userFolder->getRelativePath($file->getParent()->getPath());
- $folderLink = $this->urlGenerator->linkToRouteAbsolute("files.view.index", [
- "dir" => $folderPath,
- "scrollto" => $file->getName()
- ]);
-
$fileId = $file->getId();
- $hashCallback = $this->crypt->GetHash(["fileId" => $fileId, "userId" => $userId, "action" => "track"]);
- $fileUrl = $this->getUrl($file);
+ $fileUrl = $this->getUrl($fileId, $token);
$key = $this->getKey($file);
- $canEdit = isset($format["edit"]) && $format["edit"];
- $callback = ($file->isUpdateable() && $canEdit ? $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.track", ["doc" => $hashCallback]) : "");
-
- if (!empty($this->config->GetStorageUrl())) {
- $callback = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->GetStorageUrl(), $callback);
- }
-
- $type = "desktop";
- if (\OC::$server->getRequest()->isUserAgent([$this::USER_AGENT_MOBILE])) {
- $type = "mobile";
- }
-
$params = [
"document" => [
"fileType" => $ext,
@@ -395,22 +415,60 @@ class EditorController extends Controller {
],
"documentType" => $format["type"],
"editorConfig" => [
- "callbackUrl" => $callback,
- "customization" => [
- "goback" => [
- "url" => $folderLink
- ]
- ],
- "lang" => str_replace("_", "-", \OC::$server->getL10NFactory("")->get("")->getLanguageCode()),
- "mode" => (empty($callback) ? "view" : "edit"),
- "user" => [
- "id" => $userId,
- "name" => $this->userSession->getUser()->getDisplayName()
- ]
- ],
- "type" => $type
+ "lang" => str_replace("_", "-", \OC::$server->getL10NFactory("")->get("")->getLanguageCode())
+ ]
];
+ if (\OC::$server->getRequest()->isUserAgent([$this::USER_AGENT_MOBILE])) {
+ $params["type"] = "mobile";
+ }
+
+ $canEdit = isset($format["edit"]) && $format["edit"];
+ $editable = $file->isUpdateable()
+ && (empty($token) || ($this->getShare($token)[0]->getPermissions() & Constants::PERMISSION_UPDATE) === Constants::PERMISSION_UPDATE);
+ if ($editable && $canEdit) {
+ $hashCallback = $this->crypt->GetHash(["fileId" => $fileId, "ownerId" => $file->getOwner()->getUID(), "token" => $token, "action" => "track"]);
+ $callback = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.track", ["doc" => $hashCallback]);
+
+ if (!empty($this->config->GetStorageUrl())) {
+ $callback = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->GetStorageUrl(), $callback);
+ }
+
+ $params["editorConfig"]["callbackUrl"] = $callback;
+ } else {
+ $params["editorConfig"]["mode"] = "view";
+ }
+
+ $user = $this->userSession->getUser();
+ $userId = NULL;
+ if (!empty($user)) {
+ $userId = $user->getUID();
+ }
+
+ if (!empty($userId)) {
+ $params["editorConfig"]["user"] = [
+ "id" => $userId,
+ "name" => $user->getDisplayName()
+ ];
+
+ $userFolder = $this->root->getUserFolder($userId);
+ $folderPath = $userFolder->getRelativePath($file->getParent()->getPath());
+ $linkAttr = NULL;
+ if (!empty($folderPath)) {
+ $linkAttr = [
+ "dir" => $folderPath,
+ "scrollto" => $file->getName()
+ ];
+ }
+ $folderLink = $this->urlGenerator->linkToRouteAbsolute("files.view.index", $linkAttr);
+
+ $params["editorConfig"]["customization"]["goback"] = [
+ "url" => $folderLink
+ ];
+ }
+
+ $params = $this->setCustomization($params);
+
if (!empty($this->config->GetDocumentServerSecret())) {
$token = \Firebase\JWT\JWT::encode($params, $this->config->GetDocumentServerSecret());
$params["token"] = $token;
@@ -446,52 +504,93 @@ class EditorController extends Controller {
}
/**
- * Generate unique document identifier
+ * Getting file by token
*
- * @param \OCP\Files\File - file
+ * @param integer $fileId - file identifier
+ * @param string $token - access token
*
- * @return string
+ * @return array
*/
- private function getKey($file) {
- $fileId = $file->getId();
+ private function getFileByToken($fileId, $token) {
+ list ($share, $error) = $this->getShare($token);
- $key = $fileId . "_" . $file->getMtime();
+ if (isset($error)) {
+ return [NULL, $error];
+ }
- $ownerId = $file->getOwner()->getUID();
- try {
- $this->root->getUserFolder($ownerId);
- } catch (NoUserException $e) {
- $ownerId = $this->userSession->getUser()->getUID();
+ if (($share->getPermissions() & Constants::PERMISSION_READ) === 0) {
+ return [NULL, $this->trans->t("You do not have enough permissions to view the file")];
+ }
+
+ $node = $share->getNode();
+
+ if ($node instanceof Folder) {
+ $file = $node->getById($fileId)[0];
+ } else {
+ $file = $node;
+ }
+
+ return [$file, NULL];
+ }
+
+ /**
+ * Getting share by token
+ *
+ * @param string $token - access token
+ *
+ * @return array
+ */
+ private function getShare($token) {
+ if (empty($token)) {
+ return [NULL, $this->trans->t("FileId is empty")];
}
- $ownerView = new View("/" . $ownerId . "/files");
- $filePath = $ownerView->getPath($fileId);
- $versions = [];
- if (App::isEnabled("files_versions")) {
- $versions = Storage::getVersions($ownerId, $filePath);
+ $share = $this->shareManager->getShareByToken($token);
+ if ($share === NULL || $share === false) {
+ return [NULL, $this->trans->t("You do not have enough permissions to view the file")];
}
- $countVersions = count($versions);
- if ($countVersions > 0) {
- $key = $key . "_" . $countVersions;
+ if ($share->getPassword()
+ && (!$this->session->exists("public_link_authenticated")
+ || $this->session->get("public_link_authenticated") !== (string) $share->getId())) {
+ return [NULL, $this->trans->t("You do not have enough permissions to view the file")];
}
+ return [$share, NULL];
+ }
+
+ /**
+ * Generate unique document identifier
+ *
+ * @param File $file - file
+ *
+ * @return string
+ */
+ private function getKey($file) {
+ $fileId = $file->getId();
+
+ $key = $fileId . "_" . $file->getMtime();
+
return $key;
}
/**
* Generate secure link to download document
*
- * @param \OCP\Files\File - file
+ * @param integer $fileId - file identifier
+ * @param string $token - access token
*
* @return string
*/
- private function getUrl($file) {
- $fileId = $file->getId();
+ private function getUrl($fileId, $token = NULL) {
- $userId = $this->userSession->getUser()->getUID();
+ $user = $this->userSession->getUser();
+ $userId = NULL;
+ if (!empty($user)) {
+ $userId = $user->getUID();
+ }
- $hashUrl = $this->crypt->GetHash(["fileId" => $fileId, "userId" => $userId, "action" => "download"]);
+ $hashUrl = $this->crypt->GetHash(["fileId" => $fileId, "userId" => $userId, "token" => $token, "action" => "download"]);
$fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.download", ["doc" => $hashUrl]);
@@ -501,4 +600,40 @@ class EditorController extends Controller {
return $fileUrl;
}
+
+ /**
+ * Set customization parameters
+ *
+ * @param array params - file parameters
+ *
+ * @return array
+ */
+ private function setCustomization($params) {
+ $customer = $this->config->getSystemValue($this->config->_customization_customer);
+ if (isset($customer)) {
+ $params["editorConfig"]["customization"]["customer"] = $customer;
+ }
+
+ $feedback = $this->config->getSystemValue($this->config->_customization_feedback);
+ if (isset($feedback)) {
+ $params["editorConfig"]["customization"]["feedback"] = $feedback;
+ }
+
+ $loaderLogo = $this->config->getSystemValue($this->config->_customization_loaderLogo);
+ if (isset($loaderLogo)) {
+ $params["editorConfig"]["customization"]["loaderLogo"] = $loaderLogo;
+ }
+
+ $loaderName = $this->config->getSystemValue($this->config->_customization_loaderName);
+ if (isset($loaderName)) {
+ $params["editorConfig"]["customization"]["loaderName"] = $loaderName;
+ }
+
+ $logo = $this->config->getSystemValue($this->config->_customization_logo);
+ if (isset($logo)) {
+ $params["editorConfig"]["customization"]["logo"] = $logo;
+ }
+
+ return $params;
+ }
} \ No newline at end of file
diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php
index 0726e56..f8175c5 100644
--- a/controller/settingscontroller.php
+++ b/controller/settingscontroller.php
@@ -1,7 +1,7 @@
<?php
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
@@ -184,6 +184,8 @@ class SettingsController extends Controller {
* @return array
*
* @NoAdminRequired
+ * @NoCSRFRequired
+ * @PublicPage
*/
public function GetSettings() {
$result = [
@@ -272,7 +274,7 @@ class SettingsController extends Controller {
return false;
}
- $crypt = new \OCA\Encryption\Crypto\Crypt(\OC::$server->getLogger(), \OC::$server->getUserSession(), \OC::$server->getConfig(), \OC::$server->getL10N('encryption'));
+ $crypt = new \OCA\Encryption\Crypto\Crypt(\OC::$server->getLogger(), \OC::$server->getUserSession(), \OC::$server->getConfig(), \OC::$server->getL10N("encryption"));
$util = new \OCA\Encryption\Util(new \OC\Files\View(), $crypt, \OC::$server->getLogger(), \OC::$server->getUserSession(), \OC::$server->getConfig(), \OC::$server->getUserManager());
if ($util->isMasterKeyEnabled()) {
return false;
diff --git a/css/editor.css b/css/editor.css
index bf1d825..758ac6d 100644
--- a/css/editor.css
+++ b/css/editor.css
@@ -1,6 +1,6 @@
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
@@ -24,6 +24,7 @@
*/
#app > iframe {
+ position: absolute;
vertical-align: top;
}
diff --git a/css/main.css b/css/main.css
index d2c5773..9f4fb11 100644
--- a/css/main.css
+++ b/css/main.css
@@ -1,6 +1,6 @@
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
diff --git a/css/settings.css b/css/settings.css
index 047bd96..e960290 100644
--- a/css/settings.css
+++ b/css/settings.css
@@ -1,6 +1,6 @@
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
diff --git a/img/btn-edit.svg b/img/app-dark.svg
index b9e4967..b9e4967 100644
--- a/img/btn-edit.svg
+++ b/img/app-dark.svg
diff --git a/js/editor.js b/js/editor.js
index 9ca1b8e..803edee 100644
--- a/js/editor.js
+++ b/js/editor.js
@@ -1,6 +1,6 @@
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
@@ -38,7 +38,8 @@
};
var fileId = $("#iframeEditor").data("id");
- if (!fileId) {
+ var fileToken = $("#iframeEditor").data("token");
+ if (!fileId && !fileToken) {
displayError(t(OCA.Onlyoffice.AppName, "FileId is empty"));
return;
}
@@ -49,7 +50,7 @@
}
$.ajax({
- url: OC.generateUrl("apps/onlyoffice/ajax/config/" + fileId),
+ url: OC.generateUrl("apps/onlyoffice/ajax/config/" + fileId + (fileToken ? "?token=" + encodeURIComponent(fileToken) : "")),
success: function onSuccess(config) {
if (config) {
if (config.error != null) {
@@ -65,7 +66,7 @@
if (docIsChanged !== event.data) {
var titleChange = function () {
- window.document.title = config.document.title + (event.data ? " *" : "") + ' - ' + oc_defaults.title;
+ window.document.title = config.document.title + (event.data ? " *" : "") + " - " + oc_defaults.title;
docIsChanged = event.data;
};
diff --git a/js/main.js b/js/main.js
index 376eec3..bf81776 100644
--- a/js/main.js
+++ b/js/main.js
@@ -1,6 +1,6 @@
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
@@ -79,6 +79,10 @@
fileId: fileId
});
+ if ($("#isPublic").val()) {
+ url += "?token=" + encodeURIComponent($("#sharingToken").val());
+ }
+
if (winEditor && winEditor.location) {
winEditor.location.href = url;
} else if (!OCA.Onlyoffice.setting.sameTab) {
@@ -91,7 +95,7 @@
OCA.Onlyoffice.FileClick = function (fileName, context, attr) {
var fileInfoModel = context.fileInfoModel || context.fileList.getModelForFile(fileName);
var fileList = context.fileList;
- if (!attr.conv) {
+ if (!attr.conv || (fileList.dirInfo.permissions & OC.PERMISSION_CREATE) !== OC.PERMISSION_CREATE || $("#isPublic").val()) {
OCA.Onlyoffice.OpenEditor(fileInfoModel.id);
return;
}
@@ -100,6 +104,7 @@
t(OCA.Onlyoffice.AppName, "Convert and open document"),
function (convert) {
if (!convert) {
+ OCA.Onlyoffice.OpenEditor(fileInfoModel.id);
return;
}
@@ -128,38 +133,54 @@
});
};
+ OCA.Onlyoffice.GetSettings = function (callbackSettings) {
+ if (OCA.Onlyoffice.setting.formats) {
+
+ callbackSettings();
+
+ } else {
+
+ $.get(OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/ajax/settings"),
+ function onSuccess(settings) {
+ OCA.Onlyoffice.setting = settings;
+
+ callbackSettings();
+ }
+ );
+
+ }
+ };
+
OCA.Onlyoffice.FileList = {
attach: function (fileList) {
if (fileList.id == "trashbin") {
return;
}
- $.get(OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/ajax/settings"),
- function onSuccess(settings) {
- OCA.Onlyoffice.setting = settings;
- var mimes = OCA.Onlyoffice.setting.formats;
-
- OCA.Onlyoffice.mimes = mimes;
- $.each(mimes, function (ext, attr) {
- fileList.fileActions.registerAction({
- name: "onlyofficeOpen",
- displayName: t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"),
- mime: attr.mime,
- permissions: OC.PERMISSION_READ,
- icon: function () {
- return OC.imagePath(OCA.Onlyoffice.AppName, "btn-edit");
- },
- actionHandler: function (fileName, context) {
- OCA.Onlyoffice.FileClick(fileName, context, attr);
- }
- });
-
- if (attr.def && !fileList.fileActions.getDefaultFileAction(attr.mime, "file", OC.PERMISSION_READ)) {
- fileList.fileActions.setDefault(attr.mime, "onlyofficeOpen");
+ var register = function() {
+ var mimes = OCA.Onlyoffice.setting.formats;
+
+ $.each(mimes, function (ext, attr) {
+ fileList.fileActions.registerAction({
+ name: "onlyofficeOpen",
+ displayName: t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"),
+ mime: attr.mime,
+ permissions: OC.PERMISSION_READ,
+ icon: function () {
+ return OC.imagePath(OCA.Onlyoffice.AppName, "app-dark");
+ },
+ actionHandler: function (fileName, context) {
+ OCA.Onlyoffice.FileClick(fileName, context, attr);
}
});
- }
- );
+
+ if (attr.def) {
+ fileList.fileActions.setDefault(attr.mime, "onlyofficeOpen");
+ }
+ });
+ }
+
+ OCA.Onlyoffice.GetSettings(register);
}
};
@@ -205,7 +226,38 @@
});
}
};
+
+ var initPage = function(){
+ if ($("#isPublic").val() && !$("#dir").val().length) {
+ var fileName = $("#filename").val();
+ var extension = fileName.substr(fileName.lastIndexOf(".") + 1);
+
+ var initSharedButton = function() {
+ var mimes = OCA.Onlyoffice.setting.formats;
+
+ var conf = mimes[extension];
+ if (conf) {
+ var button = document.createElement("a");
+ button.href = OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/s/" + encodeURIComponent($("#sharingToken").val()));
+ button.className = "button";
+ button.innerText = t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE")
+
+ if (!OCA.Onlyoffice.setting.sameTab) {
+ button.target = "_blank";
+ }
+
+ $("#preview").append(button);
+ }
+ };
+
+ OCA.Onlyoffice.GetSettings(initSharedButton);
+ } else {
+ OC.Plugins.register("OCA.Files.FileList", OCA.Onlyoffice.FileList);
+ OC.Plugins.register("OCA.Files.NewFileMenu", OCA.Onlyoffice.NewFileMenu);
+ }
+ };
+
+ $(document).ready(initPage)
+
})(OCA);
-OC.Plugins.register("OCA.Files.FileList", OCA.Onlyoffice.FileList);
-OC.Plugins.register("OCA.Files.NewFileMenu", OCA.Onlyoffice.NewFileMenu);
diff --git a/js/settings.js b/js/settings.js
index 0db83d7..2839347 100644
--- a/js/settings.js
+++ b/js/settings.js
@@ -1,6 +1,6 @@
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
diff --git a/lib/adminsection.php b/lib/adminsection.php
new file mode 100644
index 0000000..e2e1c91
--- /dev/null
+++ b/lib/adminsection.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ *
+ * (c) Copyright Ascensio System Limited 2010-2018
+ *
+ * This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
+ * In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
+ * Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
+ *
+ * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
+ *
+ * You can contact Ascensio System SIA by email at sales@onlyoffice.com
+ *
+ * The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
+ * Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
+ *
+ * Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
+ * relevant author attributions when distributing the software. If the display of the logo in its graphic
+ * form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
+ * in every copy of the program you distribute.
+ * Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
+ *
+ */
+
+namespace OCA\Onlyoffice;
+
+use OCP\IURLGenerator;
+use OCP\Settings\IIconSection;
+
+/**
+ * Settings section for the administration page
+ */
+class AdminSection implements IIconSection {
+
+ /** @var IURLGenerator */
+ private $urlGenerator;
+
+ /**
+ * @param IURLGenerator $urlGenerator - url generator service
+ */
+ public function __construct(IURLGenerator $urlGenerator) {
+ $this->urlGenerator = $urlGenerator;
+ }
+
+
+ /**
+ * Path to an 16*16 icons
+ *
+ * @return strings
+ */
+ public function getIcon() {
+ return $this->urlGenerator->imagePath("onlyoffice", "app-dark.svg");
+ }
+
+ /**
+ * ID of the section
+ *
+ * @returns string
+ */
+ public function getID() {
+ return "onlyoffice";
+ }
+
+ /**
+ * Name of the section
+ *
+ * @return string
+ */
+ public function getName() {
+ return "ONLYOFFICE";
+ }
+
+ /**
+ * Get priority order
+ *
+ * @return int
+ */
+ public function getPriority() {
+ return 50;
+ }
+}
diff --git a/lib/adminsettings.php b/lib/adminsettings.php
index 61c824f..211c6ed 100644
--- a/lib/adminsettings.php
+++ b/lib/adminsettings.php
@@ -1,7 +1,7 @@
<?php
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
@@ -75,7 +75,7 @@ class AdminSettings implements ISettings {
* @return string
*/
public function getSection() {
- return "server";
+ return "onlyoffice";
}
/**
diff --git a/lib/appconfig.php b/lib/appconfig.php
index 6979e45..02f497e 100644
--- a/lib/appconfig.php
+++ b/lib/appconfig.php
@@ -1,7 +1,7 @@
<?php
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
@@ -128,6 +128,41 @@ class AppConfig {
private $_settingsError = "settings_error";
/**
+ * The config key for the customer
+ *
+ * @var string
+ */
+ public $_customization_customer = "customization_customer";
+
+ /**
+ * The config key for the feedback
+ *
+ * @var string
+ */
+ public $_customization_feedback = "customization_feedback";
+
+ /**
+ * The config key for the loaderLogo
+ *
+ * @var string
+ */
+ public $_customization_loaderLogo = "customization_loaderLogo";
+
+ /**
+ * The config key for the loaderName
+ *
+ * @var string
+ */
+ public $_customization_loaderName = "customization_loaderName";
+
+ /**
+ * The config key for the logo
+ *
+ * @var string
+ */
+ public $_customization_logo = "customization_logo";
+
+ /**
* @param string $AppName - application name
*/
public function __construct($AppName) {
@@ -139,6 +174,21 @@ class AppConfig {
}
/**
+ * Get value from the system configuration
+ *
+ * @param string $key - key configuration
+ *
+ * @return string
+ */
+ public function 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];
+ }
+ return NULL;
+ }
+
+ /**
* Save the document service address to the application configuration
*
* @param string $documentServer - document service address
@@ -164,10 +214,8 @@ class AppConfig {
*/
public function GetDocumentServerUrl() {
$url = $this->config->getAppValue($this->appName, $this->_documentserver, "");
- if (empty($url)
- && !empty($this->config->getSystemValue($this->appName))
- && array_key_exists($this->_documentserver, $this->config->getSystemValue($this->appName))) {
- $url = $this->config->getSystemValue($this->appName)[$this->_documentserver];
+ if (empty($url)) {
+ $url = $this->getSystemValue($this->_documentserver);
}
if ($url !== "/") {
$url = rtrim($url, "/");
@@ -204,10 +252,8 @@ class AppConfig {
*/
public function GetDocumentServerInternalUrl($origin) {
$url = $this->config->getAppValue($this->appName, $this->_documentserverInternal, "");
- if (empty($url)
- && !empty($this->config->getSystemValue($this->appName))
- && array_key_exists($this->_documentserverInternal, $this->config->getSystemValue($this->appName))) {
- $url = $this->config->getSystemValue($this->appName)[$this->_documentserverInternal];
+ if (empty($url)) {
+ $url = $this->getSystemValue($this->_documentserverInternal);
}
if (!$origin && empty($url)) {
$url = $this->GetDocumentServerUrl();
@@ -241,10 +287,8 @@ class AppConfig {
*/
public function GetStorageUrl() {
$url = $this->config->getAppValue($this->appName, $this->_storageUrl, "");
- if (empty($url)
- && !empty($this->config->getSystemValue($this->appName))
- && array_key_exists($this->_storageUrl, $this->config->getSystemValue($this->appName))) {
- $url = $this->config->getSystemValue($this->appName)[$this->_storageUrl];
+ if (empty($url)) {
+ $url = $this->getSystemValue($this->_storageUrl);
}
return $url;
}
@@ -271,10 +315,8 @@ class AppConfig {
*/
public function GetDocumentServerSecret() {
$secret = $this->config->getAppValue($this->appName, $this->_jwtSecret, "");
- if (empty($secret)
- && !empty($this->config->getSystemValue($this->appName))
- && array_key_exists($this->_jwtSecret, $this->config->getSystemValue($this->appName))) {
- $secret = $this->config->getSystemValue($this->appName)[$this->_jwtSecret];
+ if (empty($secret)) {
+ $secret = $this->getSystemValue($this->_jwtSecret);
}
return $secret;
}
@@ -351,11 +393,7 @@ class AppConfig {
* @return boolean
*/
public function TurnOffVerification() {
- $turnOff = FALSE;
- if (!empty($this->config->getSystemValue($this->appName))
- && array_key_exists($this->_verification, $this->config->getSystemValue($this->appName))) {
- $turnOff = $this->config->getSystemValue($this->appName)[$this->_verification];
- }
+ $turnOff = $this->getSystemValue($this->_verification);
return $turnOff === TRUE;
}
@@ -365,10 +403,9 @@ class AppConfig {
* @return boolean
*/
public function JwtHeader() {
- $header = "Authorization";
- if (!empty($this->config->getSystemValue($this->appName))
- && array_key_exists($this->_jwtHeader, $this->config->getSystemValue($this->appName))) {
- $header = $this->config->getSystemValue($this->appName)[$this->_jwtHeader];
+ $header = $this->getSystemValue($this->_jwtHeader);
+ if (empty($header)) {
+ $header = "Authorization";
}
return $header;
}
@@ -404,13 +441,20 @@ class AppConfig {
"ppsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "type" => "presentation", "edit" => true, "def" => true ],
"txt" => [ "mime" => "text/plain", "type" => "text", "edit" => true ],
"csv" => [ "mime" => "text/csv", "type" => "spreadsheet", "edit" => true ],
+ "docm" => [ "mime" => "application/vnd.ms-word.document.macroEnabled.12", "type" => "text", "conv" => true ],
+ "xlsm" => [ "mime" => "application/vnd.ms-excel.sheet.macroEnabled.12", "type" => "spreadsheet", "conv" => true ],
+ "xltx" => [ "mime" => "application/vnd.openxmlformats-officedocument.spreadsheetml.template", "type" => "spreadsheet", "conv" => true ],
+ "xltm" => [ "mime" => "application/vnd.ms-excel.template.macroEnabled.12", "type" => "spreadsheet", "conv" => true ],
+ "pptm" => [ "mime" => "application/vnd.ms-powerpoint.presentation.macroEnabled.12", "type" => "presentation", "conv" => true ],
+ "ppsm" => [ "mime" => "application/vnd.ms-powerpoint.slideshow.macroEnabled.12", "type" => "presentation", "conv" => true ],
+ "potx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.template", "type" => "presentation", "conv" => true ],
+ "potm" => [ "mime" => "application/vnd.ms-powerpoint.template.macroEnabled.12", "type" => "presentation", "conv" => true ],
"odt" => [ "mime" => "application/vnd.oasis.opendocument.text", "type" => "text", "conv" => true ],
"ods" => [ "mime" => "application/vnd.oasis.opendocument.spreadsheet", "type" => "spreadsheet", "conv" => true ],
"odp" => [ "mime" => "application/vnd.oasis.opendocument.presentation", "type" => "presentation", "conv" => true ],
"doc" => [ "mime" => "application/msword", "type" => "text", "conv" => true ],
"xls" => [ "mime" => "application/vnd.ms-excel", "type" => "spreadsheet", "conv" => true ],
"ppt" => [ "mime" => "application/vnd.ms-powerpoint", "type" => "presentation", "conv" => true ],
- "pps" => [ "mime" => "application/vnd.ms-powerpoint", "type" => "presentation", "conv" => true ],
"epub" => [ "mime" => "application/epub+zip", "type" => "text", "conv" => true ],
"rtf" => [ "mime" => "text/rtf", "type" => "text", "type" => "text", "conv" => true ],
"mht" => [ "mime" => "message/rfc822", "conv" => true ],
diff --git a/lib/crypt.php b/lib/crypt.php
index 7b7d04e..9c31e66 100644
--- a/lib/crypt.php
+++ b/lib/crypt.php
@@ -1,7 +1,7 @@
<?php
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
diff --git a/lib/documentservice.php b/lib/documentservice.php
index e118c09..6c78abc 100644
--- a/lib/documentservice.php
+++ b/lib/documentservice.php
@@ -1,7 +1,7 @@
<?php
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
diff --git a/lib/hookhandler.php b/lib/hookhandler.php
new file mode 100644
index 0000000..d61a3b8
--- /dev/null
+++ b/lib/hookhandler.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * @author Jörn Friedrich Dreyer <jfd@butonic.de>
+ *
+ * @copyright Copyright (c) 2018, ownCloud GmbH
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Onlyoffice;
+
+use OCP\Util;
+
+use OCA\Onlyoffice\AppConfig;
+
+/**
+ * Class HookHandler
+ *
+ * handles hooks
+ *
+ * @package OCA\Onlyoffice
+ */
+class HookHandler {
+
+ public static function PublicPage() {
+ $appName = "onlyoffice";
+
+ $appConfig = new AppConfig($appName);
+
+ if (!empty($appConfig->GetDocumentServerUrl()) && $appConfig->SettingsAreSuccessful()) {
+ Util::addScript("onlyoffice", "main");
+ Util::addStyle("onlyoffice", "main");
+ }
+ }
+}
diff --git a/settings.php b/settings.php
index 249cbca..a592d4d 100644
--- a/settings.php
+++ b/settings.php
@@ -1,7 +1,7 @@
<?php
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
diff --git a/templates/editor.php b/templates/editor.php
index 8fc4c9e..6bc02fb 100644
--- a/templates/editor.php
+++ b/templates/editor.php
@@ -1,7 +1,7 @@
<?php
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
@@ -30,14 +30,11 @@
<div id="app">
- <div id="iframeEditor" data-id="<?php p($_["fileId"]) ?>"></div>
+ <div id="iframeEditor" data-id="<?php p($_["fileId"]) ?>" data-token="<?php p($_["token"]) ?>"></div>
- <?php if (!empty($_["documentServerUrl"])) {
- print_unescaped("<script nonce=\"") .
- p(base64_encode($_["requesttoken"])) .
- print_unescaped("\" src=\"") .
- p($_["documentServerUrl"]) .
- print_unescaped("web-apps/apps/api/documents/api.js\" type=\"text/javascript\"></script>");
- } ?>
+ <?php if (!empty($_["documentServerUrl"])) { ?>
+ <script nonce="<?php p(base64_encode($_["requesttoken"])) ?>"
+ src="<?php p($_["documentServerUrl"]) ?>web-apps/apps/api/documents/api.js" type="text/javascript"></script>
+ <?php } ?>
</div>
diff --git a/templates/settings.php b/templates/settings.php
index 0273b98..dbe2a2f 100644
--- a/templates/settings.php
+++ b/templates/settings.php
@@ -1,7 +1,7 @@
<?php
/**
*
- * (c) Copyright Ascensio System Limited 2010-2017
+ * (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).