diff options
author | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2023-09-28 10:55:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-28 10:55:52 +0200 |
commit | c9ed1e981bb0493cd02a4fcccfb299dcd847e618 (patch) | |
tree | 51a96cc7da5006b32f878479762f11ba23c45550 /lib | |
parent | 99e287b49abaa1c0807a5bb6e7bae6d6f764f82d (diff) | |
parent | 8049702413f4422ea299733c8f69b852732edcb2 (diff) | |
download | nextcloud-server-c9ed1e981bb0493cd02a4fcccfb299dcd847e618.tar.gz nextcloud-server-c9ed1e981bb0493cd02a4fcccfb299dcd847e618.zip |
Merge pull request #40617 from nextcloud/enh/allow-user-to-set-apporder
Read apporder from configuration value
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/App/AppManager.php | 16 | ||||
-rw-r--r-- | lib/private/NavigationManager.php | 8 |
2 files changed, 21 insertions, 3 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 88044fbf7b6..ccbb2143133 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -825,13 +825,27 @@ class AppManager implements IAppManager { public function getDefaultAppForUser(?IUser $user = null): string { // Set fallback to always-enabled files app $appId = 'files'; - $defaultApps = explode(',', $this->config->getSystemValueString('defaultapp', 'dashboard,files')); + $defaultApps = explode(',', $this->config->getSystemValueString('defaultapp', '')); + $defaultApps = array_filter($defaultApps); $user ??= $this->userSession->getUser(); if ($user !== null) { $userDefaultApps = explode(',', $this->config->getUserValue($user->getUID(), 'core', 'defaultapp')); $defaultApps = array_filter(array_merge($userDefaultApps, $defaultApps)); + if (empty($defaultApps)) { + /* Fallback on user defined apporder */ + $customOrders = json_decode($this->config->getUserValue($user->getUID(), 'core', 'apporder', '[]'), true, flags:JSON_THROW_ON_ERROR); + if (!empty($customOrders)) { + $customOrders = array_map('min', $customOrders); + asort($customOrders); + $defaultApps = array_keys($customOrders); + } + } + } + + if (empty($defaultApps)) { + $defaultApps = ['dashboard','files']; } // Find the first app that is enabled for the current user diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php index ac6f16190dc..ef6e6f4cb74 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -285,11 +285,15 @@ class NavigationManager implements INavigationManager { } if ($this->userSession->isLoggedIn()) { - $apps = $this->appManager->getEnabledAppsForUser($this->userSession->getUser()); + $user = $this->userSession->getUser(); + $apps = $this->appManager->getEnabledAppsForUser($user); + $customOrders = json_decode($this->config->getUserValue($user->getUID(), 'core', 'apporder', '[]'), true, flags:JSON_THROW_ON_ERROR); } else { $apps = $this->appManager->getInstalledApps(); + $customOrders = []; } + foreach ($apps as $app) { if (!$this->userSession->isLoggedIn() && !$this->appManager->isEnabledForUser($app, $this->userSession->getUser())) { continue; @@ -315,7 +319,7 @@ class NavigationManager implements INavigationManager { } $l = $this->l10nFac->get($app); $id = $nav['id'] ?? $app . ($key === 0 ? '' : $key); - $order = isset($nav['order']) ? $nav['order'] : 100; + $order = $customOrders[$app][$key] ?? $nav['order'] ?? 100; $type = $nav['type']; $route = !empty($nav['route']) ? $this->urlGenerator->linkToRoute($nav['route']) : ''; $icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg'; |