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_3_0]


From: paul poulain
Subject: [Koha-cvs] koha/C4 Biblio.pm [rel_3_0]
Date: Wed, 24 Jan 2007 13:50:26 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         rel_3_0
Changes by:     paul poulain <tipaul>   07/01/24 13:50:26

Modified files:
        C4             : Biblio.pm 

Log message:
        Acquisition fix
        removing newbiblio & newbiblioitems subs.
        adding Koha2Marc
        
        IMHO, all biblio handling is better handled if they are done in a 
single place, the subs with MARC::Record as parameters.
        newbiblio & newbiblioitems where koha 1.x subs, that are called when 
MARC=OFF (which is not working anymore in koha 3.0, unless someone reintroduce 
it), and in acquisition module.
        The Koha2Marc sub moves a hash (with biblio/biblioitems subfield as 
keys) into a MARC::Record, that can be used to call NewBiblio, the standard 
biblio manager sub.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Biblio.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.178.2.55&r2=1.178.2.56

Patches:
Index: Biblio.pm
===================================================================
RCS file: /sources/koha/koha/C4/Biblio.pm,v
retrieving revision 1.178.2.55
retrieving revision 1.178.2.56
diff -u -b -r1.178.2.55 -r1.178.2.56
--- Biblio.pm   17 Jan 2007 18:07:17 -0000      1.178.2.55
+++ Biblio.pm   24 Jan 2007 13:50:26 -0000      1.178.2.56
@@ -33,7 +33,7 @@
 use vars qw($VERSION @ISA @EXPORT);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.178.2.55 $' =~ /\d+/g; 
shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.178.2.56 $' =~ /\d+/g; 
shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); };
 
 @ISA = qw( Exporter );
 
@@ -99,6 +99,7 @@
   &GetMarcBiblio
   &GetMarcAuthors
   &GetMarcSeries
+  &Koha2Marc
 );
 
 # Others functions
@@ -112,8 +113,6 @@
 
 # OLD functions,
 push @EXPORT, qw(
-  &newbiblio
-  &newbiblioitem
   &newitems
   &modbiblio
   &modbibitem
@@ -175,7 +174,7 @@
 
 =head2 AddBiblio
 
-($biblionumber,$oldbibnum,$oldbibitemnum) = AddBiblio($record,$frameworkcode);
+($biblionumber,$biblioitemnumber) = AddBiblio($record,$frameworkcode);
 
 Exported function (core API) for adding a new biblio to koha.
 
@@ -278,7 +277,7 @@
     
&logaction(C4::Context->userenv->{'number'},"CATALOGUING","ADD",$biblionumber,"biblio")
 
         if C4::Context->preference("CataloguingLog");
       
-    return ( $biblionumber, $oldbibnum, $oldbibitemnum );
+    return ( $biblionumber, $oldbibitemnum );
 }
 
 =head2 AddItem
@@ -1432,6 +1431,7 @@
     $marcxml =~ s/\x1f//g;
     $marcxml =~ s/\x1d//g;
     $marcxml =~ s/\x0f//g;
+    $marcxml =~ s/\x0c//g;
     my $record = MARC::Record->new();
     $record = MARC::Record::new_from_xml( $marcxml, 
"utf8",C4::Context->preference('marcflavour')) if $marcxml;
     return $record;
@@ -1880,6 +1880,35 @@
     return $frameworkcode;
 }
 
+=head2 Koha2Marc
+
+$record = Koha2Marc( $hash )
+
+This function builds partial MARC::Record from a hash
+
+Hash entries can be from biblio or biblioitems.
+
+This function is called in acquisition module, to create a basic catalogue 
entry from user entry
+
+=cut
+
+sub Koha2Marc {
+
+    my ( $hash ) = @_;
+    my $dbh = C4::Context->dbh;
+    my $sth =
+    $dbh->prepare(
+        "select tagfield,tagsubfield from marc_subfield_structure where 
frameworkcode=? and kohafield=?"
+    );
+    my $record = MARC::Record->new();
+    foreach (keys %{$hash}) {
+        &MARCkoha2marcOnefield( $sth, $record, $_,
+            $hash->{$_}, '' );
+        }
+        warn "REC : ".$record->as_formatted;
+    return $record;
+}
+        
 =head2 MARCkoha2marcBiblio
 
 $record = MARCkoha2marcBiblio( $biblionumber, $biblioitemnumber )
@@ -2912,22 +2941,7 @@
     return undef;
 }
 
-=head1  OLD FUNCTIONS
-
-=head2 newbiblio
 
-$biblionumber = newbiblio($biblio);
-
-=cut
-
-sub newbiblio {
-    my ($biblio) = @_;
-    my $dbh = C4::Context->dbh;
-    my $bibnum = _koha_add_biblio( $dbh, $biblio );
-    my $record = &MARCkoha2marcBiblio( $bibnum );
-    MARCaddbiblio( $record, $bibnum, '' );
-    return ($bibnum);
-}
 
 =head2 modbiblio
 
@@ -2968,24 +2982,6 @@
     &_koha_modify_biblio( $dbh, $biblioitem );
 }    # sub modbibitem
 
-=head2 newbiblioitem
-
-&newbiblioitem($biblioitem)
-
-=cut
-
-sub newbiblioitem {
-    my ($biblioitem) = @_;
-    my $dbh = C4::Context->dbh;
-    my $bibitemnum = &_koha_add_biblioitem( $dbh, $biblioitem );
-
-    my $MARCbiblio =
-      MARCkoha2marcBiblio( 0, $bibitemnum )
-      ; # the 0 means "do NOT retrieve biblio, only biblioitem, in the MARC 
record
-
-    &MARCaddbiblio( $MARCbiblio, $biblioitem->{biblionumber}, '' );
-    return ($bibitemnum);
-}
 
 =head2 newitems
 
@@ -3659,8 +3655,17 @@
 
 =cut
 
-# $Id: Biblio.pm,v 1.178.2.55 2007/01/17 18:07:17 alaurin Exp $
+# $Id: Biblio.pm,v 1.178.2.56 2007/01/24 13:50:26 tipaul Exp $
 # $Log: Biblio.pm,v $
+# Revision 1.178.2.56  2007/01/24 13:50:26  tipaul
+# Acquisition fix
+# removing newbiblio & newbiblioitems subs.
+# adding Koha2Marc
+#
+# IMHO, all biblio handling is better handled if they are done in a single 
place, the subs with MARC::Record as parameters.
+# newbiblio & newbiblioitems where koha 1.x subs, that are called when 
MARC=OFF (which is not working anymore in koha 3.0, unless someone reintroduce 
it), and in acquisition module.
+# The Koha2Marc sub moves a hash (with biblio/biblioitems subfield as keys) 
into a MARC::Record, that can be used to call NewBiblio, the standard biblio 
manager sub.
+#
 # Revision 1.178.2.55  2007/01/17 18:07:17  alaurin
 # bugfixing for zebraqueue_start and biblio.pm :
 #




reply via email to

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