-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow default app to be overwritten by user config
Signed-off-by: Julius Härtl <[email protected]>
- Loading branch information
1 parent
7e2ded5
commit db86bea
Showing
1 changed file
with
14 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,7 @@ | |
use OCP\IGroupManager; | ||
use OCP\ILogger; | ||
use OCP\IUser; | ||
use OCP\IUserSession; | ||
|
||
class OC_Util { | ||
public static $scripts = []; | ||
|
@@ -1088,6 +1089,8 @@ public static function checkAdminUser() { | |
* @suppress PhanDeprecatedFunction | ||
*/ | ||
public static function getDefaultPageUrl() { | ||
/** @var IConfig $config */ | ||
$config = \OC::$server->get(IConfig::class); | ||
$urlGenerator = \OC::$server->getURLGenerator(); | ||
// Deny the redirect if the URL contains a @ | ||
// This prevents unvalidated redirects like ?redirect_url=:[email protected] | ||
|
@@ -1098,9 +1101,18 @@ public static function getDefaultPageUrl() { | |
if ($defaultPage) { | ||
$location = $urlGenerator->getAbsoluteURL($defaultPage); | ||
} else { | ||
|
||
$appId = 'files'; | ||
$config = \OC::$server->getConfig(); | ||
$defaultApps = explode(',', $config->getSystemValue('defaultapp', 'dashboard')); | ||
$defaultApps = explode(',', $config->getSystemValue('defaultapp', 'dashboard,files')); | ||
|
||
/** @var IUserSession $userSession */ | ||
$userSession = \OC::$server->get(IUserSession::class); | ||
$user = $userSession->getUser(); | ||
if ($user) { | ||
$userDefaultApps = explode(',', $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)); | ||
|