Bug 23538: Email library when new patron self-registers
Test plan: 1. Apply all patches 2. Update database 3. Restart services 4. Set email addresses in: - KohaAdminEmailAddress syspref - EmailAddressForPatronRegistrations syspref - Email address in the library branch 5. Enable PatronSelfRegistration syspref 6. Test the following use cases: - EmailPatronRegistrations syspref = 'none'. Submit OPAC registration. = OUTCOME: Confirm no OPAC_REG notice in message_queue table Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
219ae32c41
commit
1c0a187968
5 changed files with 82 additions and 20 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -13,16 +13,15 @@ return {
|
|||
'<h3>New OPAC self-registration</h3>
|
||||
<p><h4>Self-registration made by</h4>
|
||||
<ul>
|
||||
<li><<borrower_modifications.firstname>> <<borrower_modifications.surname>></li>
|
||||
<li>Physical address: <<borrower_modifications.streetnumber>> <<borrower_modifications.streettype>> <<borrower_modifications.address>> <<borrower_modifications.address2>>, <<borrower_modifications.city>>, <<borrower_modifications.state>> <<borrower_modifications.zipcode>>, <<borrower_modifications.country>></li>
|
||||
<li>Email: <<borrower_modifications.email>></li>
|
||||
<li>Phone: <<borrower_modifications.phone>></li>
|
||||
<li>Mobile: <<borrower_modifications.mobile>></li>
|
||||
<li>Fax: <<borrower_modifications.fax>></li>
|
||||
<li>Secondary email: <<borrower_modifications.emailpro>></li>
|
||||
<li>Secondary phone:<<borrower_modifications.phonepro>></li>
|
||||
<li>Home library: <<borrower_modifications.branchcode>></li>
|
||||
<li>Temporary patron category: <<borrower_modifications.categorycode>></li>
|
||||
<li><<borrowers.firstname>> <<borrowers.surname>></li>
|
||||
<li>Email: <<borrowers.email>></li>
|
||||
<li>Phone: <<borrowers.phone>></li>
|
||||
<li>Mobile: <<borrowers.mobile>></li>
|
||||
<li>Fax: <<borrowers.fax>></li>
|
||||
<li>Secondary email: <<borrowers.emailpro>></li>
|
||||
<li>Secondary phone:<<borrowers.phonepro>></li>
|
||||
<li>Home library: <<borrowers.branchcode>></li>
|
||||
<li>Patron category: <<borrowers.categorycode>></li>
|
||||
</ul>
|
||||
</p>', 'email', 'default') });
|
||||
},
|
||||
|
|
|
@ -1903,15 +1903,14 @@ tables:
|
|||
- "<h3>New OPAC self-registration</h3>"
|
||||
- "<p><h4>Self-registration made by</h4>"
|
||||
- "<ul>"
|
||||
- "<li><<borrower_modifications.firstname>> <<borrower_modifications.surname>></li>"
|
||||
- "<li>Physical address: <<borrower_modifications.streetnumber>> <<borrower_modifications.streettype>> <<borrower_modifications.address>> <<borrower_modifications.address2>>, <<borrower_modifications.city>>, <<borrower_modifications.state>> <<borrower_modifications.zipcode>>, <<borrower_modifications.country>></li>"
|
||||
- "<li>Email: <<borrower_modifications.email>></li>"
|
||||
- "<li>Phone: <<borrower_modifications.phone>></li>"
|
||||
- "<li>Mobile: <<borrower_modifications.mobile>></li>"
|
||||
- "<li>Fax: <<borrower_modifications.fax>></li>"
|
||||
- "<li>Secondary email: <<borrower_modifications.emailpro>></li>"
|
||||
- "<li>Secondary phone:<<borrower_modifications.phonepro>></li>"
|
||||
- "<li>Home library: <<borrower_modifications.branchcode>></li>"
|
||||
- "<li>Temporary patron category: <<borrower_modifications.categorycode>></li>"
|
||||
- "<li><<borrowers.firstname>> <<borrowers.surname>></li>"
|
||||
- "<li>Email: <<borrowers.email>></li>"
|
||||
- "<li>Phone: <<borrowers.phone>></li>"
|
||||
- "<li>Mobile: <<borrowers.mobile>></li>"
|
||||
- "<li>Fax: <<borrowers.fax>></li>"
|
||||
- "<li>Secondary email: <<borrowers.emailpro>></li>"
|
||||
- "<li>Secondary phone:<<borrowers.phonepro>></li>"
|
||||
- "<li>Home library: <<borrowers.branchcode>></li>"
|
||||
- "<li>Temporary patron category: <<borrowers.categorycode>></li>"
|
||||
- "</ul>"
|
||||
- "</p>"
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue