[Pkg-owncloud-commits] [owncloud] 173/273: Support for multiple default apps

David Prévot taffit at moszumanska.debian.org
Fri Jul 4 03:13:13 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit c005515ebd3fcf1d79070b3e7e2a783cf2ea53e1
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Tue Jul 1 15:42:26 2014 +0200

    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.
---
 config/config.sample.php |  6 +++++-
 lib/private/util.php     | 14 +++++++++++---
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/config/config.sample.php b/config/config.sample.php
index 59e1f38..e613609 100755
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -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 */
diff --git a/lib/private/util.php b/lib/private/util.php
index 424c27e..e9e081a 100755
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -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);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list