Bugzilla – Attachment 18677 Details for
Bug 10419
There is no cronjob script for deleting patrons
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10419: Script for deleting patrons
Bug-10419-Script-for-deleting-patrons.patch (text/plain), 3.78 KB, created by
Jonathan Druart
on 2013-06-05 14:34:29 UTC
(
hide
)
Description:
Bug 10419: Script for deleting patrons
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-06-05 14:34:29 UTC
Size:
3.78 KB
patch
obsolete
>From dd8a6b8ff5e36a2b741a6df089843ecb49bf0bef Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 5 Jun 2013 16:26:31 +0200 >Subject: [PATCH] Bug 10419: Script for deleting patrons > >This patch provides a cronjob script for deleting patrons. > >It takes 3 options: >-not_borrowered_since >-expired_date >-category_code > >See the perldoc misc/cronjobs/delete_patrons.pl >use the -v flag for a verbose mode. >--- > misc/cronjobs/delete_patrons.pl | 125 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 125 insertions(+) > create mode 100644 misc/cronjobs/delete_patrons.pl > >diff --git a/misc/cronjobs/delete_patrons.pl b/misc/cronjobs/delete_patrons.pl >new file mode 100644 >index 0000000..8874b0f >--- /dev/null >+++ b/misc/cronjobs/delete_patrons.pl >@@ -0,0 +1,125 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use Pod::Usage; >+use Getopt::Long; >+ >+use C4::Members; >+use Koha::DateUtils; >+ >+my ( $help, $verbose, $not_borrowered_since, $expired_before, $category_code, >+ $dryrun ); >+GetOptions( >+ 'h|help' => \$help, >+ 'v|verbose' => \$verbose, >+ 'not_borrowered_since:s' => \$not_borrowered_since, >+ 'expired_before:s' => \$expired_before, >+ 'category_code:s' => \$category_code, >+ 'dry-run' => \$dryrun, >+) || pod2usage(1); >+ >+if ($help) { >+ pod2usage(1); >+} >+ >+$not_borrowered_since = dt_from_string( $not_borrowered_since, 'iso' ) >+ if $not_borrowered_since; >+ >+$expired_before = dt_from_string( $expired_before, 'iso' ) >+ if $expired_before; >+ >+unless ( $not_borrowered_since or $expired_before or $category_code ) { >+ pod2usage(q{At least one filter is mandatory}); >+ exit; >+} >+ >+my $members = GetBorrowersToExpunge( >+ { >+ not_borrowered_since => $not_borrowered_since, >+ expired_before => $expired_before, >+ category_code => $category_code, >+ } >+); >+ >+say "I found " . scalar(@$members) . " patrons to delete"; >+for my $member (@$members) { >+ print "Trying delete patron " . $member->{borrowernumber} . "... "; >+ eval { >+ C4::Members::MoveMemberToDeleted( $member->{borrowernumber} ) >+ unless $dryrun; >+ }; >+ unless ($@) { >+ eval { >+ C4::Members::DelMember( $member->{borrowernumber} ) >+ unless $dryrun; >+ }; >+ unless ($@) { >+ say "OK"; >+ next; >+ } >+ say "Failed, I cannot delete this patron ($@)"; >+ } >+ say "Failed, I cannot move this patron ($@)"; >+} >+ >+=head1 NAME >+ >+delete_patrons - This script deletes patrons >+ >+=head1 SYNOPSIS >+ >+delete_patrons.pl [-h -v] --not_borrowered_since=`date -d '-3 month' "+%Y-%m-%d"` --expired_before=`date -d '-3 month' "+%Y-%m-%d"` --category_code=CAT >+ >+Options are cumulatives. >+ >+=head1 OPTIONS >+ >+=over >+ >+=item B<-h|--help> >+ >+Print a brief help message >+ >+=item B<--not_borrowered_since> >+ >+Delete patrons who have not borrowered since this date. >+ >+=item B<--expired_date> >+ >+Delete patrons with an account expired before this date. >+ >+=item B<--category_code> >+ >+Delete patrons who have this category code. >+ >+=item B<--dry-run> >+ >+Dry run mode. To use with the verbose mode. >+ >+=item B<-v|--verbose> >+ >+Verbose mode. >+ >+=back >+ >+=head1 AUTHOR >+ >+Jonathan Druart <jonathan.druart@biblibre.com> >+ >+=head1 COPYRIGHT >+ >+Copyright 2013 BibLibre >+ >+=head1 LICENSE >+ >+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 2 of the License, or (at your option) any later version. >+ >+You should have received a copy of the GNU General Public License along >+with Koha; if not, write to the Free Software Foundation, Inc., >+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+=cut >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 10419
:
18677
|
18725
|
18743
|
18754
|
18990
|
19635
|
19651
|
20112
|
20113
|
20114
|
20115
|
20133
|
20134
|
20135
|
20136
|
20137
|
20138
|
20294
|
20295
|
20296
|
20297
|
21658
|
21765
|
21766
|
21773
|
21774
|
21780
|
21781
|
21782
|
21783
|
21784
|
21785
|
21786
|
21787