Bugzilla – Attachment 4290 Details for
Bug 5636
clean borrowers run from command line
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
BZ5636 MT#4916 permit tools/cleanborrowers.pl to be used by command line
BZ5636-MT4916-permit-toolscleanborrowerspl-to-be-u.patch (text/plain), 3.22 KB, created by
Chris Cormack
on 2011-05-29 07:45:12 UTC
(
hide
)
Description:
BZ5636 MT#4916 permit tools/cleanborrowers.pl to be used by command line
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2011-05-29 07:45:12 UTC
Size:
3.22 KB
patch
obsolete
>From 5b025a79d7c15d7209da23ef1941add8f228371a Mon Sep 17 00:00:00 2001 >From: Paul Poulain <paul.poulain@biblibre.com> >Date: Wed, 19 Jan 2011 21:58:53 +0100 >Subject: [PATCH] BZ5636 MT#4916 permit tools/cleanborrowers.pl to be used by command line > >This patchs adds the possibility to run the script by command line. > >Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> >--- > tools/cleanborrowers.pl | 69 +++++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 69 insertions(+), 0 deletions(-) > >diff --git a/tools/cleanborrowers.pl b/tools/cleanborrowers.pl >index 4fde0f2..cd99190 100755 >--- a/tools/cleanborrowers.pl >+++ b/tools/cleanborrowers.pl >@@ -41,6 +41,75 @@ use C4::Dates qw/format_date format_date_in_iso/; > use C4::Members; # GetBorrowersWhoHavexxxBorrowed. > use C4::Circulation; # AnonymiseIssueHistory. > use Date::Calc qw/Today Add_Delta_YM/; >+use Getopt::Long; >+ >+if ( scalar @ARGV > 0 ) { >+ my ($untildate, $delete, $full, $anonymize, $help, $test); >+ my ($totalDel, $totalAno, $membersToDelete, $membersToAnonymize) = (0,0,0,0); >+ GetOptions( 'until=s' => \$untildate, >+ 'delete' => \$delete, >+ 'anonymize' => \$anonymize, >+ 'full' => \$full, >+ 'help|h' => \$help, >+ 'test|t' => \$test, >+ ); >+ >+ if($help or not $untildate){ >+ print <<EOF >+ This script anonymize history, and delete olds borrowers. >+ Parameters : >+ -delete to delete borrowers that have not borrowed until the specified date >+ -full do not move borrowers to deletedborrowers, delete really from the database. >+ -anonymize to anonmize history of borrowers until the specified date >+ -until=s date until to clean borrowers and/or history >+ -test|t to test and do not delete anything >+ -help|h this help >+ >+ example : >+ export PERL5LIB=/path/to/koha;export KOHA_CONF=/etc/koha/koha-conf.xml; ./tools/cleanborrowers.pl -delete -anonymize -until 2009-01-01 >+EOF >+; >+ exit; >+ } >+ if($delete){ >+ $membersToDelete = GetBorrowersWhoHaveNotBorrowedSince($untildate, 1); >+ $totalDel = scalar @$membersToDelete; >+ } >+ if($anonymize){ >+ $membersToAnonymize = GetBorrowersWithIssuesHistoryOlderThan($untildate); >+ $totalAno = scalar @$membersToAnonymize; >+ } >+ >+ print <<EOF >+ Anonymization Report: >+ * $totalDel patrons will be deleted >+ * $totalAno check-out history will be anonymized >+EOF >+; >+ exit if $test; >+ >+ if($delete){ >+ print "Deleting patrons...\n"; >+ if($full){ >+ foreach my $member (@$membersToDelete){ >+ DelMember( $member->{'borrowernumber'} ); >+ } >+ }else{ >+ foreach my $member (@$membersToDelete){ >+ MoveMemberToDeleted( $member->{'borrowernumber'} ); >+ DelMember( $member->{'borrowernumber'} ); >+ } >+ } >+ } >+ >+ if($anonymize){ >+ print "Anonimyzing check-out history...\n"; >+ AnonymiseIssueHistory($untildate); >+ } >+ >+ print "Cleaning borrowers successfully finished.\n"; >+ exit; >+} > > my $cgi = new CGI; > >-- >1.7.4.1
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 5636
: 4290