clarification
[Plinn.git] / skins / custom_control / members_add_control.py
1 ##parameters=member_id, given_name, name, password, member_email, send_password=False, **kw
2 ##title=Add a member
3 ##
4 from Products.CMFCore.utils import getToolByName
5 from Products.CMFDefault.permissions import ManageUsers
6 from Products.Plinn.RegistrationTool import MODE_REVIEWED
7
8 mtool = getToolByName(script, 'portal_membership')
9 ptool = getToolByName(script, 'portal_properties')
10 rtool = getToolByName(script, 'portal_registration')
11
12 try:
13 rtool.addMember( id=member_id, password=password,
14 properties={'username': member_id,
15 'given_name' : given_name,
16 'name' : name,
17 'email': member_email} )
18 except ValueError, errmsg:
19 return context.setStatus(False, errmsg)
20 else:
21 if send_password or (ptool.getProperty('validate_email') and rtool.getMode() != MODE_REVIEWED):
22 rtool.registeredNotify(member_id)
23 if mtool.checkPermission(ManageUsers, mtool):
24 return context.setStatus(True, 'Member registered.')
25 else:
26 return context.setStatus(True, 'Success!')