From 87c9e72539c93d87b8624cb8de351b987e5c9a7d Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 8 Mar 2022 16:15:52 +0000 Subject: [PATCH] Bug 30237: Replace AutoEmailOpacUser with AutoEmailNewUser --- C4/UsageStats.pm | 2 +- installer/data/mysql/atomicupdate/bug_30237.pl | 7 ++++++- installer/data/mysql/mandatory/sysprefs.sql | 2 +- .../prog/en/modules/admin/preferences/patrons.pref | 4 ++-- members/memberentry.pl | 4 ++-- opac/opac-memberentry.pl | 4 ++-- opac/opac-registration-verify.pl | 4 ++-- t/db_dependent/Context.t | 6 +++--- 8 files changed, 19 insertions(+), 14 deletions(-) diff --git a/C4/UsageStats.pm b/C4/UsageStats.pm index 12378b1b15..181a5cb555 100644 --- a/C4/UsageStats.pm +++ b/C4/UsageStats.pm @@ -324,7 +324,7 @@ sub _shared_preferences { TrackClicks PatronSelfRegistration OPACShelfBrowser - AutoEmailOpacUser + AutoEmailNewUser AutoEmailPrimaryAddress autoMemberNum BorrowerRenewalPeriodBase diff --git a/installer/data/mysql/atomicupdate/bug_30237.pl b/installer/data/mysql/atomicupdate/bug_30237.pl index 9f33af64b2..0114abda85 100644 --- a/installer/data/mysql/atomicupdate/bug_30237.pl +++ b/installer/data/mysql/atomicupdate/bug_30237.pl @@ -8,6 +8,11 @@ return { my ($dbh, $out) = @$args{qw(dbh out)}; # Add WELCOME notice $dbh->do( q{ - INSERT IGNORE INTO letter (module, code, name, is_html, title, content, message_transport_type) VALUES ('members', 'WELCOME', 'Welcome notice', 1, '[% USE Koha %]Welcome to [% Koha.Preference('LibraryName') %]', "[% USE Koha %]\r\nHello [% borrower.title %] [% borrower.firstname %] [% borrower.surname %].\r\n\r\nThankyou for joining [% Koha.Preference('LibraryName') %]\r\n\r\nThe library's catalog can be found here.\r\n\r\nYour library card number is [% borrower.cardnumber %]\r\n\r\nIf you have any problems or questions regarding your account, please contact your Koha Administrator.", 'email');}); + INSERT IGNORE INTO letter (module, code, name, is_html, title, content, message_transport_type) VALUES ('members', 'WELCOME', 'Welcome notice', 1, "[% USE Koha %]Welcome to [% Koha.Preference('LibraryName') %]", "[% USE Koha %]\r\nHello [% borrower.title %] [% borrower.firstname %] [% borrower.surname %].\r\n\r\nThankyou for joining [% Koha.Preference('LibraryName') %]\r\n\r\nThe library's catalog can be found here.\r\n\r\nYour library card number is [% borrower.cardnumber %]\r\n\r\nIf you have any problems or questions regarding your account, please contact your Koha Administrator.", 'email');}); + + # Update system preference + $dbh->do( q{ + UPDATE systempreferences SET variable = 'AutoEmailNewUser', explanation = 'Send an email to newly created patrons.' WHERE variable = 'AutoEmailOpacUser' + }); }, }; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index dd83a00fd8..5e6f34861b 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -73,7 +73,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('autoBarcode','OFF','incremental|annual|hbyymmincr|EAN13|OFF','Used to autogenerate a barcode: incremental will be of the form 1, 2, 3; annual of the form 2007-0001, 2007-0002; hbyymmincr of the form HB08010001 where HB=Home Branch','Choice'), ('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'), ('AutoCreditNumber', '', '', 'Automatically generate a number for account credits', 'Choice'), -('AutoEmailOpacUser','0',NULL,'Sends notification emails containing new account details to patrons - when account is created.','YesNo'), +('AutoEmailNewUser','0',NULL,'Send an email to newly created patrons.','YesNo'), ('AutoEmailPrimaryAddress','OFF','email|emailpro|B_email|cardnumber|OFF','Defines the default email address where \'Account Details\' emails are sent.','Choice'), ('AutoShareWithMana','subscription','','defines datas automatically shared with mana','multiple'), ('AutoLocation','0',NULL,'If ON, IP authentication is enabled, blocking access to the staff interface from unauthorized IP addresses','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 9ef410f24c..e5bc4918a7 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 @@ -143,11 +143,11 @@ Patrons: - "patron messaging setting on the OPAC." - '
NOTE: EnhancedMessagingPreferences must be enabled.' - - - pref: AutoEmailOpacUser + - pref: AutoEmailNewUser choices: 1: Send 0: "Don't send" - - an email to newly created patrons with their account details. + - an email to newly created patrons. - - pref: UseEmailReceipts choices: diff --git a/members/memberentry.pl b/members/memberentry.pl index be07ec6106..e33579a7a5 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -459,8 +459,8 @@ if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ delete $newdata{password}; } - # If 'AutoEmailOpacUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode. - if ( C4::Context->preference("AutoEmailOpacUser") ) { + # If 'AutoEmailNewUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode. + if ( C4::Context->preference("AutoEmailNewUser") ) { #look for defined primary email address, if blank - attempt to use borr.email and borr.emailpro instead my $emailaddr = $patron->notice_email_address; # if we manage to find a valid email address, send notice diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index e532fd4e16..5b4887e5fe 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -243,8 +243,8 @@ if ( $action eq 'create' ) { $template->param( password_cleartext => $patron->plain_text_password ); $template->param( borrower => $patron->unblessed ); - # If 'AutoEmailOpacUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode. - if ( C4::Context->preference("AutoEmailOpacUser") ) { + # If 'AutoEmailNewUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode. + if ( C4::Context->preference("AutoEmailNewUser") ) { #look for defined primary email address, if blank - attempt to use borr.email and borr.emailpro instead my $emailaddr = $patron->notice_email_address; # if we manage to find a valid email address, send notice diff --git a/opac/opac-registration-verify.pl b/opac/opac-registration-verify.pl index 96717f0405..2fc56d381c 100755 --- a/opac/opac-registration-verify.pl +++ b/opac/opac-registration-verify.pl @@ -78,8 +78,8 @@ if ( $template->param( password_cleartext => $patron->plain_text_password ); $template->param( borrower => $patron ); - # If 'AutoEmailOpacUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode. - if ( C4::Context->preference("AutoEmailOpacUser") ) { + # If 'AutoEmailNewUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode. + if ( C4::Context->preference("AutoEmailNewUser") ) { # Look up correct email address taking AutoEmailPrimaryAddress into account my $emailaddr = $patron->notice_email_address; # if we manage to find a valid email address, send notice diff --git a/t/db_dependent/Context.t b/t/db_dependent/Context.t index 433510b2cb..77a8924822 100755 --- a/t/db_dependent/Context.t +++ b/t/db_dependent/Context.t @@ -126,9 +126,9 @@ is($oConnection->option('async'), 1, "ZOOM connection is asynchronous"); $silly_preference->delete(); -# AutoEmailOpacUser should be a YesNo pref -C4::Context->set_preference('AutoEmailOpacUser', ''); -my $yesno_pref = Koha::Config::SysPrefs->find('AutoEmailOpacUser'); +# AutoEmailNewUser should be a YesNo pref +C4::Context->set_preference('AutoEmailNewUser', ''); +my $yesno_pref = Koha::Config::SysPrefs->find('AutoEmailNewUser'); is( $yesno_pref->value(), 0, 'set_preference should have set the value to 0, instead of an empty string' ); done_testing(); -- 2.20.1