Déplacement pour eggification.
[Plinn.git] / 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 (executable)
index 0000000..2dcaf08
--- /dev/null
@@ -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