From ff21352a4a54a1b61f906aeffe7feef1506d4264 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 25 Apr 2018 17:08:42 -0300 Subject: [PATCH] Bug 20661: Shortcut circ scripts if a blocking error appeared Signed-off-by: Marcel de Rooy No test plan found ;) But tested bookcount and request-article. Signed-off-by: Nick Clemens --- C4/Output.pm | 15 +++++---- circ/bookcount.pl | 31 +++++++++---------- circ/request-article.pl | 3 ++ .../prog/en/includes/blocking_errors.inc | 4 +++ .../prog/en/modules/circ/bookcount.tt | 10 ++++-- .../prog/en/modules/circ/request-article.tt | 3 ++ 6 files changed, 41 insertions(+), 25 deletions(-) diff --git a/C4/Output.pm b/C4/Output.pm index 39d9f9cd21..eef4506e87 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -50,7 +50,7 @@ BEGIN { ); push @EXPORT, qw( &output_html_with_http_headers &output_ajax_with_http_headers &output_with_http_headers - &output_and_exit_if_error + &output_and_exit_if_error &output_and_exit ); } @@ -338,14 +338,17 @@ sub output_and_exit_if_error { } } - if ( $error ) { - $template->param( blocking_error => $error ); - output_html_with_http_headers ( $query, $cookie, $template->output ); - exit; - } + output_and_exit( $query, $cookie, $template, $error ) if $error; return; } +sub output_and_exit { + my ( $query, $cookie, $template, $error ) = @_; + $template->param( blocking_error => $error ); + output_html_with_http_headers ( $query, $cookie, $template->output ); + exit; +} + sub parametrized_url { my $url = shift || ''; # ie page.pl?ln={LANG} my $vars = shift || {}; # ie { LANG => en } diff --git a/circ/bookcount.pl b/circ/bookcount.pl index 438d85126e..0d869464cc 100755 --- a/circ/bookcount.pl +++ b/circ/bookcount.pl @@ -39,22 +39,6 @@ my $biblionumber = $input->param('biblionumber'); my $biblio = Koha::Biblios->find( $biblionumber ); my $item = Koha::Items->find( $itm ); -if ( !defined $biblio or !defined $item ) { - print $input->redirect("/cgi-bin/koha/errors/400.pl"); -} - -my $lastmove = lastmove($itm); - -my $lastdate; -my $count; -if ( not $lastmove ) { - $count = issuessince( $itm, 0 ); -} else { - $lastdate = $lastmove->{'datearrived'}; - $count = issuessince( $itm, $lastdate ); -} - -# make the page ... my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -67,6 +51,21 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); +output_and_exit( $input, $cookie, $template, 'unknown_biblio') + unless $biblio; +output_and_exit( $input, $cookie, $template, 'unknown_item') + unless $item; + +my $lastdate; +my $count; +my $lastmove = lastmove($itm); +if ( not $lastmove ) { + $count = issuessince( $itm, 0 ); +} else { + $lastdate = $lastmove->{'datearrived'}; + $count = issuessince( $itm, $lastdate ); +} + my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed; for my $library ( @$libraries ) { $library->{selected} = 1 if $library->{branchcode} eq C4::Context->userenv->{branch}; diff --git a/circ/request-article.pl b/circ/request-article.pl index ea33b3ee5a..3d598ecf59 100755 --- a/circ/request-article.pl +++ b/circ/request-article.pl @@ -44,6 +44,9 @@ my $patron_cardnumber = $cgi->param('patron_cardnumber'); my $patron_id = $cgi->param('patron_id'); my $biblio = Koha::Biblios->find($biblionumber); +output_and_exit( $cgi, $cookie, $template, 'unknown_biblio') + unless $biblio; + my $patron = $patron_id ? Koha::Patrons->find($patron_id) : $patron_cardnumber ? Koha::Patrons->find( { cardnumber => $patron_cardnumber } ) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/blocking_errors.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/blocking_errors.inc index 4be8110e46..0ab6738260 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/blocking_errors.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/blocking_errors.inc @@ -3,6 +3,10 @@ [% CASE 'unknown_patron' %]
This patron does not exist. Find another patron?
[% CASE 'cannot_see_patron_infos' %]You are not allowed to see the information of this patron. + [% CASE 'unknown_biblio' %] +
This bibliographic record does not exist.
+ [% CASE 'unknown_item' %] +
This item does not exist.
[% CASE %][% blocking_error %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/bookcount.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/bookcount.tt index 2211a986cd..9ed1a663b8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/bookcount.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/bookcount.tt @@ -10,7 +10,11 @@ [% INCLUDE 'header.inc' %] [% INCLUDE 'circ-search.inc' %] - +
@@ -18,8 +22,8 @@
-

-[% title |html %] [% IF ( author ) %] by [% author |html %][% END %]

+[% INCLUDE 'blocking_errors.inc' %] +

[% title |html %] [% IF ( author ) %] by [% author |html %][% END %]

Barcode [% barcode %]

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt index 94d9b339ad..375b653ca8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt @@ -19,12 +19,15 @@ HomeCatalog + [% UNLESS blocking_error %] › [% biblio.title | html %] › Request article + [% END %] + [% INCLUDE 'blocking_errors.inc' %]
-- 2.39.5
Home libraryCurrent libraryDate arrived
at current library
Number of checkouts
since last transfer