0e07d03153d80b0da2508029c4efb0159c311175
1 ##parameters=member_id='', given_name='', name='', member_email='', email_as_login='', password='', confirm='', 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
26 password
= confirm
= rtool
.generatePassword()
28 ok
= context
.validatePassword(**form
)
31 member_id
= member_email
32 rtool
.addMember(id=member_id
, password
=password
,
33 properties
={'username': member_id
,
34 'given_name' : given_name
,
36 'email': member_email
})
37 context
.setStatus(True, _('Success!'))
38 except ValueError, errmsg
:
39 context
.setStatus(False, errmsg
)
44 # context.validatePassword(**form) and \
45 # context.members_add_control(**form) and \
46 # context.setRedirect(atool, 'user/join', b_start=b_start, ajax=ajax):
51 if context
.REQUEST
.get('portal_status_message', '') == 'Success!':
55 options
['member_id'] = member_id
56 options
['given_name'] = given_name
57 options
['name'] = name
58 options
['member_email'] = member_email
59 options
['password'] = is_newmember
and context
.REQUEST
.get('password', '') or ''
60 options
['portal_url'] = portal_url
61 options
['isAnon'] = is_anon
62 options
['isNewMember'] = is_newmember
63 options
['validate_email'] = validate_email
64 options
['isAnonRegistration'] = rtool
.getMode() == MODE_ANONYMOUS
65 options
['isReviewedRegistration'] = rtool
.getMode() == MODE_REVIEWED
69 target
= atool
.getActionInfo('user/logged_in')['url']
70 buttons
.append( {'name': 'login', 'value': 'Log in'} )
72 target
= atool
.getActionInfo('user/join')['url']
73 buttons
.append( {'name': 'add', 'value': _('Join')} )
74 options
['form'] = { 'action': target
,
75 'listButtonInfos': tuple(buttons
) }
77 return context
.join_template(**options
)