summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormacjohnny <estebanmarin@gmx.ch>2014-06-19 19:35:10 +0200
committermacjohnny <estebanmarin@gmx.ch>2014-06-19 19:35:10 +0200
commit14fcd681723e068a3398b9065a2bad4756e9b5f2 (patch)
treeb2728df116467f85ba7ccbb18550ef17cd2cdb38
parentc95416897331fc637ba0c4ae0672c5f4da514627 (diff)
downloadnextcloud-server-14fcd681723e068a3398b9065a2bad4756e9b5f2.tar.gz
nextcloud-server-14fcd681723e068a3398b9065a2bad4756e9b5f2.zip
Update manager.php
-rw-r--r--lib/private/group/manager.php34
1 files changed, 25 insertions, 9 deletions
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php
index e0b563ad488..ae20af7448f 100644
--- a/lib/private/group/manager.php
+++ b/lib/private/group/manager.php
@@ -48,6 +48,12 @@ class Manager extends PublicEmitter {
private $cachedUserGroups = array();
/**
+ * @var string[]
+ */
+ private $cachedUserGroupIds = array();
+
+
+ /**
* @param \OC\User\Manager $userManager
*/
public function __construct($userManager) {
@@ -176,7 +182,7 @@ class Manager extends PublicEmitter {
foreach ($this->backends as $backend) {
$groupIds = $backend->getUserGroups($uid);
foreach ($groupIds as $groupId) {
- $groups[$groupId] = $this->get($groupId);
+ $groups[] = $this->get($groupId);
}
}
$this->cachedUserGroups[$uid] = $groups;
@@ -186,18 +192,28 @@ class Manager extends PublicEmitter {
/**
* 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) {
- $uid = $user->getUID();
- if (isset($this->cachedUserGroups[$uid])) {
- return array_keys($this->cachedUserGroups[$uid]);
- }
$groupIds = array();
- foreach ($this->backends as $backend) {
- $groupIds = array_merge($groupIds, $backend->getUserGroups($user->getUID()));
+ $userId = $user->getUID();
+ if (isset($this->cachedUserGroupIds[$userId])) {
+ return $this->cachedUserGroupIds[$userId];
+ }
+ if (isset($this->cachedUserGroups[$userId])) {
+ foreach($this->cachedUserGroups[$userId] as $group)
+ {
+ $groupIds[] = $group->getGID();
+ }
+ }
+ else
+ {
+ foreach ($this->backends as $backend) {
+ $groupIds = array_merge($groupIds, $backend->getUserGroups($userId));
+ }
}
- return $groupIds;
+ $this->cachedUserGroupIds[$userId] = $groupIds;
+ return $this->cachedUserGroupIds[$userId];
}
/**