Skip to content

Commit

Permalink
Merge pull request #7 from nextcloud/add-instanceid-to-fileid
Browse files Browse the repository at this point in the history
Add instanceid to fileid
  • Loading branch information
LukasReschke committed Jan 3, 2017
2 parents 881d840 + 6d046cc commit ce004a2
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 37 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<description>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.</description>
<summary>Edit office documents directly in your browser.</summary>
<licence>AGPL</licence>
<version>1.1.24</version>
<version>1.1.25</version>
<author>Collabora Productivity based on work of Frank Karlitschek, Victor Dubiniuk</author>
<bugs>https://github.com/nextcloud/richdocuments/issues</bugs>
<repository type="git">https://github.com/nextcloud/richdocuments.git</repository>
Expand Down
4 changes: 2 additions & 2 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
width: 100%;
z-index: 600;
background-color: #ddd !important;
top: 45px;
top: 0px;
bottom: 0;
}

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion js/documents.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions lib/Controller/DocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ public function index($fileId) {
$params = [
'permissions' => $item->getPermissions(),
'title' => $item->getName(),
'fileId' => $item->getId(),
'fileId' => $item->getId() . '_' . $this->settings->getSystemValue('instanceid'),
'token' => $token,
'urlsrc' => $urlSrc,
'path' => '/',
'instanceId' => $this->settings->getSystemValue('instanceid'),
];

$response = new TemplateResponse('richdocuments', 'documents', $params, 'empty');
Expand Down Expand Up @@ -153,10 +154,11 @@ public function publicPage($shareToken, $fileName) {
$params = [
'permissions' => $share->getPermissions(),
'title' => $item->getName(),
'fileId' => $item->getId(),
'fileId' => $item->getId() . '_' . $this->settings->getSystemValue('instanceid'),
'token' => $token,
'urlsrc' => $urlSrc,
'path' => '/',
'instanceId' => $this->settings->getSystemValue('instanceid'),
];

$response = new TemplateResponse('richdocuments', 'documents', $params, 'empty');
Expand Down Expand Up @@ -233,7 +235,7 @@ public function create($mimetype,
$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'),
Expand Down
59 changes: 29 additions & 30 deletions lib/Controller/WopiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,42 @@
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,
];
}

/**
Expand All @@ -76,11 +86,7 @@ public function __construct($appName,
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);
Expand Down Expand Up @@ -130,11 +136,7 @@ public function checkFileInfo($fileId) {
*/
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);
Expand Down Expand Up @@ -165,12 +167,9 @@ public function getFile($fileId,
* @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);
Expand Down
1 change: 1 addition & 0 deletions templates/documents.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
var richdocuments_token = '<?php p($_['token']) ?>';
var richdocuments_urlsrc = '<?php p($_['urlsrc']) ?>';
var richdocuments_path = '<?php p($_['path']) ?>';
var instanceId = '<?php p($_['instanceId']) ?>';
</script>

<?php
Expand Down

0 comments on commit ce004a2

Please sign in to comment.