2dcaf08409b4f5f01636dd42d3d957e1c8f750b0
[Plinn.git] / skins / generic / getGroupsOfRole.py
1 ##parameters=role
2 aclu = context.aq_inner.acl_users
3 prefix = aclu.getGroupPrefix()
4 allGroupNames = aclu.getGroupNames()
5 usersAndGroupsWithLocalRole = context.users_with_local_role(role)
6
7 groupsWithLocalRole = [ gn for gn in usersAndGroupsWithLocalRole if gn.startswith(prefix) ]
8
9 groupsWithoutLocalRole = [ gn for gn in allGroupNames if gn not in groupsWithLocalRole ]
10
11 getGroupById = context.portal_groups.getGroupById
12
13
14 def sortOnTitleOrId(m0, m1) :
15 return cmp(m0.title_or_id().lower(), m1.title_or_id().lower())
16
17 insideList = map(getGroupById, groupsWithLocalRole)
18 outsideList = map(getGroupById, groupsWithoutLocalRole)
19
20 insideList.sort(sortOnTitleOrId)
21 outsideList.sort(sortOnTitleOrId)
22
23 groupsDict = {'inside' : insideList,
24 'outside' : outsideList}
25
26 return groupsDict