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

(-)a/C4/Members.pm (+4 lines)
Lines 622-633 sub IssueSlip { Link Here
622
622
623
=head2 DeleteExpiredOpacRegistrations
623
=head2 DeleteExpiredOpacRegistrations
624
624
625
    $deleted_count = DeleteExpiredOpacRegistrations([$type == "hard|soft"])
626
625
    Delete accounts that haven't been upgraded from the 'temporary' category
627
    Delete accounts that haven't been upgraded from the 'temporary' category
626
    Returns the number of removed patrons
628
    Returns the number of removed patrons
627
629
628
=cut
630
=cut
629
631
630
sub DeleteExpiredOpacRegistrations {
632
sub DeleteExpiredOpacRegistrations {
633
    my ( $type ) = @_;
631
634
632
    my $delay = C4::Context->preference('PatronSelfRegistrationExpireTemporaryAccountsDelay');
635
    my $delay = C4::Context->preference('PatronSelfRegistrationExpireTemporaryAccountsDelay');
633
    my $category_code = C4::Context->preference('PatronSelfRegistrationDefaultCategory');
636
    my $category_code = C4::Context->preference('PatronSelfRegistrationDefaultCategory');
Lines 644-649 sub DeleteExpiredOpacRegistrations { Link Here
644
    my $cnt=0;
647
    my $cnt=0;
645
    while ( my $registration = $registrations_to_del->next() ) {
648
    while ( my $registration = $registrations_to_del->next() ) {
646
        next if $registration->checkouts->count || $registration->account->balance;
649
        next if $registration->checkouts->count || $registration->account->balance;
650
        $registration->move_to_deleted if $type && $type eq 'soft';
647
        $registration->delete;
651
        $registration->delete;
648
        $cnt++;
652
        $cnt++;
649
    }
653
    }
(-)a/misc/cronjobs/cleanup_database.pl (-6 / +12 lines)
Lines 27-32 use constant DEFAULT_MESSAGES_PURGEDAYS => 365; Link Here
27
use constant DEFAULT_SEARCHHISTORY_PURGEDAYS      => 30;
27
use constant DEFAULT_SEARCHHISTORY_PURGEDAYS      => 30;
28
use constant DEFAULT_SHARE_INVITATION_EXPIRY_DAYS => 14;
28
use constant DEFAULT_SHARE_INVITATION_EXPIRY_DAYS => 14;
29
use constant DEFAULT_DEBARMENTS_PURGEDAYS         => 30;
29
use constant DEFAULT_DEBARMENTS_PURGEDAYS         => 30;
30
use constant DEFAULT_EXP_SELFREG_TYPE             => 'hard';
30
31
31
BEGIN {
32
BEGIN {
32
    # find Koha's Perl modules
33
    # find Koha's Perl modules
Lines 89-97 Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] Link Here
89
   --restrictions DAYS   purge patrons restrictions expired since more than DAYS days.
90
   --restrictions DAYS   purge patrons restrictions expired since more than DAYS days.
90
                         Defaults to 30 days if no days specified.
91
                         Defaults to 30 days if no days specified.
91
    --all-restrictions   purge all expired patrons restrictions.
92
    --all-restrictions   purge all expired patrons restrictions.
92
   --del-exp-selfreg  Delete expired self registration accounts
93
   --del-exp-selfreg     Delete expired self registration accounts
93
   --del-unv-selfreg  DAYS  Delete unverified self registrations older than DAYS
94
   --del-exp-selfreg-type TYPE Option 'hard' completely removes patrons from the database,
94
   --unique-holidays DAYS  Delete all unique holidays older than DAYS
95
                               Option 'soft' moves patron to deleted patrons table.
96
   --del-unv-selfreg  DAYS Delete unverified self registrations older than DAYS
97
   --unique-holidays  DAYS Delete all unique holidays older than DAYS
95
   --temp-uploads     Delete temporary uploads.
98
   --temp-uploads     Delete temporary uploads.
96
   --temp-uploads-days DAYS Override the corresponding preference value.
99
   --temp-uploads-days DAYS Override the corresponding preference value.
97
   --uploads-missing FLAG Delete upload records for missing files when FLAG is true, count them otherwise
100
   --uploads-missing FLAG Delete upload records for missing files when FLAG is true, count them otherwise
Lines 127-132 my $pListShareInvites; Link Here
127
my $pDebarments;
130
my $pDebarments;
128
my $allDebarments;
131
my $allDebarments;
129
my $pExpSelfReg;
132
my $pExpSelfReg;
133
my $pExpSelfRegType = 'hard';
130
my $pUnvSelfReg;
134
my $pUnvSelfReg;
131
my $fees_days;
135
my $fees_days;
132
my $special_holidays_days;
136
my $special_holidays_days;
Lines 162-167 GetOptions( Link Here
162
    'restrictions:i'    => \$pDebarments,
166
    'restrictions:i'    => \$pDebarments,
163
    'all-restrictions'  => \$allDebarments,
167
    'all-restrictions'  => \$allDebarments,
164
    'del-exp-selfreg'   => \$pExpSelfReg,
168
    'del-exp-selfreg'   => \$pExpSelfReg,
169
    'del-exp-selfreg-type' => \$pExpSelfRegType,
165
    'del-unv-selfreg'   => \$pUnvSelfReg,
170
    'del-unv-selfreg'   => \$pUnvSelfReg,
166
    'unique-holidays:i' => \$special_holidays_days,
171
    'unique-holidays:i' => \$special_holidays_days,
167
    'temp-uploads'      => \$temp_uploads,
172
    'temp-uploads'      => \$temp_uploads,
Lines 222-227 unless ( $sessions Link Here
222
    || $pPseudoTransactionsFrom
227
    || $pPseudoTransactionsFrom
223
    || $pPseudoTransactionsTo
228
    || $pPseudoTransactionsTo
224
    || $pMessages
229
    || $pMessages
230
    || ( !defined $pExpSelfRegType || $pExpSelfRegType !~ m/^hard|soft$/ )
225
) {
231
) {
226
    print "You did not specify any cleanup work for the script to do.\n\n";
232
    print "You did not specify any cleanup work for the script to do.\n\n";
227
    usage(1);
233
    usage(1);
Lines 429-435 if ($verbose) { Link Here
429
# But non trivial changes to C4::Members need to be done before.
435
# But non trivial changes to C4::Members need to be done before.
430
if( $pExpSelfReg ) {
436
if( $pExpSelfReg ) {
431
    if ( $confirm ) {
437
    if ( $confirm ) {
432
        DeleteExpiredSelfRegs();
438
        DeleteExpiredSelfRegs( $pExpSelfRegType );
433
    } elsif ( $verbose ) {
439
    } elsif ( $verbose ) {
434
        say "self-registered borrowers may be deleted";
440
        say "self-registered borrowers may be deleted";
435
    }
441
    }
Lines 689-695 sub PurgeDebarments { Link Here
689
}
695
}
690
696
691
sub DeleteExpiredSelfRegs {
697
sub DeleteExpiredSelfRegs {
692
    my $cnt= C4::Members::DeleteExpiredOpacRegistrations();
698
    my ( $type ) = @_;
699
    my $cnt = C4::Members::DeleteExpiredOpacRegistrations( $type );
693
    print "Removed $cnt expired self-registered borrowers\n" if $verbose;
700
    print "Removed $cnt expired self-registered borrowers\n" if $verbose;
694
}
701
}
695
702
696
- 

Return to bug 25183