Bug 6218

Summary: patron login gets an initial dot added when no first name
Product: Koha Reporter: Fernando L. Canizo <conan>
Component: PatronsAssignee: Fernando L. Canizo <conan>
Status: CLOSED FIXED QA Contact: Bugs List <koha-bugs>
Severity: minor    
Priority: PATCH-Sent (DO NOT USE) CC: chris, f.demians, gmcharlt, koha.sekjal
Version: 3.4   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 3674    
Attachments: fix Member.pm

Description Fernando L. Canizo 2011-04-20 15:15:26 UTC
If you create a patron with an empty opac login and an empty first name, save and then edit him/her, script will add a dot before login on OPAC Login box, for example if
your surname is 'mongo' box gets pre-filled with '.mongo'.

This is because script joins 'first name'.'surname' and with an empty first name, hence the initial dot.

It would be desirable to have 'surname' as login (without dot) when there's no first name entered.
Comment 1 Owen Leonard 2011-04-20 15:31:13 UTC
In Members.pm:

sub Generate_Userid {
  my ($borrowernumber, $firstname, $surname) = @_;
  my $newuid;
  my $offset = 0;
  do {
    $firstname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g;
    $surname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g;
    $newuid = lc("$firstname.$surname");
    $newuid .= $offset unless $offset == 0;
    $offset++;

   } while (!Check_Userid($newuid,$borrowernumber));

   return $newuid;
}
Comment 2 Fernando L. Canizo 2011-04-20 21:17:50 UTC
Created attachment 3960 [details] [review]
fix Member.pm

Now it chooses surname if firstname is blank, no dots added. It behaves the same if both are provided.
Comment 3 Ian Walls 2011-05-13 13:58:24 UTC
This patch can be verified by reading the code.  Marking as Passed QA.
Comment 4 Chris Cormack 2011-05-14 07:22:45 UTC
Merged to master please test