- $sth = $dbh->prepare("UPDATE biblioitems SET marc=?,marcxml=? WHERE biblionumber=?");
- $sth->execute( $record->as_usmarc(), $record->as_xml_record($encoding), $biblionumber );
- $sth->finish;
- ModZebra( $biblionumber, "specialUpdate", "biblioserver" );
- return $biblionumber;
-}
-
-=head2 get_biblio_authorised_values
-
-find the types and values for all authorised values assigned to this biblio.
-
-parameters:
- biblionumber
- MARC::Record of the bib
-
-returns: a hashref mapping the authorised value to the value set for this biblionumber
-
- $authorised_values = {
- 'Scent' => 'flowery',
- 'Audience' => 'Young Adult',
- 'itemtypes' => 'SER',
- };
-
-Notes: forlibrarian should probably be passed in, and called something different.
-
-=cut
-
-sub get_biblio_authorised_values {
- my $biblionumber = shift;
- my $record = shift;
-
- my $forlibrarian = 1; # are we in staff or opac?
- my $frameworkcode = GetFrameworkCode($biblionumber);
-
- my $authorised_values;
-
- my $tagslib = GetMarcStructure( $forlibrarian, $frameworkcode )
- or return $authorised_values;
-
- # assume that these entries in the authorised_value table are bibliolevel.
- # ones that start with 'item%' are item level.
- my $query = q(SELECT distinct authorised_value, kohafield
- FROM marc_subfield_structure
- WHERE authorised_value !=''
- AND (kohafield like 'biblio%'
- OR kohafield like '') );
- my $bibliolevel_authorised_values = C4::Context->dbh->selectall_hashref( $query, 'authorised_value' );
-
- foreach my $tag ( keys(%$tagslib) ) {
- foreach my $subfield ( keys( %{ $tagslib->{$tag} } ) ) {
-
- # warn "checking $subfield. type is: " . ref $tagslib->{ $tag }{ $subfield };
- if ( 'HASH' eq ref $tagslib->{$tag}{$subfield} ) {
- if ( defined $tagslib->{$tag}{$subfield}{'authorised_value'} && exists $bibliolevel_authorised_values->{ $tagslib->{$tag}{$subfield}{'authorised_value'} } ) {
- if ( defined $record->field($tag) ) {
- my $this_subfield_value = $record->field($tag)->subfield($subfield);
- if ( defined $this_subfield_value ) {
- $authorised_values->{ $tagslib->{$tag}{$subfield}{'authorised_value'} } = $this_subfield_value;
- }
- }
- }
- }
- }
+ my $metadata = {
+ biblionumber => $biblionumber,
+ format => 'marcxml',
+ marcflavour => C4::Context->preference('marcflavour'),
+ };
+ # FIXME To replace with ->find_or_create?
+ if ( my $m_rs = Koha::Biblio::Metadatas->find($metadata) ) {
+ $m_rs->metadata( $record->as_xml_record($encoding) );
+ $m_rs->store;
+ } else {
+ my $m_rs = Koha::Biblio::Metadata->new($metadata);
+ $m_rs->metadata( $record->as_xml_record($encoding) );
+ $m_rs->store;