diff --git a/debian/koha-common.cron.daily b/debian/koha-common.cron.daily index f7105f6896..134858f4a3 100644 --- a/debian/koha-common.cron.daily +++ b/debian/koha-common.cron.daily @@ -32,3 +32,4 @@ koha-foreach --chdir --enabled --noemail /usr/share/koha/bin/cronjobs/cleanup_da koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/holds/auto_unsuspend_holds.pl > /dev/null 2>&1 koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/merge_authorities.pl -b koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/plugins_nightly.pl +koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/anonymize_last_borrowers.pl diff --git a/misc/cronjobs/anonymize_last_borrowers.pl b/misc/cronjobs/anonymize_last_borrowers.pl new file mode 100755 index 0000000000..28de63a1f9 --- /dev/null +++ b/misc/cronjobs/anonymize_last_borrowers.pl @@ -0,0 +1,70 @@ +#!/usr/bin/perl + +# Copyright 2011, ByWater Solutions. +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +BEGIN { + + # find Koha's Perl modules + # test carefully before changing this + use FindBin; + eval { require "$FindBin::Bin/../kohalib.pl" }; +} + +use Koha::Script -cron; +use C4::Context; +use Koha::Patrons; +use Getopt::Long; +use C4::Log; + +sub usage { + print STDERR < \$help, + 'v|verbose' => \$verbose, +) || usage(1); + +if ($help) { + usage(0); +} + +my $pref = C4::Context->preference("AnonymizeLastBorrower"); + +if ( !$pref ) { + print "Preference 'AnonymizeLastBorrower' must be enabled to anonymize item's last borrower\n\n"; + usage(1); +} + +cronlogaction(); + +my $rows = Koha::Patrons->anonymize_last_borrowers(); +$verbose and print int($rows) . " item's last borrowers anonymized.\n"; + +exit(0);