Bugzilla – Attachment 19931 Details for
Bug 10589
Override OpacHiddenItems based on Patron Branch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Uses patron category to keep visible some things hidden by OPACHiddenItems
0001-Bug-10589-Override-OpacHiddenItems-based-on-Patron-C.patch (text/plain), 6.37 KB, created by
Mark Tompsett
on 2013-07-24 18:23:25 UTC
(
hide
)
Description:
Uses patron category to keep visible some things hidden by OPACHiddenItems
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2013-07-24 18:23:25 UTC
Size:
6.37 KB
patch
obsolete
>From 55f3cf4545bd673edb382663565f6d93975e34f0 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Wed, 10 Jul 2013 18:41:01 -0400 >Subject: [PATCH] Bug 10589 - Override OpacHiddenItems based on Patron > Category > >Two system preferences, PatronSingleBranch and >PatronEveryBranch, have been added to facilitate some >granularity on the override. > >If the home branch of the item and the patron match and the >catgegory code of the patron matches the PatronSingleBranch >patron category code, then an item which would normally be >hidden will be visible. > >If the patron category matches the PatronEveryBranch patron >category, then every item hidden by OpacHiddenItems will >be visible. > >Since the patron category codes used by default for these >two system preferences are not added, OpacHiddenItems will >continue function as expected until individual patrons and >system preferences are configured. > >There is no need to provide this functionality to staff, >as they have access to the staff client. >--- > C4/Items.pm | 20 ++++++++++++++++++-- > installer/data/mysql/sysprefs.sql | 2 ++ > installer/data/mysql/updatedatabase.pl | 16 ++++++++++++++++ > .../prog/en/modules/admin/preferences/opac.pref | 8 ++++++++ > 4 files changed, 44 insertions(+), 2 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index 212a9d3..907d9cd 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -32,6 +32,7 @@ use C4::Log; > use List::MoreUtils qw/any/; > use Data::Dumper; # used as part of logging item record changes, not just for > # debugging; so please don't remove this >+use C4::Members qw/GetBorrowerCategorycode/; > > use vars qw($VERSION @ISA @EXPORT); > >@@ -1635,6 +1636,13 @@ sub GetHiddenItemnumbers { > return (); > } > my $dbh = C4::Context->dbh; >+ my $borrowernumber = q{}; >+ my $homebranch = q{}; >+ if (C4::Context->userenv) { >+ $borrowernumber = C4::Context->userenv->{'number'} || 0; >+ $homebranch = C4::Context->userenv->{'branch'} || q{}; >+ } >+ my $categorycode = C4::Members::GetBorrowerCategorycode($borrowernumber) || q{}; > > # For each item > foreach my $item (@items) { >@@ -1654,8 +1662,16 @@ sub GetHiddenItemnumbers { > # If the results matches the values in the yaml file > if (any { $val eq $_ } @{$hidingrules->{$field}}) { > >- # We add the itemnumber to the list >- push @resultitems, $item->{'itemnumber'}; >+ my $override = 0; >+ if ( ($homebranch eq $item->{'homebranch'} && >+ $categorycode eq C4::Context->preference('PatronSingleBranch') ) || >+ $categorycode eq C4::Context->preference('PatronEveryBranch') ) { >+ $override = 1; >+ } >+ if ($override==0) { >+ # We add the itemnumber to the hidden list >+ push @resultitems, $item->{'itemnumber'}; >+ } > > # If at least one rule matched for an item, no need to test the others > last; >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index c8caee7..b1f2444 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -430,3 +430,5 @@ INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) V > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo'); > INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('AllowTooManyOverride', '1', 'If on, allow staff to override and check out items when the patron has reached the maximum number of allowed checkouts', '', 'YesNo'); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronEveryBranch','PTEB','The patron category code which allows viewing hidden items for every branch','',''); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronSingleBranch','PTSB',"The patron category code which allows viewing hidden items for only the patron's home branch",'',''); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 74aeb3e..9a2ecf2 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -7067,6 +7067,22 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.13.00.XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do( >+ q{ >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronEveryBranch','PTEB',"The patron category code which allows viewing hidden items for every branch",'',''); >+} >+ ); >+ $dbh->do( >+ q{ >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronSingleBranch','PTSB',"The patron category code which allows viewing hidden items for only the patron's home branch",'',''); >+} >+ ); >+ print "Upgrade to $DBversion done (Bug filtering: Patron Category to override OPACHiddenItems)\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 90295ef..0783df6 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 >@@ -497,6 +497,14 @@ OPAC: > class: code > - Allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations > - >+ - pref: PatronSingleBranch >+ class: short >+ - Patrons matching this patron category overrides OpacHiddenItems for their home branch only. >+ - >+ - pref: PatronEveryBranch >+ class: short >+ - Patrons matching this patron category overrides OpacHiddenItems for their every branch. >+ - > - pref: OpacAllowPublicListCreation > default: 1 > choices: >-- >1.7.9.5 >
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 10589
:
19647
|
19708
|
19931
|
19932
|
19933
|
19949
|
19954
|
21063
|
21066
|
21256
|
21620
|
22587
|
22629
|
30796
|
30806
|
82521
|
82522