Bug 41733: Honor EmailPatronRegistrations in the API

This patch adds new overrides opac_reg_yes and opac_reg_no to the patrons api
and will send a notice to the library when a patron is registered via the API if the pref is
active and the NO override is not sent, or the YES override is sent

To test:
1 - Apply patches
2 - yarn build
3 - restart_all
4 - run unit tests

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2026-01-29 15:34:00 +00:00 committed by Lucas Gass
parent 8f6677be5a
commit 99eb693cd9
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
4 changed files with 12 additions and 2 deletions

View File

@ -3338,7 +3338,7 @@ sub notify_library_of_registration {
my ( $self, $email_patron_registrations ) = @_;
if (
my $letter = C4::Letters::GetPreparedLetter(
my $letter = GetPreparedLetter(
module => 'members',
letter_code => 'OPAC_REG',
branchcode => $self->branchcode,
@ -3361,7 +3361,7 @@ sub notify_library_of_registration {
|| C4::Context->preference('KohaAdminEmailAddress');
}
my $message_id = C4::Letters::EnqueueLetter(
my $message_id = EnqueueLetter(
{
letter => $letter,
borrowernumber => $self->borrowernumber,

View File

@ -160,6 +160,13 @@ sub add {
}
}
my $notify_library = C4::Context->preference('EmailPatronRegistrations');
if ( $overrides->{opac_reg_yes}
|| ( $notify_library && !$overrides->{opac_reg_no} ) )
{
$patron->notify_library_of_registration($notify_library);
}
if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
C4::Members::Messaging::SetMessagingPreferencesFromDefaults(
{

View File

@ -435,6 +435,8 @@
enum:
- welcome_yes
- welcome_no
- opac_reg_yes
- opac_reg_no
collectionFormat: csv
consumes:
- application/json

View File

@ -912,6 +912,7 @@ OPAC:
- '<br>If you choose <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=EmailAddressForPatronRegistrations">EmailAddressForPatronRegistrations</a> you have to enter a valid email address: '
- pref: EmailAddressForPatronRegistrations
class: email
- '<br><strong>NOTE:</strong> This uses the OPAC_REG notice.'
-
- pref: PatronSelfRegistrationAlert
choices: