From 89d4b5ea58f2029f13f4cfa2a652fd4cf900faa9 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 Signed-off-by: Nick Clemens --- C4/Suggestions.pm | 5 +---- ...yspref_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 b418f06348..e2dd3e7f91 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 6528f3def7..1a9443e46c 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 e67970aeb8..79fa815e32 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -175,6 +175,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.39.5