integrate comments plugin with notifyemail

master
Joey Hess 2012-03-28 18:38:37 -04:00
parent e07b876486
commit 1916f97472
2 changed files with 19 additions and 3 deletions

View File

@ -301,7 +301,8 @@ sub editcomment ($$) {
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}],
@ -346,7 +347,15 @@ sub editcomment ($$) {
$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')) {
@ -491,6 +500,12 @@ sub editcomment ($$) {
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'),
subject => $form->field('subject'),

View File

@ -22,7 +22,8 @@
<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>