Bugzilla – Attachment 7831 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), 9.93 KB, created by
Kyle M Hall
on 2012-02-23 14:23:20 UTC
(
hide
)
Description:
Bug 4045 - No check for maximum number of allowed holds.
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2012-02-23 14:23:20 UTC
Size:
9.93 KB
patch
obsolete
>From 210c419391b740a567366502ccd50f5aaf6293c9 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/sysprefs.sql | 2 +- > installer/data/mysql/updatedatabase.pl | 7 ++++ > .../opac-tmpl/prog/en/modules/opac-reserve.tt | 13 ++++++++ > opac/opac-reserve.pl | 32 +++++++++++++------- > reserve/request.pl | 19 +++++------ > 5 files changed, 51 insertions(+), 22 deletions(-) > >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 0cc79b2..35de0cb 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -64,7 +64,7 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MARCOrgCode','OSt','Define MARC Organization Code - http://www.loc.gov/marc/organizations/orgshome.html','','free'); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MaxFine',9999,'Maximum fine a patron can have for a single late return','','Integer'); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxoutstanding',5,'maximum amount withstanding to be able make holds','','Integer'); >-INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxreserves',50,'Define maximum number of holds a patron can place','','Integer'); >+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxreserves',50,'System-wide maximum number of holds a patron can place','','Integer'); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxItemsInSearchResults',20,'Specify the maximum number of items to display for each result on a page of results',NULL,'free'); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('memberofinstitution',0,'If ON, patrons can be linked to institutions',NULL,'YesNo'); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('noissuescharge',5,'Define maximum amount withstanding before check outs are blocked','','Integer'); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index d2d9d97..f74af22 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -4712,6 +4712,13 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.07.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 DropAllForeignKeys($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 64ed80c..ecb96f6 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt >@@ -4,6 +4,7 @@ > <script type="text/javascript"> > // <![CDATA[ > var MSG_NO_COPY_SELECTED = _("Expecting a specific copy selection."); >+ 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); >@@ -111,6 +112,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() { >@@ -163,6 +171,11 @@ > <div id="bd"> > <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 b2144a9..81cf375 100755 >--- a/opac/opac-reserve.pl >+++ b/opac/opac-reserve.pl >@@ -33,7 +33,7 @@ use C4::Overdues; > use C4::Debug; > # 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( >@@ -92,6 +92,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 >@@ -268,32 +269,41 @@ if ( $borr->{'amountoutstanding'} && ($borr->{'amountoutstanding'} > $maxoutstan > if ( $borr->{gonenoaddress} && ($borr->{gonenoaddress} eq 1) ) { > $noreserves = 1; > $template->param( >- message => 1, >- GNA => 1 >- ); >+ message => 1, >+ GNA => 1 >+ ); > } > if ( $borr->{lost} && ($borr->{lost} eq 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 24557f4..2d62298 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -135,14 +135,14 @@ if ($borrowernumber_hold && !$action) { > my $count_reserv = 0; > my $maxreserves; > >-# 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; >+ $warnings = 1; > $maxreserves = 1; > } > >@@ -150,13 +150,13 @@ 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)) { >- $messages = $expiry = 1; >+ Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) { >+ $messages = $expiry = 1; > } > > # check if the borrower make the reserv in a different branch > if ( $borrowerinfo->{'branchcode'} ne C4::Context->userenv->{'branch'} ) { >- $messages = 1; >+ $messages = 1; > $diffbranch = 1; > } > >@@ -178,8 +178,8 @@ if ($borrowernumber_hold && !$action) { > maxreserves => $maxreserves, > expiry => $expiry, > diffbranch => $diffbranch, >- messages => $messages, >- warnings => $warnings >+ messages => $messages, >+ warnings => $warnings > ); > } > >@@ -460,8 +460,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