Bugzilla – Attachment 28630 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]
Add a system preference PreventItemHoldsFieldvalues
0001-Bug-12354-Prevent-reserving-items-based-on-item-fiel.patch (text/plain), 5.66 KB, created by
paxed
on 2014-06-03 05:59:26 UTC
(
hide
)
Description:
Add a system preference PreventItemHoldsFieldvalues
Filename:
MIME Type:
Creator:
paxed
Created:
2014-06-03 05:59:26 UTC
Size:
5.66 KB
patch
obsolete
>From 930d524e84073299af1cde302f52f40d9353cfe3 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. >--- > 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 d399ee0..cf76820 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -470,6 +470,13 @@ sub CanItemBeReserved{ > # item->{itype} will come for biblioitems if necessery > my $item = GetItem($itemnumber); > >+ 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 0 if ( $item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems') ); > >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index aff00ab..bb64c61 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -317,6 +317,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 01472d7..f2c2d20 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -8551,6 +8551,13 @@ if (CheckVersion($DBversion)) { > SetVersion($DBversion); > } > >+$DBversion = "3.17.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); >+} >+ > =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 839daa8..0257910 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 >@@ -386,6 +386,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.8.3.2 >
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