Bugzilla – Attachment 173821 Details for
Bug 30300
Add patron expiration email to patron messaging preferences
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30300: Update the cronjob to respect patron messaging preferences
Bug-30300-Update-the-cronjob-to-respect-patron-mes.patch (text/plain), 4.82 KB, created by
Nick Clemens (kidclamp)
on 2024-10-31 16:57:08 UTC
(
hide
)
Description:
Bug 30300: Update the cronjob to respect patron messaging preferences
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-10-31 16:57:08 UTC
Size:
4.82 KB
patch
obsolete
>From 984771638fbda475bcc0af405fc3d2f22fe3488f Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Mon, 29 Jul 2024 13:12:12 +0000 >Subject: [PATCH] Bug 30300: Update the cronjob to respect patron messaging > preferences > >Test plan: >1) Apply patch and run updatedatabase >2) In system preferences set MembershipExpiryDaysNotice to 5 >3) Choose a patron and edit their expiry date to today's date >4) Ensure that patron has a primary email address >5) Run perl misc/cronjobs/membership_expiry.pl -c -v -before 10 -after 10 >6) Check the patron's messages, there should be no expiry notice queued >7) Edit the patron's messaging preferences and select the checkbox for email in the row for 'Patron expiry' >8) Repeat step 5 >9) There should be a patron expiry message in the patron's message queue >10) Sign off! > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > misc/cronjobs/membership_expiry.pl | 77 +++++++++++++----------------- > 1 file changed, 32 insertions(+), 45 deletions(-) > >diff --git a/misc/cronjobs/membership_expiry.pl b/misc/cronjobs/membership_expiry.pl >index 3d0a53a05e1..d2cd0a6595d 100755 >--- a/misc/cronjobs/membership_expiry.pl >+++ b/misc/cronjobs/membership_expiry.pl >@@ -253,69 +253,56 @@ warn 'found ' . $upcoming_mem_expires->count . ' soon expiring members' > > # main loop > my ( $count_skipped, $count_renewed, $count_enqueued ) = ( 0, 0, 0 ); >-while ( my $recent = $upcoming_mem_expires->next ) { >- if ( $active && !$recent->is_active( { months => $active } ) ) { >+while ( my $expiring_patron = $upcoming_mem_expires->next ) { >+ if ( $active && !$expiring_patron->is_active( { months => $active } ) ) { > $count_skipped++; > next; >- } elsif ( $inactive && $recent->is_active( { months => $inactive } ) ) { >+ } elsif ( $inactive && $expiring_patron->is_active( { months => $inactive } ) ) { > $count_skipped++; > next; > } > >+ my $messaging_prefs = C4::Members::Messaging::GetMessagingPreferences( >+ { >+ borrowernumber => $expiring_patron->borrowernumber, >+ message_name => "Patron_Expiry", >+ } >+ ); >+ my @message_transports = ( keys %{ $messaging_prefs->{transports} } ); >+ my $letter_code = $messaging_prefs->{letter_code}; >+ >+ # Skip this patron if they don't want a notification email for card expiry >+ next if !$messaging_prefs; >+ > my $which_notice; > if ($renew) { >- $recent->renew_account; >+ $expiring_patron->renew_account; > $which_notice = $letter_renew; > $count_renewed++; > } else { >- $which_notice = $letter_expiry; >+ $which_notice = $letter_code || $letter_expiry; > } > >- my $from_address = $recent->library->from_email_address; >- my $letter = C4::Letters::GetPreparedLetter( >+ my $from_address = $expiring_patron->library->from_email_address; >+ my $letter_params = { > module => 'members', > letter_code => $which_notice, >- branchcode => $recent->branchcode, >- lang => $recent->lang, >+ branchcode => $expiring_patron->branchcode, >+ lang => $expiring_patron->lang, >+ borrowernumber => $expiring_patron->borrowernumber, > tables => { >- borrowers => $recent->borrowernumber, >- branches => $recent->branchcode, >+ borrowers => $expiring_patron->borrowernumber, >+ branches => $expiring_patron->branchcode, > }, >- ); >- last if !$letter; # Letters.pm already warned, just exit >- if ($nomail) { >- print $letter->{'content'}."\n"; >- next; >- } >+ }; > >- C4::Letters::EnqueueLetter({ >- letter => $letter, >- borrowernumber => $recent->borrowernumber, >- from_address => $from_address, >- message_transport_type => 'email', >- }); >- $count_enqueued++; >- >- if ($recent->smsalertnumber) { >- my $smsletter = C4::Letters::GetPreparedLetter( >- module => 'members', >- letter_code => $which_notice, >- branchcode => $recent->branchcode, >- lang => $recent->lang, >- tables => { >- borrowers => $recent->borrowernumber, >- branches => $recent->branchcode, >- }, >- message_transport_type => 'sms', >- ); >- if ($smsletter) { >- C4::Letters::EnqueueLetter({ >- letter => $smsletter, >- borrowernumber => $recent->borrowernumber, >- message_transport_type => 'sms', >- }); >- } >- } >+ my $sending_params = { >+ letter_params => $letter_params, >+ message_name => 'Patron_Expiry', >+ }; >+ >+ my $result = $expiring_patron->queue_notice($sending_params); >+ $count_enqueued++ if $result->{sent}; > } > > if ($verbose) { >-- >2.39.5
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 30300
:
169860
|
169861
|
169870
|
169871
|
173810
|
173811
|
173812
|
173820
|
173821
|
173822
|
173823
|
174713
|
174714
|
174715
|
174716
|
174717