From 5546da7b9daeb12b34b9f483ee6ad310c6b73cfe Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 2 Mar 2022 16:14:18 +0000 Subject: [PATCH] Bug 30214: Add ACCTDETAILS notice to verified self registration This patch adds the ACCTDETAILS notice trigger to the opac self registration process. Allowing new users, with varification enabled, to receive the ACCTDETAILS notice immediately after their account is varified. Test plan 1) Enable AutoEmailOpacUser system preference 2) Ensure the ACCTDETAILS notice is configured 3) Ensure `PatronSelfRegistrationVerifyByEmail` is enabled 4) Register a new user via the opac self registration process using an email address you have access to 5) Verify the user by following the link in the verification email you should have received. 6) The new user should have been created and you should be able to see the account details notice in their associated notices 7) Confirm that the email address used above has received the notice. Signed-off-by: Owen Leonard Signed-off-by: Katrin Fischer Signed-off-by: Fridolin Somers Signed-off-by: Kyle M Hall --- opac/opac-registration-verify.pl | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/opac/opac-registration-verify.pl b/opac/opac-registration-verify.pl index c4e4f22963..6587d30d90 100755 --- a/opac/opac-registration-verify.pl +++ b/opac/opac-registration-verify.pl @@ -21,6 +21,7 @@ use CGI qw ( -utf8 ); use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); +use C4::Letters qw( GetPreparedLetter EnqueueLetter SendQueuedMessages ); use C4::Members; use C4::Form::MessagingPreferences; use Koha::AuthUtils; @@ -76,6 +77,39 @@ 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") ) { + #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 + if ($emailaddr) { + eval { + my $letter = GetPreparedLetter( + module => 'members', + letter_code => 'ACCTDETAILS', + branchcode => $patron->branchcode,, + lang => $patron->lang || 'default', + tables => { + 'branches' => $patron->branchcode, + 'borrowers' => $patron->borrowernumber, + }, + want_librarian => 1, + ) or return; + + my $message_id = EnqueueLetter( + { + letter => $letter, + borrowernumber => $patron->id, + to_address => $emailaddr, + message_transport_type => 'email' + } + ); + SendQueuedMessages({ message_id => $message_id }); + }; + } + } + $template->param( PatronSelfRegistrationAdditionalInstructions => C4::Context->preference( -- 2.39.5