Bugzilla – Attachment 155137 Details for
Bug 33239
Add the ability to run borrowers-force-messaging-defaults.pl only on a specified message name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33239: Add the ability to run borrowers-force-messaging-defaults.pl only on a specified message name
Bug-33239-Add-the-ability-to-run-borrowers-force-m.patch (text/plain), 4.22 KB, created by
Kyle M Hall (khall)
on 2023-09-01 17:03:09 UTC
(
hide
)
Description:
Bug 33239: Add the ability to run borrowers-force-messaging-defaults.pl only on a specified message name
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-09-01 17:03:09 UTC
Size:
4.22 KB
patch
obsolete
>From e7b3cf412f6a02f31895d02757502c7dca404b36 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Wed, 15 Mar 2023 16:50:40 -1000 >Subject: [PATCH] Bug 33239: Add the ability to run > borrowers-force-messaging-defaults.pl only on a specified message name > >Test plan: >1) Select a patron A >2) Change all the message prefs away from defaults. >3) Run misc/maintenance/borrowers-force-messaging-defaults.pl --doit --message-name Item_due > Verify that patron A prefs changed only for 'Item due' > >Signed-off-by: Sam Lau <samalau@gmail.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/Members/Messaging.pm | 3 +++ > .../borrowers-force-messaging-defaults.pl | 19 ++++++++++++++----- > 2 files changed, 17 insertions(+), 5 deletions(-) > >diff --git a/C4/Members/Messaging.pm b/C4/Members/Messaging.pm >index 97e72c5e3e2..25e6a04a0f1 100644 >--- a/C4/Members/Messaging.pm >+++ b/C4/Members/Messaging.pm >@@ -243,6 +243,9 @@ sub SetMessagingPreferencesFromDefaults { > > my $messaging_options = GetMessagingOptions(); > OPTION: foreach my $option ( @$messaging_options ) { >+ if ( defined $params->{message_name} && $option->{'message_name'} ne $params->{message_name} ) { >+ next OPTION; >+ } > my $default_pref = GetMessagingPreferences( { categorycode => $params->{categorycode}, > message_name => $option->{'message_name'} } ); > # FIXME - except for setting the borrowernumber, it really ought to be possible >diff --git a/misc/maintenance/borrowers-force-messaging-defaults.pl b/misc/maintenance/borrowers-force-messaging-defaults.pl >index 249b4c2e94e..9d99cb68356 100755 >--- a/misc/maintenance/borrowers-force-messaging-defaults.pl >+++ b/misc/maintenance/borrowers-force-messaging-defaults.pl >@@ -34,7 +34,7 @@ sub usage { > > > sub force_borrower_messaging_defaults { >- my ($doit, $since, $not_expired, $no_overwrite, $category, $branchcode ) = @_; >+ my ($doit, $since, $not_expired, $no_overwrite, $category, $branchcode, $message_name ) = @_; > > print "Since: $since\n" if $since; > >@@ -63,10 +63,12 @@ WHERE 1|; > while ( my ($borrowernumber, $categorycode) = $sth->fetchrow ) { > print "$borrowernumber: $categorycode\n"; > next unless $doit; >- C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { >+ my $options = { > borrowernumber => $borrowernumber, > categorycode => $categorycode, >- } ); >+ }; >+ $options->{message_name} = $message_name if defined $message_name; >+ C4::Members::Messaging::SetMessagingPreferencesFromDefaults($options); > $cnt++; > } > $dbh->commit(); >@@ -74,7 +76,7 @@ WHERE 1|; > } > > >-my ( $doit, $since, $help, $not_expired, $no_overwrite, $category, $branchcode ); >+my ( $doit, $since, $help, $not_expired, $no_overwrite, $category, $branchcode, $message_name ); > my $result = GetOptions( > 'doit' => \$doit, > 'since:s' => \$since, >@@ -82,12 +84,13 @@ my $result = GetOptions( > 'no-overwrite' => \$no_overwrite, > 'category:s' => \$category, > 'library:s' => \$branchcode, >+ 'message-name:s' => \$message_name, > 'help|h' => \$help, > ); > > usage() if $help; > >-force_borrower_messaging_defaults( $doit, $since, $not_expired, $no_overwrite, $category, $branchcode ); >+force_borrower_messaging_defaults( $doit, $since, $not_expired, $no_overwrite, $category, $branchcode, $message_name ); > > =head1 NAME > >@@ -101,6 +104,7 @@ borrowers-force-messaging-defaults.pl > borrowers-force-messaging-defaults.pl --doit --not-expired > borrowers-force-messaging-defaults.pl --doit --category PT > borrowers-force-messaging-defaults.pl --doit --library CPL >+ borrowers-force-messaging-defaults.pl --doit --message-name 'Item_Due' > > =head1 DESCRIPTION > >@@ -141,6 +145,11 @@ Will only update patrons in the category specified. > > Will only update patrons whose home library matches the given library id > >+=item B<--message-name> >+ >+Will only update the specified message name. >+List of values can be found in installer/data/mysql/mandatory/sample_notices_message_attributes.sql >+ > =item B<--since> > > Will only update borrowers enrolled since the specified date. >-- >2.30.2
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 33239
:
148249
|
148250
|
151696
| 155137 |
155138