@@ -, +, @@
ldap config block
connection (with a user who has a valid email address mapped to Koha
borrower fields)
---
C4/Auth_with_ldap.pm | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
--- a/C4/Auth_with_ldap.pm
+++ a/C4/Auth_with_ldap.pm
@@ -23,6 +23,7 @@ use Carp qw( croak );
use C4::Context;
use C4::Members::Messaging;
use C4::Auth qw( checkpw_internal );
+use C4::Letters qw( GetPreparedLetter EnqueueLetter );
use Koha::Patrons;
use Koha::AuthUtils qw( hash_password );
use Net::LDAP;
@@ -74,7 +75,8 @@ if(defined $ldap->{categorycode_mapping}) {
my %config = (
anonymous => defined ($ldap->{anonymous_bind}) ? $ldap->{anonymous_bind} : 1,
replicate => defined($ldap->{replicate}) ? $ldap->{replicate} : 1, # add from LDAP to Koha database for new user
- update => defined($ldap->{update} ) ? $ldap->{update} : 1, # update from LDAP to Koha database for existing user
+ welcome => defined($ldap->{welcome}) ? $ldap->{welcome} : 0, # send welcome notice when patron is added via replicate
+ update => defined($ldap->{update}) ? $ldap->{update} : 1, # update from LDAP to Koha database for existing user
);
sub description {
@@ -226,6 +228,37 @@ sub checkpw_ldap {
die "Insert of new patron failed" unless $patron;
$borrowernumber = $patron->borrowernumber;
C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrowernumber, categorycode => $borrower{'categorycode'} } );
+
+ # Send welcome email if enabled
+ if ( $config{welcome} ) {
+ 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 => 'WELCOME',
+ 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'
+ }
+ );
+ };
+ }
+ }
} else {
return 0; # B2, D2
}
@@ -508,6 +541,7 @@ Example XML stanza for LDAP configuration in KOHA_CONF.
cn=Manager,dc=metavore,dc=com
metavore
1
+ 1
1
0
--