diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 8031257304..8d2cf1fe44 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -2108,6 +2108,57 @@ sub account_balance { return $self->account->balance; } +=head3 notify_library_of_registration + +$patron->notify_library_of_registration( $email_patron_registrations ); + +Send patron registration email to library if EmailPatronRegistrations system preference is enabled. + +=cut + +sub notify_library_of_registration { + my ( $self, $email_patron_registrations ) = @_; + + if ( + my $letter = C4::Letters::GetPreparedLetter( + module => 'members', + letter_code => 'OPAC_REG', + branchcode => $self->branchcode, + lang => $self->lang || 'default', + tables => { + 'borrowers' => $self->borrowernumber + }, + ) + ) { + my $to_address; + if ( $email_patron_registrations eq "BranchEmailAddress" ) { + my $library = Koha::Libraries->find( $self->branchcode ); + $to_address = $library->inbound_email_address; + } + elsif ( $email_patron_registrations eq "KohaAdminEmailAddress" ) { + $to_address = C4::Context->preference('ReplytoDefault') + || C4::Context->preference('KohaAdminEmailAddress'); + } + else { + $to_address = + C4::Context->preference('EmailAddressForPatronRegistrations') + || C4::Context->preference('ReplytoDefault') + || C4::Context->preference('KohaAdminEmailAddress'); + } + + my $message_id = C4::Letters::EnqueueLetter( + { + letter => $letter, + borrowernumber => $self->borrowernumber, + to_address => $to_address, + message_transport_type => 'email' + } + ) or warn "can't enqueue letter $letter"; + if ( $message_id ) { + return 1; + } + } +} =head3 has_messaging_preference diff --git a/installer/data/mysql/atomicupdate/bug23538-add_EmailPatronRegistrations_and_EmailAddressForPatronRegistrations_sysprefs.pl b/installer/data/mysql/atomicupdate/bug23538-add_EmailPatronRegistrations_and_EmailAddressForPatronRegistrations_sysprefs.pl index 61ee73395e..55082df006 100755 --- a/installer/data/mysql/atomicupdate/bug23538-add_EmailPatronRegistrations_and_EmailAddressForPatronRegistrations_sysprefs.pl +++ b/installer/data/mysql/atomicupdate/bug23538-add_EmailPatronRegistrations_and_EmailAddressForPatronRegistrations_sysprefs.pl @@ -13,16 +13,15 @@ return { '

New OPAC self-registration

Self-registration made by

', 'email', 'default') }); }, diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml index 85d2ddce85..53a7e2a068 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.yml +++ b/installer/data/mysql/en/mandatory/sample_notices.yml @@ -1903,15 +1903,14 @@ tables: - "

New OPAC self-registration

" - "

Self-registration made by

" - "" - "

" diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 41f5fbfb8c..17345c75e9 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -273,6 +273,13 @@ if ( $action eq 'create' ) { }; } } + + # Notify library of new patron registration + my $notify_library = C4::Context->preference('EmailPatronRegistrations'); + if ($notify_library) { + $patron->notify_library_of_registration($notify_library); + } + } else { # FIXME Handle possible errors here } diff --git a/opac/opac-registration-verify.pl b/opac/opac-registration-verify.pl index 73ff55e6e5..673507ab3e 100755 --- a/opac/opac-registration-verify.pl +++ b/opac/opac-registration-verify.pl @@ -117,6 +117,12 @@ if ( } } + # Notify library of new patron registration + my $notify_library = C4::Context->preference("EmailPatronRegistrations"); + if ($notify_library) { + $patron->notify_library_of_registration($notify_library); + } + $template->param( PatronSelfRegistrationAdditionalInstructions => C4::Context->preference(