]> source.dussan.org Git - nextcloud-server.git/commitdiff
Port of #9584
authorStephan Peijnik <speijnik@anexia-it.com>
Fri, 11 Jul 2014 05:12:04 +0000 (07:12 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Wed, 16 Jul 2014 10:23:26 +0000 (12:23 +0200)
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 <speijnik@anexia-it.com>
Fix indentation.

Signed-off-by: Stephan Peijnik <speijnik@anexia-it.com>
Renamed $grp to $group in foreach loop.

Signed-off-by: Stephan Peijnik <speijnik@anexia-it.com>
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 <speijnik@anexia-it.com>
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 <speijnik@anexia-it.com>
lib/private/group/metadata.php
settings/users.php

index 57abbe20c64e13fb300359aada0b8cbffc30804c..687a735347c5f4ca632705f11645d240991e72a5 100644 (file)
@@ -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;
                }
        }
 }
index 29a63a4496a3ef4c6d350354e1cb54925fb3e524..bc6c2ea7e7c26cf545e88d87ff0ed7435f09c8d6 100644 (file)
@@ -35,7 +35,14 @@ if($isAdmin) {
        $accessibleUsers = OC_User::getDisplayNames('', 30);
        $subadmins = OC_SubAdmin::getAllSubAdmins();
 }else{
-       $accessibleUsers = OC_Group::displayNamesInGroups($groups, '', 30);
+       /* Retrieve group IDs from $groups array, so we can pass that information into OC_Group::displayNamesInGroups() */
+       $gids = array();
+       foreach($groups as $group) {
+               if (isset($group['id'])) {
+                       $gids[] = $group['id'];
+               }
+       }
+       $accessibleUsers = OC_Group::displayNamesInGroups($gids, '', 30);
        $subadmins = false;
 }