f45c4717841cb2ebfe5d2b129b9bec135b2f5bef
[Plinn.git] / skins / generic / getAllMembersInRole.py
1 ##parameters=role
2
3 usersAndGroups = context.users_with_local_role(role)
4 aclu = context.aq_inner.acl_users
5 prefix = aclu.getGroupPrefix()
6 mtool = context.portal_membership
7
8 users = []
9 groups = []
10
11 for uOrG in usersAndGroups :
12 if uOrG.startswith(prefix) :
13 groups.append(uOrG)
14 else :
15 users.append(uOrG)
16
17 gtool = context.portal_groups
18 usersFromGroups = []
19 for group in groups :
20 usersFromGroups.extend(gtool.getUserNamesOfGroup(group, no_recurse = 0))
21
22 allUsersDbl = users
23 allUsersDbl.extend(usersFromGroups)
24 allUsers = []
25 for user in allUsersDbl :
26 if user not in allUsers :
27 allUsers.append(user)
28
29 allMembers = mtool.getMembers(allUsers)
30 return allMembers