[Koha-patches] [PATCH] Bug 8205: Add OPACShowUnusedAuthorities syspref

Jared Camins-Esakov jcamins at cpbibliography.com
Thu Jun 14 01:31:40 CEST 2012


Rather than list authorities that are not actually used by a library,
this commit introduces a new syspref: OPACShowUnusedAuthorities to
enable libraries to hide unused authorities in the OPAC authority browser.

To test:
1) Do a search in the OPAC authority browser that brings up multiple
   results, including some that are used in the bibliographic database
   and some that are not.
2) Observe that the results include both used and unused authorities.
3) Set OPACShowUnusedAuthorities to "Do not."
4) Repeat the same search as in step 1.
5) Observe that the results no longer include unused authorities.
---
 installer/data/mysql/sysprefs.sql                  |    1 +
 installer/data/mysql/updatedatabase.pl             |    7 +++++++
 .../prog/en/modules/admin/preferences/opac.pref    |    6 ++++++
 .../en/modules/opac-authoritiessearchresultlist.tt |    6 +++++-
 opac/opac-authorities-home.pl                      |    6 ++++++
 5 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index c4060fe..3a4eb09 100644
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -369,3 +369,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SuspendHoldsIntranet', '1', NULL , 'Allow holds to be suspended from the intranet.', 'YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SuspendHoldsOpac', '1', NULL , 'Allow holds to be suspended from the OPAC.', 'YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('DefaultLanguageField008','','Fill in the default language for field 008 Range 35-37 (e.g. eng, nor, ger, see <a href="http://www.loc.gov/marc/languages/language_code.html">MARC Code List for Languages</a>)','','Free');
+INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACShowUnusedAuthorities','1','','Show authorities that are not being used in the OPAC.','YesNo');
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 9b02cb9..1cf9e9a 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -5370,6 +5370,13 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
 }
 
 
+$DBversion = "3.09.00.XXX";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACShowUnusedAuthorities','1','','Show authorities that are not being used in the OPAC.','YesNo')");
+    print "Upgrade to $DBversion done (Add OPACShowUnusedAuthorities system preference)\n";
+    SetVersion ($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
index e4ea15b..a98b2b8 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
@@ -79,6 +79,12 @@ OPAC:
                   no: "Don't include"
             - "COinS / OpenURL / Z39.88 in OPAC search results.  <br/>Warning: Enabling this feature will slow OPAC search response times."
         -
+            - pref: OPACShowUnusedAuthorities
+              choices:
+                  yes: Show
+                  no: "Do not show"
+            - unused authorities in the OPAC authority browser.
+        -
             - pref: OPACShowHoldQueueDetails
               choices:
                   none: "Don't show any hold details"
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt
index 5fdfb27..4505658 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt
@@ -29,7 +29,11 @@
 		</div>
 		<div id="results">
 			[% IF ( total ) %]
-			<b>Results [% from %] to [% to %] of [% total %]</b>
+                [% IF ( countfuzzy ) %]
+                    <b>Showing [% resultcount %] of about [% total %] results</b>
+                [% ELSE %]
+                    <b>Results [% from %] to [% to %] of [% total %]</b>
+                [% END %]
 			[% ELSE %]
 			No results found.
 			[% END %]
diff --git a/opac/opac-authorities-home.pl b/opac/opac-authorities-home.pl
index acff077..4e9f9ab 100755
--- a/opac/opac-authorities-home.pl
+++ b/opac/opac-authorities-home.pl
@@ -127,6 +127,10 @@ if ( $op eq "do_search" ) {
     else {
         $to = ( ( $startfrom + 1 ) * $resultsperpage );
     }
+    unless (C4::Context->preference('OPACShowUnusedAuthorities')) {
+        my @usedauths = grep { $_->{used} > 0 } @$results;
+        $results = \@usedauths;
+    }
     $template->param( result => $results ) if $results;
     $template->param( FIELDS => \@fields );
     $template->param( orderby => $orderby );
@@ -138,9 +142,11 @@ if ( $op eq "do_search" ) {
         startfromnext  => $startfrom + 1,
         startfromprev  => $startfrom - 1,
         searchdata     => \@field_data,
+        countfuzzy     => !(C4::Context->preference('OPACShowUnusedAuthorities')),
         total          => $total,
         from           => $from,
         to             => $to,
+        resultcount    => scalar @$results,
         numbers        => \@numbers,
         authtypecode   => $authtypecode,
         authtypetext   => $authtypes->{$authtypecode}{'authtypetext'},
-- 
1.7.2.5



More information about the Koha-patches mailing list