summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2021-07-26 16:13:49 +0200
committerLouis (Rebase PR Action) <artonge@users.noreply.github.com>2021-07-27 11:41:32 +0000
commite558a004966e2603b19ae2f0e084f1de8c9e070e (patch)
tree4f82d98aff5c9517b386761dc4754a7196cf5fee /apps
parent702bced2b7db60f05a217ddb673360e85b3c3153 (diff)
downloadnextcloud-server-e558a004966e2603b19ae2f0e084f1de8c9e070e.tar.gz
nextcloud-server-e558a004966e2603b19ae2f0e084f1de8c9e070e.zip
Set openfile params when following internal links
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/lib/Controller/ViewController.php12
1 files changed, 9 insertions, 3 deletions
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index d834900c501..9b8b3aec40c 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -165,7 +165,7 @@ class ViewController extends Controller {
public function showFile(string $fileid = null): Response {
// This is the entry point from the `/f/{fileid}` URL which is hardcoded in the server.
try {
- return $this->redirectToFile($fileid);
+ return $this->redirectToFile($fileid, true);
} catch (NotFoundException $e) {
return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true]));
}
@@ -179,7 +179,7 @@ class ViewController extends Controller {
* @param string $view
* @param string $fileid
* @param bool $fileNotFound
- * @param string $openfile
+ * @param string $openfile - the openfile URL parameter if it was present in the initial request
* @return TemplateResponse|RedirectResponse
* @throws NotFoundException
*/
@@ -391,10 +391,11 @@ class ViewController extends Controller {
* Redirects to the file list and highlight the given file id
*
* @param string $fileId file id to show
+ * @param bool $setOpenfile - wether or not to set the openfile URL parameter
* @return RedirectResponse redirect response or not found response
* @throws \OCP\Files\NotFoundException
*/
- private function redirectToFile($fileId) {
+ private function redirectToFile($fileId, bool $setOpenfile = false) {
$uid = $this->userSession->getUser()->getUID();
$baseFolder = $this->rootFolder->getUserFolder($uid);
$files = $baseFolder->getById($fileId);
@@ -416,6 +417,11 @@ class ViewController extends Controller {
$params['dir'] = $baseFolder->getRelativePath($file->getParent()->getPath());
// and scroll to the entry
$params['scrollto'] = $file->getName();
+
+ if ($setOpenfile) {
+ // forward the openfile URL parameter.
+ $params['openfile'] = $fileId;
+ }
}
return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params));