# now add the record
$biblionumber = ModBiblioMarc( $record, $biblionumber, $frameworkcode ) unless $defer_marc_save;
- &logaction(C4::Context->userenv->{'number'},"CATALOGUING","ADD",$biblionumber,"biblio")
- if C4::Context->preference("CataloguingLog");
+ logaction("CATALOGUING", "ADD", $biblionumber, "biblio") if C4::Context->preference("CataloguingLog");
return ( $biblionumber, $biblioitemnumber );
}
my ( $record, $biblionumber, $frameworkcode ) = @_;
if (C4::Context->preference("CataloguingLog")) {
my $newrecord = GetMarcBiblio($biblionumber);
- &logaction(C4::Context->userenv->{'number'},"CATALOGUING","MODIFY",$biblionumber,"BEFORE=>".$newrecord->as_formatted);
+ logaction("CATALOGUING", "MODIFY", $biblionumber, "BEFORE=>".$newrecord->as_formatted);
}
my $dbh = C4::Context->dbh;
# from being generated by _koha_delete_biblioitems
$error = _koha_delete_biblio( $dbh, $biblionumber );
- &logaction(C4::Context->userenv->{'number'},"CATALOGUING","DELETE",$biblionumber,"")
- if C4::Context->preference("CataloguingLog");
+ logaction("CATALOGUING", "DELETE", $biblionumber, "") if C4::Context->preference("CataloguingLog");
+
return;
}
=over 4
-Returns MARC::Record of the biblionumber passed in parameter.
-the marc record contains both biblio & item datas
+my $record = GetMarcBiblio($biblionumber);
=back
+Returns MARC::Record representing bib identified by
+C<$biblionumber>. If no bib exists, returns undef.
+The MARC record contains both biblio & item data.
+
=cut
sub GetMarcBiblio {
my $subfield9 = $field->subfield('9');
for my $subject_subfield (@subfields ) {
# don't load unimarc subfields 3,4,5
- next if (($marcflavour eq "UNIMARC") and ($subject_subfield->[0] =~ (3|4|5) ) );
+ next if (($marcflavour eq "UNIMARC") and ($subject_subfield->[0] =~ /3|4|5/ ) );
my $code = $subject_subfield->[0];
my $value = $subject_subfield->[1];
my $linkvalue = $value;
my $subfield9 = $field->subfield('9');
for my $authors_subfield (@subfields) {
# don't load unimarc subfields 3, 5
- next if ($marcflavour eq 'UNIMARC' and ($authors_subfield->[0] =~ (3|5) ) );
+ next if ($marcflavour eq 'UNIMARC' and ($authors_subfield->[0] =~ /3|5/ ) );
my $subfieldcode = $authors_subfield->[0];
my $value = $authors_subfield->[1];
my $linkvalue = $value;
my $operator = " and " unless $count_auth==0;
# if we have an authority link, use that as the link, otherwise use standard searching
if ($subfield9) {
- @link_loop = ({'limit' => 'Koha-Auth-Number' ,link => "$subfield9" });
+ @link_loop = ({'limit' => 'an' ,link => "$subfield9" });
}
else {
# reset $linkvalue if UNIMARC author responsibility
for my $note ( $field->subfield('z')) {
push @notes , {note => $note};
}
- $marcurl = { MARCURL => $url,
- notes => \@notes,
- };
if($marcflavour eq 'MARC21') {
my $s3 = $field->subfield('3');
my $link = $field->subfield('y');
- $marcurl->{'linktext'} = $link || $s3 || $url ;;
+ warn $url;
+ unless($url =~ /^\w+:/) {
+ warn $field->indicator(1);
+ if($field->indicator(1) eq '7') {
+ $url = $field->subfield('2') . "://" . $url;
+ } elsif ($field->indicator(1) eq '1') {
+ $url = 'ftp://' . $url;
+ } else {
+ # properly, this should be if ind1=4,
+ # however we will assume http protocol since we're building a link.
+ $url = 'http://' . $url;
+ }
+ }
+ # TODO handle ind 2 (relationship)
+ $marcurl = { MARCURL => $url,
+ notes => \@notes,
+ };
+ $marcurl->{'linktext'} = $link || $s3 || C4::Context->preference('URLLinkText') || $url ;;
$marcurl->{'part'} = $s3 if($link);
$marcurl->{'toc'} = 1 if($s3 =~ /^[Tt]able/) ;
} else {
- $marcurl->{'linktext'} = $url;
+ $marcurl->{'linktext'} = $url || C4::Context->preference('URLLinkText') ;
}
push @marcurls, $marcurl;
}
$title = lc($record->subfield($titletag,$titlesubfield));
} else {
# for authorities, the "title" is the $a mainentry
- my $authref = C4::AuthoritiesMarc::GetAuthType($record->subfield(152,'b'));
+ my ($auth_type_tag, $auth_type_sf) = C4::AuthoritiesMarc::get_auth_type_location();
+ my $authref = C4::AuthoritiesMarc::GetAuthType($record->subfield($auth_type_tag, $auth_type_sf));
warn "ERROR : authtype undefined for ".$record->as_formatted unless $authref;
$title = $record->subfield($authref->{auth_tag_to_report},'a');
$index{'mainmainentry'}= $authref->{'auth_tag_to_report'}.'a';
$index{'mainentry'} = $authref->{'auth_tag_to_report'}.'*';
- $index{'auth_type'} = '152b';
+ $index{'auth_type'} = "${auth_type_tag}${auth_type_sf}";
}
my %result;
} else {
# warn "server : $server";
# for authorities, the "title" is the $a mainentry
- my $authref = C4::AuthoritiesMarc::GetAuthType($record->subfield(152,'b'));
+ my ($auth_type_tag, $auth_type_sf) = C4::AuthoritiesMarc::get_auth_type_location();
+ my $authref = C4::AuthoritiesMarc::GetAuthType($record->subfield($auth_type_tag, $auth_type_sf));
warn "ERROR : authtype undefined for ".$record->as_formatted unless $authref;
$title = $record->subfield($authref->{auth_tag_to_report},'a');
$index{'mainmainentry'} = $authref->{auth_tag_to_report}.'a';
$index{'mainentry'} = $authref->{auth_tag_to_report}.'*';
- $index{'auth_type'} = '152b';
+ $index{'auth_type'} = "${auth_type_tag}${auth_type_sf}";
}
# remove blancks comma (that could cause problem when decoding the string for CQL retrieval) and regexp specific values
# drop old field and create new one...
$old_field = $record->field($biblio_tag);
- $record->delete_field($old_field);
+ $record->delete_field($old_field) if $old_field;
$record->append_fields($new_field);
# deal with biblioitemnumber
}
# drop old field and create new one...
$old_field = $record->field($biblioitem_tag);
- $record->delete_field($old_field);
+ $record->delete_field($old_field) if $old_field;
$record->insert_fields_ordered($new_field);
} else {
# drop old field and create new one...
my $old_field = $record->field($biblio_tag);
- $record->delete_field($old_field);
+ $record->delete_field($old_field) if $old_field;
$record->insert_fields_ordered($new_field);
}
}
return $serviceOptions;
}
+=head3 get_biblio_authorised_values
+
+ find the types and values for all authorised values assigned to this biblio.
+
+ parameters:
+ biblionumber
+
+ returns: a hashref malling 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 $forlibrarian = 1; # are we in staff or opac?
+ my $frameworkcode = GetFrameworkCode( $biblionumber );
+
+ my $authorised_values;
+
+ my $record = GetMarcBiblio( $biblionumber )
+ or return $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 ( exists $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;
+ }
+ }
+ }
+ }
+ }
+ }
+ # warn ( Data::Dumper->Dump( [ $authorised_values ], [ 'authorised_values' ] ) );
+ return $authorised_values;
+}
+
+
1;
__END__