[Koha-patches] [PATCH] Bug 3203: ACCTDETAIL notices don't parse branches or borrowers tokens
Jared Camins-Esakov
jcamins at bywatersolutions.com
Sun Mar 27 19:05:48 CEST 2011
From: Ian Walls <ian.walls at bywatersolutions.com>
This patch enables the ACCTDETAIL notices (and any branch-specific derivatives) to use
<<branches.*>> and <<borrowers.*>> 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 <<branches.*>> 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 <jcamins at bywatersolutions.com>
---
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 d32b3cf..34e3686 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/<<borrowers.title>>/$externalid->{'title'}/g;
- $letter->{content} =~ s/<<borrowers.firstname>>/$externalid->{'firstname'}/g;
- $letter->{content} =~ s/<<borrowers.surname>>/$externalid->{'surname'}/g;
- $letter->{content} =~ s/<<borrowers.userid>>/$externalid->{'userid'}/g;
+ # must parse the password special, before it's hashed.
$letter->{content} =~ s/<<borrowers.password>>/$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 2195df4..52b39b8 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'}) {
--
1.7.2.3
More information about the Koha-patches
mailing list