Bugzilla – Attachment 30796 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]
Bug 10589 - Override OpacHiddenItems based on Patron Category
Bug-10589---Override-OpacHiddenItems-based-on-Patr.patch (text/plain), 7.97 KB, created by
Marc Véron
on 2014-08-14 17:45:35 UTC
(
hide
)
Description:
Bug 10589 - Override OpacHiddenItems based on Patron Category
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2014-08-14 17:45:35 UTC
Size:
7.97 KB
patch
obsolete
>From 0dc98dd07a21cab1072c8f837c6767543aa8d691 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 one of the pipe delimited >values in the PatronSingleBranch patron category code, then >an item which would normally be hidden will be visible. > >If the patron category matches one of the pipe delimited >values in 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. > >Rebased to current master (again). > >Signed-off-by: Srdjan <srdjan@catalyst.net.nz> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Rebased to current master (Marc) >--- > C4/Items.pm | 26 +++++++++++++++++--- > installer/data/mysql/sysprefs.sql | 2 ++ > installer/data/mysql/updatedatabase.pl | 16 ++++++++++++ > .../prog/en/modules/admin/preferences/opac.pref | 8 ++++++ > 4 files changed, 49 insertions(+), 3 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index f8e2121..05126b4 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -35,7 +35,7 @@ use DateTime::Format::MySQL; > use Data::Dumper; # used as part of logging item record changes, not just for > # debugging; so please don't remove this > use Koha::DateUtils qw/dt_from_string/; >- >+use C4::Members qw/GetBorrowerCategorycode/; > use vars qw($VERSION @ISA @EXPORT); > > BEGIN { >@@ -1697,6 +1697,18 @@ sub GetHiddenItemnumbers { > return (); > } > my $dbh = C4::Context->dbh; >+ my $borrowernumber = 0; >+ my $homebranch = q{}; >+ my $categorycode = q{}; >+ if (C4::Context->userenv) { >+ $borrowernumber = C4::Context->userenv->{'number'} || 0; >+ $homebranch = C4::Context->userenv->{'branch'} || q{}; >+ } >+ if ($borrowernumber) { >+ $categorycode = C4::Members::GetBorrowerCategorycode($borrowernumber) || q{}; >+ } >+ my @SingleBranchCodes = split /\|/,C4::Context->preference('PatronSingleBranch'); >+ my @EveryBranchCodes = split /\|/,C4::Context->preference('PatronEveryBranch'); > > # For each item > foreach my $item (@items) { >@@ -1716,8 +1728,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'} && >+ (any { /^$categorycode$/ } @SingleBranchCodes ) ) || >+ (any { /^$categorycode$/ } @EveryBranchCodes ) ) { >+ $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 03a3f1e..0be27c1 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -305,6 +305,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('OverDriveLibraryID','','Library ID for OverDrive integration','','Integer'), > ('OverdueNoticeBcc','','','Email address to bcc outgoing overdue notices sent by email','free'), > ('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'), >+('PatronEveryBranch','','Pipe delimited patron category codes which allow viewing hidden items for every branch','',''), > ('patronimages','0',NULL,'Enable patron images for the Staff Client','YesNo'), > ('PatronSelfRegistration','0',NULL,'If enabled, patrons will be able to register themselves via the OPAC.','YesNo'), > ('PatronSelfRegistrationAdditionalInstructions','','','A free text field to display additional instructions to newly self registered patrons.','free'), >@@ -313,6 +314,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('PatronSelfRegistrationDefaultCategory','','','A patron registered via the OPAC will receive a borrower category code set in this system preference.','free'), > ('PatronSelfRegistrationExpireTemporaryAccountsDelay','0',NULL,'If PatronSelfRegistrationDefaultCategory is enabled, this system preference controls how long a patron can have a temporary status before the account is deleted automatically. It is an integer value representing a number of days to wait before deleting a temporary patron account. Setting it to 0 disables the deleting of temporary accounts.','Integer'), > ('PatronSelfRegistrationVerifyByEmail','0',NULL,'If enabled, any patron attempting to register themselves via the OPAC will be required to verify themselves via email to activate his or her account.','YesNo'), >+('PatronSingleBranch','',"Pipe delimited patron category codes which allow viewing hidden items for only the patron's home branch",'',''), > ('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'), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 3f1af57..06e87be 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -8603,6 +8603,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','',"Pipe delimited patron category codes which allow viewing hidden items for every branch",'',''); >+} >+ ); >+ $dbh->do( >+ q{ >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronSingleBranch','',"Pipe delimited patron category codes which allow 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 739abb3..49c5596 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 >@@ -529,6 +529,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 one of these pipe delimited patron category codes override OpacHiddenItems for their home branch only. >+ - >+ - pref: PatronEveryBranch >+ class: short >+ - Patrons matching one of these pipe delimited patron category codes override OpacHiddenItems for every branch. >+ - > - pref: OpacAllowPublicListCreation > default: 1 > choices: >-- >1.7.10.4
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