From 04d346ecca42ce31ad7aebd5eba9a501efa12f1f Mon Sep 17 00:00:00 2001 From: Adrien Saurat Date: Thu, 24 Jan 2013 17:11:31 +0100 Subject: [PATCH] Bug 9484: userid not generated consistently (different editing pages) When modifying a patron through different pages, the userid generation does not behave always the same way; this patch corrects this: - when firstname and surname are present in the form, they are used for the generation; - if there are not in the form, the firstname and surname in database are used instead. Signed-off-by: Bernardo Gonzalez Kriegel Comment: Work as described. No errors. Test This patch lacks a test plan, so I do the following 1) New user, empty userid, autocompleted 2) Edit user, change userid, saved correctly 3) Edit user, main edit window, emptied userid, autocompleted 4) Edit user, Detail > Library use, emptied userid, not autocomplete (not even a dot) 5) Applied patch 6) Repeated 1-3, same behavior 7) Repeated 4), now autocompletes with same userid as 3) So, works as described. No koha-qa errors. NOTE: It's impossible now to delete userid from interface. Off-topic: tried an userid in Arabic, works very well. Signed-off-by: Marcel de Rooy Signed-off-by: Jared Camins-Esakov --- members/memberentry.pl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/members/memberentry.pl b/members/memberentry.pl index 3e37a8c12d..d2b701d4ab 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -254,7 +254,18 @@ $newdata{'country'} = $input->param('country') if defined($input->param('country #builds default userid if ( (defined $newdata{'userid'}) && ($newdata{'userid'} eq '')){ - $newdata{'userid'} = Generate_Userid($borrowernumber, $newdata{'firstname'}, $newdata{'surname'}); + if ( ( defined $newdata{'firstname'} ) && ( defined $newdata{'surname'} ) ) { + # Full page edit, firstname and surname input zones are present + $newdata{'userid'} = Generate_Userid( $borrowernumber, $newdata{'firstname'}, $newdata{'surname'} ); + } + elsif ( ( defined $data{'firstname'} ) && ( defined $data{'surname'} ) ) { + # Partial page edit (access through "Details"/"Library details" tab), firstname and surname input zones are not used + # Still, if the userid field is erased, we can create a new userid with available firstname and surname + $newdata{'userid'} = Generate_Userid( $borrowernumber, $data{'firstname'}, $data{'surname'} ); + } + else { + $newdata{'userid'} = $data{'userid'}; + } } $debug and warn join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry); -- 2.39.5