Bug 23431: Don't nullify DOB if it's hidden by sysprefs

To test:

Turn on  OPACPatronDetails
put dateofbirth in PatronSelfModificationBorrowerUnwantedField
Have a patron with a set date of birth
Attempt any modification on that patron through the OPAC
The date of birth will be one of the fields changed for that borrower
when you check it in the staff intranet.

Apply this patch, repeat the above.
Date of birth will not be one of the changed fields.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit d71b263a89)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 936f1450b8)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Liz Rea 2019-08-05 22:39:37 +00:00 committed by Lucas Gass
parent cede01543c
commit 1e2f5a6d3d
1 changed files with 7 additions and 3 deletions

View File

@ -484,13 +484,17 @@ sub ParseCgiForBorrower {
sub DelUnchangedFields {
my ( $borrowernumber, %new_data ) = @_;
# get the mandatory fields so we can get the hidden fields
my $mandatory = GetMandatoryFields('edit');
my $patron = Koha::Patrons->find( $borrowernumber );
my $current_data = $patron->unblessed;
# get the hidden fields so we don't obliterate them should they have data patrons aren't allowed to modify
my $hidden_fields = GetHiddenFields($mandatory, 'edit');
foreach my $key ( keys %new_data ) {
if ( $current_data->{$key} eq $new_data{$key} ) {
delete $new_data{$key};
if ( ($current_data->{$key} eq $new_data{$key}) || $hidden_fields->{$key} ) {
delete $new_data{$key};
}
}