koha-cvs
[Top][All Lists]
Advanced

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

[Koha-cvs] koha/C4 Biblio.pm [rel_2_2]


From: Ryan Higgins
Subject: [Koha-cvs] koha/C4 Biblio.pm [rel_2_2]
Date: Wed, 25 Apr 2007 06:05:30 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         rel_2_2
Changes by:     Ryan Higgins <rych>     07/04/25 06:05:29

Modified files:
        C4             : Biblio.pm 

Log message:
        Item tagorder bug revisited: had been merging items due to repeating 
tagorder
        when called from addbiblio.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Biblio.pm?cvsroot=koha&only_with_tag=rel_2_2&r1=1.115.2.68&r2=1.115.2.69

Patches:
Index: Biblio.pm
===================================================================
RCS file: /sources/koha/koha/C4/Biblio.pm,v
retrieving revision 1.115.2.68
retrieving revision 1.115.2.69
diff -u -b -r1.115.2.68 -r1.115.2.69
--- Biblio.pm   17 Apr 2007 19:40:10 -0000      1.115.2.68
+++ Biblio.pm   25 Apr 2007 06:05:29 -0000      1.115.2.69
@@ -26,7 +26,7 @@
 use vars qw($VERSION @ISA @EXPORT);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.115.2.68 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.115.2.69 $' =~ /\d+/g;
                     shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); 
};
 
 @ISA = qw(Exporter);
@@ -344,8 +344,26 @@
         ($bibid) = $sth->fetchrow;
         $sth->finish;
     }
-    my $fieldcount = 1;
+    #shift the items' tagorders for this biblio so we don't overwrite item 
tags with biblio tags..
+    my $sth = $dbh->prepare("SELECT tagfield FROM marc_subfield_structure 
WHERE kohafield LIKE 'items.%'");
+    $sth->execute;
+    my $itemtag = $sth->fetchrow_hashref->{tagfield};
+       my $save_items_sth = $dbh->prepare("SELECT subfieldid, tagorder FROM 
marc_subfield_table WHERE bibid=? AND tag=? ORDER BY tagorder");
+       my $updatesth = $dbh->prepare("UPDATE marc_subfield_table SET 
tagorder=? WHERE subfieldid=?");
+       my $fieldcount = (scalar @fields) + 1 ;
+       my $itemtagorder = 0;
+    $save_items_sth->execute($bibid,$itemtag);
+    # for every item, update the tagorder
+    while (my ($subfieldid,$tagorder) = ($save_items_sth->fetchrow_array())) {
+        if ($tagorder != $itemtagorder) {
+               $fieldcount++;
+               $itemtagorder = $tagorder;
+               }
+        $updatesth->execute($fieldcount,$subfieldid);
+    }
 
+       #done moving item tagorders - now write the biblio tags.
+       $fieldcount = 1;
     # save leader first
     &MARCaddsubfield($dbh,$bibid,'000','',$fieldcount,'',1,$record->leader);
 
@@ -381,21 +399,6 @@
     }
 
     $dbh->do("UNLOCK TABLES");
-    # now we need to reorder the tagorder in marc_subfield_table for items data
-    #search item field code
-    my $sth = $dbh->prepare("SELECT tagfield FROM marc_subfield_structure 
WHERE kohafield LIKE 'items.%'");
-    $sth->execute;
-    my $itemtag = $sth->fetchrow_hashref->{tagfield};
-    my $newsth = $dbh->prepare("SELECT distinct(tagorder) FROM 
marc_subfield_table WHERE bibid=$bibid AND tag=$itemtag ORDER BY tagorder");
-    my $updatesth = $dbh->prepare("UPDATE marc_subfield_table SET tagorder=? 
WHERE tagorder=? AND bibid=? AND tag=?");
-
-    $newsth->execute();
-
-    # for every item, update the tagorder
-    for my $tagorder ($newsth->fetchrow_array()) {
-        $fieldcount++;
-        $updatesth->execute($fieldcount,$tagorder,$bibid,$itemtag);
-    }
 
     return $bibid;
 }
@@ -3031,8 +3034,12 @@
 
 =cut
 
-# $Id: Biblio.pm,v 1.115.2.68 2007/04/17 19:40:10 rych Exp $
+# $Id: Biblio.pm,v 1.115.2.69 2007/04/25 06:05:29 rych Exp $
 # $Log: Biblio.pm,v $
+# Revision 1.115.2.69  2007/04/25 06:05:29  rych
+# Item tagorder bug revisited: had been merging items due to repeating tagorder
+# when called from addbiblio.
+#
 # Revision 1.115.2.68  2007/04/17 19:40:10  rych
 # table lock problem on previous bugfix (reordering items in marc_subfield)
 #




reply via email to

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