From a5d00a4ac1f536803a548ab7e2e460357d45e564 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 3 Sep 2021 09:33:00 +0000 Subject: [PATCH] Bug 28935: Apply modules change to controller scripts Content-Type: text/plain; charset=utf-8 --- members/memberentry.pl | 8 +++++--- opac/opac-memberentry.pl | 13 ++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/members/memberentry.pl b/members/memberentry.pl index 509b5ac19e..efddb5f803 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -48,8 +48,8 @@ use Email::Valid; use Koha::SMS::Providers; use Koha::Patron::Allowlist; -my $ui_allowlist = Koha::Patron::Allowlist->new({ interface => 'staff' }); - +my $allowlist = Koha::Patron::Allowlist->new({ interface => 'staff' }); +$allowlist->load; my $input = CGI->new; my %data; @@ -434,7 +434,9 @@ if ( defined $sms ) { $newdata{smsalertnumber} = $sms; } -$ui_allowlist->apply({ input => \%newdata }); +my $allowed_data = { %newdata }; +my $blocked = $allowlist->apply({ input => $allowed_data, verbose => 1 }); # TODO Should we log results in $blocked ? +%newdata = %$allowed_data; ### Error checks should happen before this line. $nok = $nok || scalar(@errors); diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 3c3d9434ae..7fac3d2ed6 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -48,7 +48,8 @@ use Koha::AuthorisedValues; use Koha::Patron::Allowlist; -my $ui_allowlist = Koha::Patron::Allowlist->new(); +my $allowlist = Koha::Patron::Allowlist->new; +$allowlist->load; my $cgi = CGI->new; my $dbh = C4::Context->dbh; @@ -136,7 +137,10 @@ if ( $action eq 'create' ) { delete $borrower{'password2'}; my @unwanted_fields = split( /\|/, C4::Context->preference('PatronSelfRegistrationBorrowerUnwantedField') || q|| ); - $ui_allowlist->apply({ input => \%borrower, additional_deny_list => \@unwanted_fields }); + $allowlist->remove( @unwanted_fields ); + my $allowed_data = { %borrower }; + $allowlist->apply({ input => $allowed_data }); # TODO Log blocked data ? + %borrower = %$allowed_data; my $cardnumber_error_code; if ( !grep { $_ eq 'cardnumber' } @empty_mandatory_fields ) { @@ -276,7 +280,10 @@ elsif ( $action eq 'update' ) { %borrower = ( %$borrower, %borrower ); my @unwanted_fields = split( /\|/, C4::Context->preference('PatronSelfModificationBorrowerUnwantedField') || q|| ); - $ui_allowlist->apply({ input => \%borrower, additional_deny_list => \@unwanted_fields }); + $allowlist->remove( @unwanted_fields ); + my $allowed_data = { %borrower }; + $allowlist->apply({ input => $allowed_data }); # TODO Log blocked data ? + %borrower = %$allowed_data; if (@empty_mandatory_fields || @$invalidformfields) { $template->param( -- 2.20.1