summaryrefslogtreecommitdiffstats
path: root/lib/private/app.php
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-09-02 14:30:46 +0200
committerVincent Petry <pvince81@owncloud.com>2014-09-02 17:16:14 +0200
commite05b95636b975dd119b19c14b48f291341464a19 (patch)
tree351906de1faefacf8d355ba7f9e1d23aa6df8ea5 /lib/private/app.php
parent689bbbe937a56c2975160a6ba6d4ca55fdc54e3b (diff)
downloadnextcloud-server-e05b95636b975dd119b19c14b48f291341464a19.tar.gz
nextcloud-server-e05b95636b975dd119b19c14b48f291341464a19.zip
Fix upgrade process when apps enabled for specific groups
Fix issue where the currently logged user was causing side-effects when upgrading. Now setting incognito mode (no user) on update to make sure the whole apps list is taken into account with getEnabledApps() or isEnabled().
Diffstat (limited to 'lib/private/app.php')
-rw-r--r--lib/private/app.php31
1 files changed, 24 insertions, 7 deletions
diff --git a/lib/private/app.php b/lib/private/app.php
index d10d352b432..3eed9e3c443 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -172,17 +172,29 @@ class OC_App {
*/
protected static $enabledAppsCache = array();
- public static function getEnabledApps($forceRefresh = false) {
+ /**
+ * Returns apps enabled for the current user.
+ *
+ * @param bool $forceRefresh whether to refresh the cache
+ * @param bool $all whether to return apps for all users, not only the
+ * currently logged in one
+ */
+ public static function getEnabledApps($forceRefresh = false, $all = false) {
if (!OC_Config::getValue('installed', false)) {
return array();
}
- if (!$forceRefresh && !empty(self::$enabledAppsCache)) {
+ // in incognito mode or when logged out, $user will be false,
+ // which is also the case during an upgrade
+ $user = null;
+ if (!$all) {
+ $user = \OC_User::getUser();
+ }
+ if (is_string($user) && !$forceRefresh && !empty(self::$enabledAppsCache)) {
return self::$enabledAppsCache;
}
$apps = array();
$appConfig = \OC::$server->getAppConfig();
$appStatus = $appConfig->getValues(false, 'enabled');
- $user = \OC_User::getUser();
foreach ($appStatus as $app => $enabled) {
if ($app === 'files') {
continue;
@@ -192,11 +204,16 @@ class OC_App {
} else if ($enabled !== 'no') {
$groups = json_decode($enabled);
if (is_array($groups)) {
- foreach ($groups as $group) {
- if (\OC_Group::inGroup($user, $group)) {
- $apps[] = $app;
- break;
+ if (is_string($user)) {
+ foreach ($groups as $group) {
+ if (\OC_Group::inGroup($user, $group)) {
+ $apps[] = $app;
+ break;
+ }
}
+ } else {
+ // global, consider app as enabled
+ $apps[] = $app;
}
}
}