From 93e3fed04301c935c95c5ec12bc0895c880df4a6 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 6 Feb 2024 09:25:45 -0100 Subject: [PATCH] Bug 34478: Move compatibility code All ILL backend retrocompatibility code has been moved to Illrequest.pm:get_op_param_deprecation for isolation and clarity Signed-off-by: Jonathan Druart --- Koha/Illrequest.pm | 40 +++++++++++++++++++++++++++++++++++----- ill/ill-requests.pl | 7 +------ opac/opac-illrequests.pl | 5 +---- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 4ea0bbaf3b..bf3f9c3a52 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -2003,16 +2003,34 @@ sub strings_map { return $strings; } -=head3 check_url_param_deprecation - Koha::Illrequest->check_url_param_deprecation($params); +=head3 get_op_param_deprecation -Check URL params and issue a deprecation message if any deprecated parameters are found + my $op = Koha::Illrequest->check_url_param_deprecation($params); + +Issues a deprecation message for the given parameters, if needed. +Returns the appropriate operation based on the interface type. + +=over + +=item interface + +The interface this is running on: 'opac' or 'intranet' + +=back + +=over + +=item params + +CGI parameters + +=back =cut -sub check_url_param_deprecation { - my ( $self, $params ) = @_; +sub get_op_param_deprecation { + my ( $self, $interface, $params ) = @_; my $deprecation_message; @@ -2028,6 +2046,18 @@ sub check_url_param_deprecation { if $params->{'backend'} && $deprecation_message; deprecated $deprecation_message if $deprecation_message; + + my $op; + if ( $interface eq 'opac' ) { + $op = $params->{'op'} // $params->{'method'} // 'list'; + $op = 'cud-create' if $op eq 'create' || $op eq 'add_form'; + } elsif ( $interface eq 'intranet' ) { + $op = $params->{op} // $params->{method} // 'illlist'; + $op = 'cud-create' if $op eq 'create'; + $op = 'cud-cancel' if $op eq 'cancel'; + $op = 'cud-delete' if $op eq 'delete'; + } + return $op; } =head3 _type diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl index 89389d2dc4..d9278b6db8 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -52,12 +52,7 @@ unless ( C4::Context->preference('ILLModule') ) { exit; } -Koha::Illrequest->check_url_param_deprecation($params); - -my $op = $params->{op} // $params->{method} // 'illlist'; -$op = 'cud-create' if $op eq 'create'; -$op = 'cud-cancel' if $op eq 'cancel'; -$op = 'cud-delete' if $op eq 'delete'; +my $op = Koha::Illrequest->get_op_param_deprecation( 'intranet', $params ); my ( $template, $patronnumber, $cookie ) = get_template_and_user( { template_name => 'ill/ill-requests.tt', diff --git a/opac/opac-illrequests.pl b/opac/opac-illrequests.pl index df3c44dd47..eea96ddf2e 100755 --- a/opac/opac-illrequests.pl +++ b/opac/opac-illrequests.pl @@ -61,10 +61,7 @@ my $backends_available = ( scalar @{$backends} > 0 ); $template->param( backends_available => $backends_available ); my $patron = Koha::Patrons->find($loggedinuser); -Koha::Illrequest->check_url_param_deprecation($params); - -my $op = $params->{'op'} // $params->{'method'} // 'list'; -$op = 'cud-create' if $op eq 'create' || $op eq 'add_form'; +my $op = Koha::Illrequest->get_op_param_deprecation( 'opac', $params ); my ( $illrequest_id, $request ); if ( $illrequest_id = $params->{illrequest_id} ) { -- 2.39.5