X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=C4%2FAuthoritiesMarc.pm;h=0164c8daa3d3437c9ec611dbe30e69ae6fa3f48a;hb=c2015c710355a0ab81306515a70af29e6aef3504;hp=9315e55110d234050de1e8ad731b12b97b21bc56;hpb=aaa0cdb9e82930b2d920ee02b71673e6e236b5f8;p=koha.git
diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm
index 9315e55110..0164c8daa3 100644
--- a/C4/AuthoritiesMarc.pm
+++ b/C4/AuthoritiesMarc.pm
@@ -26,6 +26,7 @@ use C4::Search;
use C4::AuthoritiesMarc::MARC21;
use C4::AuthoritiesMarc::UNIMARC;
use C4::Charset;
+use C4::Log;
use vars qw($VERSION @ISA @EXPORT);
@@ -224,12 +225,9 @@ sub SearchAuthorities {
for(my $i = 0 ; $i <= $#{$value} ; $i++)
{
if (@$value[$i]){
- ##If mainentry search $a tag
if (@$tags[$i] eq "mainmainentry") {
-# FIXME: 'Heading-Main' index not yet defined in zebra
-# $attr =" \@attr 1=Heading-Main ";
- $attr =" \@attr 1=Heading ";
+ $attr =" \@attr 1=Heading-Main ";
}elsif (@$tags[$i] eq "mainentry") {
$attr =" \@attr 1=Heading ";
@@ -245,6 +243,7 @@ sub SearchAuthorities {
} else {
$attr .=" \@attr 5=1 \@attr 4=6 ";## Word list, right truncated, anywhere
}
+ @$value[$i] =~ s/"/\\"/g; # Escape the double-quotes in the search value
$attr =$attr."\"".@$value[$i]."\"";
$q2 .=$attr;
$dosearch=1;
@@ -365,7 +364,12 @@ sub CountUsage {
my $query;
$query= "an=".$authid;
my ($err,$res,$result) = C4::Search::SimpleSearch($query,0,10);
- return ($result);
+ if ($err) {
+ warn "Error: $err from search $query";
+ $result = 0;
+ }
+
+ return $result;
}
}
@@ -623,6 +627,7 @@ sub AddAuthority {
$f5->update($time.".0");
}
+ SetUTF8Flag($record);
if ($format eq "MARC21") {
if (!$record->leader) {
$record->leader($leader);
@@ -648,17 +653,21 @@ sub AddAuthority {
}
}
- if (($format eq "UNIMARCAUTH") && (!$record->subfield('100','a'))){
- $record->leader(" nx j22 ");
+ if ($format eq "UNIMARCAUTH") {
+ $record->leader(" nx j22 ") unless ($record->leader());
my $date=POSIX::strftime("%Y%m%d",localtime);
- if ($record->field('100')){
+ if (my $string=$record->subfield('100',"a")){
+ $string=~s/fre50/frey50/;
+ $record->field('100')->update('a'=>$string);
+ }
+ elsif ($record->field('100')){
$record->field('100')->update('a'=>$date."afrey50 ba0");
- } else {
- $record->append_fields(
- MARC::Field->new('100',' ',' '
- ,'a'=>$date."afrey50 ba0")
- );
- }
+ } else {
+ $record->append_fields(
+ MARC::Field->new('100',' ',' '
+ ,'a'=>$date."afrey50 ba0")
+ );
+ }
}
my ($auth_type_tag, $auth_type_subfield) = get_auth_type_location($authtypecode);
if (!$authid and $format eq "MARC21") {
@@ -700,6 +709,7 @@ sub AddAuthority {
my $sth=$dbh->prepare("insert into auth_header (authid,datecreated,authtypecode,marc,marcxml) values (?,now(),?,?,?)");
$sth->execute($authid,$authtypecode,$record->as_usmarc,$record->as_xml_record($format));
$sth->finish;
+ logaction( "AUTHORITIES", "ADD", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog");
}
ModZebra($authid,'specialUpdate',"authorityserver",$oldRecord,$record);
return ($authid);
@@ -718,8 +728,9 @@ sub DelAuthority {
my ($authid) = @_;
my $dbh=C4::Context->dbh;
+ logaction( "AUTHORITIES", "DELETE", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog");
ModZebra($authid,"recordDelete","authorityserver",GetAuthority($authid),undef);
- my $sth = prepare("DELETE FROM auth_header WHERE authid=?");
+ my $sth = $dbh->prepare("DELETE FROM auth_header WHERE authid=?");
$sth->execute($authid);
}
@@ -748,6 +759,7 @@ sub ModAuthority {
print AUTH $authid;
close AUTH;
}
+ logaction( "AUTHORITIES", "MODIFY", $authid, "BEFORE=>" . $oldrecord->as_formatted ) if C4::Context->preference("AuthoritiesLog");
return $authid;
}
@@ -910,7 +922,7 @@ sub FindDuplicateAuthority {
}
my ($error, $results, $total_hits) = C4::Search::SimpleSearch( $query, 0, 1, [ "authorityserver" ] );
# there is at least 1 result => return the 1st one
- if (@$results>0) {
+ if (!defined $error && @{$results} ) {
my $marcrecord = MARC::File::USMARC::decode($results->[0]);
return $marcrecord->field('001')->data,BuildSummary($marcrecord,$marcrecord->field('001')->data,$authtypecode);
}
@@ -1038,7 +1050,7 @@ sub BuildSummary{
$narrowerterms =~s/-- \n$//;
$seealso =~s/-- \n$//;
$see =~s/-- \n$//;
- $summary = "".$heading."
".($notes?"$notes
":"");
+ $summary = $heading."
".($notes?"$notes
":"");
$summary.= '