summaryrefslogtreecommitdiffstats
path: root/apps/files/controller/apicontroller.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/controller/apicontroller.php')
-rw-r--r--apps/files/controller/apicontroller.php19
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);
+ }
+
}