Lines 1518-1538
Set a generated userid ($firstname.$surname if there is a $firstname, or $surnam
Link Here
|
1518 |
sub generate_userid { |
1518 |
sub generate_userid { |
1519 |
my ($self) = @_; |
1519 |
my ($self) = @_; |
1520 |
my $offset = 0; |
1520 |
my $offset = 0; |
1521 |
my $firstname = $self->firstname // q{}; |
1521 |
my $email = $self->first_valid_email_address; |
1522 |
my $surname = $self->surname // q{}; |
1522 |
|
1523 |
#The script will "do" the following code and increment the $offset until the generated userid is unique |
1523 |
if (defined($email) && $email ne '' && length($email) <= 75 && |
1524 |
do { |
1524 |
C4::Context->preference('PatronSelfRegistrationUseridGenerationMethod') eq 'email') { |
1525 |
$firstname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g; |
1525 |
# Uniqueness of email as userid is verified by |
1526 |
$surname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g; |
1526 |
# has_valid_userid, with fallback to the default method. |
1527 |
my $userid = lc(($firstname)? "$firstname.$surname" : $surname); |
1527 |
$self->userid( $email ); |
1528 |
$userid = NFKD( $userid ); |
1528 |
} |
1529 |
$userid =~ s/\p{NonspacingMark}//g; |
1529 |
|
1530 |
$userid .= $offset unless $offset == 0; |
1530 |
if (!$self->has_valid_userid) { |
1531 |
$self->userid( $userid ); |
1531 |
my $firstname = $self->firstname // q{}; |
1532 |
$offset++; |
1532 |
my $surname = $self->surname // q{}; |
1533 |
} while (! $self->has_valid_userid ); |
1533 |
#The script will "do" the following code and increment the $offset until the generated userid is unique |
1534 |
|
1534 |
do { |
1535 |
return $self; |
1535 |
$firstname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g; |
|
|
1536 |
$surname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g; |
1537 |
my $userid = lc(($firstname)? "$firstname.$surname" : $surname); |
1538 |
$userid = NFKD( $userid ); |
1539 |
$userid =~ s/\p{NonspacingMark}//g; |
1540 |
$userid .= $offset unless $offset == 0; |
1541 |
$self->userid( $userid ); |
1542 |
$offset++; |
1543 |
} while (! $self->has_valid_userid ); |
1544 |
} |
1545 |
|
1546 |
return $self; |
1536 |
} |
1547 |
} |
1537 |
|
1548 |
|
1538 |
=head3 add_extended_attribute |
1549 |
=head3 add_extended_attribute |