diff options
author | Christopher Ng <chrng8@gmail.com> | 2023-03-29 13:36:45 -0700 |
---|---|---|
committer | Christopher Ng <chrng8@gmail.com> | 2023-03-29 13:36:45 -0700 |
commit | 4f8e916585889b99247d967d51325ac0c840ec59 (patch) | |
tree | 67e9b24aa50f033cf88d52f53b648bb2bd30aab4 /lib/private/App/AppManager.php | |
parent | fc371facd202d7ede86f1adb37fc78a8c478deff (diff) | |
download | nextcloud-server-4f8e916585889b99247d967d51325ac0c840ec59.tar.gz nextcloud-server-4f8e916585889b99247d967d51325ac0c840ec59.zip |
Add label for logo link
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'lib/private/App/AppManager.php')
-rw-r--r-- | lib/private/App/AppManager.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 5f243a1250e..9b038b73826 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -827,4 +827,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; + } } |