From a50218f75e5fcd0c22bfe967cf52441ee1e7b15b Mon Sep 17 00:00:00 2001 From: Kyle M Hall 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. --- installer/data/mysql/sysprefs.sql | 2 +- installer/data/mysql/updatedatabase.pl | 7 +++++++ reserve/request.pl | 19 +++++++++---------- 3 files changed, 17 insertions(+), 11 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/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