Bug 13528: Use the different isbn variations on search on the isbn index (nb)
authorJonathan Druart <jonathan.druart@biblibre.com>
Mon, 22 Dec 2014 14:56:41 +0000 (15:56 +0100)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Thu, 16 Apr 2015 16:44:57 +0000 (13:44 -0300)
This enhancement adds the ability to search on all isbn variations when
searching on the isbn index.

Test plan:
0/ Don't apply the patch
1/ Create or choose a notice with an isbn with dashes.
2/ Try to search the notice using the isbn index by it isbn without
dashes.
=> It does not work.
3/ Apply the patch, enable the new pref SearchWithISBNVariations and
disable UseQueryParser.
4/ repeat 2 and note that the record is now returned.

Note that this only works if UseQueryParser is disabled.
It looks like QueryParser does not manage more than 1 operator.
See:
  QueryParser does not manage more than 1 operator?
  http://lists.koha-community.org/pipermail/koha-devel/2014-December/041028.html
and
  commit 036f2a50e11dab97ef8509f2f585c4cc407ea728
  Author: Galen Charlton <gmc@esilibrary.com>
  Date:   Mon May 5 19:31:00 2014 +0000
      Bug 10500: (follow-up) disable AggressiveMatchOnISBN if
      UseQueryParser is on

Signed-off-by: Morag Hills <the.invinnysible.one@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
C4/Search.pm
installer/data/mysql/sysprefs.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref

index f93dd15..357f735 100644 (file)
@@ -1569,6 +1569,13 @@ sub buildQuery {
                         $remove_stopwords
                     ) = ( 0, 0, 0, 0, 0 );
 
+                    if ( $index eq 'nb' ) {
+                        if ( C4::Context->preference("SearchWithISBNVariations") ) {
+                            my @isbns = C4::Koha::GetVariationsOfISBN( $operand );
+                            $operands[$i] = $operand =  '(nb=' . join(' OR nb=', @isbns) . ')';
+                            $indexes[$i] = $index = '';
+                        }
+                    }
                 }
 
                 if(not $index){
index 878214f..be44611 100644 (file)
@@ -367,6 +367,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('SCOUserCSS','',NULL,'Add CSS to be included in the SCO module in an embedded <style> tag.','free'),
 ('SCOUserJS','',NULL,'Define custom javascript for inclusion in the SCO module','free'),
 ('SearchMyLibraryFirst','0',NULL,'If ON, OPAC searches return results limited by the user\'s library by default if they are logged in','YesNo'),
+('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo'),
 ('SelfCheckHelpMessage','','70|10','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','Textarea'),
 ('SelfCheckReceiptPrompt','1','NULL','If ON, print receipt dialog pops up when self checkout is finished','YesNo'),
 ('SelfCheckTimeout','120','','Define the number of seconds before the Web-based Self Checkout times out a patron','Integer'),
index bc765f1..b09b5c8 100755 (executable)
@@ -10025,6 +10025,16 @@ if ( CheckVersion($DBversion) ) {
     SetVersion ($DBversion);
 }
 
+$DBversion = "3.19.00.XXX";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q|
+        INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES
+        ('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo')
+    |);
+    print "Upgrade to $DBversion done (Bug 13528 - Add the SearchWithISBNVariations syspref)\n";
+    SetVersion ($DBversion);
+}
+
 # DEVELOPER PROCESS, search for anything to execute in the db_update directory
 # SEE bug 13068
 # if there is anything in the atomicupdate, read and execute it.
index c6a19bf..8b04d39 100644 (file)
@@ -214,3 +214,10 @@ Searching:
             - Use the following text as separator for UNIMARC authors facets
             - pref: UNIMARCAuthorsFacetsSeparator
               class: short
+        -
+            - When searching on the ISBN index,
+            - pref: SearchWithISBNVariations
+              choices:
+                  yes: "search"
+                  no: "don't search"
+            - on all variations of the ISBN. Note that this preference has no effect if UseQueryParser is on.