@@ -, +, @@ SetEnv BRANCHCODE "MPL" Replace MPL with the branchcode you want to use for this test have items owned by the set library, and records which have no items owned by the set library. 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 | 58 ++++++++++++-------- opac/opac-search.pl | 8 +++- 4 files changed, 68 insertions(+), 25 deletions(-) --- a/installer/data/mysql/updatedatabase.pl +++ a/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); } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref +++ a/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 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt +++ a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt @@ -282,30 +282,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 %]
--- a/opac/opac-search.pl +++ a/opac/opac-search.pl @@ -120,6 +120,8 @@ if ($template_name eq 'opac-results.tmpl') { $template->param('COinSinOPACResults' => C4::Context->preference('COinSinOPACResults')); } +$template->param( IndependentBranchesOpacSearch => C4::Context->preference('IndependentBranchesOpacSearch') ); + # get biblionumbers stored in the cart my @cart_list; @@ -402,7 +404,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'} ) } ).')'; } --