Bugzilla – Attachment 103372 Details for
Bug 5161
Patron attributes clearing if duplicate warning
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 5161: Keep patron's attributes on warning/duplicate
Bug-5161-Keep-patrons-attributes-on-warningduplica.patch (text/plain), 4.08 KB, created by
Jonathan Druart
on 2020-04-21 12:45:40 UTC
(
hide
)
Description:
Bug 5161: Keep patron's attributes on warning/duplicate
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-04-21 12:45:40 UTC
Size:
4.08 KB
patch
obsolete
>From f4e10999fcf36eb3bafa00088d20248b39c090b1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 21 Apr 2020 14:30:19 +0200 >Subject: [PATCH] Bug 5161: Keep patron's attributes on warning/duplicate > >When a patron is added or modified and a warning appears (duplicate, >inconsistent data, etc.) the form lost the patron's attributes. > >Test plan: >Create some attribute types for patrons >Create a new patron, use an userid that already exists and fill the attributes >=> You get a warning and the attributes are kept >Modify the userid and save again >Edit the same patron >Modify the attributes, as well as the userid (to get the duplicate warning) >=> You get a warning and the attributes are kept with the modified >values >Modify the userid and save again >=> The new values are saved >Edit the attributes from the detail page (so not with the full edit form) >Modify them and save >=> The new values are saved >--- > members/memberentry.pl | 24 +++++++++++------------- > 1 file changed, 11 insertions(+), 13 deletions(-) > >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 66c32660a0..72cbda5895 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -415,6 +415,9 @@ if ($op eq 'save' || $op eq 'insert'){ > } > } > } >+elsif ( $borrowernumber ) { >+ $extended_patron_attributes = Koha::Patrons->find($borrowernumber)->extended_attributes->unblessed; >+} > > if ( ($op eq 'modify' || $op eq 'insert' || $op eq 'save'|| $op eq 'duplicate') and ($step == 0 or $step == 3 )){ > unless ($newdata{'dateexpiry'}){ >@@ -767,8 +770,8 @@ foreach (qw(dateenrolled dateexpiry dateofbirth)) { > $template->param( $_ => $data{$_}); > } > >-if (C4::Context->preference('ExtendedPatronAttributes')) { >- patron_attributes_form($template, $borrowernumber, $op); >+if ( C4::Context->preference('ExtendedPatronAttributes') ) { >+ patron_attributes_form( $template, $extended_patron_attributes, $op ); > } > > if (C4::Context->preference('EnhancedMessagingPreferences')) { >@@ -861,7 +864,7 @@ sub parse_extended_patron_attributes { > > sub patron_attributes_form { > my $template = shift; >- my $borrowernumber = shift; >+ my $attributes = shift; > my $op = shift; > > my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; >@@ -870,16 +873,11 @@ sub patron_attributes_form { > $template->param(no_patron_attribute_types => 1); > return; > } >- my @attributes; >- if ( $borrowernumber ) { >- my $patron = Koha::Patrons->find($borrowernumber); # Already fetched but outside of this sub >- @attributes = $patron->extended_attributes->as_list; # FIXME Must be improved! >- } > > # map patron's attributes into a more convenient structure > my %attr_hash = (); >- foreach my $attr (@attributes) { >- push @{ $attr_hash{$attr->code} }, $attr; >+ foreach my $attr (@$attributes) { >+ push @{ $attr_hash{$attr->{code}} }, $attr; > } > > my @attribute_loop = (); >@@ -897,16 +895,16 @@ sub patron_attributes_form { > if (exists $attr_hash{$attr_type->code()}) { > foreach my $attr (@{ $attr_hash{$attr_type->code()} }) { > my $newentry = { %$entry }; >- $newentry->{value} = $attr->attribute; >+ $newentry->{value} = $attr->{attribute}; > $newentry->{use_dropdown} = 0; > if ($attr_type->authorised_value_category()) { > $newentry->{use_dropdown} = 1; >- $newentry->{auth_val_loop} = GetAuthorisedValues($attr_type->authorised_value_category(), $attr->attribute); >+ $newentry->{auth_val_loop} = GetAuthorisedValues($attr_type->authorised_value_category(), $attr->{attribute}); > } > $i++; > undef $newentry->{value} if ($attr_type->unique_id() && $op eq 'duplicate'); > $newentry->{form_id} = "patron_attr_$i"; >- push @{$items_by_class{$attr_type->class()}}, $newentry; >+ push @{$items_by_class{$attr_type->{class}}}, $newentry; > } > } else { > $i++; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5161
:
103372
|
103418
|
103717