From 94dae0ae51733cc3b151b0b23767306ccd2e3f22 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 15 Jun 2018 14:23:27 +0000 Subject: [PATCH] Bug 20955: Add systempreference to allow triggering forbidden holds To test: 1 - Set a holds policy to allow only holds from homebranch 2 - Place a hold on an item for a patron from another branch 3 - Checkin item 4 - Hold does not trigger 5 - Apply patches and updatedatabase 6 - Check in item 7 - Hold triggers --- C4/Reserves.pm | 8 +++++--- .../bug_20955_add_TriggerForbiddenwqHolds_syspref.perl | 8 ++++++++ installer/data/mysql/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/circulation.pref | 6 ++++++ 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_20955_add_TriggerForbiddenwqHolds_syspref.perl diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 359fd98..d724621 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -739,9 +739,11 @@ sub CheckReserves { $patron ||= Koha::Patrons->find( $res->{borrowernumber} ); my $branch = GetReservesControlBranch( $iteminfo, $patron->unblessed ); my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$iteminfo->{'itype'}); - next if ($branchitemrule->{'holdallowed'} == 0); - next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $patron->branchcode)); - next if ( ($branchitemrule->{hold_fulfillment_policy} ne 'any') && ($res->{branchcode} ne $iteminfo->{ $branchitemrule->{hold_fulfillment_policy} }) ); + if( !C4::Context->preference('TriggerForbiddenHolds') ) { + next if ($branchitemrule->{'holdallowed'} == 0); + next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $patron->branchcode)); + next if ( ($branchitemrule->{hold_fulfillment_policy} ne 'any') && ($res->{branchcode} ne $iteminfo->{ $branchitemrule->{hold_fulfillment_policy} }) ); + } $priority = $res->{'priority'}; $highest = $res; last if $local_hold_match; diff --git a/installer/data/mysql/atomicupdate/bug_20955_add_TriggerForbiddenwqHolds_syspref.perl b/installer/data/mysql/atomicupdate/bug_20955_add_TriggerForbiddenwqHolds_syspref.perl new file mode 100644 index 0000000..7d80b3a --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_20955_add_TriggerForbiddenwqHolds_syspref.perl @@ -0,0 +1,8 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('TriggerForbiddenHolds','0', 'Consider holds that defy circulation/holds policies when checking items in', NULL, 'YesNo');"); + + # Always end with this (adjust the bug info) + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 20955 - Add TriggerForbiddenHolds system preference)\n"; +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 2ea76a4..d45ddf7 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -569,6 +569,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('TransfersMaxDaysWarning','3',NULL,'Define the days before a transfer is suspected of having a problem','Integer'), ('TransferWhenCancelAllWaitingHolds','0',NULL,'Transfer items when cancelling all waiting holds','YesNo'), ('TranslateNotices','0',NULL, 'Allow notices to be translated','YesNo'), +('TriggerForbiddenHolds','0',NULL, 'Consider holds that defy circulation/holds policies when checking items in', 'YesNo'), ('UNIMARCAuthorityField100','afrey50 ba0',NULL,'Define the contents of UNIMARC authority control field 100 position 08-35','Textarea'), ('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'), ('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 8c66afe..e8191b7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -726,6 +726,12 @@ Circulation: - 'Example: "itemlost: 1" to set items.itemlost to 1 when the item is marked as lost' - pref: UpdateItemWhenLostFromHoldList type: textarea + - + - pref: TriggerForbiddenHolds + choices: + yes: Do + no: "Don't" + - trigger holds that defy the circulation/holds policies. Interlibrary Loans: - - pref: ILLModule -- 2.1.4