From 6805abf40c4e76036105f88a7f426674c62b62a0 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 Signed-off-by: Jared Camins-Esakov --- C4/Auth.pm | 2 +- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 8 ++++++++ .../prog/en/modules/admin/preferences/opac.pref | 8 ++++++++ .../opac-tmpl/prog/en/modules/opac-detail.tt | 15 +++++++++------ opac/opac-detail.pl | 4 ++++ 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index d015e1e21d..d24b565fe3 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -399,7 +399,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 b6d537f140..c70ff505c0 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -336,3 +336,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerRelink',1,'If ON the authority linker will relink headings that have previously been linked every time it runs.',NULL,'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerKeepStale',0,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.',NULL,'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('CatalogModuleRelink',0,'If OFF the linker will never replace the authids that are set in the cataloging module.',NULL,'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 3ef88c7ca5..c5678600ef 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4648,6 +4648,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.06.XX.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 d6ae2b20a7..262a1fed87 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 @@ -292,6 +292,14 @@ OPAC: - pref: numSearchRSSResults class: long - search results in the RSS feed. + - + - 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 f474e98882..6f8c00ad55 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt @@ -3,7 +3,8 @@