Merge 89f2dd905f738e69db77245f429e3a653a654055 into 53abf86bb7515712b2a2d28df8029c7a22d1affa
This commit is contained in:
commit
bd1d214829
@ -17,6 +17,7 @@ return [
|
||||
['name' => 'document#index', 'url' => 'index', 'verb' => 'GET'],
|
||||
['name' => 'document#publicPage', 'url' => '/public', 'verb' => 'GET'],
|
||||
['name' => 'document#create', 'url' => 'ajax/documents/create', 'verb' => 'POST'],
|
||||
['name' => 'document#generate', 'url' => 'ajax/generate.php', 'verb' => 'GET'],
|
||||
|
||||
// WOPI access
|
||||
['name' => 'wopi#checkFileInfo', 'url' => 'wopi/files/{fileId}', 'verb' => 'GET'],
|
||||
|
@ -107,6 +107,26 @@ var odfViewer = {
|
||||
|
||||
$('#app-content #controls').addClass('hidden');
|
||||
$('#app-content').append($iframe);
|
||||
|
||||
$.ajax({type: 'GET',
|
||||
url: OC.filePath('richdocuments', 'ajax', 'generate.php'),
|
||||
data: {id: context.$file.attr('data-id')},
|
||||
async: false,
|
||||
success: function(result) {
|
||||
if(result.status==='success'){
|
||||
var $chatroom = $('<div />');
|
||||
$chatroom.attr('id','chatroom');
|
||||
$chatroom.data('chatroom-password',result.password);
|
||||
$chatroom.data('chatroom-name',result.name);
|
||||
$chatroom.data('chatroom-title',fileName);
|
||||
$('#app-content').append($chatroom);
|
||||
} else {
|
||||
console.log(result.message);
|
||||
}
|
||||
}, error: function(xhr, textStatus, errorThrown){
|
||||
console.log(errorThrown);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onClose: function() {
|
||||
@ -115,6 +135,7 @@ var odfViewer = {
|
||||
}
|
||||
$('#app-content #controls').removeClass('hidden');
|
||||
$('#richdocumentsframe').remove();
|
||||
$('#chatroom').remove();
|
||||
},
|
||||
|
||||
registerFilesMenu: function(response) {
|
||||
|
@ -288,4 +288,42 @@ class DocumentController extends Controller {
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function generate($id) {
|
||||
|
||||
if (empty($id)) {
|
||||
return array(
|
||||
'status' => 'error',
|
||||
'message' => 'no id received'
|
||||
);
|
||||
}
|
||||
$view = \OC\Files\Filesystem::getView();
|
||||
try {
|
||||
$path = $view->getPath($id);
|
||||
if ($view->is_file($path) && $view->isReadable($path)) {
|
||||
$secret = \OC::$server->getConfig()->getSystemValue('secret');
|
||||
$instanceID = \OC::$server->getConfig()->getSystemValue('instanceid');
|
||||
$chatRoomPassword = hash('sha512', 'chatroom-password'.$instanceID.$secret.$id);
|
||||
$chatRoomName = hash('sha512','chatroom-name'.$instanceID.$secret.$id);
|
||||
return array(
|
||||
'status' => 'success',
|
||||
'password' => $chatRoomPassword,
|
||||
'name' => $chatRoomName
|
||||
);
|
||||
} else {
|
||||
return array(
|
||||
'status' => 'error',
|
||||
'message' => 'user unauthorised to view file'
|
||||
);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return array(
|
||||
'status' => 'error',
|
||||
'message' => 'user unauthorised to view file'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user