]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
integrate comments plugin with notifyemail
authorJoey Hess <joey@kitenet.net>
Wed, 28 Mar 2012 22:38:37 +0000 (18:38 -0400)
committerJoey Hess <joey@kitenet.net>
Wed, 28 Mar 2012 22:38:37 +0000 (18:38 -0400)
IkiWiki/Plugin/comments.pm
templates/editcomment.tmpl

index 91a482ed6660059ed3a77f30b5236dbd891303a8..c2b2d919d4ac55c07ef2eb15a1c8f64e10282d2c 100644 (file)
@@ -301,7 +301,8 @@ sub editcomment ($$) {
 
        my @buttons = (POST_COMMENT, PREVIEW, CANCEL);
        my $form = CGI::FormBuilder->new(
 
        my @buttons = (POST_COMMENT, PREVIEW, CANCEL);
        my $form = CGI::FormBuilder->new(
-               fields => [qw{do sid page subject editcontent type author url}],
+               fields => [qw{do sid page subject editcontent type author
+                       url subscribe}],
                charset => 'utf-8',
                method => 'POST',
                required => [qw{editcontent}],
                charset => 'utf-8',
                method => 'POST',
                required => [qw{editcontent}],
@@ -346,7 +347,15 @@ sub editcomment ($$) {
        $form->field(name => "type", value => $type, force => 1,
                type => 'select', options => \@page_types);
 
        $form->field(name => "type", value => $type, force => 1,
                type => 'select', options => \@page_types);
 
-       $form->tmpl_param(username => $session->param('name'));
+       my $username=$session->param('name');
+       $form->tmpl_param(username => $username);
+       if (defined $username && IkiWiki::Plugin::notifyemail->can("subscribe")) {
+               $form->field(name => "subscribe",
+                       options => [gettext("email replies to me")]);
+       }
+       else {
+               $form->field(name => "subscribe", type => 'hidden');
+       }
 
        if ($config{comments_allowauthor} and
            ! defined $session->param('name')) {
 
        if ($config{comments_allowauthor} and
            ! defined $session->param('name')) {
@@ -490,6 +499,12 @@ sub editcomment ($$) {
 
        if ($form->submitted eq POST_COMMENT && $form->validate) {
                IkiWiki::checksessionexpiry($cgi, $session);
 
        if ($form->submitted eq POST_COMMENT && $form->validate) {
                IkiWiki::checksessionexpiry($cgi, $session);
+
+               if (defined $username && length $form->field("subscribe") &&
+                   IkiWiki::Plugin::notifyemail->can("subscribe")) {
+                       IkiWiki::Plugin::notifyemail::subscribe($username,
+                               "comment($page)");
+               }
                
                $postcomment=1;
                my $ok=IkiWiki::check_content(content => $form->field('editcontent'),
                
                $postcomment=1;
                my $ok=IkiWiki::check_content(content => $form->field('editcontent'),
index a2edc691e7cf98dedbfe6195f10791f678842f07..17c65624edc7543da21e3ee642dc8c289ca01be9 100644 (file)
@@ -22,7 +22,8 @@
 <TMPL_VAR FIELD-SUBJECT><br />
 <label for="editcontent" class="block">Comment:</label>
 <TMPL_VAR FIELD-EDITCONTENT><br />
 <TMPL_VAR FIELD-SUBJECT><br />
 <label for="editcontent" class="block">Comment:</label>
 <TMPL_VAR FIELD-EDITCONTENT><br />
-<TMPL_VAR FORM-SUBMIT> <TMPL_VAR FIELD-TYPE> <TMPL_VAR HELPONFORMATTINGLINK><br />
+<TMPL_VAR FORM-SUBMIT> <TMPL_VAR FIELD-TYPE> <TMPL_VAR HELPONFORMATTINGLINK>
+<TMPL_VAR FIELD-SUBSCRIBE><br />
 <TMPL_VAR NAME="FORM-END">
 <TMPL_VAR WMD_PREVIEW>
 
 <TMPL_VAR NAME="FORM-END">
 <TMPL_VAR WMD_PREVIEW>