Changeset 1201 in products for quintagroup.plonecomments/trunk/quintagroup/plonecomments/utils.py
- Timestamp:
- Jul 31, 2009 3:30:02 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonecomments/trunk/quintagroup/plonecomments/utils.py
r1058 r1201 1 import smtplib 1 2 from Products.CMFPlone import MessageFactory 2 3 from Products.CMFCore.utils import getToolByName 4 from Products.CMFPlone import PloneMessageFactory as _ 5 from config import warning 3 6 4 7 # Get apropriate property from (propery_sheeet) configlet … … 38 41 'enable_published_notification'), 39 42 'onDelete' : ('enable_rejected_user_notification',), 40 'onApprove': ('enable_approve_notification',)} 43 'onApprove': ('enable_approve_notification',), 44 'onAnonymousReportAbuse': ('enable_anonymous_report_abuse',), 45 'onAuthenticatedReportAbuse': ('enable_authenticated_report_abuse')} 41 46 42 47 if action == 'publishing': … … 48 53 elif action == 'aproving': 49 54 sendMails(props, actions, 'onApprove') 55 56 elif action == 'report_abuse': 57 pm = getToolByName(context, 'portal_membership') 58 if pm.isAnonymousUser(): 59 sendMails(props, actions, 'onAnonymousReportAbuse') 60 else: 61 sendMails(props, actions, 'onAuthenticatedReportAbuse') 50 62 51 63 def getMsg(context, template, args): … … 163 175 args = {} 164 176 177 elif state in ('enable_authenticated_report_abuse', 'enable_anonymous_report_abuse'): 178 template = 'report_abuse_template' 179 user_email = getProp(context, "email_discussion_manager", None) 180 if user_email: 181 message = context.REQUEST.get('message') 182 comment_id = context.REQUEST.get('comment_id') 183 pd = context.portal_discussion 184 dl = pd.getDiscussionFor(context) 185 comment = dl._container.get(comment_id) 186 args = {'mto': user_email, 187 'mfrom': admin_email, 188 'obj': reply_parent, 189 'message':message, 190 'organization_name': organization_name, 191 'name': creator_name, 192 'comment_id':comment_id, 193 'comment_desc':comment.description, 194 'comment_text':comment.text 195 } 196 subject = '[%s] A comment on "%s" has been reported for abuse.' \ 197 % (organization_name, getParent(context).Title()) 198 else: 199 args = {} 200 165 201 if args: 166 202 msg = getMsg(context, template, args) … … 168 204 site_props = context.portal_properties.site_properties 169 205 host = p_utils.getMailHost() 170 host.secureSend(msg, user_email, admin_email, 171 subject = subject, 172 subtype = 'plain', 173 debug = False, 174 charset = site_props.getProperty('default_charset', 'utf-8'), 175 From = admin_email) 206 try: 207 host.secureSend(msg, user_email, admin_email, 208 subject = subject, 209 subtype = 'plain', 210 debug = False, 211 charset = site_props.getProperty('default_charset', 'utf-8'), 212 From = admin_email) 213 except smtplib.SMTPRecipientsRefused: 214 log.error(_('SMTPRecipientsRefused: Could not send the email' 215 'notification. Have you configured an email server for Plone?')) 176 216 177 217 def setStatusMsg(state, context, msg):
Note: See TracChangeset
for help on using the changeset viewer.