aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/lib/Controller/ViewController.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/lib/Controller/ViewController.php')
-rw-r--r--apps/files/lib/Controller/ViewController.php22
1 files changed, 9 insertions, 13 deletions
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index 779a2c7aadc..db8f32ddf73 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -27,11 +27,11 @@
namespace OCA\Files\Controller;
-use OC\AppFramework\Http\Request;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\IL10N;
@@ -67,7 +67,7 @@ class ViewController extends Controller {
protected $userSession;
/** @var IAppManager */
protected $appManager;
- /** @var \OCP\Files\Folder */
+ /** @var IRootFolder */
protected $rootFolder;
/**
@@ -80,7 +80,7 @@ class ViewController extends Controller {
* @param EventDispatcherInterface $eventDispatcherInterface
* @param IUserSession $userSession
* @param IAppManager $appManager
- * @param Folder $rootFolder
+ * @param IRootFolder $rootFolder
*/
public function __construct($appName,
IRequest $request,
@@ -91,7 +91,7 @@ class ViewController extends Controller {
EventDispatcherInterface $eventDispatcherInterface,
IUserSession $userSession,
IAppManager $appManager,
- Folder $rootFolder
+ IRootFolder $rootFolder
) {
parent::__construct($appName, $request);
$this->appName = $appName;
@@ -143,15 +143,14 @@ class ViewController extends Controller {
* @param string $dir
* @param string $view
* @param string $fileid
- * @return TemplateResponse
+ * @return TemplateResponse|RedirectResponse
*/
- public function index($dir = '', $view = '', $fileid = null) {
- $fileNotFound = false;
+ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false) {
if ($fileid !== null) {
try {
return $this->showFile($fileid);
} catch (NotFoundException $e) {
- $fileNotFound = true;
+ return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true]));
}
}
@@ -267,13 +266,10 @@ class ViewController extends Controller {
* @param string $fileId file id to show
* @return RedirectResponse redirect response or not found response
* @throws \OCP\Files\NotFoundException
- *
- * @NoCSRFRequired
- * @NoAdminRequired
*/
- public function showFile($fileId) {
+ private function showFile($fileId) {
$uid = $this->userSession->getUser()->getUID();
- $baseFolder = $this->rootFolder->get($uid . '/files/');
+ $baseFolder = $this->rootFolder->getUserFolder($uid);
$files = $baseFolder->getById($fileId);
$params = [];