From 71b5e225b4db801befc539acba6a31caff2c5a12 Mon Sep 17 00:00:00 2001 From: Vitor FERNANDES Date: Tue, 15 Jan 2013 17:19:59 +0000 Subject: [PATCH] Bug 9395: Problem with callnumber and standard number searches This problem happens because there isn't a operator "phr" in the values of callnumber and standard number search. So many results aren't the corrects ones. Test plan: - Apply the patch - In the dropbox search menu of OPAC main page header, the callnum should have only callnum - In OPAC advanced search the callnumber and standard number options shouldn't have "phr" - In staff client advanced search the callnumber and standard number options shouldn't have "phr" - Change OPACNumbersPreferPhrase and IntranetNumbersPreferPhrase to "use" - The options listed before should use now the operator "phr" - This will resolve the problems with the searches of callnumbers and standard numbers in OPAC and staff client (spaces problems, no results, inconsistent results, etc...) Sponsored-by: KEEP SOLUTIONS Signed-off-by: Owen Leonard I don't know how to reproduce the searching problems described in the bug, but I can confirm that the patch works correctly to enable/disable the use of 'phr' in the searches described in the test plan. Signed-off-by: Katrin Fischer System preferences work as described, switching indexes in OPAC and staff. All tests and QA script pass. Signed-off-by: Jared Camins-Esakov Conflicts: installer/data/mysql/sysprefs.sql installer/data/mysql/updatedatabase.pl --- catalogue/search.pl | 3 +++ installer/data/mysql/sysprefs.sql | 3 +++ installer/data/mysql/updatedatabase.pl | 8 ++++++++ .../prog/en/includes/search_indexes.inc | 8 ++++++++ .../en/modules/admin/preferences/searching.pref | 16 ++++++++++++++++ .../opac-tmpl/prog/en/includes/masthead.inc | 14 +++++++++++--- .../opac-tmpl/prog/en/modules/opac-advsearch.tt | 13 +++++++++++++ opac/opac-main.pl | 4 ++++ opac/opac-search.pl | 5 +++++ 9 files changed, 71 insertions(+), 3 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index d1a3ca259b..680f8375d8 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -182,6 +182,9 @@ else { if (C4::Context->preference("marcflavour") eq "UNIMARC" ) { $template->param('UNIMARC' => 1); } +if (C4::Context->preference("IntranetNumbersPreferPhrase")) { + $template->param('numbersphr' => 1); +} if($cgi->cookie("holdfor")){ my $holdfor_patron = GetMember('borrowernumber' => $cgi->cookie("holdfor")); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index aabae1d610..4d8c612f98 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -387,3 +387,6 @@ INSERT INTO systempreferences (variable,value,explanation,type) VALUES('OPACdidy INSERT INTO systempreferences (variable,value,explanation,type) VALUES('INTRAdidyoumean',NULL,'Did you mean? configuration for the Intranet. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free'); INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('BlockReturnOfWithdrawnItems', '1', '0', 'If enabled, items that are marked as withdrawn cannot be returned.', 'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('HoldsToPullStartDate','2','Set the default start date for the Holds to pull list to this many days ago',NULL,'Integer'); +INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACNumbersPreferPhrase','0', NULL, 'Control the use of phr operator in callnumber and standard number OPAC searches', 'YesNo'); +INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('IntranetNumbersPreferPhrase','0', NULL, 'Control the use of phr operator in callnumber and standard number staff client searches', 'YesNo'); + diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index c1fb41e5ea..9b62344541 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6142,6 +6142,14 @@ $DBversion = "3.10.03.000"; if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { print "Upgrade to $DBversion done (3.10.3 release)\n"; SetVersion($DBversion); +} + +$DBversion = "3.10.03.001"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACNumbersPreferPhrase','0', NULL, 'Control the use of phr operator in callnumber and standard number OPAC searches', 'YesNo')"); + $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('IntranetNumbersPreferPhrase','0', NULL, 'Control the use of phr operator in callnumber and standard number staff client searches', 'YesNo')"); + print "Upgrade to $DBversion done (Bug 9395: Problem with callnumber and standard number search in OPAC and Staff Client)\n"; + SetVersion ($DBversion); } =head1 FUNCTIONS diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc index 8102201e92..faabc42e62 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc @@ -20,10 +20,18 @@ [% END %] + [% IF (numbersphr) %] + + [% ELSE %] + [% END %] + [% IF (numbersphr) %] + + [% ELSE %] + [% END %] [% IF (marcflavour != 'UNIMARC' ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref index 7b99173f31..451cbc95c7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref @@ -79,6 +79,22 @@ Searching: yes: show no: "don't show" - '"More options" on the OPAC and staff advanced search pages.' + - + - By default, + - pref: OPACNumbersPreferPhrase + type: boolean + choices: + yes: use + no: "don't use" + - 'the operator "phr" in the callnumber and standard number OPAC searches' + - + - By default, + - pref: IntranetNumbersPreferPhrase + type: boolean + choices: + yes: use + no: "don't use" + - 'the operator "phr" in the callnumber and standard number staff client searches' Results Display: - - By default, sort search results in the staff client by diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc index a82dc42a2d..de2d2da3f9 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc @@ -66,11 +66,19 @@ [% ELSE %] [% END %] - [% IF ( ms_callnum ) %] + [% IF ( numbersphr ) %] + [% IF ( ms_callnum ) %] + + [% ELSE %] + + [% END %] + [% ELSE %] + [% IF ( ms_callnum ) %] - [% ELSE %] + [% ELSE %] - [% END %] + [% END %] + [% END %] [% IF ( ms_value ) %]
[% ELSE %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt index be2a6f77d8..825e8be16b 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt @@ -77,7 +77,11 @@ [% IF ( expanded_options ) %] + [% IF ( numbersphr) %] + + [% ELSE %] + [% END %] [% END %] @@ -99,10 +103,19 @@ [% IF ( expanded_options ) %] + [% IF ( numbersphr) %] + + [% ELSE %] + + [% END %] + [% IF ( numbersphr) %] + [% ELSE %] + + [% END %] [% ELSE %] [% END %] diff --git a/opac/opac-main.pl b/opac/opac-main.pl index c716c60550..7c6ee363f6 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -65,4 +65,8 @@ if (C4::Context->preference('GoogleIndicTransliteration')) { $template->param('GoogleIndicTransliteration' => 1); } +if (C4::Context->preference('OPACNumbersPreferPhrase')) { + $template->param('numbersphr' => 1); +} + output_html_with_http_headers $input, $cookie, $template->output; diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 73d2c5368e..1458a41806 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -293,6 +293,11 @@ if ( $template_type && $template_type eq 'advsearch' ) { $template->param( expanded_options => $cgi->param('expanded_options')); } } + + if (C4::Context->preference('OPACNumbersPreferPhrase')) { + $template->param('numbersphr' => 1); + } + output_html_with_http_headers $cgi, $cookie, $template->output; exit; } -- 2.39.5