Support for multiple default apps

If a default app isn't visible for the user, try the next one.
Else fallback to the "files" app.
This commit is contained in:
Vincent Petry 2014-07-01 15:42:26 +02:00
parent 894d69184a
commit c005515ebd
2 changed files with 16 additions and 4 deletions

View File

@ -74,7 +74,11 @@ $CONFIG = array(
/* URL to the parent directory of the 3rdparty directory, as seen by the browser */
"3rdpartyurl" => "",
/* Default app to load on login */
/* Default app to open on login.
* This can be a comma-separated list of app ids.
* If the first app is not enabled for the current user,
* it will try with the second one and so on. If no enabled app could be found,
* the "files" app will be displayed instead. */
"defaultapp" => "files",
/* Enable the help menu item in the settings */

View File

@ -827,9 +827,17 @@ class OC_Util {
if ($defaultPage) {
$location = $urlGenerator->getAbsoluteURL($defaultPage);
} else {
$defaultApp = \OCP\Config::getSystemValue('defaultapp', 'files');
$defaultApp = OC_App::cleanAppId(strip_tags($defaultApp));
$location = $urlGenerator->getAbsoluteURL('/index.php/apps/' . $defaultApp);
$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->linkTo($appId, 'index.php');
}
}
OC_Log::write('core', 'redirectToDefaultPage: '.$location, OC_Log::DEBUG);