From 1d6f791541686dfa409843f8f5b1624f1be6e8cb Mon Sep 17 00:00:00 2001 From: Ian Walls Date: Sun, 27 Mar 2011 13:05:48 -0400 Subject: [PATCH] Bug 3203: ACCTDETAIL notices don't parse branches or borrowers tokens This patch enables the ACCTDETAIL notices (and any branch-specific derivatives) to use <> and <> tokens This patch also attempts to send the email from the branch email first, falling back to KohaAdminEmailAddress if no branch email exists. To test: 1. Enable AutoEmailOpacUser system preference 2. Add <> tokens to the ACCTDETAIL notice 3. Create a new patron, including: a. test email address in the field matching your AutoEmailPrimaryAddress syspref value b. username and password (required to send a notice) c. any other required fields to save the record 4. Check you inbox. Notice should send instantly (no need to run process_message_queue.pl) Signed-off-by: Jared Camins-Esakov Signed-off-by: Chris Cormack --- C4/Letters.pm | 12 +++++++----- members/memberentry.pl | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index d32b3cfc83..34e368658a 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -26,6 +26,7 @@ use Encode; use Carp; use C4::Members; +use C4::Branch; use C4::Log; use C4::SMS; use C4::Debug; @@ -440,15 +441,16 @@ sub SendAlerts { } # send an "account details" notice to a newly created user elsif ( $type eq 'members' ) { - $letter->{content} =~ s/<>/$externalid->{'title'}/g; - $letter->{content} =~ s/<>/$externalid->{'firstname'}/g; - $letter->{content} =~ s/<>/$externalid->{'surname'}/g; - $letter->{content} =~ s/<>/$externalid->{'userid'}/g; + # must parse the password special, before it's hashed. $letter->{content} =~ s/<>/$externalid->{'password'}/g; + parseletter( $letter, 'borrowers', $externalid->{'borrowernumber'}); + parseletter( $letter, 'branches', $externalid->{'branchcode'} ); + + my $branchdetails = GetBranchDetail($externalid->{'branchcode'}); my %mail = ( To => $externalid->{'emailaddr'}, - From => C4::Context->preference("KohaAdminEmailAddress"), + From => $branchdetails->{'branchemail'} || C4::Context->preference("KohaAdminEmailAddress"), Subject => $letter->{'title'}, Message => $letter->{'content'}, 'Content-Type' => 'text/plain; charset="utf8"', diff --git a/members/memberentry.pl b/members/memberentry.pl index 2195df44ac..52b39b82ea 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -296,6 +296,7 @@ if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ if ($op eq 'insert'){ # we know it's not a duplicate borrowernumber or there would already be an error $borrowernumber = &AddMember(%newdata); + $newdata{'borrowernumber'} = $borrowernumber; # If 'AutoEmailOpacUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode. if ( C4::Context->preference("AutoEmailOpacUser") == 1 && $newdata{'userid'} && $newdata{'password'}) { -- 2.39.2