summaryrefslogtreecommitdiffstats
path: root/lib/private/App
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/App')
-rw-r--r--lib/private/App/AppManager.php24
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;
+ }
}