Bugzilla – Attachment 21200 Details for
Bug 4045
No check for maximum number of allowed holds from OPAC.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 4045 - No check for maximum number of allowed holds.
Bug-4045---No-check-for-maximum-number-of-allowed-.patch (text/plain), 8.17 KB, created by
Kyle M Hall (khall)
on 2013-09-18 12:35:08 UTC
(
hide
)
Description:
Bug 4045 - No check for maximum number of allowed holds.
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-09-18 12:35:08 UTC
Size:
8.17 KB
patch
obsolete
>From a6dd503ef2d8bd9132baa9811dbe1aa853c5c043 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 23 Feb 2012 08:39:05 -0500 >Subject: [PATCH] Bug 4045 - No check for maximum number of allowed holds. > >Re-add the system preference maxreserves. > >All the code using maxreserves is still in place. Though it >is not used in the Reserves module, it is used in all the >scripts where holds are placed. > >Also adds a check so that a borrower cannot exceed the maximum >number of allowed holds by using the multi-hold feature via >the opac. >--- > installer/data/mysql/updatedatabase.pl | 7 ++++ > .../opac-tmpl/prog/en/modules/opac-reserve.tt | 15 +++++++++ > opac/opac-reserve.pl | 32 +++++++++++++------- > reserve/request.pl | 12 ++++--- > 4 files changed, 50 insertions(+), 16 deletions(-) > >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 31f494a..899d62b 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -7139,6 +7139,13 @@ if ( CheckVersion($DBversion) ) { > SetVersion ($DBversion); > } > >+$DBversion = "3.13.00.XXX"; >+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { >+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('maxreserves',50,'System-wide maximum number of holds a patron can place','','Integer')"); >+ print "Upgrade to $DBversion done (Re-add system preference maxreserves)\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt >index d1fdbc6..6220f93 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt >@@ -5,10 +5,13 @@ > <script type="text/javascript"> > // <![CDATA[ > var MSG_NO_COPY_SELECTED = _("Expecting a specific copy selection."); >+ > var ForceHoldNotesReasons=new Array( > _("This title consists of multiple volumes/parts. Please indicate which part you need. Clicking on specific copy information may be helpful."), > "*** Add a new reason above this line ***" ); // NOTE: Do not renumber reasons; this will affect use of existing ones. > >+ var MSG_MAX_HOLDS_EXCEEDED = _("You cannot place this many more holds, please reduce the amount of holds requested to [% new_reserves_allowed %] or less."); >+ > function prefixOf (s, tok) { > var index = s.indexOf(tok); > return s.substring(0, index); >@@ -131,6 +134,13 @@ > return false; > } > >+ [% IF ( new_reserves_allowed ) %] >+ if ($(".confirmjs:checked").size() > [% new_reserves_allowed %]) { >+ alert(MSG_MAX_HOLDS_EXCEEDED); >+ return false; >+ } >+ [% END %] >+ > // Find the items with the 'Hold' box checked > var badBib = null; > $(".confirmjs:checked").each(function() { >@@ -183,6 +193,11 @@ > [% INCLUDE 'masthead.inc' %] > <div id="yui-g"> > <div id="holds" class="container"> >+ [% IF ( new_reserves_allowed ) %] >+ <div id="new_reserves_allowed" class="dialog alert"> >+ <p><strong>Sorry</strong>, you cannot place holds on all these items. You can only place [% new_reserves_allowed %] more hold(s). Please choose the items you wish to be held.</p> >+ </div> >+ [% END %] > [% IF ( message ) %] > [% IF ( GNA ) %] > <div id="gna" class="dialog alert"> >diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl >index 4bba9a6..51cbd74 100755 >--- a/opac/opac-reserve.pl >+++ b/opac/opac-reserve.pl >@@ -37,7 +37,7 @@ use C4::Debug; > use Koha::DateUtils; > # use Data::Dumper; > >-my $MAXIMUM_NUMBER_OF_RESERVES = C4::Context->preference("maxreserves"); >+my $maxreserves = C4::Context->preference("maxreserves"); > > my $query = new CGI; > my ( $template, $borrowernumber, $cookie ) = get_template_and_user( >@@ -102,6 +102,7 @@ if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) { > &get_out($query, $cookie, $template->output); > } > >+ > # pass the pickup branch along.... > my $branch = $query->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ; > ($branches->{$branch}) or $branch = ""; # Confirm branch is real >@@ -296,32 +297,41 @@ if ( $borr->{'amountoutstanding'} && ($borr->{'amountoutstanding'} > $maxoutstan > if ( $borr->{gonenoaddress} && ($borr->{gonenoaddress} == 1) ) { > $noreserves = 1; > $template->param( >- message => 1, >- GNA => 1 >- ); >+ message => 1, >+ GNA => 1 >+ ); > } > if ( $borr->{lost} && ($borr->{lost} == 1) ) { > $noreserves = 1; > $template->param( >- message => 1, >- lost => 1 >- ); >+ message => 1, >+ lost => 1 >+ ); > } > if ( CheckBorrowerDebarred($borrowernumber) ) { > $noreserves = 1; > $template->param( >- message => 1, >- debarred => 1 >- ); >+ message => 1, >+ debarred => 1 >+ ); > } > > my @reserves = GetReservesFromBorrowernumber( $borrowernumber ); >+my $reserves_count = scalar(@reserves); > $template->param( RESERVES => \@reserves ); >-if ( $MAXIMUM_NUMBER_OF_RESERVES && (scalar(@reserves) >= $MAXIMUM_NUMBER_OF_RESERVES) ) { >+if ( $maxreserves && ( $reserves_count >= $maxreserves ) ) { > $template->param( message => 1 ); > $noreserves = 1; > $template->param( too_many_reserves => scalar(@reserves)); > } >+ >+unless ( $noreserves ) { >+ my $requested_reserves_count = scalar( @biblionumbers ); >+ if ( $maxreserves && ( $reserves_count + $requested_reserves_count >= $maxreserves ) ) { >+ $template->param( new_reserves_allowed => $maxreserves - $reserves_count ); >+ } >+} >+ > foreach my $res (@reserves) { > foreach my $biblionumber (@biblionumbers) { > if ( $res->{'biblionumber'} == $biblionumber && $res->{'borrowernumber'} == $borrowernumber) { >diff --git a/reserve/request.pl b/reserve/request.pl >index c411ce9..51da6c7 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -122,13 +122,14 @@ if ($borrowernumber_hold && !$action) { > my @getreservloop; > my $count_reserv = 0; > >-# we check the reserves of the borrower, and if he can reserv a document >-# FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ... >+ # we check the reserves of the borrower, and if he can reserv a document >+ # FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ... > > my $number_reserves = > GetReserveCount( $borrowerinfo->{'borrowernumber'} ); > > if ( C4::Context->preference('maxreserves') && ($number_reserves >= C4::Context->preference('maxreserves')) ) { >+ $warnings = 1; > $maxreserves = 1; > } > >@@ -136,7 +137,7 @@ if ($borrowernumber_hold && !$action) { > my $expiry_date = $borrowerinfo->{dateexpiry}; > my $expiry = 0; # flag set if patron account has expired > if ($expiry_date and $expiry_date ne '0000-00-00' and >- Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) { >+ Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) { > $expiry = 1; > } > >@@ -162,6 +163,8 @@ if ($borrowernumber_hold && !$action) { > cardnumber => $borrowerinfo->{'cardnumber'}, > expiry => $expiry, > diffbranch => $diffbranch, >+ messages => $messages, >+ warnings => $warnings > ); > } > >@@ -416,8 +419,7 @@ foreach my $biblionumber (@biblionumbers) { > $num_available++; > } > elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) { >- >-# If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules >+ # If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules > $item->{override} = 1; > $num_override++; > } >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 4045
:
7634
|
7827
|
7831
|
8535
|
8536
|
10411
|
10412
|
10430
|
11418
|
21200
|
21712
|
21713
|
22960
|
22961
|
22962
|
28490
|
28491
|
28492
|
30051
|
30448