Merge pull request #9751 from owncloud/issue/9748

Fix username for subadmins and only send subadmin groups
This commit is contained in:
Vincent Petry 2014-07-21 14:22:11 +02:00
commit 61598e7bb5
2 changed files with 6 additions and 5 deletions

View File

@ -38,9 +38,7 @@ $adminGroups = array();
$groupManager = \OC_Group::getManager(); $groupManager = \OC_Group::getManager();
$isAdmin = OC_User::isAdminUser(OC_User::getUser()); $isAdmin = OC_User::isAdminUser(OC_User::getUser());
//we pass isAdmin as true, because OC_SubAdmin has no search feature, $groupsInfo = new \OC\Group\MetaData(OC_User::getUser(), $isAdmin, $groupManager);
//groups will be filtered out later
$groupsInfo = new \OC\Group\MetaData(OC_User::getUser(), true, $groupManager);
$groupsInfo->setSorting($groupsInfo::SORT_USERCOUNT); $groupsInfo->setSorting($groupsInfo::SORT_USERCOUNT);
list($adminGroups, $groups) = $groupsInfo->get($groupPattern, $pattern); list($adminGroups, $groups) = $groupsInfo->get($groupPattern, $pattern);

View File

@ -76,10 +76,13 @@ if (OC_User::isAdminUser(OC_User::getUser())) {
$batch = OC_Group::usersInGroups($groups, $pattern, $limit, $offset); $batch = OC_Group::usersInGroups($groups, $pattern, $limit, $offset);
foreach ($batch as $uid) { foreach ($batch as $uid) {
$user = $userManager->get($uid); $user = $userManager->get($uid);
// Only add the groups, this user is a subadmin of
$userGroups = array_intersect(OC_Group::getUserGroups($uid), OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()));
$users[] = array( $users[] = array(
'name' => $user, 'name' => $uid,
'displayname' => $user->getDisplayName(), 'displayname' => $user->getDisplayName(),
'groups' => join(', ', OC_Group::getUserGroups($uid)), 'groups' => join(', ', $userGroups),
'quota' => OC_Preferences::getValue($uid, 'files', 'quota', 'default'), 'quota' => OC_Preferences::getValue($uid, 'files', 'quota', 'default'),
'storageLocation' => $user->getHome(), 'storageLocation' => $user->getHome(),
'lastLogin' => $user->getLastLogin(), 'lastLogin' => $user->getLastLogin(),