Bugzilla – Attachment 37501 Details for
Bug 12354
Prevent placing holds on items based on item field values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12354 - Prevent reserving items based on item field values
Bug-12354---Prevent-reserving-items-based-on-item-.patch (text/plain), 5.87 KB, created by
Mark Tompsett
on 2015-04-04 21:32:46 UTC
(
hide
)
Description:
Bug 12354 - Prevent reserving items based on item field values
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2015-04-04 21:32:46 UTC
Size:
5.87 KB
patch
obsolete
>From 9200d49d61fb350c9804d5731683d76f816fb2d5 Mon Sep 17 00:00:00 2001 >From: Pasi Kallinen <pasi.kallinen@pttk.fi> >Date: Tue, 3 Jun 2014 07:50:01 +0300 >Subject: [PATCH] Bug 12354 - Prevent reserving items based on item field > values > >Add a system preference PreventItemHoldsFieldvalues, which is >a pipe-delimited list of "fieldname=value", where fieldname is >one of the fields from items -table in the database. If >the field has the exact value, the item cannot be reserved. > >For example, "ccode=PILA|location=OHE" would prevent reserving >the item if it's collection code is 'PILA' or if it's location is 'OHE'. > >To test: >1) Go to the page where you put a hold on an item, and look > at the list of items. Note which ones are available for hold > and which ones aren't. >2) Apply patch, set the syspref value to eg. homebranch=FOO|biblionumber=12345 >3) Check that items with homebranch FOO or items for biblio 12345 > cannot be reserved by patrons, and need override permission for staff > to reserve. > >NOTE: This should apply, but is missing tests added to > t/db_dependent/Reserves.t -- mtompset >--- > C4/Reserves.pm | 7 +++++++ > installer/data/mysql/sysprefs.sql | 1 + > installer/data/mysql/updatedatabase.pl | 7 +++++++ > .../intranet-tmpl/prog/en/modules/admin/preferences/opac.pref | 5 +++++ > 4 files changed, 20 insertions(+) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index b82387f..2c0021b 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -504,6 +504,13 @@ sub CanItemBeReserved{ > my $biblioData = C4::Biblio::GetBiblioData( $item->{biblionumber} ); > my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber); > >+ if ((my $PreventHolds = C4::Context->preference('PreventItemHoldsFieldvalues'))) { >+ foreach my $part (split(/\|/, $PreventHolds)) { >+ my ($field, $val) = split(/=/, $part); >+ return 0 if (defined $item->{$field} && $item->{$field} eq $val); >+ } >+ } >+ > # If an item is damaged and we don't allow holds on damaged items, we can stop right here > return 'damaged' if ( $item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems') ); > >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 1e07e3c..069cf0e 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -338,6 +338,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('PatronsPerPage','20','20','Number of Patrons Per Page displayed by default','Integer'), > ('Persona','0','','Use Mozilla Persona for login','YesNo'), > ('PrefillItem','0','','When a new item is added, should it be prefilled with last created item values?','YesNo'), >+('PreventItemHoldsFieldvalues', '', NULL, 'This is a pipe-delimited list of \"fieldname=value\", where fieldname is one of the fields from items -table in the database. If the field has the exact value, the item cannot be reserved. For example, \"ccode=PILA|location=OHE\" would prevent reserving the item if it\'s collection code is \'PILA\' or if it\'s location is \'OHE\'.', 'free') > ('previousIssuesDefaultSortOrder','asc','asc|desc','Specify the sort order of Previous Issues on the circulation page','Choice'), > ('printcirculationslips','1','','If ON, enable printing circulation receipts','YesNo'), > ('PrintNoticesMaxLines','0','','If greater than 0, sets the maximum number of lines an overdue notice will print. If the number of items is greater than this number, the notice will end with a warning asking the borrower to check their online account for a full list of overdue items.','Integer'), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 0592a94..67b42c7 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -9971,6 +9971,13 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.19.00.XXX"; >+if (CheckVersion($DBversion)) { >+ $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('PreventItemHoldsFieldvalues', '', NULL, 'This is a pipe-delimited list of \"fieldname=value\", where fieldname is one of the fields from items -table in the database. If the field has the exact value, the item cannot be reserved. For example, \"ccode=PILA|location=OHE\" would prevent reserving the item if it''s collection code is ''PILA'' or if it''s location is ''OHE''.', 'free');"); >+ print "Upgrade to $DBversion done (Bug 12354 - Prevent reserving items based on item field values)\n"; >+ SetVersion($DBversion); >+} >+ > > # DEVELOPER PROCESS, search for anything to execute in the db_update directory > # SEE bug 13068 >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 c26d048..3c61205 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 >@@ -387,6 +387,11 @@ OPAC: > no: "Don't allow" > - patrons to access a list of the most checked out items on the OPAC. Note that this is somewhat experimental, and should be avoided if your collection has a large number of items. > - >+ - Prevent reserving items with the following field values: >+ - pref: PreventItemHoldsFieldvalues >+ - . This is a pipe-delimited list of "fieldname=value", where fieldname is one of the fields from items -table in the database. If the field has the exact value, the item cannot be reserved. >+ - For example, "ccode=PILA|location=OHE" would prevent reserving the item if it's collection code is 'PILA' or if it's location is 'OHE'. >+ - > - pref: suggestion > choices: > yes: Allow >-- >1.9.1
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 12354
:
28630
| 37501