Changeset 1120
- Timestamp:
- 05/28/08 10:07:08
- Files:
-
- qPloneComments/branches/plone-3.0/patch.py (modified) (2 diffs)
- qPloneComments/branches/plone-3.0/skins/qplonecomments/approve_comment_template.pt (modified) (1 diff)
- qPloneComments/branches/plone-3.0/skins/qplonecomments/notify_comment_template.pt (modified) (1 diff)
- qPloneComments/branches/plone-3.0/skins/qplonecomments/published_comment_template.pt (modified) (1 diff)
- qPloneComments/branches/plone-3.0/skins/qplonecomments/rejected_comment_template.pt (modified) (1 diff)
- qPloneComments/branches/plone-3.0/skins/qplonecomments/reply_notify_template.pt (modified) (1 diff)
- qPloneComments/branches/plone-3.0/utils.py (modified) (7 diffs)
- qPloneComments/branches/plone-3.0/version.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneComments/branches/plone-3.0/patch.py
r1018 r1120 5 5 from AccessControl import ClassSecurityInfo 6 6 from Globals import InitializeClass 7 import rfc822 8 from StringIO import StringIO 9 from utils import * 7 10 8 from utils import * 11 def _mungeHeaders( messageText, mto=None, mfrom=None, subject=None): 12 """Sets missing message headers, and deletes Bcc. 13 returns fixed message, fixed mto and fixed mfrom""" 14 mfile=StringIO(messageText.lstrip()) 15 mo=rfc822.Message(mfile) 16 17 # Parameters given will *always* override headers in the messageText. 18 # This is so that you can't override or add to subscribers by adding them to 19 # the message text. 20 if subject: 21 mo['Subject'] = subject 22 elif not mo.getheader('Subject'): 23 mo['Subject'] = '[No Subject]' 24 25 if mto: 26 if isinstance(mto, basestring): 27 mto = [rfc822.dump_address_pair(addr) for addr in rfc822.AddressList(mto) ] 28 if not mo.getheader('To'): 29 mo['To'] = ','.join(mto) 30 else: 31 mto = [] 32 for header in ('To', 'Cc', 'Bcc'): 33 v = mo.getheader(header) 34 if v: 35 mto += [rfc822.dump_address_pair(addr) for addr in rfc822.AddressList(v)] 36 if not mto: 37 raise MailHostError, "No message recipients designated" 38 39 if mfrom: 40 mo['From'] = mfrom 41 else: 42 if mo.getheader('From') is None: 43 raise MailHostError,"Message missing SMTP Header 'From'" 44 mfrom = mo['From'] 45 46 if mo.getheader('Bcc'): 47 mo.__delitem__('Bcc') 48 49 if not mo.getheader('Date'): 50 mo['Date'] = DateTime().rfc822() 51 52 mo.rewindbody() 53 finalmessage = mo 54 finalmessage = mo.__str__() + '\n' + mfile.read() 55 mfile.close() 56 return finalmessage, mto, mfrom 9 57 10 58 # Patching createReply method of … … 91 139 DiscussionItemContainer.createReply = createReply 92 140 DiscussionItemContainer.getReplies = getReplies 141 142 """ 143 try: 144 from Products.MailHost import MailHost 145 MailHost._mungeHeaders = _mungeHeaders 146 except ImportError: 147 pass 148 """ qPloneComments/branches/plone-3.0/skins/qplonecomments/approve_comment_template.pt
r1018 r1120 3 3 tal:define="charset here/portal_properties/site_properties/default_charset|string:utf-8; 4 4 dummy python:request.RESPONSE.setHeader('Content-Type', 'text/html;;charset=%s' % charset); 5 organization_name options/organization_name" 6 >To: <tal:x replace="options/mto"/> 7 From: <tal:x replace="options/mfrom"/> 8 Subject: <tal:x condition="organization_name" replace="string:[$organization_name] "/><tal:subject i18n:translate="approvemail_subject">New comment awaits moderation</tal:subject> 5 organization_name options/organization_name"> 9 6 10 <tal:new_comment define="obj nocall:options/obj" 7 <tal:new_comment define="obj nocall:options/obj" 11 8 i18n:translate="approvemail_new_comment_link"> 12 9 Please review new comment added to the following page "<tal:x replace="obj/Title" i18n:name="title"/>": qPloneComments/branches/plone-3.0/skins/qplonecomments/notify_comment_template.pt
r1018 r1120 4 4 dummy python:request.RESPONSE.setHeader('Content-Type', 'text/html;;charset=%s' % charset); 5 5 organization_name options/organization_name; 6 obj nocall:options/obj" 7 >To: <tal:x replace="options/mto"/> 8 From: <tal:x replace="options/mfrom"/> 9 Subject: <tal:subject define="obj nocall:options/obj" 10 i18n:translate="notifycomment_subject">Your comment on '<tal:x replace="obj/Title" i18n:name="title"/>' is now published</tal:subject> 6 obj nocall:options/obj"> 11 7 12 8 <tal:x replace="options/name"/>, qPloneComments/branches/plone-3.0/skins/qplonecomments/published_comment_template.pt
r1018 r1120 4 4 dummy python:request.RESPONSE.setHeader('Content-Type', 'text/html;;charset=%s' % charset); 5 5 organization_name options/organization_name" 6 >To: <tal:x replace="options/mto"/>7 From: <tal:x replace="options/mfrom"/>8 Subject: <tal:x condition="organization_name" replace="string:[$organization_name] "/><tal:subject i18n:translate="publishedmail_subject">New comment added</tal:subject>9 6 10 7 <tal:new_comment define="obj nocall:options/obj" i18n:translate="publishedmail_new_comment_link"> qPloneComments/branches/plone-3.0/skins/qplonecomments/rejected_comment_template.pt
r1018 r1120 4 4 dummy python:request.RESPONSE.setHeader('Content-Type', 'text/html;;charset=%s' % charset); 5 5 organization_name options/organization_name; 6 obj nocall:options/obj" 7 >To: <tal:x replace="options/mto"/> 8 From: <tal:x replace="options/mfrom"/> 9 Subject: <tal:subject define="obj nocall:options/obj" 10 i18n:translate="notifyreject_subject">Your comment on '<tal:x replace="obj/Title" i18n:name="title"/>' was not approved.</tal:subject> 6 obj nocall:options/obj"> 11 7 12 8 <tal:x replace="options/name"/>, qPloneComments/branches/plone-3.0/skins/qplonecomments/reply_notify_template.pt
r1018 r1120 4 4 dummy python:request.RESPONSE.setHeader('Content-Type', 'text/html;;charset=%s' % charset); 5 5 organization_name options/organization_name; 6 obj nocall:options/obj" 7 >To: <tal:x replace="options/mto"/> 8 From: <tal:x replace="options/mfrom"/> 9 Subject: <tal:subject define="obj nocall:options/obj" 10 i18n:translate="replynotify_subject">Someone replied to your comment on '<tal:x replace="obj/Title" i18n:name="title"/>'</tal:subject> 11 6 obj nocall:options/obj"> 12 7 <tal:x replace="options/name"/>, 13 8 <tal:notify define="obj nocall:options/obj" qPloneComments/branches/plone-3.0/utils.py
r1102 r1120 1 1 from Products.CMFCore.utils import getToolByName 2 3 2 # Get apropriate property from (propery_sheeet) configlet 4 3 def getProp(self, prop_name, marker=None): … … 95 94 admin_email = context.portal_url.getPortalObject().getProperty('email_from_address') 96 95 96 subject = '' 97 97 if state == 'enable_approve_user_notification': 98 subject = 'Your comment on %s is now published'%context.Title() 98 99 if user_email: 99 100 template = 'notify_comment_template' … … 107 108 108 109 elif state == 'enable_rejected_user_notification': 110 subject = 'Your comment on %s was not approved.'%context.Title() 109 111 if user_email: 110 112 template = 'rejected_comment_template' … … 119 121 elif state == 'enable_reply_user_notification': 120 122 template = 'reply_notify_template' 123 subject = 'Someone replied to your comment on %s'%context.Title() 121 124 di_parrent = getDIParent(reply) 122 125 if di_parrent: … … 141 144 'obj':reply_parent, 142 145 'organization_name':organization_name} 146 subject = '[%s] New comment added'%organization_name 143 147 else: 144 148 args = {} … … 152 156 'obj':reply_parent, 153 157 'organization_name':organization_name} 158 subject = '[%s] New comment awaits moderation'%organization_name 154 159 else: 155 160 args = {} … … 157 162 if args: 158 163 msg = getMsg(context, template, args) 159 #__import__("pdb").set_trace() 160 context.MailHost.send(str(msg)) 164 p_utils = context.plone_utils 165 site_props = context.portal_properties.site_properties 166 host = p_utils.getMailHost() 167 host.secureSend(msg, user_email, admin_email, 168 subject = subject, 169 subtype = 'plain', 170 debug = False, 171 charset = site_props.getProperty('default_charset', 'utf-8'), 172 From = admin_email) 161 173 162 174 qPloneComments/branches/plone-3.0/version.txt
r1103 r1120 1 3.0. 01 3.0.1
