Bug 14867: userid not generated when defined in BorrowerUnwantedField

When userid is not provided when creating a new patron, it is generated
using surname and firstname.  The bug is when userid is defined in
syspref BorrowerUnwantedField, the input text is missing in patron
creation form. When saving you always get an alert message :
"Username/password already exists". No patron can be created.

This patch corrects by adding this case to userid generation conditions.

Test plan :
- add 'userid' in syspref BorrowerUnwantedField
- try to create a new patron : /cgi-bin/koha/members/memberentry.pl
- there is not input text for userid
- choose non-existing surname and firstname
- click on save
  => Without patch : patron is not created, you see the alert message
     "Username/password already exists"
  => With patch : patron is created, userid is generated with surname
     and firstname
- remove 'userid' in syspref BorrowerUnwantedField and check it can be
  defined in patron creation form

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
  The issue is there, and this patch fixes it.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 0cbc65111c)
(cherry picked from commit ee185cfd1a)
Signed-off-by: Liz Rea <wizzyrea@gmail.com>
This commit is contained in:
Fridolin Somers 2015-09-22 09:49:39 +02:00 committed by Liz Rea
parent 839f8312a2
commit 37ca7f59fc
1 changed files with 3 additions and 2 deletions

View File

@ -275,8 +275,9 @@ $newdata{'city'} = $input->param('city') if defined($input->param('city'))
$newdata{'zipcode'} = $input->param('zipcode') if defined($input->param('zipcode'));
$newdata{'country'} = $input->param('country') if defined($input->param('country'));
#builds default userid
if ( (defined $newdata{'userid'}) && ($newdata{'userid'} eq '')){
# builds default userid
# userid input text may be empty or missing because of syspref BorrowerUnwantedField
if ( ( defined $newdata{'userid'} && $newdata{'userid'} eq '' ) || $check_BorrowerUnwantedField =~ /userid/ ) {
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'} );