Masquage du diaporama html standard.
[Plinn.git] / profiles / default / workflows / member_workflow / scripts / sendNotificationEmail.py
1 ## Script (Python) "sendNotificationEmail"
2 ##bind container=container
3 ##bind context=context
4 ##bind namespace=
5 ##bind script=script
6 ##bind subpath=traverse_subpath
7 ##parameters=sci
8 ##title=
9 ##
10 #TODO : translate messages
11 #from Products.PlacelessTranslationService.MessageID import MessageIDFactory
12 #_ = MessageIDFactory('plinn')
13 #cmfMessages = MessageIDFactory('cmf_default')
14 _ = cmfMessages = lambda x : lambda : x
15 from quopri import encodestring
16
17 portal = context.portal_url.getPortalObject()
18 mtool = portal.portal_membership
19 rtool = portal.portal_registration
20 MailHost = portal.MailHost
21
22
23 def encodeAdr(member) :
24 name = member.getMemberFullName(nameBefore=0)
25 email = member.getProperty('email')
26 qpName = encodestring(name).replace('=\n', '')
27 return '''"=?utf-8?q?%s?=" <%s>''' % (qpName, email)
28
29 member = sci.object
30
31 sender = mtool.getAuthenticatedMember()
32 sender = encodeAdr(sender)
33 mto = encodeAdr(member)
34
35 text = _( """
36 You have been registered as a member of "%(portal_title)s", which
37 allows you to personalize your view of the website and participate in
38 the community.
39 """.strip().replace('\n', ' ') )() % {'portal_title' :portal.Title()}
40
41 if portal.getProperty('validate_email') :
42 text += '\n'
43 text += _( """You will receive an other mail with your randomly-generated
44 password. Once you have logged in with this password, you
45 may change it to anything you like.""".strip().replace('\n', ' ') )()
46
47 else :
48 text += '\n'*2
49 text += cmfMessages( "You can use this URL to log in:" )()
50 text += '\n' + portal.absolute_url() + '/login_form'
51
52 message = context.echange_mail_template( From = sender
53 , To = mto
54 , Subject = "=?utf-8?q?%s?=" % encodestring(portal.Title() + " : " + \
55 _("your registration has been accepted")()).replace('=\n', '')
56 , ContentType = 'text/plain'
57 , charset = 'UTF-8'
58 , body= text
59 )
60
61
62 MailHost.send( message )
63 if portal.getProperty('validate_email') :
64 rtool.mailPassword(member.getId(), context.REQUEST)