Bug 34478: ILL INTRA preparation: Move function to ILLrequest.pm

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Pedro Amorim 2024-02-05 12:17:34 -01:00 committed by Jonathan Druart
parent a7667eafbb
commit d08c23869a
Signed by: jonathan.druart
GPG key ID: A085E712BEF0E0F0
2 changed files with 29 additions and 17 deletions

View file

@ -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

View file

@ -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},