X-Git-Url: https://scm.cri.ensmp.fr/git/Plinn.git/blobdiff_plain/3c4367d8e03450e9a73e61f4247145d2b6c86a33..959d888c17d1403d2eeecc19bc4b5e2c8d1debf6:/Products/Plinn/skins/generic/getGroupsOfRole.py diff --git a/Products/Plinn/skins/generic/getGroupsOfRole.py b/Products/Plinn/skins/generic/getGroupsOfRole.py new file mode 100755 index 0000000..2dcaf08 --- /dev/null +++ b/Products/Plinn/skins/generic/getGroupsOfRole.py @@ -0,0 +1,26 @@ +##parameters=role +aclu = context.aq_inner.acl_users +prefix = aclu.getGroupPrefix() +allGroupNames = aclu.getGroupNames() +usersAndGroupsWithLocalRole = context.users_with_local_role(role) + +groupsWithLocalRole = [ gn for gn in usersAndGroupsWithLocalRole if gn.startswith(prefix) ] + +groupsWithoutLocalRole = [ gn for gn in allGroupNames if gn not in groupsWithLocalRole ] + +getGroupById = context.portal_groups.getGroupById + + +def sortOnTitleOrId(m0, m1) : + return cmp(m0.title_or_id().lower(), m1.title_or_id().lower()) + +insideList = map(getGroupById, groupsWithLocalRole) +outsideList = map(getGroupById, groupsWithoutLocalRole) + +insideList.sort(sortOnTitleOrId) +outsideList.sort(sortOnTitleOrId) + +groupsDict = {'inside' : insideList, + 'outside' : outsideList} + +return groupsDict \ No newline at end of file