Bug 11334: add ability to control which library fields are used for facets
authorKyle M Hall <kyle@bywatersolutions.com>
Tue, 3 Dec 2013 19:13:24 +0000 (14:13 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 29 Apr 2014 15:57:53 +0000 (15:57 +0000)
The current "Library" facet is somewhat ambiguous for Koha installations
with multiple libraries. It refers to the holdingbranch, but does not
explicitly state this. It would be beneficial to allow the administrator
to choose to show facets for the holding library, home library, or both.
In addition, the facets should be more explicitly labeled.  This patch
adds this flexibility.

Test plan:
1) Apply this patch
2) Check that the facets label "Libraries" now reads "Holding libraries"
3) Update the system preference DisplayLibraryFacets to "home library"
4) Check that the facet now reads "Home libraries"
5) Update the preference again to "both home and holding library"
6) Check that both the facets for home and holding library are now
   displayed.

Signed-off-by: Jen DeMuth <jdemuth@roseville.ca.us>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.
Changes apply to both prog and bootstrap OPAC and staff client.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>

C4/Koha.pm
installer/data/mysql/sysprefs.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref
koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc
koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc

index ce17ee6..4c70480 100644 (file)
@@ -716,15 +716,36 @@ sub getFacets {
             }
             ];
 
-            my $library_facet;
-            unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) {
-                $library_facet = {
-                    idx  => 'branch',
-                    label => 'Libraries',
-                    tags        => [ qw/ 995b / ],
-                };
+            unless ( C4::Context->preference("singleBranchMode")
+                || GetBranchesCount() == 1 )
+            {
+                my $DisplayLibraryFacets = C4::Context->preference('DisplayLibraryFacets');
+                if (   $DisplayLibraryFacets eq 'both'
+                    || $DisplayLibraryFacets eq 'holding' )
+                {
+                    push(
+                        @$facets,
+                        {
+                            idx   => 'holdingbranch',
+                            label => 'HoldingLibrary',
+                            tags  => [qw / 995b /],
+                        }
+                    );
+                }
+
+                if (   $DisplayLibraryFacets eq 'both'
+                    || $DisplayLibraryFacets eq 'home' )
+                {
+                push(
+                    @$facets,
+                    {
+                        idx   => 'homebranch',
+                        label => 'HomeLibrary',
+                        tags  => [qw / 995a /],
+                    }
+                );
+                }
             }
-            push( @$facets, $library_facet );
     }
     else {
         $facets = [
@@ -777,15 +798,36 @@ sub getFacets {
             },
             ];
 
-            my $library_facet;
-            unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) {
-                $library_facet = {
-                    idx  => 'branch',
-                    label => 'Libraries',
-                    tags        => [ qw / 952b / ],
-                };
+            unless ( C4::Context->preference("singleBranchMode")
+                || GetBranchesCount() == 1 )
+            {
+                my $DisplayLibraryFacets = C4::Context->preference('DisplayLibraryFacets');
+                if (   $DisplayLibraryFacets eq 'both'
+                    || $DisplayLibraryFacets eq 'holding' )
+                {
+                    push(
+                        @$facets,
+                        {
+                            idx   => 'holdingbranch',
+                            label => 'HoldingLibrary',
+                            tags  => [qw / 952b /],
+                        }
+                    );
+                }
+
+                if (   $DisplayLibraryFacets eq 'both'
+                    || $DisplayLibraryFacets eq 'home' )
+                {
+                push(
+                    @$facets,
+                    {
+                        idx   => 'homebranch',
+                        label => 'HomeLibrary',
+                        tags  => [qw / 952a /],
+                    }
+                );
+                }
             }
-            push( @$facets, $library_facet );
     }
     return $facets;
 }
index 05a0031..c8528bb 100644 (file)
@@ -99,6 +99,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('DisplayClearScreenButton','0','','If set to ON, a clear screen button will appear on the circulation page.','YesNo'),
 ('displayFacetCount','0',NULL,NULL,'YesNo'),
 ('DisplayIconsXSLT','1','','If ON, displays the format, audience, and material type icons in XSLT MARC21 results and detail pages.','YesNo'),
+('DisplayLibraryFacets',  'holdingbranch',  'home|holding|both',  'Defines which library facets to display.',  'Choice'),
 ('DisplayMultiPlaceHold','1','','Display the ability to place multiple holds or not','YesNo'),
 ('DisplayOPACiconsXSLT','1','','If ON, displays the format, audience, and material type icons in XSLT MARC21 results and detail pages in the OPAC.','YesNo'),
 ('dontmerge','1',NULL,'If ON, modifying an authority record will not update all associated bibliographic records immediately, ask your system administrator to enable the merge_authorities.pl cron job','YesNo'),
index d3a4999..8b68faf 100755 (executable)
@@ -8225,6 +8225,24 @@ if(CheckVersion($DBversion)) {
     SetVersion($DBversion);
 }
 
+$DBversion = '3.15.00.XXX';
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        INSERT INTO  systempreferences (
+            variable,
+            value,
+            options,
+            explanation,
+            type
+            )
+        VALUES (
+            'DisplayLibraryFacets',  'holdingbranch',  'home|holding|both',  'Defines which library facets to display.',  'Choice'
+        );
+    });
+    print "Upgrade to $DBversion done (Bug 11334 - Add facet for home library)\n";
+    SetVersion ($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)
index 6cdfa2f..9bf55f0 100644 (file)
@@ -17,7 +17,8 @@
 [% IF facets_loo.type_label_Places %]<span id="facet-places">Places</span>[% END %]
 [% IF facets_loo.type_label_Series %]<span id="facet-series">Series</span>[% END %]
 [% IF facets_loo.type_label_ItemTypes %]<span id="facet-itemtypes">Item types</span>[% END %]
-[% IF facets_loo.type_label_Libraries %]<span id="facet-libraries">Libraries</span>[% END %]
+[% IF ( facets_loo.type_label_HomeLibrary ) %]Home libraries[% END %]
+[% IF ( facets_loo.type_label_HoldingLibrary ) %]Holding libraries[% END %]
 [% IF facets_loo.type_label_Location %]<span id="facet-locations">Locations</span>[% END %]
 <ul>
         [% FOREACH facet IN facets_loo.facets %]<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by %][% END %]&amp;limit=[% facet.type_link_value %]:[% facet.facet_link_value %]" title="[% facet.facet_title_value %]">[% facet.facet_label_value %]</a> [% IF ( displayFacetCount ) %]([% facet.facet_count %])[% END %]</li>[% END %][% IF ( facets_loo.expandable ) %]
index e75dac7..5a4bdf1 100644 (file)
@@ -178,6 +178,14 @@ Searching:
               class: integer
             - results per page in the OPAC.
         -
+            - "Show facets for"
+            - pref: DisplayLibraryFacets
+              type: choice
+              choices:
+                  home: "home library"
+                  holding: "holding library"
+                  both: "both home and holding library"
+        -
             - pref: OPACItemsResultsDisplay
               type: boolean
               choices:
index d4fff99..612085d 100644 (file)
                         [% IF facets_loo.type_label_Series %]<h5 id="facet-series">Series</h5>[% END %]
                         [% IF facets_loo.type_label_ItemTypes %]<h5 id="facet-itemtypes">Item types</h5>[% END %]
                         [% UNLESS singleBranchMode %]
-                          [% IF facets_loo.type_label_Libraries %]<h5 id="facet-libraries">Libraries</h5>[% END %]
+                          [% IF ( facets_loo.type_label_HomeLibrary ) %]Home libraries[% END %]
+                          [% IF ( facets_loo.type_label_HoldingLibrary ) %]Holding libraries[% END %]
                         [% END %]
                         [% IF facets_loo.type_label_Location %]<h5 id="facet-locations">Locations</h5>[% END %]
-
                         <ul>
                             [% FOREACH facet IN facets_loo.facets %]
                                 <li>
index 107bf24..5c12502 100644 (file)
@@ -17,7 +17,8 @@
 [% IF facets_loo.type_label_Series %]<span id="facet-series">Series</span>[% END %]
 [% IF facets_loo.type_label_ItemTypes %]<span id="facet-itypes">Item types</span>[% END %]
 [% UNLESS singleBranchMode %]
-  [% IF facets_loo.type_label_Libraries %]<span id="facet-libraries">Libraries</span>[% END %]
+    [% IF ( facets_loo.type_label_HomeLibrary ) %]Home libraries[% END %]
+    [% IF ( facets_loo.type_label_HoldingLibrary ) %]Holding libraries[% END %]
 [% END %]
 [% IF facets_loo.type_label_Location %]<span id="facet-locations">Locations</span>[% END %]
 <ul>