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 <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2018-06-13 10:52:33 -03:00 committed by Nick Clemens
parent 419470d3cd
commit d90ff21454
15 changed files with 7 additions and 53 deletions

View File

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

View File

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

View File

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

View File

@ -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-$_") );

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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' );

View File

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

View File

@ -21,7 +21,7 @@
<li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=FA">Fast cataloging</a></li>
[% END %][% END %]
[% IF Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes %]
<li><a href="/cgi-bin/koha/circ/checkout-notes.pl">Checkout notes</a> [% IF pending_checkout_notes %]<span class="number_box"><a href="/cgi-bin/koha/circ/checkout-notes.pl">[% pending_checkout_notes %]</span>[% END %]</li>
<li><a href="/cgi-bin/koha/circ/checkout-notes.pl">Checkout notes</a> [% IF pending_checkout_notes.count %]<span class="number_box"><a href="/cgi-bin/koha/circ/checkout-notes.pl">[% pending_checkout_notes.count %]</span>[% END %]</li>
[% END %]
</ul>

View File

@ -125,7 +125,7 @@
<div class="row">
<div class="col-sm-12">
[%# 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 ) %]
<div id="area-pending">
[% IF pending_article_requests %]
<div class="pending-info" id="article_requests_pending">
@ -172,10 +172,10 @@
</div>
[% 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 %]
<div class="pending-info" id="checkout_notes_pending">
<a href="/cgi-bin/koha/circ/checkout-notes.pl">Checkout notes pending</a>:
<span class="pending-number-link">[% pending_checkout_notes %]</span>
<span class="pending-number-link">[% pending_checkout_notes.count %]</span>
</div>
[% END %]

View File

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