From a76713165ed5e531bee223231abb3f25f56effa9 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Tue, 13 May 2014 12:31:07 +0300 Subject: [PATCH] Bug 12242: Allow hiding branches from the OPAC search pulldowns Libraries may have branches which are not in actual use, for example our system has a branch where items with errors go during database conversion from our old ILS. These branches should not be shown to the patron. This patch adds a new syspref OpacHideBranches, where you can list branch codes, separated by pipe, to hide from the OPAC. To test: 1) Apply patch 2) Check OPAC where library pulldowns are shown, eg. Advanced Search so that all libraries are listed. 3) Edit syspref OpacHideBranch, set it to some branch codes, separated by pipe. 4) Check OPAC that those libraries do not show up in the pulldowns. --- C4/Auth.pm | 12 +++++++++++- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 19 +++++++++++++++++++ .../prog/en/modules/admin/preferences/opac.pref | 3 +++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 95b2717..6cacfeb 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -408,7 +408,17 @@ sub get_template_and_user { opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"), AnonSuggestions => "" . C4::Context->preference("AnonSuggestions"), AuthorisedValueImages => C4::Context->preference("AuthorisedValueImages"), - BranchesLoop => GetBranchesLoop($opac_name), + BranchesLoop => do { + my @exclude_branches = split( /\|/, C4::Context->preference('OpacHideBranches') ); + my $tmpbranches = GetBranchesLoop($opac_name); + if (scalar(@exclude_branches)) { + my %tmp = map { $_ => 1 } @exclude_branches; + my @include_branches = grep { ! defined($tmp{$_->{branchcode}}) } @$tmpbranches; + \@include_branches; + } else { + $tmpbranches; + } + }, BranchCategoriesLoop => GetBranchCategories( 'searchdomain', 1, $opac_name ), CalendarFirstDayOfWeek => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1, LibraryName => "" . C4::Context->preference("LibraryName"), diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index be2f63f..abd8fc8 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -235,6 +235,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OPACFRBRizeEditions','0','','If ON, the OPAC will query one or more ISBN web services for associated ISBNs and display an Editions tab on the details pages','YesNo'), ('opacheader','','70|10','Add HTML to be included as a custom header in the OPAC','Textarea'), ('OpacHiddenItems','','','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations.','Textarea'), +('OpacHideBranches','',NULL,'Hide these branches from OPAC search branches pull-down. (Use short branch names, separated by pipe-characters.)','Free'), ('OpacHighlightedWords','1','','If Set, then queried words are higlighted in OPAC','YesNo'), ('OpacHoldNotes','0','','Show hold notes on OPAC','YesNo'), ('OPACItemHolds','1','','Allow OPAC users to place hold on specific items. If OFF, users can only request next available copy.','YesNo'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 3b1718c..d8e72ef 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8465,6 +8465,25 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.15.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do(" + INSERT INTO systempreferences ( + variable, + value, + explanation, + type + ) VALUES ( + 'OpacHideBranches', + '', + 'Hide these branches from OPAC search branches pull-down. (Use short branch names, separated by pipe-characters.)', + 'Free' + ) + "); + print "Upgrade to $DBversion done (Bug 12242 - Allow hiding branches from the OPAC search pulldowns)\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 428f569..9d54c63 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 @@ -131,6 +131,9 @@ OPAC: no: "Don't show" - the item's barcode on the holdings tab. - + - pref: OpacHideBranches + - Hide these branches from OPAC search branches pull-down. (Use short branch names, separated by pipe-characters.) + - - pref: OpacHighlightedWords choices: yes: Highlight -- 1.8.3.2