Index: /qPloneComments/trunk/HISTORY.txt
===================================================================
--- /qPloneComments/trunk/HISTORY.txt	(revision 1220)
+++ /qPloneComments/trunk/HISTORY.txt	(revision 1221)
@@ -5,5 +5,9 @@
 ------------------
 
-- Nothing changed yet.
+- Move add comment form in comments viewlet
+  [mylan]
+
+- Added edit comment functionality
+  [mylan]
 
 
Index: /qPloneComments/trunk/browser/comments.pt
===================================================================
--- /qPloneComments/trunk/browser/comments.pt	(revision 1220)
+++ /qPloneComments/trunk/browser/comments.pt	(revision 1221)
@@ -8,30 +8,11 @@
                    isAjaxReportAbuseEnabled view/ajax_report_abuse_enabled;
                    isAnonymousReportAbuseEnabled view/anonymous_report_abuse_enabled;
-                   isReportAbuseEnabled python:isAnonymousReportAbuseEnabled or not isAnon and isAuthenticatedReportAbuseEnabled"
+                   isReportAbuseEnabled python:isAnonymousReportAbuseEnabled or not isAnon and isAuthenticatedReportAbuseEnabled;
+                   foo context/@@plone/globalize;
+                   props_sheet here/portal_properties/qPloneComments;
+                   require_email python:props_sheet.getProperty('require_email');"
                    i18n:domain="plone">
     <div class="discussion"
          tal:condition="python:replies or (userHasReplyPermission and isDiscussionAllowed) or (isAnon and not userHasReplyPermission and isDiscussionAllowed)">
-        <form name="reply"
-              action=""
-              method="post"
-              tal:condition="python:userHasReplyPermission and isDiscussionAllowed"
-              tal:attributes="action string:${context/absolute_url}/discussion_reply_form#discussion">
-
-              <input class="standalone"
-                     style="margin-bottom: 1.25em;"
-                     type="submit"
-                     value="Add Comment"
-                     i18n:attributes="value label_add_comment;"
-                     />
-        </form>
-        <form tal:condition="python:isAnon and not userHasReplyPermission and isDiscussionAllowed"
-              tal:attributes="action view/login_action">
-            <input class="standalone"
-                   style="margin-bottom: 1.25em;"
-                   type="submit"
-                   value="Log in to add comments"
-                   i18n:attributes="value label_login_to_add_comments;"
-                   />
-        </form>
 
         <tal:getreplies repeat="reply_dict replies">
@@ -83,4 +64,16 @@
                            />
                 </form>
+		<form name="edit"
+		      action="discussion_edit_form"
+		      method="post"
+		      style="display: inline;"
+		      tal:attributes="action string:${reply/absolute_url}/discussion_edit_form"
+                      tal:condition="isModerationAllowed">
+		    <input class="standalone"
+			   type="submit"
+			   value="Edit"
+			   i18n:attributes="value label_edit;"
+			   />
+		</form>
                 <form name="delete"
                       action=""
@@ -135,6 +128,24 @@
                      i18n:domain="plonecomments"
                      tal:condition="not:isPublished">Comment must be approved before replies to comment accepted.</div>
+
             </div>
         </tal:getreplies>
+
+        <!-- Start of Adding comment form-->
+        <tal:addcomment define="template_id string:discussion_reply_form;">
+            <metal:block metal:use-macro="here/discussion_reply_form/macros/add-comment-form" />
+        </tal:addcomment>
+        <!-- End of Adding comment form -->
+
+        <form tal:condition="python:isAnon and not userHasReplyPermission and isDiscussionAllowed"
+              tal:attributes="action view/login_action">
+            <input class="standalone"
+                   style="margin-bottom: 1.25em;"
+                   type="submit"
+                   value="Log in to add comments"
+                   i18n:attributes="value label_login_to_add_comments;"
+                   />
+        </form>
+
     </div>
 </tal:block>
Index: /qPloneComments/trunk/skins/qplonecomments/discussion_edit.cpy
===================================================================
--- /qPloneComments/trunk/skins/qplonecomments/discussion_edit.cpy	(revision 1221)
+++ /qPloneComments/trunk/skins/qplonecomments/discussion_edit.cpy	(revision 1221)
@@ -0,0 +1,50 @@
+## Script (Python) "discussion_edit"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=subject,body_text
+##title=Delete discussion item
+##
+
+from Products.PythonScripts.standard import url_quote_plus
+from Products.CMFCore.utils import getToolByName
+from Products.CMFPlone import PloneMessageFactory as _
+dtool = getToolByName(context, 'portal_discussion')
+req = context.REQUEST
+
+tb = dtool.getDiscussionFor(context)
+id = context.getId()
+reply = tb.getReply(id)
+
+modif_date = reply.modification_date
+
+# Set Title
+reply.setTitle(subject)
+
+# Update text
+reply.edit(text_format=reply.Format(), text=body_text)
+
+# TODO THIS NEEDS TO GO AWAY!
+if hasattr(dtool.aq_explicit, 'cookReply'):
+    dtool.cookReply(reply, text_format='plain')
+
+# Set modification date to old value
+reply.setModificationDate(modification_date=modif_date)
+
+parent = tb.aq_parent
+
+# return to the discussable object.
+redirect_target = context.plone_utils.getDiscussionThread(tb)[0]
+view = redirect_target.getTypeInfo().getActionInfo('object/view',
+                                                   redirect_target)['url']
+anchor = reply.getId()
+
+from Products.CMFPlone.utils import transaction_note
+transaction_note('Added comment to %s at %s' % (parent.title_or_id(),
+                                                reply.absolute_url()))
+
+context.plone_utils.addPortalMessage(_(u'Comment updated.'))
+target = '%s#%s' % (view, anchor)
+return req.RESPONSE.redirect(target)
Index: /qPloneComments/trunk/skins/qplonecomments/discussion_edit_form.cpt
===================================================================
--- /qPloneComments/trunk/skins/qplonecomments/discussion_edit_form.cpt	(revision 1221)
+++ /qPloneComments/trunk/skins/qplonecomments/discussion_edit_form.cpt	(revision 1221)
@@ -0,0 +1,156 @@
+<html xmlns:tal="http://xml.zope.org/namespaces/tal"
+      xmlns:metal="http://xml.zope.org/namespaces/metal"
+      metal:use-macro="here/main_template/macros/master"
+      i18n:domain="plone">
+<body>
+
+<metal:block fill-slot="top_slot"
+             tal:define="dummy python:request.set('disable_border',1)" />
+
+<metal:block fill-slot="sub" />
+
+<div metal:fill-slot="main"
+     tal:define="errors options/state/getErrors;
+                 thread python:putils.getDiscussionThread(here);
+                 discussable python:thread[0];
+                 replies python:thread[1:]">
+
+
+    <form name="edit_form"
+          method="post"
+          action="talkback"
+          tal:attributes="action string:$here_url/$template_id">
+
+        <fieldset>
+
+            <legend i18n:translate="legend_edit_comment">Edit comment</legend>
+            <p i18n:translate="description_edit_comment">
+                You can edit a comment by filling out the form below. Plain text
+                formatting.
+            </p>
+
+            <input type="hidden" name="Creator" value=""
+                   tal:attributes="value member/getUserName" />
+
+            <div class="portalMessage"
+                 tal:condition="isAnon">
+
+                <tal:block replace="structure here/info.gif"/>
+
+                <p i18n:translate="legend_note_reply_anonymous">
+                    Note: you are not logged in. You may optionally enter your
+                    username and password below. If you don't enter your
+                    username and password below, this comment will be posted as
+                    the 'Anonymous User'.
+                </p>
+
+                <div class="field">
+
+                    <label for="username" i18n:translate="label_name">Name</label>
+
+                    <input name="username"
+                           id="username"
+                           value="" alt="Username" title="Name"
+                           size="40"
+                           tabindex=""
+                           i18n:attributes="title label_name; alt label_username;"
+                           tal:attributes="tabindex tabindex/next;" />
+
+                </div>
+
+                <div class="field">
+
+                    <label for="password" i18n:translate="label_password">Password</label>
+
+                    <input type="password"
+                           id="password"
+                           name="password"
+                           tabindex=""
+                           value="" alt="Password" title="Password"
+                           size="40"
+                           i18n:attributes="title label_password; alt label_password;"
+                           tal:attributes="tabindex tabindex/next;" />
+
+                </div>
+
+            </div>
+
+
+        <div class="field"
+        tal:define="error errors/subject|nothing;"
+        tal:attributes="class python:test(error, 'field error', 'field')">
+
+                <label for="subject" i18n:translate="label_subject">Subject</label>
+
+        <span class="fieldRequired" title="Required"
+              i18n:attributes="title title_required;"
+              i18n:translate="label_required">(Required)</span>
+
+            <div tal:content="error">Validation error output</div>
+
+                <input name="subject"
+                       id="subject"
+                       value=""
+                       size="40"
+                       tabindex=""
+                       tal:attributes="value context/title|request/subject|request/title_override|nothing;
+                                       tabindex tabindex/next" />
+
+            </div>
+
+        <div class="field"
+        tal:define="error errors/body_text|nothing;"
+        tal:attributes="class python:test(error, 'field error', 'field')">
+
+          <label for="body_text" i18n:translate="label_comment">Comment</label>
+
+        <span class="fieldRequired" title="Required"
+              i18n:attributes="title title_required;"
+              i18n:translate="label_required">(Required)</span>
+
+            <div tal:content="error">Validation error output</div>
+
+                <textarea name="body_text"
+                          id="body_text"
+                          cols="40"
+                          rows="20"
+                          tabindex=""
+                          tal:content="context/text|request/body_text|request/text_override | nothing"
+                          tal:attributes="tabindex tabindex/next"
+                        ></textarea>
+
+            </div>
+
+             <div tal:condition="nocall:here/captcha_widget|nothing"
+                  tal:omit-tag="">
+                <div metal:use-macro="here/captcha_widget/macros/captcha" />
+             </div>
+	     
+            <div class="formControls">
+
+                <input class="context"
+                       tabindex=""
+                       type="submit"
+                       value="Save"
+                       name="form.button.Save"
+                       i18n:attributes="value label_save;"
+                       tal:attributes="tabindex tabindex/next;" />
+                <input class="standalone"
+                       tabindex=""
+                       type="submit"
+                       value="Cancel"
+                       name="form.button.Cancel"
+                       i18n:attributes="value label_cancel;"
+                       tal:attributes="tabindex tabindex/next;" />
+
+            </div>
+          <input type="hidden" name="form.submitted" value="1" />
+
+        </fieldset>
+
+    </form>
+
+</div>
+
+</body>
+</html>
Index: /qPloneComments/trunk/skins/qplonecomments/discussion_edit_form.cpt.metadata
===================================================================
--- /qPloneComments/trunk/skins/qplonecomments/discussion_edit_form.cpt.metadata	(revision 1221)
+++ /qPloneComments/trunk/skins/qplonecomments/discussion_edit_form.cpt.metadata	(revision 1221)
@@ -0,0 +1,14 @@
+[default]
+title=Discussioin edit form
+
+[security]
+View=1:Manager
+
+[validators]
+validators=validate_talkback
+validators..Cancel=
+
+[actions]
+action.success=redirect_to:string:view
+action.success..Save=traverse_to:string:discussion_edit
+action.failure=traverse_to:string:discussion_edit_form
Index: /qPloneComments/trunk/skins/qplonecomments/discussion_reply_form.cpt
===================================================================
--- /qPloneComments/trunk/skins/qplonecomments/discussion_reply_form.cpt	(revision 1220)
+++ /qPloneComments/trunk/skins/qplonecomments/discussion_reply_form.cpt	(revision 1221)
@@ -62,4 +62,6 @@
     <a name="discussion"></a>
 
+    <metal:block metal:define-macro="add-comment-form">
+
     <form name="edit_form"
           class="enableAutoFocus"
@@ -254,4 +256,6 @@
     </form>
 
+    </metal:block>
+
 </div>
 
