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

(-)a/C4/Members.pm (+4 lines)
Lines 612-623 sub IssueSlip { Link Here
612
612
613
=head2 DeleteExpiredOpacRegistrations
613
=head2 DeleteExpiredOpacRegistrations
614
614
615
    $deleted_count = DeleteExpiredOpacRegistrations([$type == "hard|soft"])
616
615
    Delete accounts that haven't been upgraded from the 'temporary' category
617
    Delete accounts that haven't been upgraded from the 'temporary' category
616
    Returns the number of removed patrons
618
    Returns the number of removed patrons
617
619
618
=cut
620
=cut
619
621
620
sub DeleteExpiredOpacRegistrations {
622
sub DeleteExpiredOpacRegistrations {
623
    my ( $type ) = @_;
621
624
622
    my $delay = C4::Context->preference('PatronSelfRegistrationExpireTemporaryAccountsDelay');
625
    my $delay = C4::Context->preference('PatronSelfRegistrationExpireTemporaryAccountsDelay');
623
    my $category_code = C4::Context->preference('PatronSelfRegistrationDefaultCategory');
626
    my $category_code = C4::Context->preference('PatronSelfRegistrationDefaultCategory');
Lines 634-639 sub DeleteExpiredOpacRegistrations { Link Here
634
    my $cnt=0;
637
    my $cnt=0;
635
    while ( my $registration = $registrations_to_del->next() ) {
638
    while ( my $registration = $registrations_to_del->next() ) {
636
        next if $registration->checkouts->count || $registration->account->balance;
639
        next if $registration->checkouts->count || $registration->account->balance;
640
        $registration->move_to_deleted if $type && $type eq 'soft';
637
        $registration->delete;
641
        $registration->delete;
638
        $cnt++;
642
        $cnt++;
639
    }
643
    }
(-)a/misc/cronjobs/cleanup_database.pl (-6 / +12 lines)
Lines 26-31 use constant DEFAULT_LOGS_PURGEDAYS => 180; Link Here
26
use constant DEFAULT_SEARCHHISTORY_PURGEDAYS      => 30;
26
use constant DEFAULT_SEARCHHISTORY_PURGEDAYS      => 30;
27
use constant DEFAULT_SHARE_INVITATION_EXPIRY_DAYS => 14;
27
use constant DEFAULT_SHARE_INVITATION_EXPIRY_DAYS => 14;
28
use constant DEFAULT_DEBARMENTS_PURGEDAYS         => 30;
28
use constant DEFAULT_DEBARMENTS_PURGEDAYS         => 30;
29
use constant DEFAULT_EXP_SELFREG_TYPE             => 'hard';
29
30
30
BEGIN {
31
BEGIN {
31
    # find Koha's Perl modules
32
    # find Koha's Perl modules
Lines 76-84 Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu Link Here
76
   --restrictions DAYS   purge patrons restrictions expired since more than DAYS days.
77
   --restrictions DAYS   purge patrons restrictions expired since more than DAYS days.
77
                         Defaults to 30 days if no days specified.
78
                         Defaults to 30 days if no days specified.
78
    --all-restrictions   purge all expired patrons restrictions.
79
    --all-restrictions   purge all expired patrons restrictions.
79
   --del-exp-selfreg  Delete expired self registration accounts
80
   --del-exp-selfreg     Delete expired self registration accounts
80
   --del-unv-selfreg  DAYS  Delete unverified self registrations older than DAYS
81
   --del-exp-selfreg-type TYPE Option 'hard' completely removes patrons from the database,
81
   --unique-holidays DAYS  Delete all unique holidays older than DAYS
82
                               Option 'soft' moves patron to deleted patrons table.
83
   --del-unv-selfreg  DAYS Delete unverified self registrations older than DAYS
84
   --unique-holidays  DAYS Delete all unique holidays older than DAYS
82
   --temp-uploads     Delete temporary uploads.
85
   --temp-uploads     Delete temporary uploads.
83
   --temp-uploads-days DAYS Override the corresponding preference value.
86
   --temp-uploads-days DAYS Override the corresponding preference value.
84
   --uploads-missing FLAG Delete upload records for missing files when FLAG is true, count them otherwise
87
   --uploads-missing FLAG Delete upload records for missing files when FLAG is true, count them otherwise
Lines 109-114 my $pListShareInvites; Link Here
109
my $pDebarments;
112
my $pDebarments;
110
my $allDebarments;
113
my $allDebarments;
111
my $pExpSelfReg;
114
my $pExpSelfReg;
115
my $pExpSelfRegType = 'hard';
112
my $pUnvSelfReg;
116
my $pUnvSelfReg;
113
my $fees_days;
117
my $fees_days;
114
my $special_holidays_days;
118
my $special_holidays_days;
Lines 140-145 GetOptions( Link Here
140
    'restrictions:i'    => \$pDebarments,
144
    'restrictions:i'    => \$pDebarments,
141
    'all-restrictions'  => \$allDebarments,
145
    'all-restrictions'  => \$allDebarments,
142
    'del-exp-selfreg'   => \$pExpSelfReg,
146
    'del-exp-selfreg'   => \$pExpSelfReg,
147
    'del-exp-selfreg-type' => \$pExpSelfRegType,
143
    'del-unv-selfreg'   => \$pUnvSelfReg,
148
    'del-unv-selfreg'   => \$pUnvSelfReg,
144
    'unique-holidays:i' => \$special_holidays_days,
149
    'unique-holidays:i' => \$special_holidays_days,
145
    'temp-uploads'      => \$temp_uploads,
150
    'temp-uploads'      => \$temp_uploads,
Lines 192-197 unless ( $sessions Link Here
192
    || $pOldIssues
197
    || $pOldIssues
193
    || $pOldReserves
198
    || $pOldReserves
194
    || $pTransfers
199
    || $pTransfers
200
    || ( !defined $pExpSelfRegType || $pExpSelfRegType !~ m/^hard|soft$/ )
195
) {
201
) {
196
    print "You did not specify any cleanup work for the script to do.\n\n";
202
    print "You did not specify any cleanup work for the script to do.\n\n";
197
    usage(1);
203
    usage(1);
Lines 354-360 elsif ($verbose) { Link Here
354
}
360
}
355
361
356
if( $pExpSelfReg ) {
362
if( $pExpSelfReg ) {
357
    DeleteExpiredSelfRegs();
363
    DeleteExpiredSelfRegs( $pExpSelfRegType );
358
}
364
}
359
if( $pUnvSelfReg ) {
365
if( $pUnvSelfReg ) {
360
    DeleteUnverifiedSelfRegs( $pUnvSelfReg );
366
    DeleteUnverifiedSelfRegs( $pUnvSelfReg );
Lines 569-575 sub PurgeDebarments { Link Here
569
}
575
}
570
576
571
sub DeleteExpiredSelfRegs {
577
sub DeleteExpiredSelfRegs {
572
    my $cnt= C4::Members::DeleteExpiredOpacRegistrations();
578
    my ( $type ) = @_;
579
    my $cnt = C4::Members::DeleteExpiredOpacRegistrations( $type );
573
    print "Removed $cnt expired self-registered borrowers\n" if $verbose;
580
    print "Removed $cnt expired self-registered borrowers\n" if $verbose;
574
}
581
}
575
582
576
- 

Return to bug 25183