From 79ffb8841b1f052a104b9a7605c46eeacbd1142a Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 28 Aug 2024 14:57:18 -0300 Subject: [PATCH] Bug 37757: Update EmailFieldPrimary value Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- .../data/mysql/atomicupdate/bug_37757.pl | 20 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 2 +- .../en/modules/admin/preferences/patrons.pref | 4 ++-- 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_37757.pl diff --git a/installer/data/mysql/atomicupdate/bug_37757.pl b/installer/data/mysql/atomicupdate/bug_37757.pl new file mode 100755 index 0000000000..28f75a2fe5 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_37757.pl @@ -0,0 +1,20 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_failure say_success say_info); + +return { + bug_number => "37757", + description => "More robust handling of EmailFieldPrimary syspref values", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ + UPDATE systempreferences + SET value=IF(value='OFF','',value), + options='|email|emailpro|B_email|cardnumber|MULTI' + WHERE variable='EmailFieldPrimary'; + } + ) == 1 && say_success( $out, "Updated system preference 'EmailFieldPrimary'" ); + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 4e140968af..20d11d36ab 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -234,7 +234,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('EmailAddressForPatronRegistrations', '', '', ' If you choose EmailAddressForPatronRegistrations you have to enter a valid email address: ', 'free'), ('EmailAddressForSuggestions','','',' If you choose EmailAddressForSuggestions you have to enter a valid email address: ','free'), ('EmailFieldPrecedence','email|emailpro|B_email','','Ordered list of patron email fields to use when AutoEmailPrimaryAddress is set to first valid','multiple'), -('EmailFieldPrimary','OFF','email|emailpro|B_email|cardnumber|OFF|MULTI','Defines the default email address field where patron email notices are sent.','Choice'), +('EmailFieldPrimary','','|email|emailpro|B_email|cardnumber|MULTI','Defines the default email address field where patron email notices are sent.','Choice'), ('EmailFieldSelection','','email|emailpro|B_email','Selection list of patron email fields to use whern AutoEmailPrimaryAddress is set to selected addresses','multiple'), ('emailLibrarianWhenHoldIsPlaced','0',NULL,'If ON, emails the librarian whenever a hold is placed','YesNo'), ('EmailOverduesNoEmail','1',NULL,'Send send overdues of patrons without email address to staff','YesNo'), 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 3db000432f..4376132e57 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 @@ -193,13 +193,13 @@ Patrons: - - "Use the patron's" - pref: EmailFieldPrimary - default: "OFF" + default: "" choices: email: primary email emailpro: secondary email B_email: alternate email cardnumber: card number - "OFF": first valid email address + "": first valid email address "MULTI": selected addresses - 'for sending out email notices.' - '
NOTE: If set to "first valid", the order in which the email addresses are checked is set in EmailFieldPrecedence.' -- 2.39.5