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

(-)a/C4/Members.pm (-1 / +5 lines)
Lines 644-650 sub DeleteExpiredOpacRegistrations { Link Here
644
    my $delay = C4::Context->preference('PatronSelfRegistrationExpireTemporaryAccountsDelay');
644
    my $delay = C4::Context->preference('PatronSelfRegistrationExpireTemporaryAccountsDelay');
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 unless $category_code && $delay;
648
        # DO NOT REMOVE test on delay here!
649
        # Some libraries may not use a temporary category, but want to keep patrons.
650
        # We should not delete patrons when the value is NULL, empty string or 0.
651
648
    my $date_enrolled = dt_from_string();
652
    my $date_enrolled = dt_from_string();
649
    $date_enrolled->subtract( days => $delay );
653
    $date_enrolled->subtract( days => $delay );
650
654
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-2 / +3 lines)
Lines 810-822 OPAC: Link Here
810
            - pref: PatronSelfRegistrationDefaultCategory
810
            - pref: PatronSelfRegistrationDefaultCategory
811
              choices: patron-categories
811
              choices: patron-categories
812
            - "as the default patron category for patrons registered via the OPAC."
812
            - "as the default patron category for patrons registered via the OPAC."
813
            - "<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."
813
            - "<br><strong>WARNING: Do not use a regular patron category for self registration.</strong><br>
814
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 that delay is empty or zero)."
814
        -
815
        -
815
            - Delete patrons still in the category indicated by <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=PatronSelfRegistrationDefaultCategory">PatronSelfRegistrationDefaultCategory</a>
816
            - Delete patrons still in the category indicated by <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=PatronSelfRegistrationDefaultCategory">PatronSelfRegistrationDefaultCategory</a>
816
            - pref: PatronSelfRegistrationExpireTemporaryAccountsDelay
817
            - pref: PatronSelfRegistrationExpireTemporaryAccountsDelay
817
              class: integer
818
              class: integer
818
            - "days after account creation."
819
            - "days after account creation."
819
            - "<br><strong>NOTE:</strong> This system preference requires the <code>misc/cronjobs/cleanup_database.pl</code> cronjob. Ask your system administrator to schedule it."
820
            - "<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>No patrons will be deleted if you set the pref to zero or make it empty."
820
        -
821
        -
821
            - "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 modification screen:"
822
            - "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 modification screen:"
822
            - pref: PatronSelfModificationMandatoryField
823
            - pref: PatronSelfModificationMandatoryField
(-)a/t/db_dependent/Members.t (-3 / +13 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 => 8;
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
    t::lib::Mocks::mock_preference('PatronSelfRegistrationExpireTemporaryAccountsDelay', q{} );
431
    is( C4::Members::DeleteExpiredOpacRegistrations(), 0, "DeleteExpiredOpacRegistrations with empty delay" );
432
    # Test zero too
433
    t::lib::Mocks::mock_preference('PatronSelfRegistrationExpireTemporaryAccountsDelay', 0 );
434
    is( C4::Members::DeleteExpiredOpacRegistrations(), 0, "DeleteExpiredOpacRegistrations with delay 0" );
435
    # Also check empty category
436
    t::lib::Mocks::mock_preference('PatronSelfRegistrationDefaultCategory', q{} );
437
    t::lib::Mocks::mock_preference('PatronSelfRegistrationExpireTemporaryAccountsDelay', 360 );
438
    is( C4::Members::DeleteExpiredOpacRegistrations(), 0, "DeleteExpiredOpacRegistrations with empty category" );
439
    t::lib::Mocks::mock_preference('PatronSelfRegistrationDefaultCategory', $c );
440
430
    my $checkout     = $builder->build_object({
441
    my $checkout     = $builder->build_object({
431
        class=>'Koha::Checkouts',
442
        class=>'Koha::Checkouts',
432
        value=>{
443
        value=>{
433
- 

Return to bug 28943