bug #2757: change the opac login generation

This patch change the method used to generate a new login for a user when his informations are modified(memberentry.pl).

Before the login are generated with the first letter of lastname and the 9 first letter of the surname, and do not verify the
login already exist).
Now the login will be lastname.surnameX, where X is an incremented digit if the login already exists.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
This commit is contained in:
Nahuel Angelinetti 2008-12-02 11:24:30 +01:00 committed by Galen Charlton
parent 41db97255c
commit 873d1c6336
2 changed files with 26 additions and 14 deletions

View file

@ -97,15 +97,16 @@ BEGIN {
);
#Check data
push @EXPORT, qw(
&checkuniquemember
&checkuserpassword
&Check_Userid
&fixEthnicity
&ethnicitycategories
&fixup_cardnumber
&checkcardnumber
);
push @EXPORT, qw(
&checkuniquemember
&checkuserpassword
&Check_Userid
&Generate_Userid
&fixEthnicity
&ethnicitycategories
&fixup_cardnumber
&checkcardnumber
);
}
=head1 NAME
@ -799,6 +800,21 @@ sub Check_Userid {
}
}
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;
}
sub changepassword {
my ( $uid, $member, $digest ) = @_;

View file

@ -181,13 +181,10 @@ if ($guarantorid eq '') {
#builds default userid
if ( (defined $newdata{'userid'}) && ($newdata{'userid'} eq '')){
my $onefirstnameletter = substr($data{'firstname'},0,1);
my $fivesurnameletter = substr($data{'surname'} ,0,9);
$newdata{'userid'}=lc($onefirstnameletter.$fivesurnameletter);
$newdata{'userid'} = Generate_Userid($borrowernumber, $newdata{'firstname'}, $newdata{'surname'});
}
$debug and warn join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry);
my $loginexist = 0;
my $extended_patron_attributes = ();
if ($op eq 'save' || $op eq 'insert'){
if (checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){
@ -214,7 +211,6 @@ if ($op eq 'save' || $op eq 'insert'){
# Check if the userid is unique
unless (Check_Userid($newdata{'userid'},$borrowernumber)) {
push @errors, "ERROR_login_exist";
$loginexist=1;
}
my $password = $input->param('password');