Bugzilla – Attachment 109559 Details for
Bug 21781
message_transport_type should allow fallbacks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21781: Fallback to SMS if no email address where email address hardcoded
Bug-21781-Fallback-to-SMS-if-no-email-address-wher.patch (text/plain), 11.24 KB, created by
Alex Buckley
on 2020-09-02 21:20:54 UTC
(
hide
)
Description:
Bug 21781: Fallback to SMS if no email address where email address hardcoded
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2020-09-02 21:20:54 UTC
Size:
11.24 KB
patch
obsolete
>From 96cb44906df6be2e5db2e00df309ee9c2cda9bb0 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Wed, 22 Apr 2020 02:46:02 +0000 >Subject: [PATCH] Bug 21781: Fallback to SMS if no email address where email > address hardcoded > >Extend use of FallbackToSMSIfNoEmail syspref to fallback to SMS if no >patron email address outside of it's current usage sending suggestion >notices. > >Test plan for C4/Acquisition.pm: >1. Input a value into SMSSendDriver syspref >2. Create a patron with sms (under Member messaging preferences) and no email address >3. In Acquistions module make currency, active budget, fund, vendor >4. Create a basket >5. Add to basket. Click to add 'From a new (empty) record' >6. Under 'Patrons' header add a user and search for your patron (added >in #1) >7. Submit new order >8. Receive the order: >'Close this basket' >'Receive shipment' >Submit invoice page >Select 'Receive' link on right hand side of page >Tick checkbox to add 1 quantity of item and Save >9. Revisit your patrons page and in the 'Notices' tab you'll see a >'Order received' notice with type of 'email' >11. Apply patch and restart plack >12. Repeat steps 4-9 and observe the 'Order received' notice has a type >of SMS > >Test plan for amendment to circ/pendingreserves.pl (patch has been >applied in 'Test plan for C4/Acquisition.pm): >1. Set 'FallbackToSMSIfNoEmail' syspref to 'Disable' >2. Set CanMarkHoldsToPullAsLost syspref to 'Allow to mark items as lost >and notify the patron' >3. Using the patron from test plan for C4/Acquisitions.pm (i.e. sms alert >number and no email) place a hold on an item currently available >4. Visit Circulation > Holds to pull >5. Select 'Mark lost and notify patron' >6. Return to patron page look in 'Notices' tab and observe 'Hold has >been cancelled' notice has type of 'email' >7. Change 'FallbackToSMSIfNoEmail' to 'Enable' and repeat steps 3,4,5,6 >and observe the new 'Hold has been cancelled' notice has type 'sms' > >Test plan for amendment to misc/cronjobs/automatic_renewals.pl (patch >has been applied already): >1. Set 'FallbackToSMSIfNoEmail' syspref to 'Disable' >2. Enable automatic renewals in Administration > Circulation and fine >rules >3. Checkout an item to our patron and set due date in the past >4. cd into misc/cronjobs >5. Jump into koha-shell and run automatic_renewals.pl cronjob >sudo koha-shell <instancename> >./automatic_renewals.pl --confirm --send-notices >6. Observe in patron records 'Notices' tab there is a 'Auto renewals' >notice with type 'email' >7. Set 'FallbackToSMSIfNoEmail' syspref to 'Enable' and repeat steps >3,4,5,6 and observe the new 'Auto renewals' notice is type 'sms' > >Test plan for amendment to misc/cronjobs/membership_expiry.pl (patch has >been applied already): >1. Set 'FallbackToSMSIfNoEmail' syspref to 'Disable' >2. Set 'MembershipExpiryDaysNotice' to '1' >3. Edit our patrons record setting 'Expiry date' to 1 day in future >4. cd to misc/cronjobs directory >5. Jump into koha-shell and run membership_expiry.pl cronjob: >sudo koha-shell <instancename> >./membership_expiry.pl -c >6. Visit the patron record's 'Notices' tab and observe 'Account >expiration' notice with type 'email' >7. Change 'FallbackToSMSIfNoEmail' syspref to 'Enable' >8. Reset patrons epxiration date to 1 day in future >9. Repeat step 4,5,6 and observe new 'Account expiration' notice is type >'sms' > >Test plan for opac/opac-shareshelf.pl (patch has been applied already): >1. Set 'FallbackToSMSIfNoEmail' syspref to 'Disable' >2. Set 'OpacAllowSharingPrivateLists' syspref to 'Allow' >3. Ensure OPACBaseURL is set >4. In OPAC log in as the patron with set smsalertnumber and no email >5. Create a private list, select 'Share' link, input email >address and submit >6. Back in staff client make a new patron record >7. Return to OPAC and login as patron from step #5 >8. Query database: >select content from message_queue where letter_code='SHARE_INVITE'; >9. Click on the link in the message_queue notice >10. OPAC loads >11. Query database again: >select to_address, message_transport_type from >message_queue where letter_code='SHARE_ACCEPT'; >12. Observe there is no 'Share on list <listname> accepted' notice >13. Set 'FallbackToSMSIfNoEmail' to 'Enable' and repeat steps 4,5,7,8, >9,10,11,12 and observe there is a 'Share on list <listname> accepted' >notice with to_address = smsalertnumber and message_transport_type is 'sms' > >14. Set 'FallbackToSMSIfNoEmail' to 'disable' and edit the patron with >smsalertnumber set and no email setting an email address and repeat >steps 4,5,7,8,9,10,11,12 and observe there is a 'Share on list ><listname> accepted' notice with the to_address of the email you set and >message_transport_type of 'email' > >Sponsored-by: Catalyst IT >--- > C4/Acquisition.pm | 5 ++++- > circ/pendingreserves.pl | 4 +++- > .../prog/en/modules/admin/preferences/patrons.pref | 12 ++++++------ > misc/cronjobs/automatic_renewals.pl | 4 +++- > misc/cronjobs/membership_expiry.pl | 5 ++++- > opac/opac-shareshelf.pl | 9 +++++++-- > 6 files changed, 27 insertions(+), 12 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 3aff14d6674..babf640ba64 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -3050,12 +3050,15 @@ sub NotifyOrderUsers { > }, > ); > if ( $letter ) { >+ >+ my $transport = (C4::Context->preference("FallbackToSMSIfNoEmail")) && ($patron->smsalertnumber) && (!$patron->email) ? 'sms' : 'email'; >+ > C4::Letters::EnqueueLetter( > { > letter => $letter, > borrowernumber => $borrowernumber, > LibraryName => C4::Context->preference("LibraryName"), >- message_transport_type => 'email', >+ message_transport_type => $transport, > } > ) or warn "can't enqueue letter $letter"; > } >diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl >index 24d4f67f560..1a4362a7915 100755 >--- a/circ/pendingreserves.pl >+++ b/circ/pendingreserves.pl >@@ -86,10 +86,12 @@ if ( $op eq 'cancel_reserve' and $reserve_id ) { > if ( $letter ) { > my $admin_email_address = $library->branchemail || C4::Context->preference('KohaAdminEmailAddress'); > >+ my $transport = (C4::Context->preference("FallbackToSMSIfNoEmail")) && ($patron->smsalertnumber) && (!$patron->email) ? 'sms' : 'email'; >+ > C4::Letters::EnqueueLetter( > { letter => $letter, > borrowernumber => $patron->borrowernumber, >- message_transport_type => 'email', >+ message_transport_type => $transport, > from_address => $admin_email_address, > } > ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >index fc8e8b6c7e9..89c832701a6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >@@ -136,6 +136,12 @@ Patrons: > no: "Don't send" > - an email to newly created patrons with their account details. > - >+ - pref: FallbackToSMSIfNoEmail >+ choices: >+ yes: Enable >+ no: Disable >+ - Send notices by SMS if no patron email is defined. >+ - > - pref: UseEmailReceipts > choices: > yes: Send >@@ -171,12 +177,6 @@ Patrons: > - ". Override from address with" > - pref: EmailSMSSendDriverFromAddress > - "for emails sent using \"Email\" send driver." >- - >- - pref: FallbackToSMSIfNoEmail >- choices: >- yes: Enable >- no: Disable >- - sending purchase suggestion messages by SMS if no patron email is defined. > Patron forms: > - > - "The following <a href='http://schema.koha-community.org/__VERSION__/tables/borrowers.html' target='blank'>database columns</a> must be filled in on the patron entry screen:" >diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl >index a76f7dfb355..3704a58f694 100755 >--- a/misc/cronjobs/automatic_renewals.pl >+++ b/misc/cronjobs/automatic_renewals.pl >@@ -140,10 +140,12 @@ if ( $send_notices ) { > my $library = Koha::Libraries->find( $patron->branchcode ); > my $admin_email_address = $library->branchemail || C4::Context->preference('KohaAdminEmailAddress'); > >+ my $transport = (C4::Context->preference("FallbackToSMSIfNoEmail")) && ($patron->smsalertnumber) && (!$patron->email) ? 'sms' : 'email'; >+ > C4::Letters::EnqueueLetter( > { letter => $letter, > borrowernumber => $borrowernumber, >- message_transport_type => 'email', >+ message_transport_type => $transport, > from_address => $admin_email_address, > } > ) if $confirm; >diff --git a/misc/cronjobs/membership_expiry.pl b/misc/cronjobs/membership_expiry.pl >index 5038ce1f9f1..b804fd16240 100755 >--- a/misc/cronjobs/membership_expiry.pl >+++ b/misc/cronjobs/membership_expiry.pl >@@ -198,11 +198,14 @@ while ( my $recent = $upcoming_mem_expires->next ) { > if( $nomail ) { > print $letter->{'content'}."\n"; > } else { >+ >+ my $transport = (C4::Context->preference("FallbackToSMSIfNoEmail")) && ($recent->smsalertnumber) && (!$recent->email) ? 'sms' : 'email'; >+ > C4::Letters::EnqueueLetter({ > letter => $letter, > borrowernumber => $recent->borrowernumber, > from_address => $from_address, >- message_transport_type => 'email', >+ message_transport_type => $transport, > }); > } > } >diff --git a/opac/opac-shareshelf.pl b/opac/opac-shareshelf.pl >index 34a17788ed6..32bff2cf20d 100755 >--- a/opac/opac-shareshelf.pl >+++ b/opac/opac-shareshelf.pl >@@ -165,8 +165,12 @@ sub notify_owner { > my $patron = Koha::Patrons->find( $param->{owner} ); > return unless $patron; > >- my $toaddr = $patron->notice_email_address or return; >+ my $transport = (C4::Context->preference("FallbackToSMSIfNoEmail")) && ($patron->smsalertnumber) && (!$patron->email) ? 'sms' : 'email'; > >+ warn $transport; >+ my $toaddr = $transport eq 'sms' ? $patron->smsalertnumber : $patron->notice_email_address or return; >+ >+ warn $toaddr; > #prepare letter > my $letter = C4::Letters::GetPreparedLetter( > module => 'members', >@@ -181,7 +185,7 @@ sub notify_owner { > C4::Letters::EnqueueLetter( > { > letter => $letter, >- message_transport_type => 'email', >+ message_transport_type => $transport, > from_address => C4::Context->preference('KohaAdminEmailAddress'), > to_address => $toaddr, > } >@@ -209,6 +213,7 @@ sub process_addrlist { > > sub send_invitekey { > my ($param) = @_; >+ > my $fromaddr = C4::Context->preference('KohaAdminEmailAddress'); > my $url = > C4::Context->preference('OPACBaseURL') >-- >2.11.0
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 21781
:
103525
|
103526
|
105328
|
109559
|
124868
|
124869
|
168199
|
168200
|
168201