## Script (Python) "get_searchable_student_states"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=key=None
##title=
##
# $Id: get_searchable_student_states.py 3903 2009-02-03 08:19:08Z henrik $
"""
return the searchable student_states depending on context
"""
wftool = context.portal_workflow
mtool = context.portal_membership
member = mtool.getAuthenticatedMember()
roles = member.getRolesInContext(context)
voc = context.portal_vocabularies.searchable_student_states
if key is not None:
    return voc.get(key)
voc_filtered = [('all', 'all states')] 
if "ClearanceOfficers" in member.getGroups():
    voc_filtered += [item for item in voc.items() if item[0].startswith('clear')]
if "CourseAdvisers" in member.getGroups():
    voc_filtered += [item for item in voc.items() if item[0].startswith('courses')]

if len(voc_filtered) > 1:
    return voc_filtered
else:
    return voc.items()


