diff options
author | Christopher Ng <chrng8@gmail.com> | 2023-03-29 13:36:45 -0700 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2023-03-30 00:32:30 +0000 |
commit | f943853c3d51a907ab394f97d67f90d658b9b89d (patch) | |
tree | 3bb04766f5887e6896aeac1d852392667e4a04db /lib | |
parent | 25ff7c91e5304800c1f88cc4d4a3b025bf753f7b (diff) | |
download | nextcloud-server-f943853c3d51a907ab394f97d67f90d658b9b89d.tar.gz nextcloud-server-f943853c3d51a907ab394f97d67f90d658b9b89d.zip |
Add label for logo link
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/App/AppManager.php | 24 | ||||
-rw-r--r-- | lib/private/TemplateLayout.php | 8 | ||||
-rw-r--r-- | lib/private/URLGenerator.php | 18 | ||||
-rw-r--r-- | lib/public/App/IAppManager.php | 9 |
4 files changed, 41 insertions, 18 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index d14f0a2644e..b5fe41e581e 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -601,4 +601,28 @@ class AppManager implements IAppManager { return $this->defaultEnabled; } + + public function getDefaultAppForUser(?IUser $user = null): string { + // Set fallback to always-enabled files app + $appId = 'files'; + $defaultApps = explode(',', $this->config->getSystemValueString('defaultapp', 'dashboard,files')); + + $user ??= $this->userSession->getUser(); + + if ($user !== null) { + $userDefaultApps = explode(',', $this->config->getUserValue($user->getUID(), 'core', 'defaultapp')); + $defaultApps = array_filter(array_merge($userDefaultApps, $defaultApps)); + } + + // Find the first app that is enabled for the current user + foreach ($defaultApps as $defaultApp) { + $defaultApp = \OC_App::cleanAppId(strip_tags($defaultApp)); + if ($this->isEnabledForUser($defaultApp, $user)) { + $appId = $defaultApp; + break; + } + } + + return $appId; + } } diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index d127443944f..123fd6debb5 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -119,10 +119,16 @@ class TemplateLayout extends \OC_Template { $this->assign('enabledThemes', $themesService->getEnabledThemes()); } - // set logo link target + // Set logo link target $logoUrl = $this->config->getSystemValueString('logo_url', ''); $this->assign('logoUrl', $logoUrl); + // Set default app name + $defaultApp = \OC::$server->getAppManager()->getDefaultAppForUser(); + $defaultAppInfo = \OC::$server->getAppManager()->getAppInfo($defaultApp); + $l10n = \OC::$server->getL10NFactory()->get($defaultApp); + $this->assign('defaultAppName', $l10n->t($defaultAppInfo['name'])); + // Add navigation entry $this->assign('application', ''); $this->assign('appid', $appId); diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php index 7be2895a1ef..a5a3609703b 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -311,23 +311,7 @@ class URLGenerator implements IURLGenerator { return $this->getAbsoluteURL($defaultPage); } - $appId = 'files'; - $defaultApps = explode(',', $this->config->getSystemValue('defaultapp', 'dashboard,files')); - - $userId = $this->userSession->isLoggedIn() ? $this->userSession->getUser()->getUID() : null; - if ($userId !== null) { - $userDefaultApps = explode(',', $this->config->getUserValue($userId, 'core', 'defaultapp')); - $defaultApps = array_filter(array_merge($userDefaultApps, $defaultApps)); - } - - // find the first app that is enabled for the current user - foreach ($defaultApps as $defaultApp) { - $defaultApp = \OC_App::cleanAppId(strip_tags($defaultApp)); - if (\OC::$server->getAppManager()->isEnabledForUser($defaultApp)) { - $appId = $defaultApp; - break; - } - } + $appId = $this->getAppManager()->getDefaultAppForUser(); if ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true') { diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index de36fafcdfe..95136c56da1 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -207,4 +207,13 @@ interface IAppManager { * @since 17.0.0 */ public function getAppRestriction(string $appId): array; + + /** + * Returns the id of the user's default app + * + * If `user` is not passed, the currently logged in user will be used + * + * @since 25.0.6 + */ + public function getDefaultAppForUser(?IUser $user = null): string; } |