[Koha-cvs] CVS: koha/C4 AuthoritiesMarc.pm,1.11,1.12
Henri-Damien LAURENT
hdl at users.sourceforge.net
Tue Apr 5 11:58:51 CEST 2005
Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1330/C4
Modified Files:
AuthoritiesMarc.pm
Log Message:
Adding double authority search before creating a new authority
Index: AuthoritiesMarc.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/AuthoritiesMarc.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** AuthoritiesMarc.pm 7 Mar 2005 08:55:29 -0000 1.11
--- AuthoritiesMarc.pm 5 Apr 2005 09:58:48 -0000 1.12
***************
*** 52,55 ****
--- 52,56 ----
&MARCaddword &MARCdelword
&char_decode
+ &FindDuplicate
);
***************
*** 845,848 ****
--- 846,889 ----
}
+ 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)
***************
*** 859,862 ****
--- 900,906 ----
# $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
More information about the Koha-cvs
mailing list