Bug 7935: Introduce sys pref to control 'browse results' in OPAC
authorKatrin Fischer <Katrin.Fischer.83@web.de>
Mon, 9 Apr 2012 19:27:16 +0000 (21:27 +0200)
committerPaul Poulain <paul.poulain@biblibre.com>
Tue, 10 Apr 2012 13:26:37 +0000 (15:26 +0200)
Patch introduces a new system preference "OpacBrowseResults" to control
the feature for browsing and paging through results shown on top of the
left menu on detail pages in OPAC.

Preference is activated by default and can be deactivated using the
system preference.

To test:
 - Check database update works correctly
 - Check that browsing and paging still works with after database update
 - Deactivate the feature by setting 'OpacBrowseResults' to 'Disable'
 - Check the feature does no longer show up in OPAC
 - Check that a new installation also has the system preference with correct default

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
C4/Auth.pm
installer/data/mysql/sysprefs.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
opac/opac-detail.pl

index df97408..ffee1bb 100644 (file)
@@ -372,7 +372,7 @@ sub get_template_and_user {
         $LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi;
         $LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg;
         # clean up the busc param in the session if the page is not opac-detail
-        if ($in->{'template_name'} =~ /opac-(.+)\.(?:tt|tmpl)$/ && $1 !~ /^(?:MARC|ISBD)?detail$/) {
+        if (C4::Context->preference("OpacBrowseResults") && $in->{'template_name'} =~ /opac-(.+)\.(?:tt|tmpl)$/ && $1 !~ /^(?:MARC|ISBD)?detail$/) {
             my $sessionSearch = get_session($sessionID || $in->{'query'}->cookie("CGISESSID"));
             $sessionSearch->clear(["busc"]) if ($sessionSearch->param("busc"));
         }
index b16b40f..7a3731c 100644 (file)
@@ -361,3 +361,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
 INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free');
 INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('AutoResumeSuspendedHolds',  '1', NULL ,  'Allow suspended holds to be automatically resumed by a set date.',  'YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacStarRatings','all',NULL,'disable|all|details','Choice');
+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacBrowseResults','1','Disable/enable browsing and paging search results from the OPAC detail page.',NULL,'YesNo');
index 25e3543..4c18dac 100755 (executable)
@@ -5089,7 +5089,7 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
 $DBversion = "3.07.00.041";
 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free')");
-    print "Upgrade to $DBversion done (Add System Preferences SubscriptionDuplicateDroppedInput)\n";
+    print "Upgrade to $DBversion done (Add system preference SubscriptionDuplicateDroppedInput)\n";
     SetVersion($DBversion);
 }
 
@@ -5189,6 +5189,13 @@ q /INSERT INTO systempreferences (variable,value,explanation,options,type) VALUE
     SetVersion($DBversion);
 }
 
+$DBversion = "3.07.00.049";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacBrowseResults','1','Disable/enable browsing and paging search results from the OPAC detail page.',NULL,'YesNo')");
+    print "Upgrade to $DBversion done (Add system preference OpacBrowseResults ))\n";
+    SetVersion($DBversion);
+}
+
 
 =head1 FUNCTIONS
 
index 1fd5234..eb74d81 100644 (file)
@@ -323,6 +323,14 @@ OPAC:
                   yes: Enable
                   no: Disable
             - social network links in opac detail pages
+        -
+            - pref: OpacBrowseResults
+              default: 1
+              choices:
+                  yes: Enable
+                  no: Disable
+            - browsing and paging search results from the OPAC detail page.
+
     Policy:
         -
             - pref: singleBranchMode
index 4520c90..cc59fb2 100644 (file)
@@ -14,7 +14,8 @@
 
 <script type="text/JavaScript" language="JavaScript">
 //<![CDATA[
-    [% IF ( busc ) %]
+
+    [% IF ( OpacBrowseResults && busc ) %]
         var arrPagination = new Array();
         var pag_index_ini = [% indexPag %];
         [% IF ( listResults ) %]
@@ -58,7 +59,9 @@
         [% END %]
        [% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %][% IF ( TagsEnabled ) %]
         $(".tagbutton").click(KOHA.Tags.add_tag_button);[% END %][% END %][% END %]
-        [% IF ( busc ) %]
+
+
+    [% IF ( OpacBrowseResults && busc ) %]
         if (arrPagination.length > 0) {
             renderPagIndexList(pag_index_ini, $("#listResults"));
         }
@@ -83,7 +86,7 @@
             var navigation = $(".pagination");
             navigation.hide();
         });
-        [% END %]
+    [% END %]
 
         $(".branch-info-tooltip-trigger").tooltip({delay: 100, position: "top right"});
 
@@ -136,8 +139,7 @@ $(function () {
 
 });
 
-[% IF ( busc ) %]
-
+[% IF ( OpacBrowseResults && busc ) %]
 var timeoutRFW;
 var totalPagItemList = 10;
 
@@ -1165,7 +1167,8 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
 
 <div class="yui-u">
 <div id="ulactioncontainer" class="container">
-[% IF ( busc ) %]
+
+[% IF ( OpacBrowseResults && busc ) %]
     <div class="nav_results">
         <div class="l_Results">[% IF ( listResults ) %]<a href="#" id="a_listResults" title="Show pagination list ([% indexPag %]-[% indexPagEnd %] / [% totalPag %])">Browse results</a>[% ELSE %]<span>Browse results</span>[% END %]</div>
         <ul class="pg_menu clearfix">
index 11fae95..afc9498 100755 (executable)
@@ -96,8 +96,11 @@ if (C4::Context->preference("OPACXSLTDetailsDisplay") ) {
     $template->param( 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "OPACXSLTDetailsDisplay" ) );
 }
 
+my $OpacBrowseResults = C4::Context->preference("OpacBrowseResults");
+$template->{VARS}->{'OpacBrowseResults'} = $OpacBrowseResults;
 
 # We look for the busc param to build the simple paging from the search
+if ($OpacBrowseResults) {
 my $session = get_session($query->cookie("CGISESSID"));
 my %paging = (previous => {}, next => {});
 if ($session->param('busc')) {
@@ -377,6 +380,7 @@ if ($session->param('busc')) {
     $template->param('listResults' => \@listResults) if (@listResults);
     $template->param('indexPag' => 1 + $offset, 'totalPag' => $arrParamsBusc{'total'}, 'indexPagEnd' => scalar(@arrBiblios) + $offset);
 }
+}