X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/accf79f94a6eed08c36d4e6a3b21fb51b11ab00d..bf04cd554546f044049727a95be69e0aff6578ab:/IkiWiki/Plugin/notifyemail.pm?ds=sidebyside diff --git a/IkiWiki/Plugin/notifyemail.pm b/IkiWiki/Plugin/notifyemail.pm index 79771af74..58f0c9920 100644 --- a/IkiWiki/Plugin/notifyemail.pm +++ b/IkiWiki/Plugin/notifyemail.pm @@ -6,7 +6,6 @@ use strict; use IkiWiki 3.00; sub import { - hook(type => "formbuilder_setup", id => "notifyemail", call => \&formbuilder_setup); hook(type => "formbuilder", id => "notifyemail", call => \&formbuilder); hook(type => "getsetup", id => "notifyemail", call => \&getsetup); hook(type => "changes", id => "notifyemail", call => \¬ify); @@ -17,29 +16,26 @@ sub getsetup () { plugin => { safe => 1, rebuild => 0, - section => "misc", }, } -sub formbuilder_setup (@) { +sub formbuilder (@) { my %params=@_; - my $form=$params{form}; return unless $form->title eq "preferences"; my $session=$params{session}; + my $username=$session->param("name"); $form->field(name => "subscriptions", size => 50, fieldset => "preferences", - comment => "(".htmllink("", "", "ikiwiki/PageSpec", noimageinline => 1).")", - value => getsubscriptions($session->param("name"))); -} - -sub formbuilder (@) { - my %params=@_; - my $form=$params{form}; - return unless $form->title eq "preferences" && - $form->submitted eq "Save Preferences" && $form->validate && - defined $form->field("subscriptions"); - setsubscriptions($form->field('name'), $form->field('subscriptions')); + comment => "(".htmllink("", "", "ikiwiki/PageSpec", noimageinline => 1).")"); + if (! $form->submitted) { + $form->field(name => "subscriptions", force => 1, + value => getsubscriptions($username)); + } + elsif ($form->submitted eq "Save Preferences" && $form->validate && + defined $form->field("subscriptions")) { + setsubscriptions($username, $form->field('subscriptions')); + } } sub getsubscriptions ($) { @@ -62,7 +58,8 @@ sub subscribe ($$) { my $user=shift; my $addpagespec=shift; my $pagespec=getsubscriptions($user); - setsubscriptions($user, $pagespec." or ".$addpagespec); + setsubscriptions($user, + length $pagespec ? $pagespec." or ".$addpagespec : $addpagespec); } sub notify (@) {