From d08c23869a0e4b612fcf6e6fa184699cc9f6cca5 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 5 Feb 2024 12:17:34 -0100 Subject: [PATCH] Bug 34478: ILL INTRA preparation: Move function to ILLrequest.pm Signed-off-by: Jonathan Druart --- Koha/Illrequest.pm | 27 +++++++++++++++++++++++++++ opac/opac-illrequests.pl | 19 ++----------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 831d6fa52d..4ea0bbaf3b 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -2003,6 +2003,33 @@ sub strings_map { return $strings; } +=head3 check_url_param_deprecation + + Koha::Illrequest->check_url_param_deprecation($params); + +Check URL params and issue a deprecation message if any deprecated parameters are found + +=cut + +sub check_url_param_deprecation { + my ( $self, $params ) = @_; + + my $deprecation_message; + + $deprecation_message = '"method" form param is DEPRECATED in favor of "op". ' if ( exists( $params->{'method'} ) ); + + if ( exists( $params->{'op'} ) && $params->{'op'} eq 'create' + || exists( $params->{'method'} ) && $params->{'method'} eq 'create' ) + { + $deprecation_message .= '"create" op is DEPRECATED in favor of "cud-create" or "add_form".'; + } + + $deprecation_message .= ' Used by ' . $params->{'backend'} . ' backend.' + if $params->{'backend'} && $deprecation_message; + + deprecated $deprecation_message if $deprecation_message; +} + =head3 _type =cut diff --git a/opac/opac-illrequests.pl b/opac/opac-illrequests.pl index 83c7a11e31..df3c44dd47 100755 --- a/opac/opac-illrequests.pl +++ b/opac/opac-illrequests.pl @@ -27,10 +27,9 @@ use C4::Koha; use C4::Output qw( output_html_with_http_headers ); use POSIX qw( strftime ); -use Mojo::Util qw(deprecated); - use Koha::Illrequest::Config; use Koha::Illrequests; +use Koha::Illrequest; use Koha::Libraries; use Koha::Patrons; use Koha::Illrequest::Workflow::Availability; @@ -62,12 +61,9 @@ my $backends_available = ( scalar @{$backends} > 0 ); $template->param( backends_available => $backends_available ); my $patron = Koha::Patrons->find($loggedinuser); -show_param_deprecation_message('"method" form param is DEPRECATED in favor of "op".') if ( $params->{'method'} ); +Koha::Illrequest->check_url_param_deprecation($params); my $op = $params->{'op'} // $params->{'method'} // 'list'; - -show_param_deprecation_message('"create" op is DEPRECATED in favor of "cud-create".') if ( $op eq 'create' ); - $op = 'cud-create' if $op eq 'create' || $op eq 'add_form'; my ( $illrequest_id, $request ); @@ -186,17 +182,6 @@ if ( $op eq 'list' ) { } } -=head3 show_param_deprecation_message - -Generate deprecation message for the given parameter and append the backend information if available - -=cut -sub show_param_deprecation_message { - my ($message) = @_; - $message .= ' Used by ' . $params->{'backend'} . ' backend' if $params->{'backend'}; - deprecated $message; -} - $template->param( can_place_ill_in_opac => $patron->_result->categorycode->can_place_ill_in_opac, message => $params->{message}, -- 2.39.5