From e06c1931872f2a54e2a12cf2b8468480e613ce5c Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 22 Mar 2017 18:51:48 -0300 Subject: [PATCH] Bug 13757: (QA followup) Filter out non-editable params before storing Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- opac/opac-memberentry.pl | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 670c11d87a..d62d89c749 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -607,30 +607,35 @@ sub ParsePatronAttributes { my @codes = $cgi->multi_param('patron_attribute_code'); my @values = $cgi->multi_param('patron_attribute_value'); + my @editable_attribute_types + = map { $_->code } Koha::Patron::Attribute::Types->search({ opac_editable => 1 }); + my $ea = each_array( @codes, @values ); my @attributes; my $delete_candidates = {}; while ( my ( $code, $value ) = $ea->() ) { - if ( !defined($value) or $value eq '' ) { - $delete_candidates->{$code} = 1 - unless $delete_candidates->{$code}; - } - else { - # we've got a value - push @attributes, { code => $code, value => $value }; + if ( any { $_ eq $code } @editable_attribute_types ) { + # It is an editable attribute + if ( !defined($value) or $value eq '' ) { + $delete_candidates->{$code} = 1 + unless $delete_candidates->{$code}; + } + else { + # we've got a value + push @attributes, { code => $code, value => $value }; - # 'code' is no longer a delete candidate - delete $delete_candidates->{$code}; + # 'code' is no longer a delete candidate + delete $delete_candidates->{$code} + if defined $delete_candidates->{$code}; + } } } foreach my $code ( keys %{$delete_candidates} ) { - if (Koha::Patron::Attributes->search( - { borrowernumber => $borrowernumber, code => $code } - )->count > 0 - ) + if ( Koha::Patron::Attributes->search({ + borrowernumber => $borrowernumber, code => $code })->count > 0 ) { push @attributes, { code => $code, value => '' } unless any { $_->{code} eq $code } @attributes;