[Koha-patches] [PATCH 35/35] Removing hyphens from isbn and issn when cataloging a biblio. It removes hyphens from isbn and issn only in marcxml, not in the field isbn in biblioitems where it is in the original format

Nicole Engard nengard at gmail.com
Thu Jul 14 20:29:19 CEST 2011


Juan,

You might want to review the steps for submitting patches to Koha:
http://wiki.koha-community.org/wiki/Bug-enhancement-patch_Workflow

Every patch needs to have a bug/enhancement report for it.

Nicole

On Thu, Jul 14, 2011 at 2:03 PM, Juan F. Romay Sieira <
juan.sieira at xercode.es> wrote:

> **
> There is not a bug, I think. The question is about the search of an isbn
> without hyphens. If isbn is indexed with hyphens, and you try to search for
> it with them, you'll not found it. This feature will index the isbn and issn
> whithout hyphens and will remove hyphens from search if you try to find a
> query like 978-84-92404-61-2.
> To try the patch, simply execute installer/data/mysql/updatedatabase.pl to
> insert the new syspref, insert a biblio and try to search it.
>
>
>  El 14/07/11 19:33, Nicole Engard escribió:
>
> What is the bug number for this? and can you include instructions for
> testing on the bug or in the patch please.
>
>
> Nicole
>
> On Thu, Jul 14, 2011 at 1:01 PM, Juan Romay Sieira <juan.sieira at xercode.es
> > wrote:
>
>> ---
>>  C4/Biblio.pm                                   |   34
>> ++++++++++++++++++++++++
>>  C4/Search.pm                                   |    1 +
>>  installer/data/mysql/en/mandatory/sysprefs.sql |    1 +
>>  installer/data/mysql/updatedatabase.pl         |    7 +++++
>>  kohaversion.pl                                 |    2 +-
>>  5 files changed, 44 insertions(+), 1 deletions(-)
>>
>> diff --git a/C4/Biblio.pm b/C4/Biblio.pm
>> index d797f40..332d476 100644
>> --- a/C4/Biblio.pm
>> +++ b/C4/Biblio.pm
>> @@ -3461,6 +3461,40 @@ sub ModBiblioMarc {
>>         # the previous version of the record
>>         $oldRecord = GetMarcBiblio($biblionumber);
>>     }
>> +
>> +    #
>> +    if (C4::Context->preference("IsbnIssnRemoveHyphens")){
>> +           my $isbn;
>> +           my $issn;
>> +               if ( $encoding eq 'UNIMARC' ) {
>> +                       if ( my $f010 = $record->field('010') ) {
>> +                               if ( $f010->subfield('a') ) {
>> +                                       $isbn = $f010->subfield('a');
>> +                                       $isbn =~ s/-//g;
>> +                                       $f010->update( 'a' => $isbn );
>> +                               }
>> +                       }
>> +                       if ( my $f011 = $record->field('011') ) {
>> +                               if ( $f011->subfield('a') ) {
>> +                                       $issn = $f011->subfield('a');
>> +                                       $issn =~ s/-//g;
>> +                                       $f011->update( 'a' => $issn );
>> +                               }
>> +                       }
>> +               } else {
>> +                       if ( my $f020 = $record->field('020') ) {
>> +                               $isbn = $f020->subfield('a');
>> +                               $isbn =~ s/-//g;
>> +                               $f020->update( 'a' => $isbn );
>> +                       }
>> +                       if ( my $f022 = $record->field('022') ) {
>> +                               $issn = $f022->subfield('a');
>> +                               $issn =~ s/-//g;
>> +                               $f022->update( 'a' => $issn );
>> +                       }
>> +               }
>> +    }
>> +
>>     $sth = $dbh->prepare("UPDATE biblioitems SET marc=?,marcxml=? WHERE
>> biblionumber=?");
>>     $sth->execute( $record->as_usmarc(),
>> $record->as_xml_record($encoding), $biblionumber );
>>     $sth->finish;
>> diff --git a/C4/Search.pm b/C4/Search.pm
>> index c3cff65..2bc934f 100644
>> --- a/C4/Search.pm
>> +++ b/C4/Search.pm
>> @@ -1159,6 +1159,7 @@ sub buildQuery {
>>                 }
>>                 # ISBN,ISSN,Standard Number, don't need special treatment
>>                 elsif ( $index eq 'nb' || $index eq 'ns' ) {
>> +                       $operand =~ s/-//g if
>> (C4::Context->preference("IsbnIssnRemoveHyphens"));
>>                     (
>>                         $stemming,      $auto_truncation,
>>                         $weight_fields, $fuzzy_enabled,
>> diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql
>> b/installer/data/mysql/en/mandatory/sysprefs.sql
>> index 0abf9d8..991c80a 100755
>> --- a/installer/data/mysql/en/mandatory/sysprefs.sql
>> +++ b/installer/data/mysql/en/mandatory/sysprefs.sql
>> @@ -314,3 +314,4 @@ INSERT INTO `systempreferences`
>> (variable,value,explanation,options,type) VALUES
>>  INSERT INTO `systempreferences` (variable,value,explanation,options,type)
>> VALUES('OpacHiddenItems','','This syspref allows to define custom rules for
>> hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more
>> informations.','','Textarea');
>>  INSERT INTO `systempreferences` (variable,value,explanation,options,type)
>> VALUES('numSearchRSSResults',50,'Specify the maximum number of results to
>> display on a RSS page of results',NULL,'Integer');
>>  INSERT INTO systempreferences (variable,value,explanation,options,type)
>> VALUES ('OpacRenewalBranch','checkoutbranch','Choose how the branch for an
>> OPAC renewal is recorded in
>> statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice');
>> +INSERT INTO `systempreferences` (`variable`, `value`, `options`,
>> `explanation`, `type`) VALUES ('IsbnIssnRemoveHyphens', '1', '', 'Remove or
>> not hyphens from ISBN and ISSN', 'YesNo');
>> diff --git a/installer/data/mysql/updatedatabase.plb/installer/data/mysql/
>> updatedatabase.pl
>> index 8fb9656..23daacf 100755
>> --- a/installer/data/mysql/updatedatabase.pl
>> +++ b/installer/data/mysql/updatedatabase.pl
>> @@ -4370,6 +4370,13 @@ if (C4::Context->preference("Version") <
>> TransformToNum($DBversion)) {
>>     SetVersion($DBversion);
>>  }
>>
>> +$DBversion = "3.05.00.005";
>> +if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
>> +    $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`,
>> `options`, `explanation`, `type`) VALUES ('IsbnIssnRemoveHyphens', '1', '',
>> 'Remove or not hyphens from ISBN and ISSN', 'YesNo');");
>> +    print "Upgrade to $DBversion done (Add SysPref to remove hyphens or
>> not into isbn and issn)\n";
>> +    SetVersion($DBversion);
>> +}
>> +
>>  =head1 FUNCTIONS
>>
>>  =head2 DropAllForeignKeys($table)
>> diff --git a/kohaversion.pl b/kohaversion.pl
>> index 00bdbec..9021eb0 100644
>> --- a/kohaversion.pl
>> +++ b/kohaversion.pl
>> @@ -16,7 +16,7 @@ the kohaversion is divided in 4 parts :
>>  use strict;
>>
>>  sub kohaversion {
>> -    our $VERSION = '3.05.00.004';
>> +    our $VERSION = '3.05.00.005';
>>     # version needs to be set this way
>>     # so that it can be picked up by Makefile.PL
>>     # during install
>> --
>> 1.7.1
>>
>> _______________________________________________
>> Koha-patches mailing list
>> Koha-patches at lists.koha-community.org
>> http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
>> website : http://www.koha-community.org/
>> git : http://git.koha-community.org/
>> bugs : http://bugs.koha-community.org/
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/koha-patches/attachments/20110714/99384821/attachment.htm>


More information about the Koha-patches mailing list