From 351bdabf4ae44f2f031128db113f20d5ea7cde6e 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 | 8 ++- 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 | 59 ++++++++++-------- 5 files changed, 104 insertions(+), 54 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index 8624b3b..2d7c43d 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -179,9 +179,11 @@ else { flagsrequired => { catalogue => 1 }, } ); + if (C4::Context->preference("marcflavour") eq "UNIMARC" ) { $template->param('UNIMARC' => 1); } + if (C4::Context->preference("IntranetNumbersPreferPhrase")) { $template->param('numbersphr' => 1); } @@ -411,7 +413,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..55374dd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt @@ -1,3 +1,4 @@ +[% USE Koha %] [% INCLUDE 'doc-head-open.inc' %] Koha › Catalog › Advanced search [% INCLUDE 'doc-head-close.inc' %] @@ -229,34 +230,42 @@ [% END %] -
Location and availability -
-

-
+
Location and availability +
+

+
+ + [% UNLESS Koha.Preference('IndependentBranchesIntranetSearch') %] +
+

+ + +

-
-

- - [% IF ( searchdomainloop ) %] -

OR

-

+ [% IF ( searchdomainloop ) %] +

OR

+

+ + +

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