Avancement sur l’upload par glisser / déposer dans les dossiers. On affiche le fragme...
[Plinn.git] / skins / custom_generic / join_form.py
1 ##parameters=b_start=0, member_id='', given_name='', name='', member_email='', password='', confirm='', send_password='', add='', cancel='', ajax=''
2 ##
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
7 mtool = getToolByName(script, 'portal_membership')
8 ptool = getToolByName(script, 'portal_properties')
9 rtool = getToolByName(script, 'portal_registration')
10 atool = getToolByName(script, 'portal_actions')
11 utool = getToolByName(script, 'portal_url')
12 portal_url = utool()
13 validate_email = ptool.getProperty('validate_email')
14 is_anon = mtool.isAnonymousUser()
15 is_newmember = False
16 is_usermanager = mtool.checkPermission(ManageUsers, mtool)
17
18
19 form = context.REQUEST.form
20 if add and \
21 context.validatePassword(**form) and \
22 context.members_add_control(**form) and \
23 context.setRedirect(atool, 'user/join', b_start=b_start, ajax=ajax):
24 return
25 elif cancel and \
26 context.setRedirect(mtool, 'global/manage_members', b_start=b_start, ajax=ajax):
27 return
28
29
30 options = {}
31
32 if context.REQUEST.get('portal_status_message', '') == 'Success!':
33 is_anon = False
34 is_newmember = True
35
36 options['title'] = is_usermanager and 'Register Member' or 'Become a Member'
37 options['member_id'] = member_id
38 options['given_name'] = given_name
39 options['name'] = name
40 options['member_email'] = member_email
41 options['password'] = is_newmember and context.REQUEST.get('password', '') or ''
42 options['send_password'] = send_password
43 options['portal_url'] = portal_url
44 options['isAnon'] = is_anon
45 options['isAnonOrUserManager'] = is_anon or is_usermanager
46 options['isNewMember'] = is_newmember
47 options['isOrdinaryMember'] = not (is_anon or is_newmember or is_usermanager)
48 options['validate_email'] = validate_email
49 options['isAnonRegistration'] = rtool.getMode() == MODE_ANONYMOUS
50 options['isReviewedRegistration'] = rtool.getMode() == MODE_REVIEWED
51
52 buttons = []
53 if is_newmember:
54 target = atool.getActionInfo('user/logged_in')['url']
55 buttons.append( {'name': 'login', 'value': 'Log in'} )
56 else:
57 target = atool.getActionInfo('user/join')['url']
58 buttons.append( {'name': 'add', 'value': 'Register'} )
59 buttons.append( {'name': 'cancel', 'value': 'Cancel'} )
60 options['form'] = { 'action': target,
61 'listButtonInfos': tuple(buttons) }
62 options['ajax']=ajax
63 return context.join_template(**options)