From 7364dc9d214f98dd9921a691a57d671a402e60cb Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 17 Jan 2025 13:10:56 +0000 Subject: [PATCH] Bug 36197: (QA follow-up): Move unauth_request_data_check to core Move this out of Standard specific logic. Other backends that support unauthenticated requests may want to make use of this and not duplicate code. --- Koha/ILL/Backend/Standard.pm | 22 ++-------------------- Koha/ILL/Request.pm | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Koha/ILL/Backend/Standard.pm b/Koha/ILL/Backend/Standard.pm index e5f3e77d248..a063f50885b 100644 --- a/Koha/ILL/Backend/Standard.pm +++ b/Koha/ILL/Backend/Standard.pm @@ -24,6 +24,7 @@ use C4::Installer; use Koha::DateUtils qw/ dt_from_string /; use Koha::I18N qw(__); +use Koha::ILL::Request; use Koha::ILL::Requests; use Koha::ILL::Request::Attribute; use C4::Biblio qw( AddBiblio ); @@ -292,7 +293,7 @@ sub create { C4::Context->preference("ILLOpacUnauthenticatedRequest") && !$other->{'cardnumber'}; if($unauthenticated_request){ ( $failed, $result ) = _validate_form_params( $other, $result, $params); - if ( !_unauth_request_data_check($other) ) { + if ( !Koha::ILL::Request::unauth_request_data_check($other) ) { $result->{status} = "missing_unauth_data"; $result->{value} = $params; $failed = 1; @@ -1225,25 +1226,6 @@ sub _set_suppression { return 1; } -=head3 _unauth_request_data_check - - _unauth_request_data_check($other); - -Checks if unauthenticated request data is present - -=cut - -sub _unauth_request_data_check { - my ($other) = @_; - - return 1 unless C4::Context->preference("ILLOpacUnauthenticatedRequest"); - - return - $other->{unauthenticated_first_name} - && $other->{unauthenticated_last_name} - && $other->{unauthenticated_email}; -} - =head3 _validate_form_params _validate_form_params( $other, $result, $params ); diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm index 0d8fa7f1edf..3c9df02ae9c 100644 --- a/Koha/ILL/Request.pm +++ b/Koha/ILL/Request.pm @@ -1925,6 +1925,25 @@ sub append_unauthenticated_notes { $self->notesopac($unauthenticated_notes_text)->store; } +=head3 unauth_request_data_check + + unauth_request_data_check($metadata); + +Checks if unauthenticated request data is present + +=cut + +sub unauth_request_data_check { + my ($metadata) = @_; + + return 1 unless C4::Context->preference("ILLOpacUnauthenticatedRequest"); + + return + $metadata->{unauthenticated_first_name} + && $metadata->{unauthenticated_last_name} + && $metadata->{unauthenticated_email}; +} + =head3 append_to_note append_to_note("Some text"); -- 2.39.5