summaryrefslogtreecommitdiffstats
path: root/apps/files/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/lib')
-rw-r--r--apps/files/lib/AppInfo/Application.php4
-rw-r--r--apps/files/lib/Controller/ApiController.php175
-rw-r--r--apps/files/lib/Controller/ViewController.php83
3 files changed, 233 insertions, 29 deletions
diff --git a/apps/files/lib/AppInfo/Application.php b/apps/files/lib/AppInfo/Application.php
index 064f2baa987..d4dac5befa8 100644
--- a/apps/files/lib/AppInfo/Application.php
+++ b/apps/files/lib/AppInfo/Application.php
@@ -26,6 +26,7 @@
*/
namespace OCA\Files\AppInfo;
+use OCA\Files\Activity\Helper;
use OCA\Files\Controller\ApiController;
use OCP\AppFramework\App;
use \OCA\Files\Service\TagService;
@@ -65,7 +66,8 @@ class Application extends App {
$server->getEventDispatcher(),
$server->getUserSession(),
$server->getAppManager(),
- $server->getRootFolder()
+ $server->getRootFolder(),
+ $c->query(Helper::class)
);
});
diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php
index a66b1b4d565..aae1bec2e78 100644
--- a/apps/files/lib/Controller/ApiController.php
+++ b/apps/files/lib/Controller/ApiController.php
@@ -11,7 +11,7 @@
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Tobias Kaminsky <tobias@kaminsky.me>
* @author Vincent Petry <pvince81@owncloud.com>
- *
+ * @author Felix Nüsse <felix.nuesse@t-online.de>
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
@@ -45,6 +45,7 @@ use OCP\IPreview;
use OCP\Share\IManager;
use OC\Files\Node\Node;
use OCP\IUserSession;
+use Sabre\VObject\Property\Boolean;
/**
* Class ApiController
@@ -54,7 +55,7 @@ use OCP\IUserSession;
class ApiController extends Controller {
/** @var TagService */
private $tagService;
- /** @var IManager **/
+ /** @var IManager * */
private $shareManager;
/** @var IPreview */
private $previewManager;
@@ -107,7 +108,7 @@ class ApiController extends Controller {
* @return DataResponse|FileDisplayResponse
*/
public function getThumbnail($x, $y, $file) {
- if($x < 1 || $y < 1) {
+ if ($x < 1 || $y < 1) {
return new DataResponse(['message' => 'Requested size must be numeric and a positive value.'], Http::STATUS_BAD_REQUEST);
}
@@ -199,6 +200,30 @@ class ApiController extends Controller {
}
/**
+ * Returns a list of favorites modifed folder.
+ *
+ * @NoAdminRequired
+ *
+ * @return DataResponse
+ */
+ public function getFavoritesFolder() {
+ $nodes = $this->userFolder->searchByTag('_$!<Favorite>!$_', $this->userSession->getUser()->getUID());
+
+ $favorites = [];
+ $i = 0;
+ foreach ($nodes as &$node) {
+
+ $favorites[$i]['id'] = $node->getId();
+ $favorites[$i]['name'] = $node->getName();
+ $favorites[$i]['path'] = $node->getInternalPath();
+ $favorites[$i]['mtime'] = $node->getMTime();
+ $i++;
+ }
+
+ return new DataResponse(['favoriteFolders' => $favorites]);
+ }
+
+ /**
* Return a list of share types for outgoing shares
*
* @param Node $node file node
@@ -261,8 +286,150 @@ class ApiController extends Controller {
* @param bool $show
*/
public function showHiddenFiles($show) {
- $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', (int) $show);
+ $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', (int)$show);
+ return new Response();
+ }
+
+ /**
+ * Toggle default for showing/hiding QuickAccess folder
+ *
+ * @NoAdminRequired
+ *
+ * @param bool $show
+ *
+ * @return Response
+ */
+ public function showQuickAccess($show) {
+ $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', (int)$show);
+ return new Response();
+ }
+
+ /**
+ * Toggle default for showing/hiding QuickAccess folder
+ *
+ * @NoAdminRequired
+ *
+ * @return String
+ */
+ public function getShowQuickAccess() {
+
+ return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', 0);
+ }
+
+ /**
+ * quickaccess-sorting-strategy
+ *
+ * @NoAdminRequired
+ *
+ * @param string $strategy
+ * @return Response
+ */
+ public function setSortingStrategy($strategy) {
+ $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sorting_strategy', (String)$strategy);
return new Response();
}
+ /**
+ * Get reverse-state for quickaccess-list
+ *
+ * @NoAdminRequired
+ *
+ * @return String
+ */
+ public function getSortingStrategy() {
+ return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sorting_strategy', 'alphabet');
+ }
+
+ /**
+ * Toggle for reverse quickaccess-list
+ *
+ * @NoAdminRequired
+ *
+ * @param bool $reverse
+ * @return Response
+ */
+ public function setReverseQuickaccess($reverse) {
+ $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_reverse_list', (int)$reverse);
+ return new Response();
+ }
+
+ /**
+ * Get reverse-state for quickaccess-list
+ *
+ * @NoAdminRequired
+ *
+ * @return bool
+ */
+ public function getReverseQuickaccess() {
+ if ($this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_reverse_list', false)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Set state for show sorting menu
+ *
+ * @NoAdminRequired
+ *
+ * @param bool $show
+ * @return Response
+ */
+ public function setShowQuickaccessSettings($show) {
+ $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_show_settings', (int)$show);
+ return new Response();
+ }
+
+ /**
+ * Get state for show sorting menu
+ *
+ * @NoAdminRequired
+ *
+ * @return bool
+ */
+ public function getShowQuickaccessSettings() {
+ if ($this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_show_settings', false)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Set sorting-order for custom sorting
+ *
+ * @NoAdminRequired
+ *
+ * @param String $order
+ * @return Response
+ */
+ public function setSortingOrder($order) {
+ $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_custom_sorting_order', (String)$order);
+ return new Response();
+ }
+
+ /**
+ * Get sorting-order for custom sorting
+ *
+ * @NoAdminRequired
+ *
+ * @return String
+ */
+ public function getSortingOrder() {
+ return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_custom_sorting_order', "");
+ }
+
+ /**
+ * Get sorting-order for custom sorting
+ *
+ * @NoAdminRequired
+ *
+ * @param String
+ * @return String
+ */
+ public function getNodeType($folderpath) {
+ $node = $this->userFolder->get($folderpath);
+ return $node->getType();
+ }
+
+
}
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index 7cb0f112f72..f240e04c721 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -8,6 +8,7 @@
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Vincent Petry <pvince81@owncloud.com>
+ * @author Felix Nüsse <felix.nuesse@t-online.de>
*
* @license AGPL-3.0
*
@@ -27,6 +28,7 @@
namespace OCA\Files\Controller;
+use OCA\Files\Activity\Helper;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\RedirectResponse;
@@ -67,19 +69,10 @@ class ViewController extends Controller {
protected $appManager;
/** @var IRootFolder */
protected $rootFolder;
+ /** @var Helper */
+ protected $activityHelper;
- /**
- * @param string $appName
- * @param IRequest $request
- * @param IURLGenerator $urlGenerator
- * @param IL10N $l10n
- * @param IConfig $config
- * @param EventDispatcherInterface $eventDispatcherInterface
- * @param IUserSession $userSession
- * @param IAppManager $appManager
- * @param IRootFolder $rootFolder
- */
- public function __construct($appName,
+ public function __construct(string $appName,
IRequest $request,
IURLGenerator $urlGenerator,
IL10N $l10n,
@@ -87,7 +80,8 @@ class ViewController extends Controller {
EventDispatcherInterface $eventDispatcherInterface,
IUserSession $userSession,
IAppManager $appManager,
- IRootFolder $rootFolder
+ IRootFolder $rootFolder,
+ Helper $activityHelper
) {
parent::__construct($appName, $request);
$this->appName = $appName;
@@ -99,6 +93,7 @@ class ViewController extends Controller {
$this->userSession = $userSession;
$this->appManager = $appManager;
$this->rootFolder = $rootFolder;
+ $this->activityHelper = $activityHelper;
}
/**
@@ -159,28 +154,68 @@ class ViewController extends Controller {
// FIXME: Make non static
$storageInfo = $this->getStorageInfo();
+ $user = $this->userSession->getUser()->getUID();
+
+ try {
+ $favElements = $this->activityHelper->getFavoriteFilePaths($this->userSession->getUser()->getUID());
+ } catch (\RuntimeException $e) {
+ $favElements['folders'] = null;
+ }
+
+ $collapseClasses = '';
+ if (count($favElements['folders']) > 0) {
+ $collapseClasses = 'collapsible';
+ }
+
+ $favoritesSublistArray = Array();
+
+ $navBarPositionPosition = 6;
+ $currentCount = 0;
+ foreach ($favElements['folders'] as $dir) {
+
+ $id = substr($dir, strrpos($dir, '/') + 1, strlen($dir));
+ $link = $this->urlGenerator->linkToRoute('files.view.index', ['dir' => $dir, 'view' => 'files']);
+ $sortingValue = ++$currentCount;
+ $element = [
+ 'id' => str_replace('/', '-', $dir),
+ 'view' => 'files',
+ 'href' => $link,
+ 'dir' => $dir,
+ 'order' => $navBarPositionPosition,
+ 'folderPosition' => $sortingValue,
+ 'name' => $id,
+ 'icon' => 'files',
+ 'quickaccesselement' => 'true'
+ ];
+
+ array_push($favoritesSublistArray, $element);
+ $navBarPositionPosition++;
+ }
+
+
+ // show_Quick_Access stored as string
+ $defaultExpandedState = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', '0') === '1';
+
\OCA\Files\App::getNavigationManager()->add(
[
'id' => 'favorites',
'appname' => 'files',
'script' => 'simplelist.php',
+ 'classes' => $collapseClasses,
'order' => 5,
- 'name' => $this->l10n->t('Favorites')
+ 'name' => $this->l10n->t('Favorites'),
+ 'sublist' => $favoritesSublistArray,
+ 'defaultExpandedState' => $defaultExpandedState,
+ 'enableMenuButton' => 0,
]
);
$navItems = \OCA\Files\App::getNavigationManager()->getAll();
- usort($navItems, function($item1, $item2) {
+ usort($navItems, function ($item1, $item2) {
return $item1['order'] - $item2['order'];
});
- $nav->assign('navigationItems', $navItems);
- $webdavurl = $this->urlGenerator->linkTo('', 'remote.php') .
- '/dav/files/' .
- $this->userSession->getUser()->getUID() .
- '/';
- $webdavurl = $this->urlGenerator->getAbsoluteURL($webdavurl);
- $nav->assign('webdavurl', $webdavurl);
+ $nav->assign('navigationItems', $navItems);
$nav->assign('usage', \OC_Helper::humanFileSize($storageInfo['used']));
if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) {
@@ -215,10 +250,9 @@ class ViewController extends Controller {
$params['ownerDisplayName'] = $storageInfo['ownerDisplayName'];
$params['isPublic'] = false;
$params['allowShareWithLink'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes');
- $user = $this->userSession->getUser()->getUID();
$params['defaultFileSorting'] = $this->config->getUserValue($user, 'files', 'file_sorting', 'name');
$params['defaultFileSortingDirection'] = $this->config->getUserValue($user, 'files', 'file_sorting_direction', 'asc');
- $showHidden = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false);
+ $showHidden = (bool)$this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false);
$params['showHiddenFiles'] = $showHidden ? 1 : 0;
$params['fileNotFound'] = $fileNotFound ? 1 : 0;
$params['appNavigation'] = $nav;
@@ -234,6 +268,7 @@ class ViewController extends Controller {
$policy->addAllowedFrameDomain('\'self\'');
$response->setContentSecurityPolicy($policy);
+
return $response;
}