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_HOLIDAYS_PURGEDAYS => 30; |
29 |
|
30 |
|
30 |
BEGIN { |
31 |
BEGIN { |
31 |
# find Koha's Perl modules |
32 |
# find Koha's Perl modules |
Lines 71-76
Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu
Link Here
|
71 |
--all-restrictions purge all expired patrons restrictions. |
72 |
--all-restrictions purge all expired patrons restrictions. |
72 |
--del-exp-selfreg Delete expired self registration accounts |
73 |
--del-exp-selfreg Delete expired self registration accounts |
73 |
--del-unv-selfreg DAYS Delete unverified self registrations older than DAYS |
74 |
--del-unv-selfreg DAYS Delete unverified self registrations older than DAYS |
|
|
75 |
--holidays DAYS purge special holidays that passed more then DAYS days ago. |
76 |
Defaults to 30 days of no days specified. |
74 |
USAGE |
77 |
USAGE |
75 |
exit $_[0]; |
78 |
exit $_[0]; |
76 |
} |
79 |
} |
Lines 92-116
my (
Link Here
|
92 |
$allDebarments, |
95 |
$allDebarments, |
93 |
$pExpSelfReg, |
96 |
$pExpSelfReg, |
94 |
$pUnvSelfReg, |
97 |
$pUnvSelfReg, |
|
|
98 |
$pHolidays, |
95 |
); |
99 |
); |
96 |
|
100 |
|
97 |
GetOptions( |
101 |
GetOptions( |
98 |
'h|help' => \$help, |
102 |
'h|help' => \$help, |
99 |
'sessions' => \$sessions, |
103 |
'sessions' => \$sessions, |
100 |
'sessdays:i' => \$sess_days, |
104 |
'sessdays:i' => \$sess_days, |
101 |
'v|verbose' => \$verbose, |
105 |
'v|verbose' => \$verbose, |
102 |
'm|mail:i' => \$mail, |
106 |
'm|mail:i' => \$mail, |
103 |
'zebraqueue:i' => \$zebraqueue_days, |
107 |
'zebraqueue:i' => \$zebraqueue_days, |
104 |
'merged' => \$purge_merged, |
108 |
'merged' => \$purge_merged, |
105 |
'import:i' => \$pImport, |
109 |
'import:i' => \$pImport, |
106 |
'z3950' => \$pZ3950, |
110 |
'z3950' => \$pZ3950, |
107 |
'logs:i' => \$pLogs, |
111 |
'logs:i' => \$pLogs, |
108 |
'searchhistory:i' => \$pSearchhistory, |
112 |
'searchhistory:i' => \$pSearchhistory, |
109 |
'list-invites:i' => \$pListShareInvites, |
113 |
'list-invites:i' => \$pListShareInvites, |
110 |
'restrictions:i' => \$pDebarments, |
114 |
'restrictions:i' => \$pDebarments, |
111 |
'all-restrictions' => \$allDebarments, |
115 |
'all-restrictions' => \$allDebarments, |
112 |
'del-exp-selfreg' => \$pExpSelfReg, |
116 |
'del-exp-selfreg' => \$pExpSelfReg, |
113 |
'del-unv-selfreg' => \$pUnvSelfReg, |
117 |
'del-unv-selfreg' => \$pUnvSelfReg, |
|
|
118 |
'holidays:i' => \$pHolidays |
114 |
) || usage(1); |
119 |
) || usage(1); |
115 |
|
120 |
|
116 |
# Use default values |
121 |
# Use default values |
Lines 122-127
$mail = DEFAULT_MAIL_PURGEDAYS if defined($mail)
Link Here
|
122 |
$pSearchhistory = DEFAULT_SEARCHHISTORY_PURGEDAYS if defined($pSearchhistory) && $pSearchhistory == 0; |
127 |
$pSearchhistory = DEFAULT_SEARCHHISTORY_PURGEDAYS if defined($pSearchhistory) && $pSearchhistory == 0; |
123 |
$pListShareInvites = DEFAULT_SHARE_INVITATION_EXPIRY_DAYS if defined($pListShareInvites) && $pListShareInvites == 0; |
128 |
$pListShareInvites = DEFAULT_SHARE_INVITATION_EXPIRY_DAYS if defined($pListShareInvites) && $pListShareInvites == 0; |
124 |
$pDebarments = DEFAULT_DEBARMENTS_PURGEDAYS if defined($pDebarments) && $pDebarments == 0; |
129 |
$pDebarments = DEFAULT_DEBARMENTS_PURGEDAYS if defined($pDebarments) && $pDebarments == 0; |
|
|
130 |
$pHolidays = DEFAULT_HOLIDAYS_PURGEDAYS if defined($pHolidays) && $pHolidays == 0; |
125 |
|
131 |
|
126 |
if ($help) { |
132 |
if ($help) { |
127 |
usage(0); |
133 |
usage(0); |
Lines 140-145
unless ( $sessions
Link Here
|
140 |
|| $allDebarments |
146 |
|| $allDebarments |
141 |
|| $pExpSelfReg |
147 |
|| $pExpSelfReg |
142 |
|| $pUnvSelfReg |
148 |
|| $pUnvSelfReg |
|
|
149 |
|| $pHolidays |
143 |
) { |
150 |
) { |
144 |
print "You did not specify any cleanup work for the script to do.\n\n"; |
151 |
print "You did not specify any cleanup work for the script to do.\n\n"; |
145 |
usage(1); |
152 |
usage(1); |
Lines 266-282
if ($pDebarments) {
Link Here
|
266 |
print "$count restrictions were deleted.\nDone with restrictions purge.\n" if $verbose; |
273 |
print "$count restrictions were deleted.\nDone with restrictions purge.\n" if $verbose; |
267 |
} |
274 |
} |
268 |
|
275 |
|
269 |
if($allDebarments) { |
276 |
if ($allDebarments) { |
270 |
print "All expired patrons restrictions purge triggered.\n" if $verbose; |
277 |
print "All expired patrons restrictions purge triggered.\n" if $verbose; |
271 |
$count = PurgeDebarments(0); |
278 |
$count = PurgeDebarments(0); |
272 |
print "$count restrictions were deleted.\nDone with all restrictions purge.\n" if $verbose; |
279 |
print "$count restrictions were deleted.\nDone with all restrictions purge.\n" if $verbose; |
273 |
} |
280 |
} |
274 |
|
281 |
|
275 |
if( $pExpSelfReg ) { |
282 |
if ($pExpSelfReg) { |
276 |
DeleteExpiredSelfRegs(); |
283 |
DeleteExpiredSelfRegs(); |
277 |
} |
284 |
} |
278 |
if( $pUnvSelfReg ) { |
285 |
if ($pUnvSelfReg) { |
279 |
DeleteUnverifiedSelfRegs( $pUnvSelfReg ); |
286 |
DeleteUnverifiedSelfRegs($pUnvSelfReg); |
|
|
287 |
} |
288 |
|
289 |
if ($pHolidays) { |
290 |
print "Passed special holidays purge triggered for $pHolidays days.\n" if $verbose; |
291 |
PurgeHolidays(); |
292 |
print "Done with holidays purge.\n" if $verbose; |
280 |
} |
293 |
} |
281 |
|
294 |
|
282 |
exit(0); |
295 |
exit(0); |
Lines 376-378
sub DeleteUnverifiedSelfRegs {
Link Here
|
376 |
my $cnt= C4::Members::DeleteUnverifiedOpacRegistrations( $_[0] ); |
389 |
my $cnt= C4::Members::DeleteUnverifiedOpacRegistrations( $_[0] ); |
377 |
print "Removed $cnt unverified self-registrations\n" if $verbose; |
390 |
print "Removed $cnt unverified self-registrations\n" if $verbose; |
378 |
} |
391 |
} |
379 |
- |
392 |
|
|
|
393 |
sub PurgeHolidays { |
394 |
$sth = $dbh->prepare( |
395 |
q{ |
396 |
DELETE FROM special_holidays |
397 |
WHERE DATE( CONCAT( year, '-', month, '-', day ) ) < DATE_SUB( CURDATE(), INTERVAL ? DAY ) |
398 |
} |
399 |
); |
400 |
$sth->execute( $pHolidays ) or die $dbh->errstr; |
401 |
} |