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

(-)a/Koha/Patron.pm (-15 / +26 lines)
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
(-)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 514-519 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
514
('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'),
514
('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'),
515
('PatronSelfRegistrationLibraryList','',NULL,'Only display libraries listed. If empty, all libraries are displayed.','Free'),
515
('PatronSelfRegistrationLibraryList','',NULL,'Only display libraries listed. If empty, all libraries are displayed.','Free'),
516
('PatronSelfRegistrationPrefillForm','1',NULL,'Display password and prefill login form after a patron has self registered','YesNo'),
516
('PatronSelfRegistrationPrefillForm','1',NULL,'Display password and prefill login form after a patron has self registered','YesNo'),
517
('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.', ''),
517
('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'),
518
('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'),
518
('PatronsPerPage','20','20','Number of Patrons Per Page displayed by default','Integer'),
519
('PatronsPerPage','20','20','Number of Patrons Per Page displayed by default','Integer'),
519
('EnablePayPalOpacPayments',  '0', NULL ,  'Enables the ability to pay fees and fines from  the OPAC via PayPal',  'YesNo' ),
520
('EnablePayPalOpacPayments',  '0', NULL ,  'Enables the ability to pay fees and fines from  the OPAC via PayPal',  'YesNo' ),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-1 / +7 lines)
Lines 863-868 OPAC: Link Here
863
                  yes: Require
863
                  yes: Require
864
                  no: "Don't require"
864
                  no: "Don't require"
865
            - patrons to confirm their email address by entering it twice.
865
            - patrons to confirm their email address by entering it twice.
866
        -
867
            - Use
868
            - pref: PatronSelfRegistrationUseridGenerationMethod
869
              choices:
870
                  default: "firstname.surname[uniqueness number, if needed]"
871
                  email: "email address"
872
            - to generate the user name of a borrower when self registering in OPAC.
866
        -
873
        -
867
            - pref: OPACPatronDetails
874
            - pref: OPACPatronDetails
868
              choices:
875
              choices:
869
- 

Return to bug 29480