Merge "Add config setting to only suggest users which are in a visible group" into stable

This commit is contained in:
Shawn Pearce 2011-05-20 07:46:45 -07:00 committed by Android Code Review
commit e647a81b1d
3 changed files with 20 additions and 0 deletions

View File

@ -1779,6 +1779,9 @@ or a user to a group.
If `SAME_GROUP`, only users who are also members of a group the
current user is a member of will be offered.
+
If `VISIBLE_GROUP`, only users who are members of at least one group
that is visible to the current user will be offered.
+
If `OFF`, no account suggestions are given.
+
Default is `ALL`.

View File

@ -17,5 +17,6 @@ package com.google.gerrit.httpd.rpc;
public enum SuggestAccountsEnum {
ALL,
SAME_GROUP,
VISIBLE_GROUP,
OFF;
}

View File

@ -165,6 +165,22 @@ class SuggestServiceImpl extends BaseServiceImplementation implements
}
break;
}
case VISIBLE_GROUP: {
Set<AccountGroup.Id> usersGroups = groupsOf(account);
usersGroups.removeAll(authConfig.getRegisteredGroups());
usersGroups.remove(authConfig.getBatchUsersGroup());
for (AccountGroup.Id usersGroup : usersGroups) {
try {
if (groupControlFactory.controlFor(usersGroup).isVisible()) {
map.put(account.getId(), info);
break;
}
} catch (NoSuchGroupException e) {
continue;
}
}
break;
}
case OFF:
break;
default: