diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-07-01 20:39:13 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-07-01 20:39:13 +0200 |
commit | 3d921ed3c35cba877015062fef27f2ad83717e7e (patch) | |
tree | 4d228a4d434c92454c598123f96ba41bafd4be90 /lib | |
parent | 19a6dc5420d3a27c50590b2f060700edff2ef73e (diff) | |
parent | 7c174520289dc5337dda1d32352e7542cb329670 (diff) | |
download | nextcloud-server-3d921ed3c35cba877015062fef27f2ad83717e7e.tar.gz nextcloud-server-3d921ed3c35cba877015062fef27f2ad83717e7e.zip |
Merge pull request #9334 from owncloud/defaultappfix
Default app fix
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/app.php | 2 | ||||
-rwxr-xr-x | lib/private/util.php | 32 |
2 files changed, 28 insertions, 6 deletions
diff --git a/lib/private/app.php b/lib/private/app.php index 9fb0ec2e34f..0ca2ca36bd2 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -163,7 +163,7 @@ class OC_App { /** * get all enabled apps */ - private static $enabledAppsCache = array(); + protected static $enabledAppsCache = array(); public static function getEnabledApps($forceRefresh = false) { if (!OC_Config::getValue('installed', false)) { diff --git a/lib/private/util.php b/lib/private/util.php index 7836489832d..897795f7535 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -815,10 +815,13 @@ class OC_Util { } /** - * Redirect to the user default page - * @return void + * Returns the URL of the default page + * based on the system configuration and + * the apps visible for the current user + * + * @return string URL */ - public static function redirectToDefaultPage() { + public static function getDefaultPageUrl() { $urlGenerator = \OC::$server->getURLGenerator(); if(isset($_REQUEST['redirect_url'])) { $location = urldecode($_REQUEST['redirect_url']); @@ -827,11 +830,30 @@ class OC_Util { if ($defaultPage) { $location = $urlGenerator->getAbsoluteURL($defaultPage); } else { - $location = $urlGenerator->getAbsoluteURL('/index.php/apps/files'); + $appId = 'files'; + $defaultApps = explode(',', \OCP\Config::getSystemValue('defaultapp', 'files')); + // find the first app that is enabled for the current user + foreach ($defaultApps as $defaultApp) { + $defaultApp = OC_App::cleanAppId(strip_tags($defaultApp)); + if (OC_App::isEnabled($defaultApp)) { + $appId = $defaultApp; + break; + } + } + $location = $urlGenerator->getAbsoluteURL('/index.php/apps/' . $appId . '/'); } } + return $location; + } + + /** + * Redirect to the user default page + * @return void + */ + public static function redirectToDefaultPage() { + $location = self::getDefaultPageUrl(); OC_Log::write('core', 'redirectToDefaultPage: '.$location, OC_Log::DEBUG); - header( 'Location: '.$location ); + header('Location: '.$location); exit(); } |