[MKDoc-commit] [1.6] Comment plugin posting sends an email to the superuser

bruno at mkdoc.demon.co.uk bruno at mkdoc.demon.co.uk
Wed Aug 24 15:52:47 BST 2005


Log Message:
-----------
[1.6] Comment plugin posting sends an email to the superuser

Tags:
----
mkdoc-1-6

Modified Files:
--------------
    mkd/flo/plugin:
        Comment.pm

Added Files:
-----------
    mkd/templates/comment/email:
        en.xml

-------------- next part --------------
Index: Comment.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/plugin/Attic/Comment.pm,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -Lflo/plugin/Comment.pm -Lflo/plugin/Comment.pm -u -r1.1.2.1 -r1.1.2.2
--- flo/plugin/Comment.pm
+++ flo/plugin/Comment.pm
@@ -25,6 +25,7 @@
 use flo::Standard;
 use flo::Plugin;
 use flo::editor::Comment;
+use Petal::Mail;
 use strict;
 use warnings;
 use 5.008_000;
@@ -81,6 +82,8 @@
     my $cgi   = $self->cgi();
 
     $self->_update_document_from_cgi();
+    $self->{comment} = $self->cgi->param ('comment');
+    $self->_send_mail();
 
     print $cgi->redirect ($self->parent->uri);
     return 'TERMINATE';
@@ -123,6 +126,26 @@
     return $self;
 }
 
+
+sub _send_mail
+{
+    my $self   = shift;
+    
+    my $xml_mail = eval {
+        my $mail = new Petal::Mail (
+            file     => '/comment/email',
+            language => $self->language(),
+        );
+
+	$mail->send (
+	    self       => $self,
+	    object     => $self->parent(),
+	    __input__  => 'XML',
+	    __output__ => 'XML',
+	);
+    };
+}
+
 1;
 
 __END__
--- /dev/null
+++ templates/comment/email/en.xml
@@ -0,0 +1,31 @@
+<Message
+  xmlns="http://www.openhealth.org/xmtp#"
+  petal:define="user_domain config: USER_DOMAIN;
+                root_user user_root:">
+
+  <Content-Type>text/plain; charset=utf-8; format=flowed</Content-Type>
+  <Content-Disposition>inline</Content-Disposition>
+  <Content-Transfer-Encoding>8bit</Content-Transfer-Encoding>
+  <Content-Language>en</Content-Language>
+  <MIME-Version>1.0</MIME-Version>
+
+  <From petal:content="string:${root_user/real_name} &lt;${root_user/email}&gt;">MKDoc &lt;info at mkdoc.com&gt;</From>
+  <To petal:content="string:${root_user/real_name} &lt;${root_user/email}&gt;">MKDoc &lt;info at mkdoc.com&gt;</To>
+  <Subject petal:content="string: ${object/root/title} : ${object/title} - comment added by ${self/user/real_name}">MKDoc : Feedback - comment added by Fred Flintstone</Subject>
+  <User-Agent>MKDoc Mailer v1.6</User-Agent>
+  <Organization petal:content="object/root/title">MKDoc</Organization>
+ 
+  <body xmlns="http://www.w3.org/1999/xhtml">
+<p>
+  <span petal:replace="self/user/real_name">Fred Flintstone</span> &lt;<span petal:replace="self/user/email">fred at example.com</span>&gt; has posted this comment to <span petal:replace="object/uri">http://www.example.com/feedback/</span>:
+</p>
+
+<pre petal:content="self/comment">
+   Blah blah, I am so clever.
+</pre>
+
+<pre>-- 
+Best Regards,
+<span petal:replace="root_user/real_name">MKDoc</span> &lt;<span petal:replace="root_user/email">example at example.com</span>&gt;</pre>
+  </body>
+</Message>


More information about the MKDoc-commit mailing list