Bug 30646: Add welcome email support to SAML2
This patch adds the ability to enable the welcome email notice for new users added via the Shibboleth autocreate option. Test plan 1) Configure Shibboleth for authentication 2) Enable the welcome email by adding '<welcome>1</welcome>' to your shibboleth config block 3) Confirm you have autocreate enabled for your Shibboleth config 4) Attempt to login with an entirely new user to Koha using the shibboleth connection (with a user who has a valid email address mapped to Koha borrower fields) 5) Confirm the email is sent by looking at the notices for the new user. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
e9e10c5e72
commit
a951e6d131
1 changed files with 36 additions and 1 deletions
|
@ -23,6 +23,7 @@ use C4::Context;
|
|||
use Koha::AuthUtils qw( get_script_name );
|
||||
use Koha::Database;
|
||||
use Koha::Patrons;
|
||||
use C4::Letters qw( GetPreparedLetter EnqueueLetter );
|
||||
use C4::Members::Messaging;
|
||||
use Carp qw( carp );
|
||||
use List::MoreUtils qw( any );
|
||||
|
@ -134,8 +135,42 @@ sub _autocreate {
|
|||
}
|
||||
|
||||
my $patron = Koha::Patron->new( \%borrower )->store;
|
||||
C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $patron->borrowernumber, categorycode => $patron->categorycode } );
|
||||
C4::Members::Messaging::SetMessagingPreferencesFromDefaults(
|
||||
{
|
||||
borrowernumber => $patron->borrowernumber,
|
||||
categorycode => $patron->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) {
|
||||
my $letter = C4::Letters::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 = C4::Letters::EnqueueLetter(
|
||||
{
|
||||
letter => $letter,
|
||||
borrowernumber => $patron->id,
|
||||
to_address => $emailaddr,
|
||||
message_transport_type => 'email'
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
return ( 1, $patron->cardnumber, $patron->userid );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue