Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# Copyright 2011, ByWater Solutions. |
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 |
|
22 |
BEGIN { |
23 |
|
24 |
# find Koha's Perl modules |
25 |
# test carefully before changing this |
26 |
use FindBin; |
27 |
eval { require "$FindBin::Bin/../kohalib.pl" }; |
28 |
} |
29 |
|
30 |
use Koha::Script -cron; |
31 |
use C4::Context; |
32 |
use Koha::Patrons; |
33 |
use Getopt::Long; |
34 |
use C4::Log; |
35 |
|
36 |
sub usage { |
37 |
print STDERR <<USAGE; |
38 |
Usage: $0 [-h|--help] |
39 |
-v --verbose gives a little more information |
40 |
-h --help prints this help message, and exits, ignoring all |
41 |
other options |
42 |
Note: If the system preference 'AnonymousPatron' is not defined, NULL will be used. |
43 |
USAGE |
44 |
exit $_[0]; |
45 |
} |
46 |
|
47 |
my ( $help, $verbose ); |
48 |
|
49 |
GetOptions( |
50 |
'h|help' => \$help, |
51 |
'v|verbose' => \$verbose, |
52 |
) || usage(1); |
53 |
|
54 |
if ($help) { |
55 |
usage(0); |
56 |
} |
57 |
|
58 |
my $pref = C4::Context->preference("AnonymizeLastBorrower"); |
59 |
|
60 |
if ( !$pref ) { |
61 |
print "Preference 'AnonymizeLastBorrower' must be enabled to anonymize item's last borrower\n\n"; |
62 |
usage(1); |
63 |
} |
64 |
|
65 |
cronlogaction(); |
66 |
|
67 |
my $rows = Koha::Patrons->anonymize_last_borrowers(); |
68 |
$verbose and print int($rows) . " item's last borrowers anonymized.\n"; |
69 |
|
70 |
exit(0); |