From e6a204723b0128bcd0df289d0b3a6ddaaa8bc0ce Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Fri, 17 Aug 2018 02:06:56 +1200 Subject: [PATCH] Bug 21241: Conditional to choose appropriate message_transport_type for suggestion notices Introducing a conditional into C4/Suggestions.pm to check if no patron email exists but a smsalertnumber does exist then the suggestion notice message_transport_type is set to 'sms', otherwise the suggestion message_transport_type='email'. This ensures patrons with no email address still receieve their suggestion notices because at present the message_transport_type is hardcoded to 'email'. Test plan: 1. Chose a patron who has no email address set, but does have a smsalertnumber set (this value is set in the Patron messaging preferences section after the SMSSendDriver syspref is set) 2. Log into the OPAC with that user and submit a suggestion 3. In the staff client go to Acquisitions->Suggestions and tick the suggestion and set its status to 'Accepted' 4. In the database query the message_queue and notice the message_transport_type of the message is set to 'email' even though the patron has no email address set. 5. Apply this patch, restart memcached and plack 6. Repeat steps 2,3 with the same patron and query the message_queue table again and notice this time the message_transport_type = 'sms' 7. Repeat steps 2,3 with a patron with no smsalertnumber or email address. Query the database and observe the message_transport_type=email. If no smsalertnumber is set then the message_transport_type is set to 'email' by default Sponsored-By: Brimbank Library, Australia Signed-off-by: Owen Leonard --- C4/Suggestions.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index 70b7b0d..e3a7ffd 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -503,6 +503,15 @@ sub ModSuggestion { # fetch the entire updated suggestion so that we can populate the letter my $full_suggestion = GetSuggestion( $suggestion->{suggestionid} ); my $patron = Koha::Patrons->find( $full_suggestion->{suggestedby} ); + my $transport; + + #Set message_transport_type of suggestion notice to email by default, unless the patron has a smsalertnumber set and no email address set + if ($patron->smsalertnumber && (!$patron->email)) { + $transport="sms"; + } else { + $transport="email"; + } + if ( my $letter = C4::Letters::GetPreparedLetter( module => 'suggestions', @@ -524,7 +533,7 @@ sub ModSuggestion { borrowernumber => $full_suggestion->{suggestedby}, suggestionid => $full_suggestion->{suggestionid}, LibraryName => C4::Context->preference("LibraryName"), - message_transport_type => 'email', + message_transport_type => $transport, } ) or warn "can't enqueue letter $letter"; } -- 2.1.4