From 4d74aa09bf7102a1104549b08c6bebe2382ec0cd Mon Sep 17 00:00:00 2001 From: Stephan Peijnik Date: Fri, 11 Jul 2014 07:12:04 +0200 Subject: Port of #9584 Fixes #9583 lib/private/group/metadata.php: For subadmins also return an array of groups, indexed by their GIDs. settings/users.php: Convert array of arrays to array of GIDs before calling into OC_Group::displayNamesInGroups. Signed-off-by: Stephan Peijnik Fix indentation. Signed-off-by: Stephan Peijnik Renamed $grp to $group in foreach loop. Signed-off-by: Stephan Peijnik Use is_null() instead of empty() when checking the return value of GroupManager::get(). Additionally, $grp was renamed to $group inside \OC\Group\MetaData::fetchGroups(). Signed-off-by: Stephan Peijnik Updated code to reflect changes introduced to \OC\Group\MetaData. Now that fetchGroups() does not exist anymore and getGroups() is called directory, the 'groups' property does not exist anymore. Instead, we now generate that array on the fly and return it from getGroups. Signed-off-by: Stephan Peijnik --- lib/private/group/metadata.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/private') diff --git a/lib/private/group/metadata.php b/lib/private/group/metadata.php index 57abbe20c64..687a735347c 100644 --- a/lib/private/group/metadata.php +++ b/lib/private/group/metadata.php @@ -168,7 +168,21 @@ class MetaData { if($this->isAdmin) { return $this->groupManager->search($search); } else { - return \OC_SubAdmin::getSubAdminsGroups($this->user); + $groupIds = \OC_SubAdmin::getSubAdminsGroups($this->user); + + /* \OC_SubAdmin::getSubAdminsGroups() returns an array of GIDs, but this + * method is expected to return an array with the GIDs as keys and group objects as + * values, so we need to convert this information. + */ + $groups = array(); + foreach($groupIds as $gid) { + $group = $this->groupManager->get($gid); + if (!is_null($group)) { + $groups[$gid] = $group; + } + } + + return $groups; } } } -- cgit v1.2.3