Adding double authority search before creating a new authority
This commit is contained in:
parent
f875f7ec54
commit
4ff9cae64b
3 changed files with 76 additions and 4 deletions
|
@ -51,6 +51,7 @@ $VERSION = 0.01;
|
|||
&AUTHaddword
|
||||
&MARCaddword &MARCdelword
|
||||
&char_decode
|
||||
&FindDuplicate
|
||||
);
|
||||
|
||||
sub authoritysearch {
|
||||
|
@ -844,6 +845,46 @@ sub nsb_clean {
|
|||
return($string) ;
|
||||
}
|
||||
|
||||
sub FindDuplicate {
|
||||
my ($record,$authtypecode)=@_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
warn "".$record->as_formatted;
|
||||
# search duplicate on ISBN, easy and fast...
|
||||
my $sth = $dbh->prepare("select auth_tag_to_report from auth_types where authtypecode=?");
|
||||
$sth->execute($authtypecode);
|
||||
my ($auth_tag_to_report) = $sth->fetchrow;
|
||||
$sth->finish;
|
||||
# a more complex search : build a request for authoritysearch
|
||||
my (@tags, @and_or, @excluding, @operator, @value, $offset, $length);
|
||||
# search on biblio.title
|
||||
warn " tag a reporter : $auth_tag_to_report";
|
||||
if ($record->fields($auth_tag_to_report)) {
|
||||
my $sth = $dbh->prepare("select tagfield,tagsubfield from auth_subfield_structure where tagfield=? and authtypecode=? and tab >= 0");
|
||||
$sth->execute($auth_tag_to_report,$authtypecode);
|
||||
warn " Champ $auth_tag_to_report present";
|
||||
while (my ($tag,$subfield) = $sth->fetchrow){
|
||||
if ($record->field($tag)->subfields($subfield)) {
|
||||
warn "tag :".$tag." subfield: $subfield value : $record->field($tag)->subfield($subfield)->as_formatted";
|
||||
push @tags, "'".$tag.$subfield."'";
|
||||
push @and_or, "and";
|
||||
push @excluding, "";
|
||||
push @operator, "contains";
|
||||
push @value, $record->field($tag)->subfield($subfield);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my ($finalresult,$nbresult) = authoritysearch($dbh,\@tags,\@and_or,\@excluding,\@operator,\@value,0,10,$authtypecode);
|
||||
# there is at least 1 result => return the 1st one
|
||||
if ($nbresult) {
|
||||
warn "$nbresult => ".@$finalresult[0]->{authid},@$finalresult[0]->{summary};
|
||||
return @$finalresult[0]->{authid},@$finalresult[0]->{authid},@$finalresult[0]->{summary};
|
||||
}
|
||||
# no result, returns nothing
|
||||
return;
|
||||
}
|
||||
|
||||
END { } # module clean-up code here (global destructor)
|
||||
|
||||
=back
|
||||
|
@ -858,6 +899,9 @@ Paul POULAIN paul.poulain@free.fr
|
|||
|
||||
# $Id$
|
||||
# $Log$
|
||||
# Revision 1.12 2005/04/05 09:58:48 hdl
|
||||
# Adding double authority search before creating a new authority
|
||||
#
|
||||
# Revision 1.11 2005/03/07 08:55:29 tipaul
|
||||
# synch'ing with 2.2
|
||||
#
|
||||
|
|
|
@ -334,12 +334,30 @@ if ($op eq "add") {
|
|||
}
|
||||
my $record = AUTHhtml2marc($dbh,\@tags,\@subfields,\@values,%indicators);
|
||||
# MARC::Record built => now, record in DB
|
||||
if ($is_a_modif) {
|
||||
AUTHmodauthority($dbh,$authid,$record,$authtypecode);
|
||||
# check for a duplicate
|
||||
my ($duplicateauthnumber,$duplicateauthid,$duplicateauthvalue) = FindDuplicate($record,$authtypecode) if ($op eq "add") && (!$is_a_modif);
|
||||
my $confirm_not_duplicate = $input->param('confirm_not_duplicate');
|
||||
# it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate)
|
||||
if (!$duplicateauthnumber or $confirm_not_duplicate) {
|
||||
# MARC::Record built => now, record in DB
|
||||
if ($is_a_modif) {
|
||||
AUTHmodauthority($dbh,$authid,$record,$authtypecode);
|
||||
} else {
|
||||
($authid) = AUTHaddauthority($dbh,$record,$authid,$authtypecode);
|
||||
}
|
||||
# now, redirect to additem page
|
||||
print $input->redirect("detail.pl?authid=$authid");
|
||||
exit;
|
||||
} else {
|
||||
($authid) = AUTHaddauthority($dbh,$record,$authid,$authtypecode);
|
||||
# it may be a duplicate, warn the user and do nothing
|
||||
# build_tabs ($template, $record, $dbh,$encoding);
|
||||
# build_hidden_data;
|
||||
$template->param(
|
||||
duplicateauthnumber => $duplicateauthnumber,
|
||||
duplicateauthid => $duplicateauthid,
|
||||
duplicateauthvalue => $duplicateauthvalue,
|
||||
);
|
||||
}
|
||||
print $input->redirect("detail.pl?authid=$authid");
|
||||
#------------------------------------------------------------------------------------------------------------------------------
|
||||
} elsif ($op eq "addfield") {
|
||||
#------------------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -19,6 +19,16 @@
|
|||
|
||||
<br><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<!-- TMPL_IF name="duplicatebiblionumber" -->
|
||||
<div class="problem">
|
||||
<p>Duplicate suspected with <a href='javascript:openWindow("detail.pl?authid=<!-- TMPL_VAR name="duplicateauthnumber" -->&popup=1", "Duplicate Authority")' class="button catalogue"><!-- TMPL_VAR name="duplicateauthvalue" --></a></p>
|
||||
<p>You must either :</p>
|
||||
<ul>
|
||||
<p><input type="checkbox" value=1 name="confirm_not_duplicate">confirm it's not a duplicate (and click on Add Auth again)</p>
|
||||
<p>Go to <a href="authorities.pl?authid=<!-- TMPL_VAR name="duplicateauthid" --> class="button catalogue">edit items</a> from this duplicate Authority</p>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_LOOP NAME="0XX" -->
|
||||
<!-- TMPL_IF name="tag" -->
|
||||
<p class="MARCtag">
|
||||
|
|
Loading…
Reference in a new issue