From 60ed441033ede7eb720036dd23d7eefdf6f25939 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Sun, 14 Jun 2009 17:34:30 +0000 Subject: [PATCH] set the username oder creator when a reply is added to a comment. svn path=/plone.app.discussion/trunk/; revision=27447 --- plone/app/discussion/browser/comments.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index a3a04d9..399cdeb 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -185,8 +185,11 @@ class ReplyToComment(BrowserView): if self.request.has_key('form.button.AddComment'): reply_to_comment_id = self.request.get('form.reply_to_comment_id') + subject = self.request.get('subject') text = self.request.get('body_text') + author_username = self.request.get('author_username') + author_email = self.request.get('author_email') # The add-comment view is called on the conversation object conversation = self.context @@ -201,6 +204,25 @@ class ReplyToComment(BrowserView): comment.title = subject comment.text = text + portal_membership = getToolByName(self.context, 'portal_membership') + + if portal_membership.isAnonymousUser(): + comment.creator = author_username + comment.author_name = author_username + comment.author_email = author_email + comment.creation_date = comment.modification_date = datetime.now() + else: + member = portal_membership.getAuthenticatedMember() + fullname = member.getProperty('fullname') + if fullname == '' or None: + comment.creator = member.id + else: + comment.creator = fullname + comment.author_username = member.getUserName() + comment.author_name = member.getProperty('fullname') + comment.author_email = member.getProperty('email') + comment.creation_date = comment.modification_date = datetime.now() + # Add the reply to the comment new_re_id = replies.addComment(comment)