From a4683bcfa9d2670a5284b7b27f0a475de8be44b7 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 12 Apr 2016 11:08:26 +0200 Subject: persist file sorting changes --- apps/files/controller/apicontroller.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'apps/files/controller/apicontroller.php') diff --git a/apps/files/controller/apicontroller.php b/apps/files/controller/apicontroller.php index ad286284386..82d3ebb58b7 100644 --- a/apps/files/controller/apicontroller.php +++ b/apps/files/controller/apicontroller.php @@ -1,6 +1,7 @@ + * @author Christoph Wurst * @author Lukas Reschke * @author Morris Jobke * @author Roeland Jago Douma @@ -29,13 +30,13 @@ namespace OCA\Files\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Controller; +use OCP\IConfig; use OCP\IRequest; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataDisplayResponse; use OCA\Files\Service\TagService; use OCP\IPreview; use OCP\Share\IManager; -use OCP\Files\FileInfo; use OCP\Files\Node; use OCP\IUserSession; @@ -53,6 +54,8 @@ class ApiController extends Controller { private $previewManager; /** IUserSession */ private $userSession; + /** IConfig */ + private $config; /** * @param string $appName @@ -65,12 +68,14 @@ class ApiController extends Controller { IUserSession $userSession, TagService $tagService, IPreview $previewManager, - IManager $shareManager) { + IManager $shareManager, + IConfig $config) { parent::__construct($appName, $request); $this->userSession = $userSession; $this->tagService = $tagService; $this->previewManager = $previewManager; $this->shareManager = $shareManager; + $this->config = $config; } /** @@ -196,4 +201,14 @@ class ApiController extends Controller { return $shareTypes; } + public function updateFileSorting($mode, $direction) { + $allowedMode = ['name', 'size', 'mtime']; + $allowedDirection = ['asc', 'desc']; + if (!in_array($mode, $allowedMode) || !in_array($direction, $allowedDirection)) { + return $this->buildResponse(null)->setStatus(Http::STATUS_UNPROCESSABLE_ENTITY); + } + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'file_sorting', $mode); + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'file_sorting_direction', $direction); + } + } -- cgit v1.2.3