From 35770c8a8cba3ffbbf581abf60f9317f7a9a1e19 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 27 Oct 2014 13:12:04 +0100 Subject: [PATCH] Bug 13096: Send account notice when user completes self-registration Content-Type: text/plain; charset=utf-8 If you have enabled AutoEmailOPACUser, a notice is sent to a patron at creation time. This patch will make Koha send a notice when someone self-registers and submits or follows the verification link. The usercode and password are prefilled on the form, but many patrons will find it helpful to have them in a mail. Instead of creating a new pref for this specific case, I have chosen to extend pref AutoEmailOpacUser. These situations are very similar. The pref text is adjusted in a follow-up. Note: If the user does not enter an email address, he will not receive any notice. (No verification link either.) Test plan: [1] Enable the prefs AutoEmailOPACUser and PatronSelfRegistration. [2] Enable PatronSelfRegistrationVerifyByEmail. [3] Self-register an account. Verify the account with the link in the mail. Check that you receive another mail with account details now. [4] Disable PatronSelfRegistrationVerifyByEmail. [5] Self-register again. Check if you receive a mail when submitting. --- opac/opac-memberentry.pl | 10 ++++++++++ opac/opac-registration-verify.pl | 10 ++++++++++ 2 files changed, 20 insertions(+), 0 deletions(-) diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 8ca517b..377f2a7 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -22,6 +22,7 @@ use Digest::MD5 qw( md5_base64 md5_hex ); use String::Random qw( random_string ); use C4::Auth; +use C4::Letters qw/SendAlerts/; use C4::Output; use C4::Members; use Koha::Borrower::Modifications; @@ -153,6 +154,15 @@ if ( $action eq 'create' ) { C4::Context->preference( 'PatronSelfRegistrationAdditionalInstructions') ); + if( C4::Context->preference('AutoEmailOPACUser') ) { + my $external = { + borrowernumber => $borrowernumber, + emailaddr => $borrower{email}||$borrower{emailpro}, + branchcode => $borrower{branchcode}, + password => $password, + }; + SendAlerts ( 'members', $external, "ACCTDETAILS" ); + } } } } diff --git a/opac/opac-registration-verify.pl b/opac/opac-registration-verify.pl index 05b258f..51a80e2 100755 --- a/opac/opac-registration-verify.pl +++ b/opac/opac-registration-verify.pl @@ -20,6 +20,7 @@ use Modern::Perl; use CGI; use C4::Auth; +use C4::Letters qw/SendAlerts/; use C4::Output; use C4::Members; use Koha::Borrower::Modifications; @@ -65,6 +66,15 @@ if ( $m->Verify() ) { C4::Context->preference( 'PatronSelfRegistrationAdditionalInstructions') ); + if( C4::Context->preference('AutoEmailOPACUser') ) { + my $external = { + borrowernumber => $borrowernumber, + emailaddr => $borrower->{email}||$borrower->{emailpro}, + branchcode => $borrower->{branchcode}, + password => $password, + }; + SendAlerts ( 'members', $external, "ACCTDETAILS" ); + } } } -- 1.7.7.6