From b0da4938e9af442f05bb38218ff366e9cd44b309 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 6 May 2013 09:44:01 -0400 Subject: [PATCH] Bug 10200 - Add more Independent Branches options - Part 1 - IndependentBranchesIntranetSearch Enabling IndependentBranchesIntranetSearch will automatically add a branch limit filter to the search results thus hiding all records without one or more items owned by the logged in library, including records with no items attached. Test Plan: 1) Apply patch 2) Run updatedatabase.pl 3) Perform a search that will give results for both records which have items owned by the logged in library, and records which have no items owned by the logged in library. 4) Enable the new system preference IndependentBranchesIntranetSearch 5) Perform the same search again, any records without items owned by the currently logged in library should not appear. --- catalogue/search.pl | 10 +++- installer/data/mysql/updatedatabase.pl | 20 ++++++ .../intranet-tmpl/prog/en/includes/cat-search.inc | 64 +++++++++++--------- .../prog/en/modules/admin/preferences/admin.pref | 7 ++ .../prog/en/modules/catalogue/advsearch.tt | 58 ++++++++++-------- 5 files changed, 105 insertions(+), 54 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index 8624b3b..6d4ebd1 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -179,9 +179,13 @@ else { flagsrequired => { catalogue => 1 }, } ); + +$template->param( IndependentBranchesIntranetSearch => C4::Context->preference('IndependentBranchesIntranetSearch') ); + if (C4::Context->preference("marcflavour") eq "UNIMARC" ) { $template->param('UNIMARC' => 1); } + if (C4::Context->preference("IntranetNumbersPreferPhrase")) { $template->param('numbersphr' => 1); } @@ -411,7 +415,11 @@ my @operands = $cgi->param('q'); # limits are use to limit to results to a pre-defined category such as branch or language my @limits = $cgi->param('limit'); -if($params->{'multibranchlimit'}) { +if ( C4::Context->preference('IndependentBranchesIntranetSearch') ) { + @limits = map { ( $_ =~ /^branch:/ ) ? undef : $_ } @limits; + push( @limits, "branch: " . C4::Context->userenv->{branch} ); +} +elsif( $params->{'multibranchlimit'} ) { push @limits, '('.join( " or ", map { "branch: $_ " } @{ GetBranchesInCategory( $params->{'multibranchlimit'} ) } ).')'; } diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index be4dfa2..a8cec45 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6784,6 +6784,26 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = "3.11.00.XXX"; +if ( CheckVersion($DBversion) ) { + print "Upgrade to $DBversion done (IndependentBranches)\n"; + $dbh->do(" + INSERT INTO systempreferences ( + variable, + value, + options, + explanation, + type + ) VALUES ( + 'IndependentBranchesIntranetSearch', + '0', + '', + 'If on, the staff interface search will hide all records that do not contain an item owned by the logged in branch.', + 'YesNo' + ) + "); + SetVersion ($DBversion); +} =head1 FUNCTIONS diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-search.inc index 186f1d1..4cf3e71 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-search.inc @@ -1,33 +1,41 @@
-

[% LibraryName %]

-
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 bb5c546..41b04a9 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 @@ -70,6 +70,13 @@ Administration: yes: Prevent no: "Don't prevent" - staff (but not superlibrarians) from modifying objects (holds, items, patrons, etc.) belonging to other libraries. + - + - pref: IndependentBranchesIntranetSearch + default: 0 + choices: + yes: Prevent + no: "Don't prevent" + - staff from seeing records without items owned by the logged in branch. CAS Authentication: - - pref: casAuthentication diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt index c982eb4..a3f6048 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt @@ -229,34 +229,42 @@ [% END %] -
Location and availability -
-

-
+
Location and availability +
+

+
+ + [% UNLESS IndependentBranchesIntranetSearch %] +
+

+ + +

-
-

- - [% IF ( searchdomainloop ) %] -

OR

-

+ [% IF ( searchdomainloop ) %] +

OR

+

+ + +

+ [% END %] +
[% END %]
-
-- 1.7.2.5