Bugzilla – Attachment 34513 Details for
Bug 13478
Force item holds only for specific biblios
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13478: Force item holds only for specific biblios
Bug-13478-Force-item-holds-only-for-specific-bibli.patch (text/plain), 14.79 KB, created by
Marcel de Rooy
on 2014-12-18 12:37:14 UTC
(
hide
)
Description:
Bug 13478: Force item holds only for specific biblios
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2014-12-18 12:37:14 UTC
Size:
14.79 KB
patch
obsolete
>From 80b659926a1c7ef7f463a92de87a86f6dd08f80e Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 18 Dec 2014 11:59:13 +0100 >Subject: [PATCH] Bug 13478: Force item holds only for specific biblios >Content-Type: text/plain; charset=utf-8 > >This patch adds the option to selectively force item holds for specific >biblionumbers. These numbers are saved in a separate table. >The patch adds routine C4::Reserves::CheckBiblioForceItemHolds. It is >tested in Reserves.t. >The preference OPACItemHolds gets a new choice: selectiveforce. >The description of the pref is adjusted. > >Please note that this option is specifically targeted for the OPAC. Staff >users still have both possibilities. > >A follow-up patch adds the possibility for staff users to add or remove >a biblio from the list of books with forced item holds. > >TEST PLAN: >[ 1] Run the database revision. >[ 2] Run the unit test t/db_dependent/Reserves.t. >[ 3] Set OPACItemHolds to force. >[ 4] Add a hold in the OPAC; verify that you cannot place a next/av hold. >[ 5] Set OPACItemHolds to Allow. >[ 6] Add a hold in the OPAC; verify that you can place both hold types. >[ 7] Set OPACItemHolds to Do not allow. >[ 8] Add a hold in the OPAC; verify that you can only place next/av holds. >[ 9] Add two biblio numbers into table biblio_force_item_holds. >[10] Set OPACItemHolds to Selectively force. >[11] Add a hold on three biblionumbers at once (including these two). > Verify that you have two hold types for the single biblio and that > you have only item holds for the two other biblios. >--- > C4/Reserves.pm | 17 ++++++ > Koha/Schema/Result/BiblioForceItemHold.pm | 53 ++++++++++++++++++++ > installer/data/mysql/kohastructure.sql | 10 ++++ > installer/data/mysql/sysprefs.sql | 2 +- > installer/data/mysql/updatedatabase.pl | 15 ++++++ > .../prog/en/modules/admin/preferences/opac.pref | 3 +- > .../opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 22 +++++---- > opac/opac-reserve.pl | 3 + > t/db_dependent/Reserves.t | 19 +++++++- > 9 files changed, 131 insertions(+), 13 deletions(-) > create mode 100644 Koha/Schema/Result/BiblioForceItemHold.pm > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 5058c51..328f25c 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -2440,6 +2440,23 @@ sub IsItemOnHoldAndFound { > return $found; > } > >+=head2 CheckBiblioForceItemHolds >+ >+ This subroutine returns true if item holds are forced for each biblio >+ by OPACItemHolds. If this pref is set to selective, the biblio should >+ be found in the designated table. >+ In other cases it returns undef. >+ >+=cut >+ >+sub CheckBiblioForceItemHolds { >+ my ( $biblionumber ) = @_; >+ return 1 if C4::Context->preference('OPACItemHolds') eq 'force'; >+ return if C4::Context->preference('OPACItemHolds') ne 'selectiveforce'; >+ my $rs = Koha::Database->new()->schema()->resultset('BiblioForceItemHold'); >+ return 1 if $rs->find( $biblionumber ); >+} >+ > =head1 AUTHOR > > Koha Development Team <http://koha-community.org/> >diff --git a/Koha/Schema/Result/BiblioForceItemHold.pm b/Koha/Schema/Result/BiblioForceItemHold.pm >new file mode 100644 >index 0000000..7a11232 >--- /dev/null >+++ b/Koha/Schema/Result/BiblioForceItemHold.pm >@@ -0,0 +1,53 @@ >+use utf8; >+package Koha::Schema::Result::BiblioForceItemHold; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+=head1 NAME >+ >+Koha::Schema::Result::BiblioForceItemHold >+ >+=cut >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+=head1 TABLE: C<biblio_force_item_holds> >+ >+=cut >+ >+__PACKAGE__->table("biblio_force_item_holds"); >+ >+=head1 ACCESSORS >+ >+=head2 biblionumber >+ >+ data_type: 'integer' >+ is_nullable: 0 >+ >+=cut >+ >+__PACKAGE__->add_columns("biblionumber", { data_type => "integer", is_nullable => 0 }); >+ >+=head1 PRIMARY KEY >+ >+=over 4 >+ >+=item * L</biblionumber> >+ >+=back >+ >+=cut >+ >+__PACKAGE__->set_primary_key("biblionumber"); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07036 @ 2014-12-18 10:00:44 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fJDe98uyvYlbqjrElzM/rQ >+ >+ >+# You can replace this text with custom code or comments, and it will be preserved on regeneration >+1; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 4ffbbf2..48e4542 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -132,6 +132,16 @@ CREATE TABLE `biblio` ( -- table that stores bibliographic information > ) ENGINE=InnoDB DEFAULT CHARSET=utf8; > > -- >+-- Table structure for table `biblio_force_item_holds` >+-- >+ >+DROP TABLE IF EXISTS `biblio_force_item_holds`; >+CREATE TABLE `biblio_force_item_holds` ( -- biblios with forced item holds >+ `biblionumber` int NOT NULL, -- primary key >+ PRIMARY KEY (`biblionumber`) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- > -- Table structure for table `biblio_framework` > -- > >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index c3e308f..ab9aa77 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -262,7 +262,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('OpacHiddenItems','','','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations.','Textarea'), > ('OpacHighlightedWords','1','','If Set, then queried words are higlighted in OPAC','YesNo'), > ('OpacHoldNotes','0','','Show hold notes on OPAC','YesNo'), >-('OPACItemHolds','1','0|1|force','Allow OPAC users to place hold on specific items. If No, users can only request next available copy. If Yes, users can choose between next available and specific copy. If Force, users *must* choose a specific copy.','Choice'), >+('OPACItemHolds','1','0|1|force|selectiveforce','Allow OPAC users to place hold on specific items. If No, users can only request next available copy. If Yes, users can choose between next available and specific copy. If Force, users *must* choose a specific copy. Selectiveforce works on specific biblios.','Choice'), > ('OpacItemLocation','callnum','callnum|ccode|location','Show the shelving location of items in the opac','Choice'), > ('OPACItemsResultsDisplay','0','','If OFF : show only the status of items in result list.If ON : show full location of items (branch+location+callnumber) as in staff interface','YesNo'), > ('OpacKohaUrl','1',NULL,'Show \'Powered by Koha\' text on OPAC footer.',NULL), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index cf17e0b..0e0234f 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -9585,6 +9585,21 @@ if ( CheckVersion($DBversion) ) { > SetVersion ($DBversion); > } > >+ >+$DBversion = "3.19.00.XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do(qq| >+ CREATE TABLE biblio_force_item_holds >+ (biblionumber int NOT NULL PRIMARY KEY); >+ |); >+ $dbh->do(qq| >+ UPDATE systempreferences SET explanation = 'Allow OPAC users to place hold on specific items. If No, users can only request next available copy. If Yes, users can choose between next available and specific copy. If Force, users *must* choose a specific copy. Selectiveforce works on specific biblios.' >+ WHERE variable = 'OPACItemHolds'; >+ |); >+ print "Upgrade to $DBversion done (Update OPACItemHolds description)\n"; >+ SetVersion ($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index 45df9f8..d33a144 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -494,7 +494,8 @@ OPAC: > no: "Don't allow" > yes: Allow > force: Force >- - patrons to place holds on specific items in the OPAC. If this is disabled, users can only put a hold on the next available item. If this is forced, users must put a hold on a specific item. >+ selectiveforce: Selectively force >+ - patrons to place holds on specific items in the OPAC. If this is disabled, users can only put a hold on the next available item. If this is forced, users must put a hold on a specific item. The 'selective force'-option works with a list of biblios with forced item holds. > - > - pref: OpacRenewalAllowed > choices: >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt >index 6558e6e..f5def52 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt >@@ -119,7 +119,7 @@ > <div id="bigloop"> > > [% FOREACH bibitemloo IN bibitemloop %] >- <div class="holdrow"> >+ <div class="holdrow" id="holdrow_[% bibitemloo.biblionumber %]"> > <p> > [% IF ( bibitemloo.holdable ) %] > <input class="reserve_mode" name="reserve_mode" type="hidden" value="single"/> >@@ -243,7 +243,7 @@ > </li> > [% END # / IF OpacHoldNotes %] > >- [% IF OPACItemHolds == '1' or OPACItemHolds == 'force' %] >+ [% IF OPACItemHolds %] > <!-- ITEM HOLDS --> > <li class="lradio place_on_type" style="display:none;"> > <label class="radio inline" for="reqany_[% bibitemloo.biblionumber %]">Next available item</label> >@@ -262,7 +262,7 @@ > /> > [% END %] > <label class="radio inline" for="reqspecific_[% bibitemloo.biblionumber %]">A specific item</label> >- [% IF OPACItemHolds == "force" %] >+ [% IF bibitemloo.force_item_holds %] > <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]" > id="reqspecific_[% bibitemloo.biblionumber %]" > class="selectspecific" >@@ -280,7 +280,7 @@ > [% END # / IF OPACItemHolds %] > </ul> > >- [% IF OPACItemHolds == '1' || OPACItemHolds == 'force' %] >+ [% IF OPACItemHolds %] > <table class="copiesrow table table-bordered table-striped" id="copiesrow_[% bibitemloo.biblionumber %]"> > <caption>Select a specific item:</caption> > <tr> >@@ -460,8 +460,8 @@ > // Hides all 'specific copy' table rows on load. > $(".copiesrow").hide(); > >- [% IF OPACItemHolds == 'force' %] >- [% FOREACH bibitemloo IN bibitemloop %] >+ [% FOREACH bibitemloo IN bibitemloop %] >+ [% IF bibitemloo.force_item_holds %] > [% IF bibitemloo.holdable %] > $("#toggle-hold-options-[% bibitemloo.biblionumber %]").click(); > $("#copiesrow_[% bibitemloo.biblionumber %]").show(); >@@ -523,15 +523,17 @@ > > $("#place_on_hdr").show(); > >- [% IF OPACItemHolds == '1' %] >- $(".place_on_type").show(); >+ [% FOREACH bibitemloo IN bibitemloop %] >+ [% IF OPACItemHolds == '1' OR !bibitemloo.force_item_holds %] >+ $("#holdrow_[% bibitemloo.biblionumber %]").find(".place_on_type").show(); > // onload, selectany is checked >- $(".selectany").attr("checked", "checked"); >+ $("#holdrow_[% bibitemloo.biblionumber %]").find(".selectany").attr("checked", "checked"); >+ [% END %] > [% END %] > > // If the user is *allowed* to choose a specific item > // The first one is preselected >- [% IF OPACItemHolds =="1" %] >+ [% IF OPACItemHolds %] > $("table.copiesrow").each(function(){ > var id = suffixOf($(this).attr("id"), "_"); > select_first_available(id); >diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl >index ba778db..23599c8 100755 >--- a/opac/opac-reserve.pl >+++ b/opac/opac-reserve.pl >@@ -561,6 +561,9 @@ foreach my $biblioNum (@biblionumbers) { > > if( $biblioLoopIter{holdable} ){ $anyholdable++; } > >+ $biblioLoopIter{force_item_holds} = >+ C4::Reserves::CheckBiblioForceItemHolds( $biblioNum ); >+ > push @$biblioLoop, \%biblioLoopIter; > } > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 4676a60..6c061c4 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 53; >+use Test::More tests => 57; > > use MARC::Record; > use DateTime::Duration; >@@ -506,6 +506,23 @@ is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 'OK', "Res > ####### EO Bug 13113 <<< > #### > >+#Tests for CheckBiblioForceItemHolds >+$dbh->do('DELETE FROM biblio_force_item_holds'); >+C4::Context->set_preference('OPACItemHolds', 'force'); >+is( C4::Reserves::CheckBiblioForceItemHolds($bibnum), 1, >+ 'If OPACItemHolds==force, each bib should force item holds'); >+C4::Context->set_preference('OPACItemHolds', 'selectiveforce'); >+isnt( C4::Reserves::CheckBiblioForceItemHolds($bibnum), 1, >+ 'For selectiveforce this bib should not be found'); >+$dbh->do('INSERT INTO biblio_force_item_holds (biblionumber) VALUES (?)', >+ undef, ( $bibnum ) ); >+is( C4::Reserves::CheckBiblioForceItemHolds($bibnum), 1, >+ 'For selectiveforce this bib should be found now'); >+C4::Context->set_preference('OPACItemHolds', '1'); >+isnt( C4::Reserves::CheckBiblioForceItemHolds($bibnum), 1, >+ 'For Allow this bib should return false again'); >+#End of tests for CheckBiblioForceItemHolds >+ > $dbh->rollback; > > sub count_hold_print_messages { >-- >1.7.7.6
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 13478
:
34513
|
34947
|
34948
|
36193
|
36237
|
36238
|
36566
|
36567
|
36866
|
36867