Delivered-To: jcamins@cpbibliography.com Received: by 10.42.132.72 with SMTP id c8cs18004ict; Sun, 27 Mar 2011 10:03:35 -0700 (PDT) Received: by 10.223.143.16 with SMTP id s16mr3553073fau.57.1301245414317; Sun, 27 Mar 2011 10:03:34 -0700 (PDT) Return-Path: Received: from eliot.biblibre.com (eliot.biblibre.com [188.165.204.78]) by mx.google.com with ESMTPS id 9si3077836fat.17.2011.03.27.10.03.32 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 27 Mar 2011 10:03:33 -0700 (PDT) Received-SPF: neutral (google.com: 188.165.204.78 is neither permitted nor denied by best guess record for domain of koha-patches-bounces@lists.koha-community.org) client-ip=188.165.204.78; Authentication-Results: mx.google.com; spf=neutral (google.com: 188.165.204.78 is neither permitted nor denied by best guess record for domain of koha-patches-bounces@lists.koha-community.org) smtp.mail=koha-patches-bounces@lists.koha-community.org Received: from eliot.biblibre.com (localhost.localdomain [127.0.0.1]) by eliot.biblibre.com (Postfix) with ESMTP id 8306E47060; Sun, 27 Mar 2011 19:03:32 +0200 (CEST) X-Original-To: koha-patches@lists.koha-community.org Delivered-To: koha-patches_lists.koha-community.org@eliot.biblibre.com Received: from mail-qy0-f172.google.com (mail-qy0-f172.google.com [209.85.216.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by eliot.biblibre.com (Postfix) with ESMTPS id 7074A46E05 for ; Sun, 27 Mar 2011 19:03:30 +0200 (CEST) Received: by qyk29 with SMTP id 29so737746qyk.17 for ; Sun, 27 Mar 2011 10:03:28 -0700 (PDT) Received: by 10.229.106.214 with SMTP id y22mr2424629qco.105.1301245407731; Sun, 27 Mar 2011 10:03:27 -0700 (PDT) Received: from localhost.localdomain (user-387g03k.cable.mindspring.com [208.120.0.116]) by mx.google.com with ESMTPS id g28sm207395qck.15.2011.03.27.10.03.26 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 27 Mar 2011 10:03:27 -0700 (PDT) From: Jared Camins-Esakov To: koha-patches@lists.koha-community.org Date: Sun, 27 Mar 2011 13:05:48 -0400 Message-Id: <1301245548-4049-1-git-send-email-jcamins@bywatersolutions.com> X-Mailer: git-send-email 1.7.2.3 Cc: Jared Camins-Esakov Subject: [Koha-patches] [PATCH] Bug 3203: ACCTDETAIL notices don't parse branches or borrowers tokens X-BeenThere: koha-patches@lists.koha-community.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Patches submitted to Koha List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: koha-patches-bounces@lists.koha-community.org Errors-To: koha-patches-bounces@lists.koha-community.org From: Ian Walls 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 --- 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/<>/$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 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