11778d682b7e3528aab231daf1c9fa86460f4ad8
1 ##parameters=rtool, request, member=None, password=''
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
9 portal
= context
.portal_url
.getPortalObject()
10 mtool
= portal
.portal_membership
13 def convertMessage(msg
) :
14 return msg
.replace('${', '%(').replace('}', ')s')
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
)
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
)
28 mto
= encodeAdr(member
)
30 subject
= convertMessage(_("${portal_title}: Membership reminder")()) % {'portal_title': portal
.title
}
35 pr(convertMessage(_("Your member id and password are: Member ID: ${member_id} Password: ${password}")()) % {'member_id':member
.getId(), 'password':password
})
37 pr(_("You can use this URL to log in:")())
40 login_url
= mtool
.getActionInfo('user/login')['url']
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.")())
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
})
52 text
= '\n'.join(text
)
54 message
= context
.echange_mail_template( From
= sender
56 , Subject
= "=?utf-8?q?%s?=" % encodestring(subject
).replace('=\n', '')
57 , ContentType
= 'text/plain'
61 return message
.encode('utf-8')