579a38f0049a1ec1f4162be893244316c1862ebb
1 ##parameters=b_start=0, member_id='', given_name='', name='', member_email='', password='', confirm='', send_password='', add='', ajax=''
3 from Products
.CMFCore
.utils
import getToolByName
4 from Products
.CMFDefault
.permissions
import ManageUsers
5 from Products
.Plinn
.RegistrationTool
import MODE_ANONYMOUS
, MODE_REVIEWED
6 from Products
.Plinn
.utils
import translate
7 def _(message
) : return translate(message
, context
).encode('utf-8')
10 mtool
= getToolByName(script
, 'portal_membership')
11 ptool
= getToolByName(script
, 'portal_properties')
12 rtool
= getToolByName(script
, 'portal_registration')
13 atool
= getToolByName(script
, 'portal_actions')
14 utool
= getToolByName(script
, 'portal_url')
16 validate_email
= ptool
.getProperty('validate_email')
17 is_anon
= mtool
.isAnonymousUser()
19 is_usermanager
= mtool
.checkPermission(ManageUsers
, mtool
)
22 form
= context
.REQUEST
.form
24 context
.validatePassword(**form
) and \
25 context
.members_add_control(**form
) and \
26 context
.setRedirect(atool
, 'user/join', b_start
=b_start
, ajax
=ajax
):
31 if context
.REQUEST
.get('portal_status_message', '') == 'Success!':
35 options
['member_id'] = member_id
36 options
['given_name'] = given_name
37 options
['name'] = name
38 options
['member_email'] = member_email
39 options
['password'] = is_newmember
and context
.REQUEST
.get('password', '') or ''
40 options
['send_password'] = send_password
41 options
['portal_url'] = portal_url
42 options
['isAnon'] = is_anon
43 options
['isAnonOrUserManager'] = is_anon
or is_usermanager
44 options
['isNewMember'] = is_newmember
45 options
['isOrdinaryMember'] = not (is_anon
or is_newmember
or is_usermanager
)
46 options
['validate_email'] = validate_email
47 options
['isAnonRegistration'] = rtool
.getMode() == MODE_ANONYMOUS
48 options
['isReviewedRegistration'] = rtool
.getMode() == MODE_REVIEWED
52 target
= atool
.getActionInfo('user/logged_in')['url']
53 buttons
.append( {'name': 'login', 'value': 'Log in'} )
55 target
= atool
.getActionInfo('user/join')['url']
56 buttons
.append( {'name': 'add', 'value': _('Join')} )
57 options
['form'] = { 'action': target
,
58 'listButtonInfos': tuple(buttons
) }
60 return context
.join_template(**options
)