Activation de l’upload par glisser / déposer que si permission d’ajouter.
[Plinn.git] / skins / custom_generic / mail_password_template.py
1 ##parameters=rtool, request, member=None, password=''
2
3 #TODO : translate messages
4 #from Products.PlacelessTranslationService.MessageID import MessageIDFactory
5 #_ = MessageIDFactory('cmf_default')
6 _ = lambda x : lambda : x
7 from quopri import encodestring
8
9 portal = context.portal_url.getPortalObject()
10 mtool = portal.portal_membership
11
12
13 def convertMessage(msg) :
14 return msg.replace('${', '%(').replace('}', ')s')
15
16 def encodeAdr(member) :
17 name = member.getMemberFullName(nameBefore=0)
18 email = member.getProperty('email')
19 qpName = encodestring(name).replace('=\n', '')
20 return '''"=?utf-8?q?%s?=" <%s>''' % (qpName, email)
21
22 mfromName = portal.email_from_name
23 mfromEmail = portal.email_from_address
24 mfromQpName = encodestring(mfromName).replace('=\n', '')
25 mfrom = '''"=?utf-8?q?%s?=" <%s>''' % (mfromQpName, mfromEmail)
26
27 sender = mfrom
28 mto = encodeAdr(member)
29
30 subject = convertMessage(_("${portal_title}: Membership reminder")()) % {'portal_title': portal.title}
31
32 text = []
33 pr = text.append
34
35 pr(convertMessage(_("Your member id and password are: Member ID: ${member_id} Password: ${password}")()) % {'member_id':member.getId(), 'password':password})
36 pr('')
37 pr(_("You can use this URL to log in:")())
38 pr('')
39
40 login_url = mtool.getActionInfo('user/login')['url']
41 pr(login_url)
42 pr('')
43
44 if len(login_url) > 70 :
45 pr(_("Be aware that this URL might wrap over two lines. If your browser shows an error message when you try to access the URL please make sure that you put in the complete string.")())
46
47
48 time = context.ZopeTime().strftime(_("%Y/%m/%d at %I:%M:%S %p")())
49 ip = request.HTTP_X_FORWARDED_FOR or request.REMOTE_ADDR
50 pr(convertMessage(_("Request made by IP ${ip} at ${time}")()) % {'ip':ip, 'time':time})
51
52 text = '\n'.join(text)
53
54 message = context.echange_mail_template( From = sender
55 , To = mto
56 , Subject = "=?utf-8?q?%s?=" % encodestring(subject).replace('=\n', '')
57 , ContentType = 'text/plain'
58 , charset = 'UTF-8'
59 , body= text
60 )
61 return message.encode('utf-8')