diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2016-04-12 11:08:26 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2016-04-13 11:28:42 +0200 |
commit | a4683bcfa9d2670a5284b7b27f0a475de8be44b7 (patch) | |
tree | 78ebd2ddc0224993dcd9c2aac6cfbea20d47871f /apps/files/controller/apicontroller.php | |
parent | 3f492dd82681ca92e9e86acfcf1c15dfcfcf34cf (diff) | |
download | nextcloud-server-a4683bcfa9d2670a5284b7b27f0a475de8be44b7.tar.gz nextcloud-server-a4683bcfa9d2670a5284b7b27f0a475de8be44b7.zip |
persist file sorting changes
Diffstat (limited to 'apps/files/controller/apicontroller.php')
-rw-r--r-- | apps/files/controller/apicontroller.php | 19 |
1 files changed, 17 insertions, 2 deletions
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 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <rullzer@owncloud.com> @@ -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); + } + } |