From 708a9e748845c7a16b4da53354ba0f9b18e5b753 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 29 Jan 2026 15:34:00 +0000 Subject: [PATCH] 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 --- Koha/Patron.pm | 4 ++-- Koha/REST/V1/Patrons.pm | 7 +++++++ api/v1/swagger/paths/patrons.yaml | 2 ++ .../prog/en/modules/admin/preferences/opac.pref | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index b174636cdd4..a3c27dba022 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -3281,7 +3281,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, @@ -3304,7 +3304,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, diff --git a/Koha/REST/V1/Patrons.pm b/Koha/REST/V1/Patrons.pm index 05ae08688eb..a6f9fb6657d 100644 --- a/Koha/REST/V1/Patrons.pm +++ b/Koha/REST/V1/Patrons.pm @@ -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( { diff --git a/api/v1/swagger/paths/patrons.yaml b/api/v1/swagger/paths/patrons.yaml index 6ec12ddedf6..7257bc17980 100644 --- a/api/v1/swagger/paths/patrons.yaml +++ b/api/v1/swagger/paths/patrons.yaml @@ -435,6 +435,8 @@ enum: - welcome_yes - welcome_no + - opac_reg_yes + - opac_reg_no collectionFormat: csv consumes: - application/json diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index 37202dc17c6..dc6758d5beb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -911,6 +911,7 @@ OPAC: - '
If you choose EmailAddressForPatronRegistrations you have to enter a valid email address: ' - pref: EmailAddressForPatronRegistrations class: email + - '
NOTE: This uses the OPAC_REG notice.' - - pref: PatronSelfRegistrationAlert choices: -- 2.39.5