Bugzilla – Attachment 90849 Details for
Bug 23170
in j2a.pl when a patron passes to an adult the name and surname of Guarantor stay on account
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
add anonymize option to j2a.pl
0001-PATCH-Bug-23170-add-anonymize-option-to-j2a.pl.patch (text/plain), 5.96 KB, created by
Christophe Croullebois
on 2019-06-20 14:09:52 UTC
(
hide
)
Description:
add anonymize option to j2a.pl
Filename:
MIME Type:
Creator:
Christophe Croullebois
Created:
2019-06-20 14:09:52 UTC
Size:
5.96 KB
patch
obsolete
>From 721896a6b5a9933ea81fb8b7be921e1915d176e5 Mon Sep 17 00:00:00 2001 >From: Christophe Croullebois <christophe.croullebois@biblibre.com> >Date: Thu, 20 Jun 2019 15:30:21 +0200 >Subject: [PATCH 1/1] [PATCH] Bug 23170: add anonymize option to j2a.pl > >--- > misc/cronjobs/j2a.pl | 104 +++++++++++++++++++++++++++++++------------ > 1 file changed, 75 insertions(+), 29 deletions(-) > >diff --git a/misc/cronjobs/j2a.pl b/misc/cronjobs/j2a.pl >index cdbb8f81ed..182fc404c0 100755 >--- a/misc/cronjobs/j2a.pl >+++ b/misc/cronjobs/j2a.pl >@@ -46,6 +46,7 @@ juv2adult.pl [ -b=<branchcode> -f=<categorycode> -t=<categorycode> ] > --man full documentation > -v verbose mode > -n take no action, display only >+ -a anonymize, delete mame, surname, title of the guarantor > -b <branchname> only deal with patrons from this library/branch > -f <categorycode> change patron category from this category > -t <categorycode> change patron category to this category >@@ -70,6 +71,10 @@ Verbose. Without this flag set, only fatal errors are reported. > > No Action. With this flag set, script will report changes but not actually execute them on the database. > >+=item B<-a> >+ >+Anonymize. With this flag set, script will delete contactname, contactfirstname, contacttitle in the database. >+ > =item B<-b> > > changes patrons for one specific branch. Use the value in the >@@ -101,10 +106,11 @@ C<juv2adult.pl> -f=<categorycode> -t=<categorycode> -v -n - Processes all branch > # These variables are set by command line options. > # They are initially set to default values. > >-my $help = 0; >-my $man = 0; >-my $verbose = 0; >-my $noaction = 0; >+my $help = 0; >+my $man = 0; >+my $verbose = 0; >+my $noaction = 0; >+my $anonymize = 0; > my $mybranch; > my $fromcat; > my $tocat; >@@ -114,6 +120,7 @@ GetOptions( > 'man' => \$man, > 'v' => \$verbose, > 'n' => \$noaction, >+ 'a' => \$anonymize, > 'f=s' => \$fromcat, > 't=s' => \$tocat, > 'b=s' => \$mybranch, >@@ -166,19 +173,39 @@ my $itsyourbirthday = "$year-$mon-$mday"; > if ( not $noaction ) { > if ($mybranch) { #yep, we received a specific branch to work on. > $verbose and print "Looking for patrons of $mybranch to update from $fromcat to $tocat that were born before $itsyourbirthday\n"; >- my $query = qq| >- UPDATE borrowers >- SET guarantorid ='0', >- categorycode = ? >- WHERE dateofbirth <= ? >- AND dateofbirth != '0000-00-00' >- AND branchcode = ? >- AND categorycode IN ( >- SELECT categorycode >- FROM categories >- WHERE category_type = 'C' >- AND categorycode = ? >- )|; >+ if ($anonymize) { >+ my $query = qq| >+ UPDATE borrowers >+ SET guarantorid ='0', >+ contactname = NULL, >+ contactfirstname = NULL, >+ contacttitle = NULL, >+ categorycode = ? >+ WHERE dateofbirth <= ? >+ AND dateofbirth != '0000-00-00' >+ AND branchcode = ? >+ AND categorycode IN ( >+ SELECT categorycode >+ FROM categories >+ WHERE category_type = 'C' >+ AND categorycode = ? >+ )|; >+ } >+ else { >+ my $query = qq| >+ UPDATE borrowers >+ SET guarantorid ='0', >+ categorycode = ? >+ WHERE dateofbirth <= ? >+ AND dateofbirth != '0000-00-00' >+ AND branchcode = ? >+ AND categorycode IN ( >+ SELECT categorycode >+ FROM categories >+ WHERE category_type = 'C' >+ AND categorycode = ? >+ )|; >+ } > my $sth = $dbh->prepare($query); > my $res = $sth->execute( $tocat, $itsyourbirthday, $mybranch, $fromcat ) > or die "can't execute"; >@@ -192,18 +219,37 @@ if ( not $noaction ) { > } > else { # branch was not supplied, processing all branches > $verbose and print "Looking in all branches for patrons to update from $fromcat to $tocat that were born before $itsyourbirthday\n"; >- my $query = qq| >- UPDATE borrowers >- SET guarantorid = '0', >- categorycode = ? >- WHERE dateofbirth <= ? >- AND dateofbirth!='0000-00-00' >- AND categorycode IN ( >- SELECT categorycode >- FROM categories >- WHERE category_type = 'C' >- AND categorycode = ? >- )|; >+ if ($anonymize) { >+ my $query = qq| >+ UPDATE borrowers >+ SET guarantorid = '0', >+ contactname = NULL, >+ contactfirstname = NULL, >+ contacttitle = NULL, >+ categorycode = ? >+ WHERE dateofbirth <= ? >+ AND dateofbirth!='0000-00-00' >+ AND categorycode IN ( >+ SELECT categorycode >+ FROM categories >+ WHERE category_type = 'C' >+ AND categorycode = ? >+ )|; >+ } >+ else { >+ my $query = qq| >+ UPDATE borrowers >+ SET guarantorid = '0', >+ categorycode = ? >+ WHERE dateofbirth <= ? >+ AND dateofbirth!='0000-00-00' >+ AND categorycode IN ( >+ SELECT categorycode >+ FROM categories >+ WHERE category_type = 'C' >+ AND categorycode = ? >+ )|; >+ } > my $sth = $dbh->prepare($query); > my $res = $sth->execute( $tocat, $itsyourbirthday, $fromcat ) > or die "can't execute"; >-- >2.17.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 23170
: 90849