View | Details | Raw Unified | Return to bug 29480
Collapse All | Expand All

(-)a/Koha/Patron.pm (-15 / +26 lines)
Lines 1680-1700 Set a generated userid ($firstname.$surname if there is a $firstname, or $surnam Link Here
1680
sub generate_userid {
1680
sub generate_userid {
1681
    my ($self) = @_;
1681
    my ($self) = @_;
1682
    my $offset = 0;
1682
    my $offset = 0;
1683
    my $firstname = $self->firstname // q{};
1683
    my $email = $self->first_valid_email_address;
1684
    my $surname = $self->surname // q{};
1684
1685
    #The script will "do" the following code and increment the $offset until the generated userid is unique
1685
    if (defined($email) && $email ne '' && length($email) <= 75 &&
1686
    do {
1686
        C4::Context->preference('PatronSelfRegistrationUseridGenerationMethod') eq 'email') {
1687
      $firstname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g;
1687
        # Uniqueness of email as userid is verified by
1688
      $surname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g;
1688
        # has_valid_userid, with fallback to the default method.
1689
      my $userid = lc(($firstname)? "$firstname.$surname" : $surname);
1689
	$self->userid( $email );
1690
      $userid = NFKD( $userid );
1690
    }
1691
      $userid =~ s/\p{NonspacingMark}//g;
1691
1692
      $userid .= $offset unless $offset == 0;
1692
    if (!$self->has_valid_userid) {
1693
      $self->userid( $userid );
1693
	my $firstname = $self->firstname // q{};
1694
      $offset++;
1694
	my $surname = $self->surname // q{};
1695
     } while (! $self->has_valid_userid );
1695
	#The script will "do" the following code and increment the $offset until the generated userid is unique
1696
1696
	do {
1697
     return $self;
1697
	    $firstname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g;
1698
	    $surname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g;
1699
	    my $userid = lc(($firstname)? "$firstname.$surname" : $surname);
1700
            $userid = NFKD( $userid );
1701
            $userid =~ s/\p{NonspacingMark}//g;
1702
	    $userid .= $offset unless $offset == 0;
1703
	    $self->userid( $userid );
1704
	    $offset++;
1705
	} while (! $self->has_valid_userid );
1706
    }
1707
1708
    return $self;
1698
}
1709
}
1699
1710
1700
=head3 add_extended_attribute
1711
=head3 add_extended_attribute
(-)a/installer/data/mysql/atomicupdate/bug_29480-add_PatronSelfRegistrationUseridGenerationMethod_syspref.perl (+11 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
4
        $dbh->do(<<'EOF');
5
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type`) VALUES
6
('PatronSelfRegistrationUseridGenerationMethod', 'default', 'default|email', 'Method for generating userid of of a borrower when self registering in OPAC.  Fallback to generating a userid from the name of the borrower.', '');
7
EOF
8
9
    # Always end with this (adjust the bug info)
10
    NewVersion( $DBversion, 29480, "Add new system preference PatronSelfRegistrationUseridGenerationMethod");
11
}
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 554-559 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
554
('PatronSelfRegistrationExpireTemporaryAccountsDelay','0',NULL,'If PatronSelfRegistrationDefaultCategory is enabled, this system preference controls how long a patron can have a temporary status before the account is deleted automatically. It is an integer value representing a number of days to wait before deleting a temporary patron account. Setting it to 0 disables the deleting of temporary accounts.','Integer'),
554
('PatronSelfRegistrationExpireTemporaryAccountsDelay','0',NULL,'If PatronSelfRegistrationDefaultCategory is enabled, this system preference controls how long a patron can have a temporary status before the account is deleted automatically. It is an integer value representing a number of days to wait before deleting a temporary patron account. Setting it to 0 disables the deleting of temporary accounts.','Integer'),
555
('PatronSelfRegistrationLibraryList','',NULL,'Only display libraries listed. If empty, all libraries are displayed.','Free'),
555
('PatronSelfRegistrationLibraryList','',NULL,'Only display libraries listed. If empty, all libraries are displayed.','Free'),
556
('PatronSelfRegistrationPrefillForm','1',NULL,'Display password and prefill login form after a patron has self registered','YesNo'),
556
('PatronSelfRegistrationPrefillForm','1',NULL,'Display password and prefill login form after a patron has self registered','YesNo'),
557
('PatronSelfRegistrationUseridGenerationMethod', 'default', 'default|email', 'Method for generating userid of of a borrower when self registering in OPAC.  Fallback to generating a userid from the name of the borrower.', ''),
557
('PatronSelfRegistrationVerifyByEmail','0',NULL,'If enabled, any patron attempting to register themselves via the OPAC will be required to verify themselves via email to activate their account.','YesNo'),
558
('PatronSelfRegistrationVerifyByEmail','0',NULL,'If enabled, any patron attempting to register themselves via the OPAC will be required to verify themselves via email to activate their account.','YesNo'),
558
('PatronsPerPage','20','20','Number of Patrons Per Page displayed by default','Integer'),
559
('PatronsPerPage','20','20','Number of Patrons Per Page displayed by default','Integer'),
559
('PatronQuickAddFields',  '', NULL ,  'A list of fields separated by "|" to be displayed along with mandatory fields in the patron quick add form if chosen at patron entry',  'Free' ),
560
('PatronQuickAddFields',  '', NULL ,  'A list of fields separated by "|" to be displayed along with mandatory fields in the patron quick add form if chosen at patron entry',  'Free' ),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-1 / +7 lines)
Lines 802-807 OPAC: Link Here
802
                  1: Require
802
                  1: Require
803
                  0: "Don't require"
803
                  0: "Don't require"
804
            - patrons to confirm their email address by entering it twice.
804
            - patrons to confirm their email address by entering it twice.
805
        -
806
            - Use
807
            - pref: PatronSelfRegistrationUseridGenerationMethod
808
              choices:
809
                  default: "firstname.surname[uniqueness number, if needed]"
810
                  email: "email address"
811
            - to generate the user name of a borrower when self registering in OPAC.
805
        -
812
        -
806
            - pref: OPACPatronDetails
813
            - pref: OPACPatronDetails
807
              choices:
814
              choices:
808
- 

Return to bug 29480