From 5ed773c6434c4e992898720d3033ce14e484a68b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 28 Mar 2012 20:56:22 -0400 Subject: [PATCH] more fixes to subscription prefs --- IkiWiki/Plugin/notifyemail.pm | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/IkiWiki/Plugin/notifyemail.pm b/IkiWiki/Plugin/notifyemail.pm index 0c067270c..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); @@ -20,28 +19,23 @@ sub getsetup () { }, } -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).")"); if (! $form->submitted) { $form->field(name => "subscriptions", force => 1, - value => getsubscriptions($session->param("name"))); + value => getsubscriptions($username)); + } + elsif ($form->submitted eq "Save Preferences" && $form->validate && + defined $form->field("subscriptions")) { + setsubscriptions($username, $form->field('subscriptions')); } -} - -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')); } sub getsubscriptions ($) { -- 2.26.2