Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f74a7b7f4a | ||
|
cc5fb99cb4 | ||
|
d4e0ac2387 | ||
|
586c925bb1 | ||
|
5e42ea1dab | ||
|
6925e4f2f6 | ||
|
bd68097a92 | ||
|
2385b70915 | ||
|
b1e51782fc | ||
|
ff1ee24c46 | ||
|
ff7aa2d5e8 | ||
|
472a22ef21 | ||
|
c21c029fa4 | ||
|
7e4c59e360 | ||
|
ad61db1158 | ||
|
6b629b2c67 | ||
|
f790f640b1 | ||
|
674a6cb384 | ||
|
df0c7cce94 | ||
|
1cc5e43106 | ||
|
f74b0b3018 | ||
|
bf72f5b01d |
19
CHANGELOG.md
19
CHANGELOG.md
@ -1,3 +1,22 @@
|
|||||||
|
**1.11.29**
|
||||||
|
- Bug: fix undefined instanceId
|
||||||
|
|
||||||
|
**1.11.28**
|
||||||
|
- Bug: Allow full screen
|
||||||
|
- Updated screenshots
|
||||||
|
|
||||||
|
**1.11.27**
|
||||||
|
- Bug: Fix revision history
|
||||||
|
|
||||||
|
**1.1.25.1**
|
||||||
|
- Bug: Fix height for revision history viewer
|
||||||
|
- Bug: Set the correct language tag expected by JS
|
||||||
|
- Bug: Replace trailing slash of WOPI URL
|
||||||
|
- Bug: Try opening readonly documents too
|
||||||
|
- Bug: Fix revision history
|
||||||
|
- Feature: Add rtf and txt as supported file formats
|
||||||
|
- Feature: Support for multitenancy installations of LibreOffice Online
|
||||||
|
|
||||||
**1.1.24**
|
**1.1.24**
|
||||||
- Bug: Fix undefined PHP notices
|
- Bug: Fix undefined PHP notices
|
||||||
- Security: Properly check for password on password protected shares
|
- Security: Properly check for password on password protected shares
|
@ -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>
|
<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>
|
<summary>Edit office documents directly in your browser.</summary>
|
||||||
<licence>AGPL</licence>
|
<licence>AGPL</licence>
|
||||||
<version>1.1.24</version>
|
<version>1.11.29</version>
|
||||||
<author>Collabora Productivity based on work of Frank Karlitschek, Victor Dubiniuk</author>
|
<author>Collabora Productivity based on work of Frank Karlitschek, Victor Dubiniuk</author>
|
||||||
<bugs>https://github.com/nextcloud/richdocuments/issues</bugs>
|
<bugs>https://github.com/nextcloud/richdocuments/issues</bugs>
|
||||||
<repository type="git">https://github.com/nextcloud/richdocuments.git</repository>
|
<repository type="git">https://github.com/nextcloud/richdocuments.git</repository>
|
||||||
@ -22,7 +22,6 @@
|
|||||||
<prevent_group_restriction/>
|
<prevent_group_restriction/>
|
||||||
</types>
|
</types>
|
||||||
<screenshot>https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-document.png</screenshot>
|
<screenshot>https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-document.png</screenshot>
|
||||||
<screenshot>https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-app.png</screenshot>
|
|
||||||
<screenshot>https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-presentation.png</screenshot>
|
<screenshot>https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-presentation.png</screenshot>
|
||||||
<screenshot>https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-spreadsheet.png</screenshot>
|
<screenshot>https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-spreadsheet.png</screenshot>
|
||||||
<settings>
|
<settings>
|
||||||
|
@ -133,7 +133,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 600;
|
z-index: 600;
|
||||||
background-color: #ddd !important;
|
background-color: #ddd !important;
|
||||||
top: 45px;
|
top: 0px;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +149,7 @@
|
|||||||
z-index: 600;
|
z-index: 600;
|
||||||
background-color: #efefef !important;
|
background-color: #efefef !important;
|
||||||
right: 0;
|
right: 0;
|
||||||
top: 45px;
|
top: 0px;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
@ -4,7 +4,7 @@ var documentsSettings = {
|
|||||||
save : function() {
|
save : function() {
|
||||||
$('#wopi_apply').attr('disabled', true);
|
$('#wopi_apply').attr('disabled', true);
|
||||||
var data = {
|
var data = {
|
||||||
wopi_url : $('#wopi_url').val()
|
wopi_url : $('#wopi_url').val().replace(/\/$/, '')
|
||||||
};
|
};
|
||||||
|
|
||||||
OC.msg.startAction('#documents-admin-msg', t('richdocuments', 'Saving...'));
|
OC.msg.startAction('#documents-admin-msg', t('richdocuments', 'Saving...'));
|
||||||
|
@ -72,7 +72,6 @@ var documentsMain = {
|
|||||||
loadErrorHint : '',
|
loadErrorHint : '',
|
||||||
renderComplete: false, // false till page is rendered with all required data about the document(s)
|
renderComplete: false, // false till page is rendered with all required data about the document(s)
|
||||||
toolbar : '<div id="ocToolbar"><div id="ocToolbarInside"></div><span id="toolbar" class="claro"></span></div>',
|
toolbar : '<div id="ocToolbar"><div id="ocToolbarInside"></div><span id="toolbar" class="claro"></span></div>',
|
||||||
returnToDir : null, // directory where we started from in the 'Files' app
|
|
||||||
|
|
||||||
UI : {
|
UI : {
|
||||||
/* Editor wrapper HTML */
|
/* Editor wrapper HTML */
|
||||||
@ -129,7 +128,7 @@ var documentsMain = {
|
|||||||
var urlsrc = documentsMain.urlsrc +
|
var urlsrc = documentsMain.urlsrc +
|
||||||
"WOPISrc=" + wopisrc +
|
"WOPISrc=" + wopisrc +
|
||||||
"&title=" + encodeURIComponent(title) +
|
"&title=" + encodeURIComponent(title) +
|
||||||
"&lang=" + OC.getLocale() +
|
"&lang=" + OC.getLocale().replace('_', '-') + // loleaflet expects a BCP47 language tag syntax
|
||||||
"&permission=readonly";
|
"&permission=readonly";
|
||||||
|
|
||||||
// access_token - must be passed via a form post
|
// access_token - must be passed via a form post
|
||||||
@ -163,7 +162,6 @@ var documentsMain = {
|
|||||||
if (version === 0) {
|
if (version === 0) {
|
||||||
formattedTimestamp = t('richdocuments', 'Latest revision');
|
formattedTimestamp = t('richdocuments', 'Latest revision');
|
||||||
downloadUrl = OC.generateUrl('apps/files/download'+ documentPath);
|
downloadUrl = OC.generateUrl('apps/files/download'+ documentPath);
|
||||||
fileId = fileId.replace(/_.*/, '');
|
|
||||||
} else {
|
} else {
|
||||||
downloadUrl = OC.generateUrl('apps/files_versions/download.php?file={file}&revision={revision}',
|
downloadUrl = OC.generateUrl('apps/files_versions/download.php?file={file}&revision={revision}',
|
||||||
{file: documentPath, revision: version});
|
{file: documentPath, revision: version});
|
||||||
@ -268,12 +266,8 @@ var documentsMain = {
|
|||||||
documentsMain.UI.notify(t('richdocuments', 'Failed to revert the document to older version'));
|
documentsMain.UI.notify(t('richdocuments', 'Failed to revert the document to older version'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate file id with returnToDir information in it, if any
|
|
||||||
var fileid = e.currentTarget.parentElement.dataset.fileid.replace(/_.*/, '') +
|
|
||||||
(documentsMain.returnToDir ? '_' + documentsMain.returnToDir : '');
|
|
||||||
|
|
||||||
// load the file again, it should get reverted now
|
// load the file again, it should get reverted now
|
||||||
window.location = OC.generateUrl('apps/richdocuments/index#{fileid}', {fileid: fileid});
|
window.location = OC.generateUrl('apps/richdocuments/index#{fileid}', {fileid: e.currentTarget.parentElement.dataset.fileid});
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
documentsMain.overlay.documentOverlay('hide');
|
documentsMain.overlay.documentOverlay('hide');
|
||||||
}
|
}
|
||||||
@ -320,7 +314,7 @@ var documentsMain = {
|
|||||||
var urlsrc = documentsMain.urlsrc +
|
var urlsrc = documentsMain.urlsrc +
|
||||||
"WOPISrc=" + wopisrc +
|
"WOPISrc=" + wopisrc +
|
||||||
"&title=" + encodeURIComponent(title) +
|
"&title=" + encodeURIComponent(title) +
|
||||||
"&lang=" + OC.getLocale() +
|
"&lang=" + OC.getLocale().replace('_', '-') + // loleaflet expects a BCP47 language tag syntax
|
||||||
"&closebutton=1" +
|
"&closebutton=1" +
|
||||||
"&revisionhistory=1";
|
"&revisionhistory=1";
|
||||||
if (!documentsMain.canEdit || action === "view") {
|
if (!documentsMain.canEdit || action === "view") {
|
||||||
@ -426,11 +420,6 @@ var documentsMain = {
|
|||||||
// Does anything indicate that we need to autostart a session?
|
// Does anything indicate that we need to autostart a session?
|
||||||
fileId = getURLParameter('fileid').replace(/^\W*/, '');
|
fileId = getURLParameter('fileid').replace(/^\W*/, '');
|
||||||
|
|
||||||
if (fileId.indexOf('_') >= 0) {
|
|
||||||
documentsMain.returnToDir = unescape(fileId.replace(/^[^_]*_/, ''));
|
|
||||||
fileId = fileId.replace(/_.*/, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
documentsMain.show(fileId);
|
documentsMain.show(fileId);
|
||||||
|
|
||||||
if (fileId) {
|
if (fileId) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* globals FileList, OCA.Files.fileActions, oc_debug */
|
/* globals FileList, OCA.Files.fileActions, oc_debug */
|
||||||
var odfViewer = {
|
var odfViewer = {
|
||||||
isDocuments : false,
|
isDocuments : false,
|
||||||
supportedMimesReadWrite: [
|
supportedMimes: [
|
||||||
'application/vnd.oasis.opendocument.text',
|
'application/vnd.oasis.opendocument.text',
|
||||||
'application/vnd.oasis.opendocument.spreadsheet',
|
'application/vnd.oasis.opendocument.spreadsheet',
|
||||||
'application/vnd.oasis.opendocument.graphics',
|
'application/vnd.oasis.opendocument.graphics',
|
||||||
@ -12,6 +12,9 @@ var odfViewer = {
|
|||||||
'application/vnd.wordperfect',
|
'application/vnd.wordperfect',
|
||||||
'application/msonenote',
|
'application/msonenote',
|
||||||
'application/msword',
|
'application/msword',
|
||||||
|
'application/rtf',
|
||||||
|
'text/rtf',
|
||||||
|
'text/plain',
|
||||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||||
'application/vnd.ms-word.document.macroEnabled.12',
|
'application/vnd.ms-word.document.macroEnabled.12',
|
||||||
@ -35,34 +38,19 @@ var odfViewer = {
|
|||||||
|
|
||||||
register : function() {
|
register : function() {
|
||||||
var i,
|
var i,
|
||||||
mimeReadOnly,
|
mime;
|
||||||
mimeReadWrite;
|
|
||||||
|
|
||||||
for (i = 0; i < odfViewer.supportedMimesReadWrite.length; ++i) {
|
for (i = 0; i < odfViewer.supportedMimes.length; ++i) {
|
||||||
mimeReadOnly = odfViewer.supportedMimesReadWrite[i];
|
mime = odfViewer.supportedMimes[i];
|
||||||
OCA.Files.fileActions.register(mimeReadOnly, 'View', OC.PERMISSION_READ, '', odfViewer.onEdit);
|
|
||||||
OCA.Files.fileActions.setDefault(mimeReadOnly, 'View');
|
|
||||||
}
|
|
||||||
for (i = 0; i < odfViewer.supportedMimesReadWrite.length; ++i) {
|
|
||||||
mimeReadWrite = odfViewer.supportedMimesReadWrite[i];
|
|
||||||
OCA.Files.fileActions.register(
|
OCA.Files.fileActions.register(
|
||||||
mimeReadWrite,
|
mime,
|
||||||
'Edit',
|
'Edit',
|
||||||
OC.PERMISSION_UPDATE,
|
OC.PERMISSION_UPDATE | OC.PERMISSION_READ,
|
||||||
OC.imagePath('core', 'actions/rename'),
|
OC.imagePath('core', 'actions/rename'),
|
||||||
odfViewer.onEdit,
|
odfViewer.onEdit,
|
||||||
t('richdocuments', 'Edit')
|
t('richdocuments', 'Edit')
|
||||||
);
|
);
|
||||||
OCA.Files.fileActions.register(
|
OCA.Files.fileActions.setDefault(mime, 'Edit');
|
||||||
mimeReadWrite,
|
|
||||||
'View',
|
|
||||||
OC.PERMISSION_READ,
|
|
||||||
OC.imagePath('core', 'actions/rename'),
|
|
||||||
odfViewer.onEdit,
|
|
||||||
t('richdocuments', 'View')
|
|
||||||
);
|
|
||||||
OCA.Files.fileActions.setDefault(mimeReadWrite, 'View');
|
|
||||||
OCA.Files.fileActions.setDefault(mimeReadWrite, 'Edit');
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -89,7 +77,7 @@ var odfViewer = {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
viewer = OC.generateUrl(
|
viewer = OC.generateUrl(
|
||||||
'apps/richdocuments/index?fileId={fileId}_{dir}&requesttoken={requesttoken}',
|
'apps/richdocuments/index?fileId={fileId}&requesttoken={requesttoken}',
|
||||||
{
|
{
|
||||||
fileId: fileId,
|
fileId: fileId,
|
||||||
dir: fileDir,
|
dir: fileDir,
|
||||||
@ -102,7 +90,7 @@ var odfViewer = {
|
|||||||
FileList.setViewerMode(true);
|
FileList.setViewerMode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var $iframe = $('<iframe id="richdocumentsframe" style="width:100%;height:100%;display:block;position:absolute;top:0;" src="'+viewer+'" />');
|
var $iframe = $('<iframe id="richdocumentsframe" allowfullscreen style="width:100%;height:100%;display:block;position:absolute;top:0;z-index:5;" src="'+viewer+'" />');
|
||||||
if ($('#isPublic').val()) {
|
if ($('#isPublic').val()) {
|
||||||
// force the preview to adjust its height
|
// force the preview to adjust its height
|
||||||
$('#preview').append($iframe).css({height: '100%'});
|
$('#preview').append($iframe).css({height: '100%'});
|
||||||
@ -227,7 +215,7 @@ $(document).ready(function() {
|
|||||||
// FIXME: Hack for single public file view since it is not attached to the fileslist
|
// FIXME: Hack for single public file view since it is not attached to the fileslist
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
// FIXME: FIlter compatible mime types
|
// FIXME: FIlter compatible mime types
|
||||||
if ($('#isPublic').val() && odfViewer.supportedMimesReadWrite.indexOf($('#mimetype').val()) !== -1) {
|
if ($('#isPublic').val() && odfViewer.supportedMimes.indexOf($('#mimetype').val()) !== -1) {
|
||||||
odfViewer.onEdit($('#filename').val());
|
odfViewer.onEdit($('#filename').val());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -104,10 +104,11 @@ class DocumentController extends Controller {
|
|||||||
$params = [
|
$params = [
|
||||||
'permissions' => $item->getPermissions(),
|
'permissions' => $item->getPermissions(),
|
||||||
'title' => $item->getName(),
|
'title' => $item->getName(),
|
||||||
'fileId' => $item->getId(),
|
'fileId' => $item->getId() . '_' . $this->settings->getSystemValue('instanceid'),
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
'urlsrc' => $urlSrc,
|
'urlsrc' => $urlSrc,
|
||||||
'path' => '/',
|
'path' => $folder->getRelativePath($item->getPath()),
|
||||||
|
'instanceId' => $this->settings->getSystemValue('instanceid'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = new TemplateResponse('richdocuments', 'documents', $params, 'empty');
|
$response = new TemplateResponse('richdocuments', 'documents', $params, 'empty');
|
||||||
@ -153,10 +154,11 @@ class DocumentController extends Controller {
|
|||||||
$params = [
|
$params = [
|
||||||
'permissions' => $share->getPermissions(),
|
'permissions' => $share->getPermissions(),
|
||||||
'title' => $item->getName(),
|
'title' => $item->getName(),
|
||||||
'fileId' => $item->getId(),
|
'fileId' => $item->getId() . '_' . $this->settings->getSystemValue('instanceid'),
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
'urlsrc' => $urlSrc,
|
'urlsrc' => $urlSrc,
|
||||||
'path' => '/',
|
'path' => '/',
|
||||||
|
'instanceId' => $this->settings->getSystemValue('instanceid'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = new TemplateResponse('richdocuments', 'documents', $params, 'empty');
|
$response = new TemplateResponse('richdocuments', 'documents', $params, 'empty');
|
||||||
@ -231,12 +233,13 @@ class DocumentController extends Controller {
|
|||||||
if ($content && $view->file_put_contents($path, $content)) {
|
if ($content && $view->file_put_contents($path, $content)) {
|
||||||
$info = $view->getFileInfo($path);
|
$info = $view->getFileInfo($path);
|
||||||
$ret = $this->wopiParser->getUrlSrc($mimetype);
|
$ret = $this->wopiParser->getUrlSrc($mimetype);
|
||||||
|
$lolang = strtolower(str_replace('_', '-', $this->settings->getUserValue($this->uid, 'core', 'lang', 'en')));
|
||||||
$response = array(
|
$response = array(
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'fileid' => $info['fileid'],
|
'fileid' => $info['fileid'] . '_' . $this->settings->getSystemValue('instanceid'),
|
||||||
'urlsrc' => $ret['urlsrc'],
|
'urlsrc' => $ret['urlsrc'],
|
||||||
'action' => $ret['action'],
|
'action' => $ret['action'],
|
||||||
'lolang' => $this->settings->getUserValue($this->uid, 'core', 'lang', 'en'),
|
'lolang' => $lolang,
|
||||||
'data' => \OCA\Files\Helper::formatFileInfo($info)
|
'data' => \OCA\Files\Helper::formatFileInfo($info)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
|
|
||||||
namespace OCA\Richdocuments\Controller;
|
namespace OCA\Richdocuments\Controller;
|
||||||
|
|
||||||
|
use OC\Files\View;
|
||||||
use OCA\Richdocuments\Db\Wopi;
|
use OCA\Richdocuments\Db\Wopi;
|
||||||
|
use OCA\Richdocuments\Helper;
|
||||||
use OCA\Richdocuments\WOPI\Parser;
|
use OCA\Richdocuments\WOPI\Parser;
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
@ -35,32 +37,19 @@ use OCP\AppFramework\Http\StreamResponse;
|
|||||||
class WopiController extends Controller {
|
class WopiController extends Controller {
|
||||||
/** @var IRootFolder */
|
/** @var IRootFolder */
|
||||||
private $rootFolder;
|
private $rootFolder;
|
||||||
/** @var string */
|
|
||||||
private $userId;
|
|
||||||
/** @var IUserManager */
|
|
||||||
private $userManager;
|
|
||||||
/** @var Parser */
|
|
||||||
private $wopiParser;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $appName
|
* @param string $appName
|
||||||
* @param IRequest $request
|
* @param IRequest $request
|
||||||
* @param IRootFolder $rootFolder
|
* @param IRootFolder $rootFolder
|
||||||
* @param string $UserId
|
* @param string $UserId
|
||||||
* @param IUserManager $userManager
|
|
||||||
* @param Parser $wopiParser
|
|
||||||
*/
|
*/
|
||||||
public function __construct($appName,
|
public function __construct($appName,
|
||||||
$UserId,
|
$UserId,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
IRootFolder $rootFolder,
|
IRootFolder $rootFolder) {
|
||||||
IUserManager $userManager,
|
|
||||||
Parser $wopiParser) {
|
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->rootFolder = $rootFolder;
|
$this->rootFolder = $rootFolder;
|
||||||
$this->userId = $UserId;
|
|
||||||
$this->userManager = $userManager;
|
|
||||||
$this->wopiParser = $wopiParser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,16 +65,9 @@ class WopiController extends Controller {
|
|||||||
public function checkFileInfo($fileId) {
|
public function checkFileInfo($fileId) {
|
||||||
$token = $this->request->getParam('access_token');
|
$token = $this->request->getParam('access_token');
|
||||||
|
|
||||||
$arr = explode('_', $fileId, 2);
|
list($fileId, , $version) = Helper::parseFileId($fileId);
|
||||||
$version = '0';
|
$db = new Wopi();
|
||||||
if (count($arr) === 2) {
|
$res = $db->getPathForToken($fileId, $token);
|
||||||
list($fileId, $version) = $arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
$row = new Wopi();
|
|
||||||
$row->loadBy('token', $token);
|
|
||||||
|
|
||||||
$res = $row->getPathForToken($fileId, $version, $token);
|
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return new JSONResponse([], Http::STATUS_FORBIDDEN);
|
return new JSONResponse([], Http::STATUS_FORBIDDEN);
|
||||||
}
|
}
|
||||||
@ -130,22 +112,32 @@ class WopiController extends Controller {
|
|||||||
*/
|
*/
|
||||||
public function getFile($fileId,
|
public function getFile($fileId,
|
||||||
$access_token) {
|
$access_token) {
|
||||||
$arr = explode('_', $fileId, 2);
|
list($fileId, , $version) = Helper::parseFileId($fileId);
|
||||||
$version = '0';
|
|
||||||
if (count($arr) === 2) {
|
|
||||||
list($fileId, $version) = $arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
$row = new Wopi();
|
$row = new Wopi();
|
||||||
$row->loadBy('token', $access_token);
|
$row->loadBy('token', $access_token);
|
||||||
|
$res = $row->getPathForToken($fileId, $access_token);
|
||||||
$res = $row->getPathForToken($fileId, $version, $access_token);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/** @var File $file */
|
/** @var File $file */
|
||||||
$userFolder = $this->rootFolder->getUserFolder($res['owner']);
|
$userFolder = $this->rootFolder->getUserFolder($res['owner']);
|
||||||
$file = $userFolder->getById($fileId)[0];
|
$file = $userFolder->getById($fileId)[0];
|
||||||
$response = new StreamResponse($file->fopen('rb'));
|
|
||||||
|
if ($version !== '0')
|
||||||
|
{
|
||||||
|
$view = new View('/' . $res['owner'] . '/files');
|
||||||
|
$relPath = $view->getRelativePath($file->getPath());
|
||||||
|
$versionPath = '/files_versions/' . $relPath . '.v' . $version;
|
||||||
|
$view = new View('/' . $res['owner']);
|
||||||
|
if ($view->file_exists($versionPath)){
|
||||||
|
$response = new StreamResponse($view->fopen($versionPath, 'rb'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$response->setStatus(Http::STATUS_NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$response = new StreamResponse($file->fopen('rb'));
|
||||||
|
}
|
||||||
$response->addHeader('Content-Disposition', 'attachment');
|
$response->addHeader('Content-Disposition', 'attachment');
|
||||||
$response->addHeader('Content-Type', 'application/octet-stream');
|
$response->addHeader('Content-Type', 'application/octet-stream');
|
||||||
return $response;
|
return $response;
|
||||||
@ -165,17 +157,14 @@ class WopiController extends Controller {
|
|||||||
* @param string $access_token
|
* @param string $access_token
|
||||||
* @return JSONResponse
|
* @return JSONResponse
|
||||||
*/
|
*/
|
||||||
public function putFile($fileId, $access_token) {
|
public function putFile($fileId,
|
||||||
$arr = explode('_', $fileId, 2);
|
$access_token) {
|
||||||
$version = '0';
|
list($fileId, , $version) = Helper::parseFileId($fileId);
|
||||||
if (count($arr) === 2) {
|
|
||||||
list($fileId, $version) = $arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
$row = new Wopi();
|
$row = new Wopi();
|
||||||
$row->loadBy('token', $access_token);
|
$row->loadBy('token', $access_token);
|
||||||
|
|
||||||
$res = $row->getPathForToken($fileId, $version, $access_token);
|
$res = $row->getPathForToken($fileId, $access_token);
|
||||||
if (!$res['canwrite']) {
|
if (!$res['canwrite']) {
|
||||||
return new JSONResponse([], Http::STATUS_FORBIDDEN);
|
return new JSONResponse([], Http::STATUS_FORBIDDEN);
|
||||||
}
|
}
|
||||||
@ -185,6 +174,9 @@ class WopiController extends Controller {
|
|||||||
$userFolder = $this->rootFolder->getUserFolder($res['owner']);
|
$userFolder = $this->rootFolder->getUserFolder($res['owner']);
|
||||||
$file = $userFolder->getById($fileId)[0];
|
$file = $userFolder->getById($fileId)[0];
|
||||||
$content = fopen('php://input', 'rb');
|
$content = fopen('php://input', 'rb');
|
||||||
|
// Setup the FS which is needed to emit hooks (versioning).
|
||||||
|
\OC_Util::tearDownFS();
|
||||||
|
\OC_Util::setupFS($res['owner']);
|
||||||
$file->putContent($content);
|
$file->putContent($content);
|
||||||
return new JSONResponse();
|
return new JSONResponse();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
namespace OCA\Richdocuments;
|
namespace OCA\Richdocuments;
|
||||||
|
|
||||||
use OC\Share\Constants;
|
use OC\Share\Constants;
|
||||||
|
use OCA\Richdocuments\Helper;
|
||||||
use OCA\Richdocuments\Db\Wopi;
|
use OCA\Richdocuments\Db\Wopi;
|
||||||
use OCA\Richdocuments\WOPI\Parser;
|
use OCA\Richdocuments\WOPI\Parser;
|
||||||
use OCP\Files\File;
|
use OCP\Files\File;
|
||||||
@ -64,12 +65,7 @@ class TokenManager {
|
|||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function getToken($fileId, $shareToken = null) {
|
public function getToken($fileId, $shareToken = null) {
|
||||||
$arr = explode('_', $fileId, 2);
|
list($fileId,, $version) = Helper::parseFileId($fileId);
|
||||||
$version = '0';
|
|
||||||
if (count($arr) === 2) {
|
|
||||||
list($fileId, $version) = $arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the user is not logged-in do use the sharers storage
|
// if the user is not logged-in do use the sharers storage
|
||||||
if($shareToken !== null) {
|
if($shareToken !== null) {
|
||||||
/** @var File $file */
|
/** @var File $file */
|
||||||
|
@ -56,12 +56,12 @@ class Wopi extends \OCA\Richdocuments\Db{
|
|||||||
* constructs and validates the path.
|
* constructs and validates the path.
|
||||||
* Returns the path, if valid, else false.
|
* Returns the path, if valid, else false.
|
||||||
*/
|
*/
|
||||||
public function getPathForToken($fileId, $version, $token){
|
public function getPathForToken($fileId, $token){
|
||||||
|
|
||||||
$wopi = new Wopi();
|
$wopi = new Wopi();
|
||||||
$row = $wopi->loadBy('token', $token)->getData();
|
$row = $wopi->loadBy('token', $token)->getData();
|
||||||
\OC::$server->getLogger()->debug('Loaded WOPI Token record: {row}.', [ 'row' => $row ]);
|
\OC::$server->getLogger()->debug('Loaded WOPI Token record: {row}.', [ 'row' => $row ]);
|
||||||
if (count($row) == 0)
|
if (count($row) === 0)
|
||||||
{
|
{
|
||||||
// Invalid token.
|
// Invalid token.
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
@ -75,11 +75,6 @@ class Wopi extends \OCA\Richdocuments\Db{
|
|||||||
//$wopi->deleteBy('id', $row['id']);
|
//$wopi->deleteBy('id', $row['id']);
|
||||||
//return false;
|
//return false;
|
||||||
}
|
}
|
||||||
if ($row['fileid'] != $fileId || $row['version'] != $version){
|
|
||||||
// File unknown / user unauthorized (for the requested file).
|
|
||||||
http_response_code(404);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'owner' => $row['owner_uid'],
|
'owner' => $row['owner_uid'],
|
||||||
|
@ -14,6 +14,34 @@ namespace OCA\Richdocuments;
|
|||||||
class Helper {
|
class Helper {
|
||||||
const APP_ID = 'richdocuments';
|
const APP_ID = 'richdocuments';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $fileId
|
||||||
|
* @return array
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public static function parseFileId($fileId) {
|
||||||
|
$arr = explode('_', $fileId);
|
||||||
|
if (count($arr) === 1) {
|
||||||
|
$fileId = $arr[0];
|
||||||
|
$instanceId = '';
|
||||||
|
$version = '0';
|
||||||
|
} else 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,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function getNewFileName($view, $path, $prepend = ' '){
|
public static function getNewFileName($view, $path, $prepend = ' '){
|
||||||
$fileNum = 1;
|
$fileNum = 1;
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
var richdocuments_token = '<?php p($_['token']) ?>';
|
var richdocuments_token = '<?php p($_['token']) ?>';
|
||||||
var richdocuments_urlsrc = '<?php p($_['urlsrc']) ?>';
|
var richdocuments_urlsrc = '<?php p($_['urlsrc']) ?>';
|
||||||
var richdocuments_path = '<?php p($_['path']) ?>';
|
var richdocuments_path = '<?php p($_['path']) ?>';
|
||||||
|
var instanceId = '<?php p($_['instanceId']) ?>';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
Loading…
x
Reference in New Issue
Block a user