From 1441bdc59423beac0ec72e92d4c3e2a78ad1da10 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 3 Jan 2017 19:50:07 +0100 Subject: [PATCH 1/4] Add instance id to file id For multitenancy Signed-off-by: Lukas Reschke --- lib/Controller/DocumentController.php | 6 +-- lib/Controller/WopiController.php | 59 +++++++++++++-------------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/lib/Controller/DocumentController.php b/lib/Controller/DocumentController.php index 4fde3599..d8df677a 100644 --- a/lib/Controller/DocumentController.php +++ b/lib/Controller/DocumentController.php @@ -104,7 +104,7 @@ class DocumentController extends Controller { $params = [ 'permissions' => $item->getPermissions(), 'title' => $item->getName(), - 'fileId' => $item->getId(), + 'fileId' => $item->getId() . '_' . $this->settings->getSystemValue('instanceid'), 'token' => $token, 'urlsrc' => $urlSrc, 'path' => '/', @@ -153,7 +153,7 @@ class DocumentController extends Controller { $params = [ 'permissions' => $share->getPermissions(), 'title' => $item->getName(), - 'fileId' => $item->getId(), + 'fileId' => $item->getId() . '_' . $this->settings->getSystemValue('instanceid'), 'token' => $token, 'urlsrc' => $urlSrc, 'path' => '/', @@ -233,7 +233,7 @@ class DocumentController extends Controller { $ret = $this->wopiParser->getUrlSrc($mimetype); $response = array( 'status' => 'success', - 'fileid' => $info['fileid'], + 'fileid' => $info['fileid'] . '_' . $this->settings->getSystemValue('instanceid'), 'urlsrc' => $ret['urlsrc'], 'action' => $ret['action'], 'lolang' => $this->settings->getUserValue($this->uid, 'core', 'lang', 'en'), diff --git a/lib/Controller/WopiController.php b/lib/Controller/WopiController.php index 0ced4669..561305e0 100644 --- a/lib/Controller/WopiController.php +++ b/lib/Controller/WopiController.php @@ -35,32 +35,42 @@ use OCP\AppFramework\Http\StreamResponse; class WopiController extends Controller { /** @var IRootFolder */ private $rootFolder; - /** @var string */ - private $userId; - /** @var IUserManager */ - private $userManager; - /** @var Parser */ - private $wopiParser; /** * @param string $appName * @param IRequest $request * @param IRootFolder $rootFolder * @param string $UserId - * @param IUserManager $userManager - * @param Parser $wopiParser */ public function __construct($appName, $UserId, IRequest $request, - IRootFolder $rootFolder, - IUserManager $userManager, - Parser $wopiParser) { + IRootFolder $rootFolder) { parent::__construct($appName, $request); $this->rootFolder = $rootFolder; - $this->userId = $UserId; - $this->userManager = $userManager; - $this->wopiParser = $wopiParser; + } + + /** + * @param string $fileId + * @return array + * @throws \Exception + */ + private function parseFileId($fileId) { + $arr = explode('_', $fileId, 2); + if (count($arr) === 2) { + list($fileId, $instanceId) = $arr; + $version = '0'; + } else if (count($arr) === 3) { + list($fileId, $instanceId, $version) = $arr; + } else { + throw new \Exception('$fileId has not the expected format'); + } + + return [ + $fileId, + $instanceId, + $version, + ]; } /** @@ -76,11 +86,7 @@ class WopiController extends Controller { public function checkFileInfo($fileId) { $token = $this->request->getParam('access_token'); - $arr = explode('_', $fileId, 2); - $version = '0'; - if (count($arr) === 2) { - list($fileId, $version) = $arr; - } + list($fileId, , $version) = $this->parseFileId($fileId); $row = new Wopi(); $row->loadBy('token', $token); @@ -130,11 +136,7 @@ class WopiController extends Controller { */ public function getFile($fileId, $access_token) { - $arr = explode('_', $fileId, 2); - $version = '0'; - if (count($arr) === 2) { - list($fileId, $version) = $arr; - } + list($fileId, , $version) = $this->parseFileId($fileId); $row = new Wopi(); $row->loadBy('token', $access_token); @@ -165,12 +167,9 @@ class WopiController extends Controller { * @param string $access_token * @return JSONResponse */ - public function putFile($fileId, $access_token) { - $arr = explode('_', $fileId, 2); - $version = '0'; - if (count($arr) === 2) { - list($fileId, $version) = $arr; - } + public function putFile($fileId, + $access_token) { + list($fileId, , $version) = $this->parseFileId($fileId); $row = new Wopi(); $row->loadBy('token', $access_token); From 43ffbf2e97701cb62a71d0e81bc8efda1b1e9e5b Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 3 Jan 2017 20:18:44 +0100 Subject: [PATCH 2/4] Uses proper top height Fixes https://github.com/nextcloud/richdocuments/issues/5 Signed-off-by: Lukas Reschke --- css/style.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/css/style.css b/css/style.css index 78160fa9..3368cc7a 100644 --- a/css/style.css +++ b/css/style.css @@ -133,7 +133,7 @@ width: 100%; z-index: 600; background-color: #ddd !important; - top: 45px; + top: 0px; bottom: 0; } @@ -149,7 +149,7 @@ z-index: 600; background-color: #efefef !important; right: 0; - top: 45px; + top: 0px; bottom: 0; box-sizing: border-box; overflow-x: hidden; From 9cd9258dbbf1e4c740213c8ab4cc6dfcbbab2a29 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 3 Jan 2017 20:31:35 +0100 Subject: [PATCH 3/4] Append instance id to rev history Signed-off-by: Lukas Reschke --- js/documents.js | 2 +- lib/Controller/DocumentController.php | 2 ++ templates/documents.php | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/js/documents.js b/js/documents.js index 7beebee4..3c44b34b 100644 --- a/js/documents.js +++ b/js/documents.js @@ -119,7 +119,7 @@ var documentsMain = { } // WOPISrc - URL that loolwsd will access (ie. pointing to ownCloud) - var wopiurl = window.location.protocol + '//' + window.location.host + OC.generateUrl('apps/richdocuments/wopi/files/{file_id}', {file_id: fileId}); + var wopiurl = window.location.protocol + '//' + window.location.host + OC.generateUrl('apps/richdocuments/wopi/files/{file_id}_{instanceId}', {file_id: fileId, instanceId: instanceId}); var wopisrc = encodeURIComponent(wopiurl); // urlsrc - the URL from discovery xml that we access for the particular diff --git a/lib/Controller/DocumentController.php b/lib/Controller/DocumentController.php index d8df677a..731f10bc 100644 --- a/lib/Controller/DocumentController.php +++ b/lib/Controller/DocumentController.php @@ -108,6 +108,7 @@ class DocumentController extends Controller { 'token' => $token, 'urlsrc' => $urlSrc, 'path' => '/', + 'instanceId' => $this->settings->getSystemValue('instanceid'), ]; $response = new TemplateResponse('richdocuments', 'documents', $params, 'empty'); @@ -157,6 +158,7 @@ class DocumentController extends Controller { 'token' => $token, 'urlsrc' => $urlSrc, 'path' => '/', + 'instanceId' => $this->settings->getSystemValue('instanceid'), ]; $response = new TemplateResponse('richdocuments', 'documents', $params, 'empty'); diff --git a/templates/documents.php b/templates/documents.php index 41e114e0..6d5dc79a 100644 --- a/templates/documents.php +++ b/templates/documents.php @@ -5,6 +5,7 @@ var richdocuments_token = ''; var richdocuments_urlsrc = ''; var richdocuments_path = ''; + var instanceId = ''; Date: Tue, 3 Jan 2017 20:35:29 +0100 Subject: [PATCH 4/4] Increase version Signed-off-by: Lukas Reschke --- CHANGELOG.md | 4 ++++ appinfo/info.xml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5f8415f..01463807 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +**1.1.25** +- Bug: Fix height for revision history viewer +- Feature: Support for multitenancy installations of LibreOffice Online + **1.1.24** - Bug: Fix undefined PHP notices - Security: Properly check for password on password protected shares \ No newline at end of file diff --git a/appinfo/info.xml b/appinfo/info.xml index 94ca260e..f3519366 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -5,7 +5,7 @@ Collabora Online allows you to to work with all kinds of office documents directly in your browser. This application requires Collabora Cloudsuite to be installed on one of your servers, please read the documentation to learn more about that. Edit office documents directly in your browser. AGPL - 1.1.24 + 1.1.25 Collabora Productivity based on work of Frank Karlitschek, Victor Dubiniuk https://github.com/nextcloud/richdocuments/issues https://github.com/nextcloud/richdocuments.git