Back to index

plone3  3.1.7
prefs_user_group_search.py
Go to the documentation of this file.
00001 ## Script (Python) "prefs_valid_search_restriction.py"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=searchstring, restrict, return_form=None, ignore=[]
00008 ##title=Valid Search Resriction
00009 ##
00010 #MembershipTool.searchForMembers
00011 groups_tool = context.portal_groups
00012 members_tool = context.portal_membership
00013 retlist = []
00014 
00015 if restrict != "groups":
00016     retlist = retlist + members_tool.searchForMembers(REQUEST=None, name=searchstring)
00017 if restrict != "users":
00018     retlist = retlist + groups_tool.searchForGroups(REQUEST=None, title_or_name=searchstring)
00019 
00020 if ignore:
00021   retlist = [r for r in retlist if r not in ignore]
00022 
00023 # reorder retlist?
00024 if return_form:
00025     context.REQUEST.RESPONSE.redirect( context.absolute_url() + '/' + return_form )
00026 return retlist