diff --git a/appinfo/routes.php b/appinfo/routes.php index 9c1f0515..c23bbaaf 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -33,7 +33,7 @@ $application->registerRoutes($this, [ ['name' => 'document#listAll', 'url' => 'ajax/documents/list', 'verb' => 'GET'], ['name' => 'document#download', 'url' => 'ajax/download.php', 'verb' => 'GET'], //documents - for CloudSuite access - ['name' => 'document#localLoad', 'url' => 'ajax/documents/load/{esId}', 'verb' => 'POST'], + ['name' => 'document#localLoad', 'url' => 'load/{fileId}', 'verb' => 'POST'], //settings ['name' => 'settings#savePersonal', 'url' => 'ajax/personal.php', 'verb' => 'POST'], ['name' => 'settings#setUnstable', 'url' => 'ajax/config/unstable', 'verb' => 'POST'], diff --git a/controller/documentcontroller.php b/controller/documentcontroller.php index 8c7ba0ed..e0946fb9 100644 --- a/controller/documentcontroller.php +++ b/controller/documentcontroller.php @@ -115,23 +115,11 @@ class DocumentController extends Controller{ * Copy the file to a temporary location that is shared between the * cloudsuite server part and owncloud. */ - public function localLoad($esId){ - $session = new Db\Session(); - $session->load($esId); - - $member = new Db\Member(); - $member->load($this->uid); - - try { - if ($member->getIsGuest()){ - $file = File::getByShareToken($member->getToken()); - } else { - $file = new File($session->getFileId()); - } + public function localLoad($fileId){ + $view = \OC\Files\Filesystem::getView(); + $path = $view->getPath($fileId); - $view = $file->getOwnerView(true); - $path = $file->getPath(true); - } catch (\Exception $e){ + if (!$view->is_file($path)) { return array( 'status' => 'error', 'message' => (string) $this->l10n->t('Unable to copy document for CloudSuite access.') diff --git a/js/documents.js b/js/documents.js index b3e5c040..d2610ead 100644 --- a/js/documents.js +++ b/js/documents.js @@ -277,8 +277,11 @@ var documentsMain = { } documentsMain.show(); + if (fileId){ documentsMain.overlay.documentOverlay('show'); + documentsMain.prepareSession(); + documentsMain.joinSession(fileId); } documentsMain.ready = true; @@ -508,7 +511,7 @@ var documentsMain = { }, loadDocument: function() { - var url = OC.generateUrl('apps/documents/ajax/documents/load/{es_id}', {es_id: documentsMain.esId}); + var url = OC.generateUrl('apps/documents/load/{file_id}', {file_id: documentsMain.fileId}); $.post( url, {}, diff --git a/js/viewer/viewer.js b/js/viewer/viewer.js index 22a2c720..0ad91a4d 100644 --- a/js/viewer/viewer.js +++ b/js/viewer/viewer.js @@ -53,7 +53,7 @@ var odfViewer = { onEdit : function(fileName, context){ var fileId = context.$file.attr('data-id'); - window.location = OC.linkTo('documents', 'index.php') + '#' + fileId; + window.location = OC.generateUrl('apps/documents/index#{file_id}', {file_id: fileId}); }, onView: function(filename, context) {