From d90ff21454ed1d2f9682cbbfa7e07c87381a3257 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 13 Jun 2018 10:52:33 -0300 Subject: [PATCH] Bug 17698: Do not send pending_checkout_notes from all circ scripts It's safer to send what we need from C4::Auth it's needed from a whole module. The SELECT COUNT(*) query will only be done when needed (so not made from scripts outside of circ) Signed-off-by: Jonathan Druart Signed-off-by: Nick Clemens --- C4/Auth.pm | 4 +++- circ/branchoverdues.pl | 4 ---- circ/branchtransfers.pl | 4 ---- circ/checkout-notes.pl | 6 ------ circ/circulation.pl | 4 ---- circ/on-site_checkouts.pl | 3 --- circ/renew.pl | 4 ---- circ/returns.pl | 4 ---- circ/selectbranchprinter.pl | 4 ---- circ/transferstoreceive.pl | 4 ---- circ/view_holdsqueue.pl | 4 ---- circ/waitingreserves.pl | 4 ---- koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc | 2 +- koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt | 6 +++--- mainpage.pl | 3 --- 15 files changed, 7 insertions(+), 53 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 2731ff2512..e27b1b3ad7 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -32,6 +32,7 @@ use C4::Search::History; use Koha; use Koha::Caches; use Koha::AuthUtils qw(get_script_name hash_password); +use Koha::Checkouts; use Koha::DateUtils qw(dt_from_string); use Koha::Library::Groups; use Koha::Libraries; @@ -498,7 +499,8 @@ sub get_template_and_user { EnableBorrowerFiles => C4::Context->preference('EnableBorrowerFiles'), UseKohaPlugins => C4::Context->preference('UseKohaPlugins'), UseCourseReserves => C4::Context->preference("UseCourseReserves"), - useDischarge => C4::Context->preference('useDischarge') + useDischarge => C4::Context->preference('useDischarge'), + pending_checkout_notes => scalar Koha::Checkouts->search({ noteseen => 0 }), ); } else { diff --git a/circ/branchoverdues.pl b/circ/branchoverdues.pl index ed4b85522d..d4c20cbb18 100755 --- a/circ/branchoverdues.pl +++ b/circ/branchoverdues.pl @@ -27,7 +27,6 @@ use C4::Koha; use C4::Debug; use Koha::DateUtils; use Koha::BiblioFrameworks; -use Koha::Checkouts; use Data::Dumper; =head1 branchoverdues.pl @@ -99,13 +98,10 @@ foreach my $num (@getoverdues) { push( @overduesloop, \%overdueforbranch ); } -my $pending_checkout_notes = Koha::Checkouts->search({ noteseen => 0 })->count; - # initiate the templates for the overdueloop $template->param( overduesloop => \@overduesloop, location => $location, - pending_checkout_notes => $pending_checkout_notes, ); # Checking if there is a Fast Cataloging Framework diff --git a/circ/branchtransfers.pl b/circ/branchtransfers.pl index 7de588c1ab..3e15cdfda7 100755 --- a/circ/branchtransfers.pl +++ b/circ/branchtransfers.pl @@ -35,7 +35,6 @@ use Koha::AuthorisedValues; use Koha::Holds; use Koha::Items; use Koha::Patrons; -use Koha::Checkouts; ############################################### # Getting state @@ -222,8 +221,6 @@ foreach my $code ( keys %$messages ) { # use Data::Dumper; # warn "FINAL ============= ".Dumper(@trsfitemloop); -my $pending_checkout_notes = Koha::Checkouts->search({ noteseen => 0 })->count; - $template->param( found => $found, reserved => $reserved, @@ -239,7 +236,6 @@ $template->param( trsfitemloop => \@trsfitemloop, errmsgloop => \@errmsgloop, CircAutocompl => C4::Context->preference("CircAutocompl"), - pending_checkout_notes => $pending_checkout_notes, ); # Checking if there is a Fast Cataloging Framework diff --git a/circ/checkout-notes.pl b/circ/checkout-notes.pl index 5bad39a4bf..97fb925977 100755 --- a/circ/checkout-notes.pl +++ b/circ/checkout-notes.pl @@ -37,12 +37,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); -my $pending_checkout_notes = Koha::Checkouts->search({ noteseen => 0 })->count; - -$template->param( - pending_checkout_notes => $pending_checkout_notes, -); - my $action; foreach (qw( seen notseen )) { $action = $_ if ( $query->param("mark_selected-$_") ); diff --git a/circ/circulation.pl b/circ/circulation.pl index e0de5d0994..1617584cf4 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -56,7 +56,6 @@ use Koha::Patron::Messages; use Koha::SearchEngine; use Koha::SearchEngine::Search; use Koha::Patron::Modifications; -use Koha::Checkouts; use Date::Calc qw( Today @@ -146,9 +145,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user ( ); my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in"; -my $pending_checkout_notes = Koha::Checkouts->search({ noteseen => 0 })->count; -$template->param( pending_checkout_notes => $pending_checkout_notes ); - my $force_allow_issue = $query->param('forceallow') || 0; if (!C4::Auth::haspermission( C4::Context->userenv->{id} , { circulate => 'force_checkout' } )) { $force_allow_issue = 0; diff --git a/circ/on-site_checkouts.pl b/circ/on-site_checkouts.pl index 05eef2c71c..96cea5a66f 100755 --- a/circ/on-site_checkouts.pl +++ b/circ/on-site_checkouts.pl @@ -23,7 +23,6 @@ use C4::Circulation qw( GetPendingOnSiteCheckouts ); use C4::Output; use C4::Koha; use Koha::BiblioFrameworks; -use Koha::Checkouts; my $cgi = new CGI; @@ -40,12 +39,10 @@ my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( # Checking if there is a Fast Cataloging Framework $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); -my $pending_checkout_notes = Koha::Checkouts->search({ noteseen => 0 })->count; my $pending_onsite_checkouts = C4::Circulation::GetPendingOnSiteCheckouts(); $template->param( pending_onsite_checkouts => $pending_onsite_checkouts, - pending_checkout_notes => $pending_checkout_notes, ); output_html_with_http_headers $cgi, $cookie, $template->output; diff --git a/circ/renew.pl b/circ/renew.pl index 01c37cd048..246c26629f 100755 --- a/circ/renew.pl +++ b/circ/renew.pl @@ -28,7 +28,6 @@ use C4::Koha; use Koha::DateUtils; use Koha::Database; use Koha::BiblioFrameworks; -use Koha::Checkouts; my $cgi = new CGI; @@ -122,7 +121,4 @@ if ($barcode) { # Checking if there is a Fast Cataloging Framework $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); -my $pending_checkout_notes = Koha::Checkouts->search({ noteseen => 0 })->count; -$template->param( pending_checkout_notes => $pending_checkout_notes ); - output_html_with_http_headers( $cgi, $cookie, $template->output ); diff --git a/circ/returns.pl b/circ/returns.pl index 103d290fb3..a82bdc1432 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -52,7 +52,6 @@ use Koha::BiblioFrameworks; use Koha::Holds; use Koha::Items; use Koha::Patrons; -use Koha::Checkouts; my $query = new CGI; @@ -580,8 +579,6 @@ foreach ( sort { $a <=> $b } keys %returneditems ) { push @riloop, \%ri; } -my $pending_checkout_notes = Koha::Checkouts->search({ noteseen => 0 })->count; - $template->param( riloop => \@riloop, printer => $printer, @@ -592,7 +589,6 @@ $template->param( forgivemanualholdsexpire => $forgivemanualholdsexpire, overduecharges => $overduecharges, AudioAlerts => C4::Context->preference("AudioAlerts"), - pending_checkout_notes => $pending_checkout_notes, ); $itemnumber = GetItemnumberFromBarcode( $barcode ); diff --git a/circ/selectbranchprinter.pl b/circ/selectbranchprinter.pl index 935cb4e7ee..03fa65b1ec 100755 --- a/circ/selectbranchprinter.pl +++ b/circ/selectbranchprinter.pl @@ -27,7 +27,6 @@ use C4::Print; # GetPrinters use C4::Koha; use Koha::BiblioFrameworks; use Koha::Libraries; -use Koha::Checkouts; # this will be the script that chooses branch and printer settings.... @@ -127,14 +126,11 @@ if (scalar @updated and not scalar @recycle_loop) { print $query->redirect($referer || '/cgi-bin/koha/circ/circulation.pl'); } -my $pending_checkout_notes = Koha::Checkouts->search({ noteseen => 0 })->count; - $template->param( referer => $referer, printerloop => \@printerloop, branch => $branch, recycle_loop=> \@recycle_loop, - pending_checkout_notes => $pending_checkout_notes, ); # Checking if there is a Fast Cataloging Framework diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl index cf43499866..a727dda165 100755 --- a/circ/transferstoreceive.pl +++ b/circ/transferstoreceive.pl @@ -40,7 +40,6 @@ use Koha::Libraries; use Koha::DateUtils; use Koha::BiblioFrameworks; use Koha::Patrons; -use Koha::Checkouts; my $input = new CGI; my $itemnumber = $input->param('itemnumber'); @@ -126,14 +125,11 @@ while ( my $library = $libraries->next ) { push( @branchesloop, \%branchloop ) if %branchloop; } -my $pending_checkout_notes = Koha::Checkouts->search({ noteseen => 0 })->count; - $template->param( branchesloop => \@branchesloop, show_date => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), TransfersMaxDaysWarning => C4::Context->preference('TransfersMaxDaysWarning'), latetransfers => $latetransfers ? 1 : 0, - pending_checkout_notes => $pending_checkout_notes, ); # Checking if there is a Fast Cataloging Framework diff --git a/circ/view_holdsqueue.pl b/circ/view_holdsqueue.pl index d471476c4d..f7dbbc23c6 100755 --- a/circ/view_holdsqueue.pl +++ b/circ/view_holdsqueue.pl @@ -30,7 +30,6 @@ use C4::Biblio; use C4::Items; use C4::HoldsQueue qw(GetHoldsQueueItems); use Koha::BiblioFrameworks; -use Koha::Checkouts; use Koha::ItemTypes; my $query = new CGI; @@ -64,9 +63,6 @@ if ( $run_report ) { ); } -my $pending_checkout_notes = Koha::Checkouts->search({ noteseen => 0 })->count; -$template->param( pending_checkout_notes => $pending_checkout_notes ); - # Checking if there is a Fast Cataloging Framework $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); diff --git a/circ/waitingreserves.pl b/circ/waitingreserves.pl index 93ca0e9590..aae9cbe7d0 100755 --- a/circ/waitingreserves.pl +++ b/circ/waitingreserves.pl @@ -39,7 +39,6 @@ use Koha::BiblioFrameworks; use Koha::Items; use Koha::ItemTypes; use Koha::Patrons; -use Koha::Checkouts; my $input = new CGI; @@ -151,8 +150,6 @@ while ( my $hold = $holds->next ) { $template->param(cancel_result => \@cancel_result) if @cancel_result; -my $pending_checkout_notes = Koha::Checkouts->search({ noteseen => 0 })->count; - $template->param( reserveloop => \@reservloop, reservecount => $reservcount, @@ -161,7 +158,6 @@ $template->param( show_date => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), ReservesMaxPickUpDelay => $max_pickup_delay, tab => $tab, - pending_checkout_notes => $pending_checkout_notes, ); # Checking if there is a Fast Cataloging Framework diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc index 0c69790927..b686fbbaf8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc @@ -21,7 +21,7 @@
  • Fast cataloging
  • [% END %][% END %] [% IF Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes %] -
  • Checkout notes [% IF pending_checkout_notes %][% pending_checkout_notes %][% END %]
  • +
  • Checkout notes [% IF pending_checkout_notes.count %][% pending_checkout_notes.count %][% END %]
  • [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt index 55048c0b84..7cb0632530 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -125,7 +125,7 @@
    [%# Following statement must be in one line for translatability %] - [% IF ( ( CAN_user_tools_moderate_comments && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) || ( CAN_user_borrowers_edit_borrowers && pending_borrower_modifications ) || ( CAN_user_acquisition && pendingsuggestions ) || ( CAN_user_borrowers_edit_borrowers && pending_discharge_requests ) || pending_article_requests) || ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes ) %] + [% IF ( ( CAN_user_tools_moderate_comments && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) || ( CAN_user_borrowers_edit_borrowers && pending_borrower_modifications ) || ( CAN_user_acquisition && pendingsuggestions ) || ( CAN_user_borrowers_edit_borrowers && pending_discharge_requests ) || pending_article_requests) || ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes.count ) %]
    [% IF pending_article_requests %]
    @@ -172,10 +172,10 @@
    [% END %] - [% IF Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes %] + [% IF Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes.count %]
    Checkout notes pending: - [% pending_checkout_notes %] + [% pending_checkout_notes.count %]
    [% END %] diff --git a/mainpage.pl b/mainpage.pl index 34cd3a41c6..da6aaee924 100755 --- a/mainpage.pl +++ b/mainpage.pl @@ -31,7 +31,6 @@ use Koha::Patron::Modifications; use Koha::Patron::Discharge; use Koha::Reviews; use Koha::ArticleRequests; -use Koha::Checkouts; my $query = new CGI; @@ -75,7 +74,6 @@ my $pending_article_requests = Koha::ArticleRequests->search_limited( $branch ? ( branchcode => $branch ) : (), } )->count; -my $pending_checkout_notes = Koha::Checkouts->search({ noteseen => 0 })->count; $template->param( pendingcomments => $pendingcomments, @@ -84,7 +82,6 @@ $template->param( pending_borrower_modifications => $pending_borrower_modifications, pending_discharge_requests => $pending_discharge_requests, pending_article_requests => $pending_article_requests, - pending_checkout_notes => $pending_checkout_notes, ); output_html_with_http_headers $query, $cookie, $template->output; -- 2.39.5