Hi Guillaume, I also needed this behaviour, and what I did was to write it in an overloaded version of getAllGroupsNamesforMember, with 2 extra parameters (that allowed to control whether it should look it up recursive and whether to stop on local wiki or go global), and which was copying the behaviour of the old rights service, it was even using the same groups cache that the rights service was using. I planned to contribute this function as part of the API, but I didn't get the time and I would say now it's obsolete as the authorization module has changed. I think a function that gives the list is more interesting than a function that only says if the user is a member or not, you can easily compute the latter from the former but not the other way around. So I would be for 2/ but with a different function, getAllGroupsNamesForMember() with 3 parameters. Have fun, Anca On 06/27/2013 08:23 AM, Guillaume "Louis-Marie" Delhumeau wrote:
Hi devs !
In order to fix http://jira.xwiki.org/browse/XWIKI-2900, I have some proposals to you.
The problem is : the Inclusion of groups in groups aren't taken into account when querying user memberships.
Let suppose we have the following use case: User 1 inside the Goup A Group A inside the Group B
The actual behaviour of XwikiGroupService# getAllGroupsNamesForMember() when calling it with "User 1" as input, is to return "Group A" only. Because, only "Group A" has actually a member called "User 1".
We might want to keep this behaviour, because we may need to have only the declared members of that group.
But we can modify this method to also returns the members of the subgroups, by changing XwikiGroupService#getAllGroupsNamesForMember(), which returns the groups of a member.
Other solution, adding a new method: boolean isMemberInGroup(DocumentReference memberReference, DocumentReference groupReference)
which only check if the user (or the group) given on the input is a member of the group or not.
But it's an API breakage.
So my proposal is: 1/ Changing the behaviour of XWikiGroupService#getAllGroupsNamesForMember(), XWikiGroupService#getAllGroupsReferencesForMember(), XWikiGroupService#getAllMembersNamesForGroup(), XWikiGroupService#getAllMatchedMembersNamesForGroup(), XWikiGroupService#countAllGroupsNamesForMember() and XWikiGroupService#countAllMembersNamesForGroup()
or
2/ Adding isMemberInGroup(DocumentReference memberReference, DocumentReference groupReference, XWikiContext context) in XWikiGroupService, which is an API breakage, and my Pull Request : https://github.com/xwiki/xwiki-platform/pull/117/
or
3/ Only change XWikiUser#isUserInGroup() and do the recursive stuff there.
Thanks for your help!
Louis-Marie _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs