Bug 14056: Small punctuation error in description for deleting a holiday
[koha.git] / misc / cronjobs / delete_unverified_opac_registrations.pl
1 #!/usr/bin/perl
2
3 # Copyright 2009-2010 Kyle Hall
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20 use Modern::Perl;
21 use Getopt::Long;
22
23 BEGIN {
24
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 };
29 }
30
31 use C4::Context;
32 use C4::Members qw/ DelMember /;
33 use C4::Log;
34
35 my $help;
36 my $confirm;
37 my $hours = 24;
38
39 GetOptions(
40     'h|help'    => \$help,
41     'c|confirm' => \$confirm,
42     't|time=i'  => \$hours,
43 );
44 my $usage = << 'ENDUSAGE';
45
46 This script removes unconfirmed OPAC based patron registrations
47 that have not been confirmed within the required time period.
48
49 This script has the following parameters :
50     -h --help:    This message
51
52     -t --time:    The length in hours to wait before removing an unconfirmed registration.
53                   Defaults to 24 hours if not set.
54
55     -c --confirm: Without this flag set, this script will do nothing.
56 ENDUSAGE
57
58 if ( $help || !$confirm ) {
59     print $usage;
60     exit;
61 }
62
63 cronlogaction();
64
65 my $dbh = C4::Context->dbh;
66
67 $dbh->do( "
68          DELETE FROM borrower_modifications
69          WHERE
70              borrowernumber = 0
71            AND
72              TIME_TO_SEC( TIMEDIFF( NOW(), timestamp )) / 3600 > ?
73 ", undef, $hours );