summaryrefslogtreecommitdiffstats
path: root/lib/private/group
diff options
context:
space:
mode:
authorblizzz <blizzz@owncloud.com>2014-10-17 12:07:27 +0200
committerblizzz <blizzz@owncloud.com>2014-10-17 12:07:27 +0200
commit688a141586dad961b24b364e79cd11c1aa343730 (patch)
tree1da583b0fda2dba7c012297578a4f082ba5780d3 /lib/private/group
parentf1a5ebd59d5403cdae1ed60513c9feb469365d09 (diff)
parentde53bee9b38a4a757d7b24d7d0e70311e07358b5 (diff)
downloadnextcloud-server-688a141586dad961b24b364e79cd11c1aa343730.tar.gz
nextcloud-server-688a141586dad961b24b364e79cd11c1aa343730.zip
Merge pull request #9104 from macjohnny/macjohnny-drastic-ldap-speedup
drastic ldap speedup (update)
Diffstat (limited to 'lib/private/group')
-rw-r--r--lib/private/group/manager.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php
index 58a23924872..816e7b427f5 100644
--- a/lib/private/group/manager.php
+++ b/lib/private/group/manager.php
@@ -48,6 +48,7 @@ class Manager extends PublicEmitter implements IGroupManager {
*/
private $cachedUserGroups = array();
+
/**
* @param \OC\User\Manager $userManager
*/
@@ -180,18 +181,24 @@ class Manager extends PublicEmitter implements IGroupManager {
$groups[$groupId] = $this->get($groupId);
}
}
- $this->cachedUserGroups[$uid] = array_values($groups);
+ $this->cachedUserGroups[$uid] = $groups;
return $this->cachedUserGroups[$uid];
}
+
/**
+ * get a list of group ids for a user
* @param \OC\User\User $user
- * @return array with group names
+ * @return array with group ids
*/
public function getUserGroupIds($user) {
$groupIds = array();
- foreach ($this->backends as $backend) {
- $groupIds = array_merge($groupIds, $backend->getUserGroups($user->getUID()));
-
+ $userId = $user->getUID();
+ if (isset($this->cachedUserGroups[$userId])) {
+ return array_keys($this->cachedUserGroups[$userId]);
+ } else {
+ foreach ($this->backends as $backend) {
+ $groupIds = array_merge($groupIds, $backend->getUserGroups($userId));
+ }
}
return $groupIds;
}