From b670f80c3a9a3fd39537d70c2d2314de4ec000eb Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 6 May 2013 10:16:56 -0400 Subject: [PATCH] Bug 10200 - Add more Independent Branches options - Part 2 - IndependentBranchesOpacSearch Enabling IndependentBranchesIntranetSearch will automatically add a branch limit filter to the search results thus hiding all records without one of more items owned by the library as defined by the webserver environment variable BRANCHCODE for the given OPAC, including records with no items attach. Test Plan: 1) Apply the patch 2) Run updatedatabase.pl 3) Add this line to the http-conf for your OPAC: SetEnv BRANCHCODE "MPL" Replace MPL with the branchcode you want to use for this test 4) Perform a search that will give results for both records which have items owned by the set library, and records which have no items owned by the set library. 5) Enable the new system preference IndependentBranchesOpacSearch 6) Perform the same search again, any records without items owned by the library set in the BRANCHCODE environment variable should not appear. --- installer/data/mysql/updatedatabase.pl | 20 ++++++- .../prog/en/modules/admin/preferences/admin.pref | 7 ++ .../opac-tmpl/prog/en/modules/opac-advsearch.tt | 59 ++++++++++++------- opac/opac-search.pl | 6 ++- 4 files changed, 67 insertions(+), 25 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index a8cec45..7d61069 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6787,7 +6787,7 @@ if ( CheckVersion($DBversion) ) { $DBversion = "3.11.00.XXX"; if ( CheckVersion($DBversion) ) { print "Upgrade to $DBversion done (IndependentBranches)\n"; - $dbh->do(" + $dbh->do(q{ INSERT INTO systempreferences ( variable, value, @@ -6801,7 +6801,23 @@ if ( CheckVersion($DBversion) ) { 'If on, the staff interface search will hide all records that do not contain an item owned by the logged in branch.', 'YesNo' ) - "); + }); + + $dbh->do(q{ + INSERT INTO systempreferences ( + variable, + value, + options, + explanation, + type + ) VALUES ( + 'IndependentBranchesOpacSearch', + '0', + '', + "If on, the opac catalog search will hide all records that do not contain an item owned by the branchcode defined by the OPAC's branch via the URL.", + 'YesNo' + ) + }); SetVersion ($DBversion); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref index 41b04a9..5435daf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref @@ -77,6 +77,13 @@ Administration: yes: Prevent no: "Don't prevent" - staff from seeing records without items owned by the logged in branch. + - + - pref: IndependentBranchesOpacSearch + default: 0 + choices: + yes: Prevent + no: "Don't prevent" + - OPAC search results from containing records that do not have item's owned by the library defined by the OPAC's branch via the URL. CAS Authentication: - - pref: casAuthentication diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt index 825e8be..d1ab34a 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt @@ -1,3 +1,4 @@ +[% USE Koha %] [% INCLUDE 'doc-head-open.inc' %] [% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Advanced search @@ -282,30 +283,44 @@
[% UNLESS ( singleBranchMode ) %] -
Location and availability: +
+
+ Location and availability: - - - [% IF ( searchdomainloop ) %] -

OR

- + + [% FOREACH BranchesLoo IN BranchesLoop %] + [% IF ( BranchesLoo.selected ) %] + + [% ELSE %] + + [% END %] + [% END %] + + + [% IF ( searchdomainloop ) %] +

OR

+ + + + [% END %] [% END %] - - [% END %] -
-
+ +
+ +
+
+
[% END %]
diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 363a11e..8103981 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -402,7 +402,11 @@ if ($operands[0] && !$operands[1]) { my @limits = $cgi->param('limit'); @limits = map { uri_unescape($_) } @limits; -if($params->{'multibranchlimit'}) { +if ( C4::Context->preference('IndependentBranchesOpacSearch') ) { + @limits = map { ( $_ =~ /^branch:/ ) ? undef : $_ } @limits; + push( @limits, "branch: " . $ENV{'BRANCHCODE'} ); +} +elsif($params->{'multibranchlimit'}) { push @limits, '('.join( " or ", map { "branch: $_ " } @{ GetBranchesInCategory( $params->{'multibranchlimit'} ) } ).')'; } -- 1.7.2.5