View | Details | Raw Unified | Return to bug 21241
Collapse All | Expand All

(-)a/C4/Suggestions.pm (-2 / +2 lines)
Lines 504-511 sub ModSuggestion { Link Here
504
        my $full_suggestion = GetSuggestion( $suggestion->{suggestionid} );
504
        my $full_suggestion = GetSuggestion( $suggestion->{suggestionid} );
505
        my $patron = Koha::Patrons->find( $full_suggestion->{suggestedby} );
505
        my $patron = Koha::Patrons->find( $full_suggestion->{suggestedby} );
506
        my $transport;
506
        my $transport;
507
        #If MessageTransportTypeFallbackToSMSIfNoPatronEmail syspref is enabled and the patron has a smsalertnumber but no email address then set message_transport_type of suggestion notice to sms
507
        #If FallbackToSMSIfNoEmail syspref is enabled and the patron has a smsalertnumber but no email address then set message_transport_type of suggestion notice to sms
508
        if (C4::Context->preference("MessageTransportTypeFallbackToSMSIfNoPatronEmail")) {
508
        if (C4::Context->preference("FallbackToSMSIfNoEmail")) {
509
            if (($patron->smsalertnumber) && (!$patron->email)) {
509
            if (($patron->smsalertnumber) && (!$patron->email)) {
510
                $transport="sms";
510
                $transport="sms";
511
            } else {
511
            } else {
(-)a/installer/data/mysql/atomicupdate/bug_21241-add_syspref_to_control_fallback_to_sms_if_no_email_defined.sql (-1 / +1 lines)
Line 1 Link Here
1
INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('MessageTransportTypeFallbackToSMSIfNoPatronEmail', 0, 'Enable|Disable', 'Send messages by SMS if no patron email is defined', 'YesNo');
1
INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('FallbackToSMSIfNoEmail', 0, 'Enable|Disable', 'Send messages by SMS if no patron email is defined', 'YesNo');
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-1 / +1 lines)
Lines 7-13 Patrons: Link Here
7
               no: "Don't send"
7
               no: "Don't send"
8
         - an email to newly created patrons with their account details.
8
         - an email to newly created patrons with their account details.
9
     -
9
     -
10
         - pref: MessageTransportTypeFallbackToSMSIfNoPatronEmail
10
         - pref: FallbackToSMSIfNoEmail
11
           choices:
11
           choices:
12
               yes: Enable
12
               yes: Enable
13
               no: Disable
13
               no: Disable
(-)a/t/db_dependent/Suggestions.t (-10 / +9 lines)
Lines 209-216 my $mod_suggestion3 = { Link Here
209
209
210
#Test the message_transport_type of suggestion notices
210
#Test the message_transport_type of suggestion notices
211
211
212
#Check the message_transport_type when the 'MessageTransportTypeFallbackToSMSIfNoPatronEmail' syspref is disabled
212
#Check the message_transport_type when the 'FallbackToSMSIfNoEmail' syspref is disabled
213
t::lib::Mocks::mock_preference( 'MessageTransportTypeFallbackToSMSIfNoPatronEmail', 0 );
213
t::lib::Mocks::mock_preference( 'FallbackToSMSIfNoEmail', 0 );
214
$status = ModSuggestion($mod_suggestion3);
214
$status = ModSuggestion($mod_suggestion3);
215
is( $status, 1, 'ModSuggestion modifies one entry' );
215
is( $status, 1, 'ModSuggestion modifies one entry' );
216
$suggestion = GetSuggestion($my_suggestionid);
216
$suggestion = GetSuggestion($my_suggestionid);
Lines 219-240 $messages = C4::Letters::GetQueuedMessages({ Link Here
219
    borrowernumber => $borrowernumber,
219
    borrowernumber => $borrowernumber,
220
});
220
});
221
is( @$messages, 1, 'ModSuggestion sends an email if the status is updated' );
221
is( @$messages, 1, 'ModSuggestion sends an email if the status is updated' );
222
is ($messages->[0]->{message_transport_type}, 'email', 'When MessageTransportTypeFallbackToSMSIfNoPatronEmail syspref is disabled the suggestion message_transport_type is always email');
222
is ($messages->[0]->{message_transport_type}, 'email', 'When FallbackToSMSIfNoEmail syspref is disabled the suggestion message_transport_type is always email');
223
is( CountSuggestion('CHECKED'), 1, 'CountSuggestion returns the correct number of suggestions' );
223
is( CountSuggestion('CHECKED'), 1, 'CountSuggestion returns the correct number of suggestions' );
224
224
225
#Check the message_transport_type when the 'MessageTransportTypeFallbackToSMSIfNoPatronEmail' syspref is enabled and the borrower has a smsalertnumber and no email
225
#Check the message_transport_type when the 'FallbackToSMSIfNoEmail' syspref is enabled and the borrower has a smsalertnumber and no email
226
t::lib::Mocks::mock_preference( 'MessageTransportTypeFallbackToSMSIfNoPatronEmail', 1 );
226
t::lib::Mocks::mock_preference( 'FallbackToSMSIfNoEmail', 1 );
227
ModSuggestion($mod_suggestion3);
227
ModSuggestion($mod_suggestion3);
228
$messages = C4::Letters::GetQueuedMessages({
228
$messages = C4::Letters::GetQueuedMessages({
229
    borrowernumber => $borrowernumber,
229
    borrowernumber => $borrowernumber,
230
});
230
});
231
is ($messages->[1]->{message_transport_type}, 'sms', 'When MessageTransportTypeFallbackToSMSIfNoPatronEmail syspref is enabled the suggestion message_transport_type is sms if the borrower has no email');
231
is ($messages->[1]->{message_transport_type}, 'sms', 'When FallbackToSMSIfNoEmail syspref is enabled the suggestion message_transport_type is sms if the borrower has no email');
232
232
233
#Make a new suggestion for a borrower with defined email and no smsalertnumber
233
#Make a new suggestion for a borrower with defined email and no smsalertnumber
234
my $my_suggestion_2_id = NewSuggestion($my_suggestion_with_budget2);
234
my $my_suggestion_2_id = NewSuggestion($my_suggestion_with_budget2);
235
235
236
#Check the message_transport_type when the 'MessageTransportTypeFallbackToSMSIfNoPatronEmail' syspref is enabled and the borrower has a defined email and no smsalertnumber
236
#Check the message_transport_type when the 'FallbackToSMSIfNoEmail' syspref is enabled and the borrower has a defined email and no smsalertnumber
237
t::lib::Mocks::mock_preference( 'MessageTransportTypeFallbackToSMSIfNoPatronEmail', 1 );
237
t::lib::Mocks::mock_preference( 'FallbackToSMSIfNoEmail', 1 );
238
my $mod_suggestion4 = {
238
my $mod_suggestion4 = {
239
    STATUS       => 'CHECKED',
239
    STATUS       => 'CHECKED',
240
    suggestionid => $my_suggestion_2_id,
240
    suggestionid => $my_suggestion_2_id,
Lines 243-249 ModSuggestion($mod_suggestion4); Link Here
243
$messages = C4::Letters::GetQueuedMessages({
243
$messages = C4::Letters::GetQueuedMessages({
244
    borrowernumber => $borrowernumber2,
244
    borrowernumber => $borrowernumber2,
245
});
245
});
246
is ($messages->[0]->{message_transport_type}, 'email', 'When MessageTransportTypeFallbackToSMSIfNoPatronEmail syspref is enabled the suggestion message_transport_type is email if the borrower has an email');
246
is ($messages->[0]->{message_transport_type}, 'email', 'When FallbackToSMSIfNoEmail syspref is enabled the suggestion message_transport_type is email if the borrower has an email');
247
247
248
is( GetSuggestionInfo(), undef, 'GetSuggestionInfo without the suggestion id returns undef' );
248
is( GetSuggestionInfo(), undef, 'GetSuggestionInfo without the suggestion id returns undef' );
249
$suggestion = GetSuggestionInfo($my_suggestionid);
249
$suggestion = GetSuggestionInfo($my_suggestionid);
250
- 

Return to bug 21241