Bug 27604: Make sure PatronSelfRegistrationLibraryList is used

The value of PatronSelfRegistrationLibraryList is used to display the dropdown
list of the libraries, but not after the form is submitted.

Test plan:
1. Empty PatronSelfRegistrationLibraryList
2. Self register a new patron
=> Confirm the dropdown list with the libraries contain all the
libraries
3. Fill in PatronSelfRegistrationLibraryList with branchcodes (eg. "CPL|MPL")
4. Self register a new patron
5. Edit the HTML form and replace the option's value with another
branchcode (FPL)
6. Save
=> Without this patch the branchcode FPL is used
=> With this patch applied an ugly 500 is returned

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 376bf9b980)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 41aaad8098)

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2021-02-03 16:14:12 +01:00 committed by Andrew Fuerste-Henry
parent 1bc7b45698
commit cd8fd0bb45
1 changed files with 13 additions and 8 deletions

View File

@ -75,15 +75,18 @@ if ( $action eq q{} ) {
my $mandatory = GetMandatoryFields($action);
my @libraries = Koha::Libraries->search;
if ( $action eq 'new'
&& ( my @libraries_to_display = split '\|', C4::Context->preference('PatronSelfRegistrationLibraryList') )
) {
@libraries = map {
my $b = $_;
my $branchcode = $_->branchcode;
( grep { $_ eq $branchcode } @libraries_to_display ) ? $b : ()
} @libraries;
if ( $action eq 'create' || $action eq 'new' ) {
my @PatronSelfRegistrationLibraryList = split '\|', C4::Context->preference('PatronSelfRegistrationLibraryList');
if (@PatronSelfRegistrationLibraryList) {
@libraries = map {
my $l = $_;
( grep { $l->branchcode eq $_ } @PatronSelfRegistrationLibraryList )
? $l
: ()
} @libraries;
}
}
my ( $min, $max ) = C4::Members::get_cardnumber_length();
if ( defined $min ) {
$template->param(
@ -155,6 +158,8 @@ if ( $action eq 'create' ) {
borrower => \%borrower
);
$template->param( patron_attribute_classes => GeneratePatronAttributesForm( undef, $attributes ) );
} elsif ( ! grep { $borrower{branchcode} eq $_->branchcode } @libraries ) {
die "Branchcode not allowed"; # They hack the form
}
else {
if (