Bug 9662 - ISSN search field not passed to Z3950Search
[koha.git] / misc / cronjobs / delete_unverified_opac_registrations.pl
blob6909c707960c6ec092936a28991d3f914f314d15
1 #!/usr/bin/perl
3 # Copyright 2009-2010 Kyle Hall
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 use Modern::Perl;
21 use Getopt::Long;
23 BEGIN {
25 # find Koha's Perl modules
26 # test carefully before changing this
27 use FindBin;
28 eval { my $lib = "$FindBin::Bin/../kohalib.pl"; require $lib };
31 use C4::Context;
32 use C4::Members qw/ DelMember /;
34 my $help;
35 my $confirm;
36 my $hours = 24;
38 GetOptions(
39 'h|help' => \$help,
40 'c|confirm' => \$confirm,
41 't|time=i' => \$hours,
43 my $usage = << 'ENDUSAGE';
45 This script removes unconfirmed OPAC based patron registrations
46 that have not been confirmed within the required time period.
48 This script has the following parameters :
49 -h --help: This message
51 -t --time: The length in hours to wait before removing an unconfirmed registration.
52 Defaults to 24 hours if not set.
54 -c --confirm: Without this flag set, this script will do nothing.
55 ENDUSAGE
57 if ( $help || !$confirm ) {
58 print $usage;
59 exit;
62 my $dbh = C4::Context->dbh;
64 $dbh->do( "
65 DELETE FROM borrower_modifications
66 WHERE
67 borrowernumber = 0
68 AND
69 TIME_TO_SEC( TIMEDIFF( NOW(), timestamp )) / 3600 > ?
70 ", undef, $hours );