koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/C4 Biblio.pm,1.115.2.5,1.115.2.6


From: Paul POULAIN
Subject: [Koha-cvs] CVS: koha/C4 Biblio.pm,1.115.2.5,1.115.2.6
Date: Wed, 09 Mar 2005 07:56:04 -0800

Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23080/C4

Modified Files:
      Tag: rel_2_2
        Biblio.pm 
Log Message:
Changing MARCmoditem to be like MARCmodbiblio : a modif is a delete & create.
Longer, but solves problems with repeated subfields.

The previous version was not buggy except under certain circumstances (a 
repeated subfield, that does not exist usually in items)

Index: Biblio.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Biblio.pm,v
retrieving revision 1.115.2.5
retrieving revision 1.115.2.6
diff -C2 -r1.115.2.5 -r1.115.2.6
*** Biblio.pm   24 Feb 2005 13:54:04 -0000      1.115.2.5
--- Biblio.pm   9 Mar 2005 15:56:01 -0000       1.115.2.6
***************
*** 299,309 ****
        my $relations = C4::Context->marcfromkohafield;
        return 
($relations->{$frameworkcode}->{$kohafield}->[0],$relations->{$frameworkcode}->{$kohafield}->[1]);
- #     my $sth =
- #       $dbh->prepare(
- # "select tagfield,tagsubfield from marc_subfield_structure where 
frameworkcode=? and kohafield=?"
- #     );
- #     $sth->execute($frameworkcode,$kohafield);
- #     my ( $tagfield, $tagsubfield ) = $sth->fetchrow;
- #     return ( $tagfield, $tagsubfield );
  }
  
--- 299,302 ----
***************
*** 711,745 ****
  sub MARCmoditem {
        my ($dbh,$record,$bibid,$itemnumber,$delete)address@hidden;
! 
!       my $oldrecord=&MARCgetitem($dbh,$bibid,$itemnumber);
!       # if nothing to change, don't waste time...
!       if ($oldrecord eq $record) {
!               return;
!       }
!       # otherwise, skip through each subfield...
!       my @fields = $record->fields();
!       # search old MARC item
!       my $sth2 = $dbh->prepare("select tagorder from 
marc_subfield_table,marc_subfield_structure where 
marc_subfield_table.tag=marc_subfield_structure.tagfield and 
marc_subfield_table.subfieldcode=marc_subfield_structure.tagsubfield and 
bibid=? and kohafield='items.itemnumber' and subfieldvalue=?");
!       $sth2->execute($bibid,$itemnumber);
!       my ($tagorder) = $sth2->fetchrow_array();
!       foreach my $field (@fields) {
!               my $oldfield = $oldrecord->field($field->tag());
!               my @subfields=$field->subfields();
!               my $subfieldorder=0;
!               foreach my $subfield (@subfields) {
!                       $subfieldorder++;
!                       if ($oldfield eq 0 or 
(length($oldfield->subfield(@$subfield[0])) ==0) ) {
!               # just adding datas...
!                               
&MARCaddsubfield($dbh,$bibid,$field->tag(),$field->indicator(1).$field->indicator(2),
!                                               
$tagorder,@$subfield[0],$subfieldorder,@$subfield[1]);
!                       } else {
!               # modify he subfield if it's a different string
!                               if ($oldfield->subfield(@$subfield[0]) ne 
@$subfield[1] ) {
!                                       my 
$subfieldid=&MARCfindsubfieldid($dbh,$bibid,$field->tag(),$tagorder,@$subfield[0],$subfieldorder);
!                                       
&MARCmodsubfield($dbh,$subfieldid,@$subfield[1]);
!                               }
!                       }
!               }
!       }
  }
  
--- 704,710 ----
  sub MARCmoditem {
        my ($dbh,$record,$bibid,$itemnumber,$delete)address@hidden;
!       my $biblionumber = MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid);
!       &MARCdelitem($dbh,$bibid,$itemnumber);
!       &MARCadditem($dbh,$record,$biblionumber);
  }
  
***************
*** 2654,2657 ****
--- 2619,2628 ----
  # $Id$
  # $Log$
+ # Revision 1.115.2.6  2005/03/09 15:56:01  tipaul
+ # Changing MARCmoditem to be like MARCmodbiblio : a modif is a delete & 
create.
+ # Longer, but solves problems with repeated subfields.
+ #
+ # The previous version was not buggy except under certain circumstances (a 
repeated subfield, that does not exist usually in items)
+ #
  # Revision 1.115.2.5  2005/02/24 13:54:04  tipaul
  # exporting MARCdelsubfield sub. It's used in authority merging.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]