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

(-)a/C4/Members.pm (+3 lines)
Lines 645-650 sub DeleteExpiredOpacRegistrations { Link Here
645
    my $category_code = C4::Context->preference('PatronSelfRegistrationDefaultCategory');
645
    my $category_code = C4::Context->preference('PatronSelfRegistrationDefaultCategory');
646
646
647
    return 0 if not $category_code or not defined $delay or $delay eq q||;
647
    return 0 if not $category_code or not defined $delay or $delay eq q||;
648
        # DO NOT REMOVE the empty tests on delay here
649
        # Some libraries may not use a temporary category, but want to keep patrons
650
648
    my $date_enrolled = dt_from_string();
651
    my $date_enrolled = dt_from_string();
649
    $date_enrolled->subtract( days => $delay );
652
    $date_enrolled->subtract( days => $delay );
650
653
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 / +1 lines)
Lines 521-527 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
521
('PatronSelfRegistrationConfirmEmail', '0', NULL, 'Require users to confirm their email address by entering it twice.', 'YesNo'),
521
('PatronSelfRegistrationConfirmEmail', '0', NULL, 'Require users to confirm their email address by entering it twice.', 'YesNo'),
522
('PatronSelfRegistrationDefaultCategory','','','A patron registered via the OPAC will receive a borrower category code set in this system preference.','free'),
522
('PatronSelfRegistrationDefaultCategory','','','A patron registered via the OPAC will receive a borrower category code set in this system preference.','free'),
523
('PatronSelfRegistrationEmailMustBeUnique', '0', 'If set, the field borrowers.email will be considered as a unique field on self registering', NULL, 'YesNo'),
523
('PatronSelfRegistrationEmailMustBeUnique', '0', 'If set, the field borrowers.email will be considered as a unique field on self registering', NULL, 'YesNo'),
524
('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'),
524
('PatronSelfRegistrationExpireTemporaryAccountsDelay', '', 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. Making it empty disables the deleting of (temporary) accounts.', 'Integer' ),
525
('PatronSelfRegistrationLibraryList','',NULL,'Only display libraries listed. If empty, all libraries are displayed.','Free'),
525
('PatronSelfRegistrationLibraryList','',NULL,'Only display libraries listed. If empty, all libraries are displayed.','Free'),
526
('PatronSelfRegistrationPrefillForm','1',NULL,'Display password and prefill login form after a patron has self registered','YesNo'),
526
('PatronSelfRegistrationPrefillForm','1',NULL,'Display password and prefill login form after a patron has self registered','YesNo'),
527
('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'),
527
('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'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-2 / +3 lines)
Lines 816-828 OPAC: Link Here
816
            - pref: PatronSelfRegistrationDefaultCategory
816
            - pref: PatronSelfRegistrationDefaultCategory
817
              choices: patron-categories
817
              choices: patron-categories
818
            - "as the default patron category for patrons registered via the OPAC."
818
            - "as the default patron category for patrons registered via the OPAC."
819
            - "<br><strong>WARNING: Do not use a regular patron category for self registration.</strong> If the <code>misc/cronjobs/cleanup_database.pl</code> cronjob is setup to delete unverified and unfinished OPAC self registrations, it will permanently and unrecoverably delete all patrons that have registered more than <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=PatronSelfRegistrationExpireTemporaryAccountsDelay'>PatronSelfRegistrationExpireTemporaryAccountsDelay</a> days ago."
819
            - "<br><strong>WARNING: Do not use a regular patron category for self registration.</strong><br>
820
If the <code>misc/cronjobs/cleanup_database.pl</code> cronjob is setup to delete unverified and unfinished OPAC self registrations, it will permanently and unrecoverably delete all patrons that have registered more than <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=PatronSelfRegistrationExpireTemporaryAccountsDelay'>PatronSelfRegistrationExpireTemporaryAccountsDelay</a> days ago UNLESS you make that delay EMPTY."
820
        -
821
        -
821
            - Delete patrons still in the category indicated by <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=PatronSelfRegistrationDefaultCategory">PatronSelfRegistrationDefaultCategory</a>
822
            - Delete patrons still in the category indicated by <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=PatronSelfRegistrationDefaultCategory">PatronSelfRegistrationDefaultCategory</a>
822
            - pref: PatronSelfRegistrationExpireTemporaryAccountsDelay
823
            - pref: PatronSelfRegistrationExpireTemporaryAccountsDelay
823
              class: integer
824
              class: integer
824
            - "days after account creation."
825
            - "days after account creation."
825
            - "<br><strong>NOTE:</strong> This system preference requires the <code>misc/cronjobs/cleanup_database.pl</code> cronjob. Ask your system administrator to schedule it."
826
            - "<br><strong>NOTE:</strong> This system preference requires the <code>misc/cronjobs/cleanup_database.pl</code> cronjob. Ask your system administrator to schedule it.<br>A zero will remove all patrons; but if you make the pref EMPTY, it will not delete any patron."
826
        -
827
        -
827
            - "The following <a href='http://schema.koha-community.org/__VERSION__/tables/borrowers.html' target='blank'>database columns</a> must be filled in on the patron entry screen:"
828
            - "The following <a href='http://schema.koha-community.org/__VERSION__/tables/borrowers.html' target='blank'>database columns</a> must be filled in on the patron entry screen:"
828
            - pref: PatronSelfRegistrationBorrowerMandatoryField
829
            - pref: PatronSelfRegistrationBorrowerMandatoryField
(-)a/t/db_dependent/Members.t (-3 / +11 lines)
Lines 403-409 $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; Link Here
403
ok( $borrower->{userid},  'A userid should have been generated correctly' );
403
ok( $borrower->{userid},  'A userid should have been generated correctly' );
404
404
405
subtest 'purgeSelfRegistration' => sub {
405
subtest 'purgeSelfRegistration' => sub {
406
    plan tests => 5;
406
    plan tests => 7;
407
407
408
    #purge unverified
408
    #purge unverified
409
    my $d=360;
409
    my $d=360;
Lines 417-423 subtest 'purgeSelfRegistration' => sub { Link Here
417
    my $c= 'XYZ';
417
    my $c= 'XYZ';
418
    $dbh->do("INSERT IGNORE INTO categories (categorycode) VALUES ('$c')");
418
    $dbh->do("INSERT IGNORE INTO categories (categorycode) VALUES ('$c')");
419
    t::lib::Mocks::mock_preference('PatronSelfRegistrationDefaultCategory', $c );
419
    t::lib::Mocks::mock_preference('PatronSelfRegistrationDefaultCategory', $c );
420
    t::lib::Mocks::mock_preference('PatronSelfRegistrationExpireTemporaryAccountsDelay', 360);
421
    C4::Members::DeleteExpiredOpacRegistrations();
420
    C4::Members::DeleteExpiredOpacRegistrations();
422
    my $self_reg = $builder->build_object({
421
    my $self_reg = $builder->build_object({
423
        class => 'Koha::Patrons',
422
        class => 'Koha::Patrons',
Lines 427-432 subtest 'purgeSelfRegistration' => sub { Link Here
427
        }
426
        }
428
    });
427
    });
429
428
429
    # First test if empty PatronSelfRegistrationExpireTemporaryAccountsDelay returns zero
430
    # DO NOT REMOVE this test; it might prevent future accidents (when touching the code in Members)
431
    t::lib::Mocks::mock_preference('PatronSelfRegistrationExpireTemporaryAccountsDelay', q{} );
432
    is( C4::Members::DeleteExpiredOpacRegistrations(), 0, "DeleteExpiredOpacRegistrations with empty delay" );
433
    # Also check empty category
434
    t::lib::Mocks::mock_preference('PatronSelfRegistrationDefaultCategory', q{} );
435
    t::lib::Mocks::mock_preference('PatronSelfRegistrationExpireTemporaryAccountsDelay', 360 );
436
    is( C4::Members::DeleteExpiredOpacRegistrations(), 0, "DeleteExpiredOpacRegistrations with empty category" );
437
    t::lib::Mocks::mock_preference('PatronSelfRegistrationDefaultCategory', $c );
438
430
    my $checkout     = $builder->build_object({
439
    my $checkout     = $builder->build_object({
431
        class=>'Koha::Checkouts',
440
        class=>'Koha::Checkouts',
432
        value=>{
441
        value=>{
433
- 

Return to bug 28943