Back to index

plone3  3.1.7
members_manage_form.py
Go to the documentation of this file.
00001 ##parameters=b_start=0, ids=(), members_new='', members_delete=''
00002 ##
00003 from ZTUtils import Batch
00004 from Products.CMFCore.utils import getToolByName
00005 from Products.CMFDefault.utils import decode
00006 from Products.CMFDefault.utils import html_marshal
00007 from Products.CMFDefault.utils import Message as _
00008 
00009 atool = getToolByName(script, 'portal_actions')
00010 mtool = getToolByName(script, 'portal_membership')
00011 
00012 
00013 form = context.REQUEST.form
00014 if members_delete and \
00015         context.validateMemberIds(**form) and \
00016         context.setRedirect(atool, 'global/members_delete', b_start=b_start,
00017                             ids=ids):
00018     return
00019 elif members_new and \
00020         context.setRedirect(atool, 'user/join', b_start=b_start):
00021     return
00022 
00023 
00024 options = {}
00025 
00026 target = atool.getActionInfo('global/manage_members')['url']
00027 
00028 members = mtool.listMembers()
00029 batch_obj = Batch(members, 25, b_start, orphan=0)
00030 items = []
00031 for member in batch_obj:
00032     member_id = member.getId()
00033     login_time = member.getProperty('login_time')
00034     member_login = login_time == '2000/01/01' and '---' or login_time.Date()
00035     member_home = mtool.getHomeUrl(member_id, verifyPermission=0)
00036     items.append( {'checkbox': 'cb_%s' % member_id,
00037                    'email': member.getProperty('email'),
00038                    'login': member_login,
00039                    'id': member_id,
00040                    'home': member_home } )
00041 navigation = context.getBatchNavigation(batch_obj, target,
00042                                         'member', 'members')
00043 options['batch'] = { 'listItemInfos': tuple(items),
00044                      'navigation': navigation }
00045 
00046 hidden_vars = []
00047 for name, value in html_marshal(b_start=b_start):
00048     hidden_vars.append( {'name': name, 'value': value} )
00049 buttons = []
00050 buttons.append( {'name': 'members_new', 'value': _(u'New...')} )
00051 if items:
00052     buttons.append( {'name': 'members_delete', 'value': _(u'Delete...')} )
00053 options['form'] = { 'action': target,
00054                     'listHiddenVarInfos': tuple(hidden_vars),
00055                     'listButtonInfos': tuple(buttons) }
00056 
00057 return context.members_manage_template(**decode(options, script))