From 7b8b0e5ee2576ceb07150903d101ecb026a163f7 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Mon, 24 Dec 2018 21:38:24 +0000 Subject: [PATCH] Bug 21241: (follow-up) Made SQL change idempotent Also added the new pref to sysprefs.sql Also simplified the conditional statement. Sponsored-By: Brimbank Library, Australia --- C4/Suggestions.pm | 5 +---- ...41-add_syspref_to_control_fallback_to_sms_if_no_email_defined.sql | 2 +- installer/data/mysql/sysprefs.sql | 1 + 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index b418f06..e2dd3e7 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -504,10 +504,7 @@ sub ModSuggestion { my $full_suggestion = GetSuggestion( $suggestion->{suggestionid} ); my $patron = Koha::Patrons->find( $full_suggestion->{suggestedby} ); - my $transport = 'email'; - if (C4::Context->preference("FallbackToSMSIfNoEmail")) { - $transport = ($patron->smsalertnumber) && (!$patron->email) ? 'sms' : 'email'; - } + my $transport = (C4::Context->preference("FallbackToSMSIfNoEmail")) && ($patron->smsalertnumber) && (!$patron->email) ? 'sms' : 'email'; if ( my $letter = C4::Letters::GetPreparedLetter( diff --git a/installer/data/mysql/atomicupdate/bug_21241-add_syspref_to_control_fallback_to_sms_if_no_email_defined.sql b/installer/data/mysql/atomicupdate/bug_21241-add_syspref_to_control_fallback_to_sms_if_no_email_defined.sql index 6528f3d..1a9443e 100644 --- a/installer/data/mysql/atomicupdate/bug_21241-add_syspref_to_control_fallback_to_sms_if_no_email_defined.sql +++ b/installer/data/mysql/atomicupdate/bug_21241-add_syspref_to_control_fallback_to_sms_if_no_email_defined.sql @@ -1 +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'); +INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('FallbackToSMSIfNoEmail', 0, 'Enable|Disable', 'Send messages by SMS if no patron email is defined', 'YesNo'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 1e36c30..bacfc79 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -173,6 +173,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('FacetLabelTruncationLength','20',NULL,'Specify the facet max length in OPAC','Integer'), ('FacetMaxCount','20',NULL,'Specify the max facet count for each category','Integer'), ('FailedLoginAttempts','','','Number of login attempts before lockout the patron account','Integer'), +('FallbackToSMSIfNoEmail', 0, 'Enable|Disable', 'Send messages by SMS if no patron email is defined', 'YesNo'), ('FeeOnChangePatronCategory','1','','If set, when a patron changes to a category with enrolment fee, a fee is charged','YesNo'), ('FilterBeforeOverdueReport','0','','Do not run overdue report until filter selected','YesNo'), ('FineNotifyAtCheckin','0',NULL,'If ON notify librarians of overdue fines on the items they are checking in.','YesNo'), -- 2.1.4