Back to index

plone3  3.1.7
prefs_user_membership_edit.py
Go to the documentation of this file.
00001 ## Script (Python) "prefs_group_edit"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=userid
00008 ##title=Edit user's group membership
00009 ##
00010 REQUEST=context.REQUEST
00011 RESPONSE=REQUEST.RESPONSE
00012 
00013 delete = REQUEST.get('delete', [])
00014 for groupname in delete:
00015     group = context.portal_groups.getGroupById(groupname)
00016     group.removeMember(userid, REQUEST=context.REQUEST)
00017 
00018 add = REQUEST.get('add', [])
00019 for groupname in add:
00020     group = context.portal_groups.getGroupById(groupname)
00021     group.addMember(userid, REQUEST=context.REQUEST)
00022 
00023 return RESPONSE.redirect('%s?userid=%s' % (container.prefs_user_memberships.absolute_url(),
00024                                            userid)
00025                         )