Back to index

plone3  3.1.7
folder_localrole_edit.py
Go to the documentation of this file.
00001 ## Script (Python) "folder_localrole_edit"
00002 ##parameters=change_type, member_ids=(), member_role=[]
00003 ##title=Set local roles
00004 ##
00005 
00006 from Products.CMFPlone.utils import transaction_note
00007 from Products.CMFPlone import PloneMessageFactory as _
00008 
00009 pm = context.portal_membership
00010 
00011 if change_type == 'add':
00012     # Keep backward-compatibility
00013     if same_type(member_role, ''):
00014         member_role = [member_role]
00015     for role in member_role:
00016         pm.setLocalRoles( obj=context,
00017                           member_ids=member_ids,
00018                           member_role=role,
00019                           REQUEST=context.REQUEST)
00020 else:
00021     pm.deleteLocalRoles( obj=context,
00022                          member_ids=member_ids,
00023                       REQUEST=context.REQUEST )
00024 
00025 transaction_note('Modified sharing for folder %s at %s' % (context.title_or_id(), context.absolute_url()))
00026 context.plone_utils.addPortalMessage(_(u'Local roles changed.'))
00027 
00028 context.REQUEST.RESPONSE.redirect(context.absolute_url() + '/folder_localrole_form')