From 9ba8a29c8d85e5479f728fcde814ea10e685e30c Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Mon, 9 Apr 2012 21:27:16 +0200 Subject: [PATCH] Bug 7935: Introduce sys pref to control 'browse results' in OPAC 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 --- C4/Auth.pm | 2 +- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 12 +++++++++++- .../prog/en/modules/admin/preferences/opac.pref | 8 ++++++++ koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 15 +++++++++------ opac/opac-detail.pl | 4 ++++ 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 0d5ddba..549c5c2 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -373,7 +373,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")); } diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 34ac684..eb86cf2 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -360,3 +360,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('SocialNetworks','1','Enable/Disable social networks links in opac detail pages','','YesNo'); 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('OpacBrowseResults','1','Disable/enable browsing and paging search results from the OPAC detail page.',NULL,'YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index b3c5691..f958ce1 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5090,7 +5090,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); } @@ -5159,6 +5159,16 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } + +$DBversion = "3.07.00.XXX"; +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 =head2 DropAllForeignKeys($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 54cc43a..715bf94 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 @@ -315,6 +315,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 diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt index 36ef631..4f80aa1 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt @@ -11,7 +11,8 @@ [% END %]