Head & rel_2_2 merged
[koha.git] / C4 / AuthoritiesMarc.pm
1 package C4::AuthoritiesMarc;
2 # Copyright 2000-2002 Katipo Communications
3 #
4 # This file is part of Koha.
5 #
6 # Koha is free software; you can redistribute it and/or modify it under the
7 # terms of the GNU General Public License as published by the Free Software
8 # Foundation; either version 2 of the License, or (at your option) any later
9 # version.
10 #
11 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License along with
16 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
17 # Suite 330, Boston, MA  02111-1307 USA
18
19 use strict;
20 require Exporter;
21 use C4::Context;
22 use C4::Database;
23 use C4::Koha;
24 use MARC::Record;
25 use C4::Biblio;
26 #use ZOOM;
27 use vars qw($VERSION @ISA @EXPORT);
28
29 # set the version for version checking
30 $VERSION = 0.01;
31
32 @ISA = qw(Exporter);
33 @EXPORT = qw(
34         &AUTHgettagslib
35         &AUTHfindsubfield
36         &AUTHfind_authtypecode
37
38         &AUTHaddauthority
39         &AUTHmodauthority
40         &AUTHdelauthority
41         &AUTHaddsubfield
42         &AUTHgetauthority
43         &AUTHfind_marc_from_kohafield
44         &AUTHgetauth_type
45         &AUTHcount_usage
46         &getsummary
47         &authoritysearch
48         
49         
50         &MARCmodsubfield
51         &AUTHhtml2marc &AUTHhtml2xml
52         &AUTHaddword
53         &MARCaddword &MARCdelword
54         &char_decode
55         &FindDuplicate
56  );
57
58 sub AUTHfind_marc_from_kohafield {
59     my ( $dbh, $kohafield,$authtypecode ) = @_;
60     return 0, 0 unless $kohafield;
61 $authtypecode="" unless $authtypecode;
62 my $marcfromkohafield;
63         my $sth = $dbh->prepare("select tagfield,tagsubfield from auth_subfield_structure where kohafield= ? and authtypecode=? ");
64         $sth->execute($kohafield,$authtypecode);
65         my ($tagfield,$tagsubfield) = $sth->fetchrow;
66                 
67         return  ($tagfield,$tagsubfield);
68 }
69 sub authoritysearch {
70         my ($dbh, $tags, $and_or, $excluding, $operator, $value, $offset,$length,$authtypecode) = @_;
71         my $query;
72         my $attr;
73         # the marclist may contain "mainentry". In this case, search the tag_to_report, that depends on
74         # the authtypecode. Then, search on $a of this tag_to_report
75         # also store main entry MARC tag, to extract it at end of search
76         my $mainentrytag;
77         ##first set the authtype search
78         $query="\@attr 1=1013 \@attr 5=100 ".$authtypecode; ##No truncation on authtype
79         my $dosearch;
80         my $and;
81         my $q2;
82         for(my $i = 0 ; $i <= $#{$value} ; $i++)
83         {
84
85         if (@$value[$i]){
86         ##If mainentry search $a tag
87                 if (@$tags[$i] eq "mainentry") {
88                 $attr =" \@attr 1=21 ";
89                 }else{
90                 $attr =" \@attr 1=47 ";
91                 }
92                 
93
94         
95                 
96                 if (@$operator[$i] eq 'phrase') {
97                          $attr.=" \@attr 4=1  \@attr 5=100 \@attr 3=1 ";##Phrase, No truncation, first in field###It seems not implemented by indexdata
98                 
99                 } else {
100                 
101                          $attr .=" \@attr 4=6  \@attr 5=1  ";## Word list, right truncated, anywhere
102                 }                
103         
104                 
105                 $and .=" \@and " ;
106                 $attr =$attr."\"".@$value[$i]."\"";
107                 $q2 .=$attr;
108         $dosearch=1;            
109         }#if value              
110                 
111         }
112 ##Add how many queries generated
113 $query= $and.$query.$q2;
114 # warn $query;
115
116 $offset=0 unless $offset;
117 my $counter = $offset;
118 $length=10 unless $length;
119
120 my $oAuth=C4::Context->Zconnauth("authorityserver");
121 if ($oAuth eq "error"){
122 warn "Error/CONNECTING \n";
123   return("error",undef);
124  }
125
126 my $oAResult;
127 my $Anewq= new ZOOM::Query::PQF($query);
128 $Anewq->sortby("1=21 i< 1=47 i<");
129
130 eval {
131 $oAResult= $oAuth->search($Anewq) ; 
132 };
133 if($@){
134 warn " /CODE:", $@->code()," /MSG:",$@->message(),"\n";
135    return("error",undef);
136  }
137
138
139 my $nbresults=0;
140  $nbresults=$oAResult->size() if  ($oAResult);
141         
142         my @result = ();
143
144         
145         my @finalresult = ();
146         my $oldline;
147 #       while (($counter <= $#result) && ($counter <= ($offset + $length))) {
148         # retrieve everything
149         for (my $counter=0;$counter <=$#result;$counter++) {
150 #               warn " HERE : $counter, $#result, $offset, $length";
151                 # get MARC::Record of the authority
152                 my $record = AUTHgetauthority($dbh,$result[$counter]);
153                 # then build the summary
154                 #FIXME: all of this should be moved to the template eventually
155                 my $authtypecode = AUTHfind_authtypecode($dbh,$result[$counter]);
156                 my $authref = getauthtype($authtypecode);
157                 my $authtype =$authref->{authtypetext};
158                 my $summary = $authref->{summary};
159                 # find biblio MARC field using this authtypecode (to jump to biblio)
160                 my $sth = $dbh->prepare("select distinct tagfield from marc_subfield_structure where authtypecode=?");
161                 $sth->execute($authtypecode);
162                 my $tags_using_authtype;
163                 my $newsth;
164                 while (my ($tagfield) = $newsth->fetchrow) {
165                         $tags_using_authtype.= "'".$tagfield."9',";
166                 }
167                 chop $tags_using_authtype;
168                 # if the library has a summary defined, use it. Otherwise, build a standard one
169                 if ($summary) {
170                         my @fields = $record->fields();
171                         foreach my $field (@fields) {
172                                 my $tag = $field->tag();
173                                 my $tagvalue = $field->as_string();
174                                 $summary =~ s/\[(.?.?.?.?)$tag\*(.*?)]/$1$tagvalue$2\[$1$tag$2]/g;
175                                 if ($tag<10) {
176                                 } else {
177                                         my @subf = $field->subfields;
178                                         for my $i (0..$#subf) {
179                                                 my $subfieldcode = $subf[$i][0];
180                                                 my $subfieldvalue = $subf[$i][1];
181                                                 my $tagsubf = $tag.$subfieldcode;
182                                                 $summary =~ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
183                                         }
184                                 }
185                         }
186                         $summary =~ s/\[(.*?)]//g;
187                         $summary =~ s/\n/<br>/g;
188                 } else {
189                         my $heading; # = $authref->{summary};
190                         my $altheading;
191                         my $seeheading;
192                         my $see;
193                         my @fields = $record->fields();
194                         if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
195                         # construct UNIMARC summary, that is quite different from MARC21 one
196                                 # accepted form
197                                 foreach my $field ($record->field('2..')) {
198                                         $heading.= $field->as_string();
199                                 }
200                                 # rejected form(s)
201                                 foreach my $field ($record->field('4..')) {
202                                         $summary.= "&nbsp;&nbsp;&nbsp;<i>".$field->as_string()."</i><br/>";
203                                         $summary.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see:</i> ".$heading."<br/>";
204                                 }
205                                 # see :
206                                 foreach my $field ($record->field('5..')) {
207                                         $summary.= "&nbsp;&nbsp;&nbsp;<i>".$field->as_string()."</i><br/>";
208                                         $summary.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see:</i> ".$heading."<br/>";
209                                 }
210                                 # // form
211                                 foreach my $field ($record->field('7..')) {
212                                         $seeheading.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see also:</i> ".$field->as_string()."<br />";     
213                                         $altheading.= "&nbsp;&nbsp;&nbsp;".$field->as_string()."<br />";
214                                         $altheading.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see also:</i> ".$heading."<br />";
215                                 }
216                                 $summary = "<b>".$heading."</b><br />".$seeheading.$altheading.$summary;        
217                         } else {
218                         # construct MARC21 summary
219                                 foreach my $field ($record->field('1..')) {
220                                         if ($record->field('100')) {
221                                                 $heading.= $field->as_string('abcdefghjklmnopqrstvxyz68');
222                                         } elsif ($record->field('110')) {
223                                                 $heading.= $field->as_string('abcdefghklmnoprstvxyz68');
224                                         } elsif ($record->field('111')) {
225                                                 $heading.= $field->as_string('acdefghklnpqstvxyz68');
226                                         } elsif ($record->field('130')) {
227                                                 $heading.= $field->as_string('adfghklmnoprstvxyz68');
228                                         } elsif ($record->field('148')) {
229                                                 $heading.= $field->as_string('abvxyz68');
230                                         } elsif ($record->field('150')) {
231                                                                                         $heading.= $field->as_string('abvxyz68');       
232                                         } elsif ($record->field('151')) {
233                                                 $heading.= $field->as_string('avxyz68');
234                                         } elsif ($record->field('155')) {
235                                                 $heading.= $field->as_string('abvxyz68');
236                                         } elsif ($record->field('180')) {
237                                                 $heading.= $field->as_string('vxyz68');
238                                         } elsif ($record->field('181')) {
239                                                 $heading.= $field->as_string('vxyz68');
240                                         } elsif ($record->field('182')) {
241                                                 $heading.= $field->as_string('vxyz68');
242                                         } elsif ($record->field('185')) {
243                                                 $heading.= $field->as_string('vxyz68');
244                                         } else {
245                                                 $heading.= $field->as_string();
246                                         }
247                                 } #See From
248                                 foreach my $field ($record->field('4..')) {
249                                         $seeheading.= "&nbsp;&nbsp;&nbsp;".$field->as_string()."<br />";
250                                         $seeheading.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see:</i> ".$seeheading."<br />";  
251                                 } #See Also
252                                 foreach my $field ($record->field('5..')) {
253                                         $altheading.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see also:</i> ".$field->as_string()."<br />";     
254                                         $altheading.= "&nbsp;&nbsp;&nbsp;".$field->as_string()."<br />";
255                                         $altheading.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see also:</i> ".$altheading."<br />";
256                                 }
257                                 $summary.=$heading.$seeheading.$altheading;
258                         }
259                 }
260                 # then add a line for the template loop
261                 my %newline;
262                 $newline{summary} = $summary;
263                 $newline{authtype} = $authtype;
264                 $newline{authid} = $result[$counter];
265                 $newline{used} = &AUTHcount_usage($result[$counter]);
266                 $newline{biblio_fields} = $tags_using_authtype;
267                 $newline{even} = $counter % 2;
268                 $newline{mainentry} = $record->field($mainentrytag)->subfield('a')." ".$record->field($mainentrytag)->subfield('b') if $record->field($mainentrytag);
269                 push @finalresult, \%newline;
270         }
271         # sort everything
272         my @finalresult3= sort {$a->{summary} cmp $b->{summary}} @finalresult;
273         # cut from $offset to $offset+$length;
274         my @finalresult2;
275         for (my $i=$offset;$i<=$offset+$length;$i++) {
276                 push @finalresult2,$finalresult3[$i] if $finalresult3[$i];
277         }
278         my $nbresults = $#result + 1;
279
280         return (\@finalresult2, $nbresults);
281 }
282
283 # Creates the SQL Request
284
285 sub create_request {
286         my ($dbh,$tags, $and_or, $operator, $value) = @_;
287
288         my $sql_tables; # will contain marc_subfield_table as m1,...
289         my $sql_where1; # will contain the "true" where
290         my $sql_where2 = "("; # will contain m1.authid=m2.authid
291         my $nb_active=0; # will contain the number of "active" entries. and entry is active is a value is provided.
292         my $nb_table=1; # will contain the number of table. ++ on each entry EXCEPT when an OR  is provided.
293
294
295         for(my $i=0; $i<=@$value;$i++) {
296                 if (@$value[$i]) {
297                         $nb_active++;
298                         if ($nb_active==1) {
299                                 
300                                         $sql_tables = "auth_subfield_table as m$nb_table,";
301                                         $sql_where1 .= "( m$nb_table.subfieldvalue like '@$value[$i]' ";
302                                         if (@$tags[$i]) {
303                                                 $sql_where1 .=" and concat(m1.tag,m1.subfieldcode) in (@$tags[$i])";
304                                         }
305                                         $sql_where1.=")";
306                                 } elsif (@$operator[$i] eq "contains") {        
307                                 $sql_tables .= "auth_word as m$nb_table,";
308                                         $sql_where1 .= "(m1.word  like ".$dbh->quote("@$value[$i]%");
309                                         if (@$tags[$i]) {
310                                                  $sql_where1 .=" and m1.tagsubfield in (@$tags[$i])";
311                                         }
312                                         $sql_where1.=")";
313                                 } else {
314
315                                         $sql_tables .= "auth_subfield_table as m$nb_table,";
316                                         $sql_where1 .= "(m1.subfieldvalue @$operator[$i] ".$dbh->quote("@$value[$i]");
317                                         if (@$tags[$i]) {
318                                                  $sql_where1 .=" and concat(m1.tag,m1.subfieldcode) in (@$tags[$i])";
319                                         }
320                                         $sql_where1.=")";
321                                 }
322                         } else {
323                                 if (@$operator[$i] eq "start") {
324                                         $nb_table++;
325                                         $sql_tables .= "auth_subfield_table as m$nb_table,";
326                                         $sql_where1 .= "@$and_or[$i] (m$nb_table.subfieldvalue like ".$dbh->quote("@$value[$i]%");
327                                         if (@$tags[$i]) {
328                                                 $sql_where1 .=" and concat(m$nb_table.tag,m$nb_table.subfieldcode) in (@$tags[$i])";
329                                         }
330                                         $sql_where1.=")";
331                                         $sql_where2 .= "m1.authid=m$nb_table.authid and ";
332                                 } elsif (@$operator[$i] eq "contains") {
333                                         if (@$and_or[$i] eq 'and') {
334                                                 $nb_table++;
335                                                 $sql_tables .= "auth_word as m$nb_table,";
336                                                 $sql_where1 .= "@$and_or[$i] (m$nb_table.word like ".$dbh->quote("@$value[$i]%");
337                                                 if (@$tags[$i]) {
338                                                         $sql_where1 .=" and m$nb_table.tagsubfield in(@$tags[$i])";
339                                                 }
340                                                 $sql_where1.=")";
341                                                 $sql_where2 .= "m1.authid=m$nb_table.authid and ";
342                                         } else {
343                                                 $sql_where1 .= "@$and_or[$i] (m$nb_table.word like ".$dbh->quote("@$value[$i]%");
344                                                 if (@$tags[$i]) {
345                                                         $sql_where1 .="  and concat(m$nb_table.tag,m$nb_table.subfieldid) in (@$tags[$i])";
346                                                 }
347                                                 $sql_where1.=")";
348                                                 $sql_where2 .= "m1.authid=m$nb_table.authid and ";
349                                         }
350                                 } else {
351                                         $nb_table++;
352                                         
353                                         $sql_tables .= "auth_subfield_table as m$nb_table,";
354                                         $sql_where1 .= "@$and_or[$i] (m$nb_table.subfieldvalue   like '@$value[$i]' ";
355                                         if (@$tags[$i]) {
356                                                 $sql_where1 .="  and concat(m$nb_table.tag,m$nb_table.subfieldcode) in (@$tags[$i])";
357                                         }
358                                         $sql_where2 .= "m1.authid=m$nb_table.authid and ";
359                                         $sql_where1.=")";
360                                         $sql_where2.="m1.authid=m$nb_table.authid and ";
361                                                                 
362                                 
363                                         } 
364                                 }
365                 }
366
367         if($sql_where2 ne "(")  # some datas added to sql_where2, processing
368         {
369                 $sql_where2 = substr($sql_where2, 0, (length($sql_where2)-5)); # deletes the trailing ' and '
370                 $sql_where2 .= ")";
371         }
372         else    # no sql_where2 statement, deleting '('
373         {
374                 $sql_where2 = "";
375         }
376         chop $sql_tables;       # deletes the trailing ','
377         
378         return ($sql_tables, $sql_where1, $sql_where2);
379 }
380
381
382 sub AUTHcount_usage {
383         my ($authid) = @_;
384         my $dbh = C4::Context->dbh;
385         # find MARC fields using this authtype
386         my $authtypecode = AUTHfind_authtypecode($dbh,$authid);
387         my $sth = $dbh->prepare("select distinct tagfield from marc_subfield_structure where authtypecode=?");
388         my $tags_used=$sth->execute($authtypecode);
389         my $tags_using_authtype;
390
391         while  (my($tagfield) = $sth->fetchrow){
392 #               warn "TAG : $tagfield";
393                 $tags_using_authtype.= "'".$tagfield."9',";
394
395         }
396
397         chop $tags_using_authtype;
398 ### try ZOOM search here
399 my $oConnection=C4::Context->Zconn("biblioserver");
400 my $query;
401
402 $query= "\@attr GILS 1=2057 ".$authid;
403
404 my $oResult = $oConnection->search_pqf($query);
405
406 my $result=$oResult->size() if  ($oResult);
407
408 ### OLD API
409 #       if ($tags_using_authtype) {
410 #               $sth = $dbh->prepare("select count(*) from marc_subfield_table where concat(tag,subfieldcode) in ($tags_using_authtype) and MATCH(subfieldvalue) AGAINST(? IN BOOLEAN MODE)");
411 #       } else {
412 #               $sth = $dbh->prepare("select count(*) from marc_subfield_table where subfieldvalue=?");
413 #       }
414 #       warn "Q : select count(*) from marc_subfield_table where concat(tag,subfieldcode) in ($tags_using_authtype) and d MATCH(subfieldvalue) AGAINST($authid IN BOOLEAN MODE) ";
415 #       $sth->execute($authid);
416 #       my ($result) = $sth->fetchrow;
417 #       warn "Authority $authid TOTAL USED : $result";
418         
419         return ($result);
420 }
421
422
423
424 sub AUTHfind_authtypecode {
425         my ($dbh,$authid) = @_;
426         my $sth = $dbh->prepare("select authtypecode from auth_header where authid=?");
427         $sth->execute($authid);
428         my ($authtypecode) = $sth->fetchrow;
429         return $authtypecode;
430 }
431  
432
433 sub AUTHgettagslib {
434         my ($dbh,$forlibrarian,$authtypecode)= @_;
435         $authtypecode="" unless $authtypecode;
436         my $sth;
437         my $libfield = ($forlibrarian eq 1)? 'liblibrarian' : 'libopac';
438
439
440         # check that authority exists
441         $sth=$dbh->prepare("select count(*) from auth_tag_structure where authtypecode=?");
442         $sth->execute($authtypecode);
443         my ($total) = $sth->fetchrow;
444         $authtypecode="" unless ($total >0);
445         $sth= $dbh->prepare(
446 "select tagfield,liblibrarian,libopac,mandatory,repeatable from auth_tag_structure where authtypecode=? order by tagfield"
447     );
448
449 $sth->execute($authtypecode);
450          my ( $liblibrarian, $libopac, $tag, $res, $tab, $mandatory, $repeatable );
451
452     while ( ( $tag, $liblibrarian, $libopac, $mandatory, $repeatable ) = $sth->fetchrow ) {
453         $res->{$tag}->{lib}        = ($forlibrarian or !$libopac)?$liblibrarian:$libopac;
454         $res->{$tab}->{tab}        = "";            # XXX
455         $res->{$tag}->{mandatory}  = $mandatory;
456         $res->{$tag}->{repeatable} = $repeatable;
457     }
458         $sth=      $dbh->prepare("select tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link from auth_subfield_structure where authtypecode=? order by tagfield,tagsubfield"
459     );
460         $sth->execute($authtypecode);
461
462          my $subfield;
463     my $authorised_value;
464     my $authtypecode;
465     my $value_builder;
466     my $kohafield;
467     my $seealso;
468     my $hidden;
469     my $isurl;
470         my $link;
471
472     while (
473         ( $tag,         $subfield,   $liblibrarian,   , $libopac,      $tab,
474         $mandatory,     $repeatable, $authorised_value, $authtypecode,
475         $value_builder, $kohafield,  $seealso,          $hidden,
476         $isurl,                 $link )
477         = $sth->fetchrow
478       )
479     {
480         $res->{$tag}->{$subfield}->{lib}              = ($forlibrarian or !$libopac)?$liblibrarian:$libopac;
481         $res->{$tag}->{$subfield}->{tab}              = $tab;
482         $res->{$tag}->{$subfield}->{mandatory}        = $mandatory;
483         $res->{$tag}->{$subfield}->{repeatable}       = $repeatable;
484         $res->{$tag}->{$subfield}->{authorised_value} = $authorised_value;
485         $res->{$tag}->{$subfield}->{authtypecode}     = $authtypecode;
486         $res->{$tag}->{$subfield}->{value_builder}    = $value_builder;
487         $res->{$tag}->{$subfield}->{kohafield}        = $kohafield;
488         $res->{$tag}->{$subfield}->{seealso}          = $seealso;
489         $res->{$tag}->{$subfield}->{hidden}           = $hidden;
490         $res->{$tag}->{$subfield}->{isurl}            = $isurl;
491         $res->{$tag}->{$subfield}->{link}            = $link;
492     }
493     return $res;
494 }
495
496 sub AUTHaddauthority {
497 # pass the MARC::Record to this function, and it will create the records in the authority table
498         my ($dbh,$record,$authid,$authtypecode) = @_;
499         my @fields=$record->fields();
500 # adding main table, and retrieving authid
501 # if authid is sent, then it's not a true add, it's only a re-add, after a delete (ie, a mod)
502 #  In fact, it could still be a true add, in the case of a bulkauthimort for instance with previously
503 #  existing authids in the records. I've adjusted below to account for this instance --JF.
504         if ($authid) {
505                 $dbh->do("lock tables auth_header WRITE,auth_subfield_table WRITE, auth_word WRITE, stopwords READ");
506                 my $sth=$dbh->prepare("insert into auth_header (authid,datecreated,authtypecode) values (?,now(),?)");
507                 $sth->execute($authid,$authtypecode);
508                 $sth->finish;
509 # if authid empty => true add, find a new authid number
510         } else {
511         $dbh->do("lock tables auth_header WRITE,auth_subfield_table WRITE, auth_word WRITE, stopwords READ");
512         my $sth=$dbh->prepare("insert into auth_header (datecreated,authtypecode) values (now(),?)");
513         $sth->execute($authtypecode);
514         $sth=$dbh->prepare("select max(authid) from auth_header");
515         $sth->execute;
516         ($authid)=$sth->fetchrow;
517         $sth->finish;
518         }
519         return ($authid);
520 }
521
522 sub AUTHaddlink{
523 my ($dbh,$linkid,$authid)=@_;
524 my $record=AUTHgetauthority($dbh,$linkid);
525 my $authtypecode=AUTHfind_authtypecode($dbh,$linkid);
526 #warn "adding l:$linkid,a:$authid,auth:$authtypecode";
527 $record=AUTH2marcOnefieldlink($dbh,$record,"auth_header.linkid",$authid,$authtypecode);
528 $dbh->do("lock tables auth_header WRITE");
529         my $sth=$dbh->prepare("update auth_header set marc=? where authid=?");
530         $sth->execute($record->as_usmarc,$linkid);
531         $sth->finish;   
532         $dbh->do("unlock tables");
533         zebraopauth($dbh,$linkid,'specialUpdate');
534 }
535
536 sub AUTH2marcOnefieldlink {
537     my ( $dbh, $record, $kohafieldname, $newvalue,$authtypecode ) = @_;
538 my $sth =      $dbh->prepare(
539 "select tagfield,tagsubfield from auth_subfield_structure where authtypecode=? and kohafield=?"
540     );
541     $sth->execute($authtypecode,$kohafieldname);
542 my  ($tagfield,$tagsubfield)=$sth->fetchrow;
543             $record->add_fields( $tagfield, " ", " ", $tagsubfield => $newvalue );
544     return $record;
545 }
546 sub zebraopauth{
547
548 my ($dbh,$authid,$op)=@_;
549 my $Zconnauthority;
550 my $tried=0;
551 my $recon=0;
552 reconnect:
553 $Zconnauthority=C4::Context->Zconnauth("authorityserver");
554 if ($Zconnauthority ne "error"){
555 my      $record = AUTHgetauthority($dbh,$authid);
556 my $Zpackage = $Zconnauthority->package();
557 $Zpackage->option(action => $op);
558         $Zpackage->option(record => $record->as_xml_record);
559 retry:
560         eval {
561                 $Zpackage->send("update");
562         };
563         if ($@) {
564                 if($@->code()==10007 && $tried==0){ ##Timedout -retry
565                 $tried=1;
566                 goto "retry";
567                 }elsif($@->code()==10004 && $recon==0){##Lost connection -reconnect
568                 $recon=1;
569                 goto "reconnect";
570                 }else{
571                 warn "Error-authority updating $authid $op /CODE:", $@->code()," /MSG:",$@->message(),"\n";     
572                 zebrafiles($dbh,$authid,$op);
573                 return;
574                 }
575         }
576 $Zpackage->("commit") if (C4::Context->authorityservershadow);  
577 $Zpackage->destroy;
578 }else{
579 zebrafiles($dbh,$authid,$op);
580 }       
581 }
582
583 sub zebrafiles{
584
585 my ($dbh,$authid,$folder)=@_;
586 my $record=AUTHgetauthority($dbh,$authid);
587 my $zebradir = C4::Context->zebraconfig("authorityserver")->{directory}."/".$folder."/";
588         
589 #my $zebradir = C4::Context->authoritydir."/".$folder."/";
590         unless (opendir(DIR, "$zebradir")) {
591 warn "$zebradir not found";
592                         return;
593         } 
594         closedir DIR;
595         my $filename = $zebradir.$authid;
596 if ($record){
597         open (OUTPUT,">", $filename.".xml");
598         print OUTPUT $record->as_xml_record;
599
600         close OUTPUT;
601 }
602
603
604 }
605
606
607 sub AUTHfind_leader{
608 ##Hard coded for NEU auth types 
609 my($dbh,$authtypecode)=@_;
610
611 my $leadercode;
612 if ($authtypecode eq "AUTH"){
613 $leadercode="a";
614 }elsif ($authtypecode eq "ESUB"){
615 $leadercode="b";
616 }elsif ($authtypecode eq "TSUB"){
617 $leadercode="c";
618 }else{
619 $leadercode=" ";
620 }
621 return $leadercode;
622 }
623
624 sub AUTHgetauthority {
625 # Returns MARC::Record of the biblio passed in parameter.
626     my ($dbh,$authid)=@_;
627 my      $sth=$dbh->prepare("select marc from auth_header where authid=?");
628                 $sth->execute($authid);
629         my ($marc) = $sth->fetchrow; 
630 my $record=MARC::File::USMARC::decode($marc);
631
632         return ($record);
633 }
634
635 sub AUTHgetauth_type {
636         my ($authtypecode) = @_;
637         my $dbh=C4::Context->dbh;
638         my $sth=$dbh->prepare("select * from auth_types where authtypecode=?");
639         $sth->execute($authtypecode);
640         return $sth->fetchrow_hashref;
641 }
642 sub AUTHmodauthority {
643
644         my ($dbh,$authid,$record,$authtypecode,$merge)=@_;
645         my ($oldrecord)=&AUTHgetauthority($dbh,$authid);
646         if ($oldrecord eq $record) {
647                 return;
648         }
649 my $sth=$dbh->prepare("update auth_header set marc=? where authid=?");
650 #warn find if linked records exist and delete them
651 my($linkidfield,$linkidsubfield)=AUTHfind_marc_from_kohafield($dbh,"auth_header.linkid",$authtypecode);
652
653 if ($oldrecord->field($linkidfield)){
654 my @fields=$oldrecord->field($linkidfield);
655         foreach my $field (@fields){
656 my      $linkid=$field->subfield($linkidsubfield) ;
657         if ($linkid){                   
658                 ##Modify the record of linked 
659                 my $linkrecord=AUTHgetauthority($dbh,$linkid);
660                 my $linktypecode=AUTHfind_authtypecode($dbh,$linkid);
661                 my ( $linkidfield2,$linkidsubfield2)=AUTHfind_marc_from_kohafield($dbh,"auth_header.linkid",$linktypecode);
662                 my @linkfields=$linkrecord->field($linkidfield2);
663                         foreach my $linkfield (@linkfields){
664                         if ($linkfield->subfield($linkidsubfield2) eq $authid){
665                                 $linkrecord->delete_field($linkfield);
666                                 $sth->execute($linkrecord->as_usmarc,$linkid);
667                                 zebraopauth($dbh,$linkid,'specialUpdate');
668                         }
669                         }#foreach linkfield
670         }
671         }#foreach linkid
672 }
673 #Now rewrite the $record to table with an add
674 $authid=AUTHaddauthority($dbh,$record,$authid,$authtypecode);
675
676
677 ### If a library thinks that updating all biblios is a long process and wishes to leave that to a cron job to use merge_authotities.p
678 ### they should have a system preference "dontmerge=1" otherwise by default biblios will be updated
679 ### the $merge flag is now depreceated and will be removed at code cleaning
680
681 if (C4::Context->preference('dontmerge')){
682 # save the file in localfile/modified_authorities
683         my $cgidir = C4::Context->intranetdir ."/cgi-bin";
684         unless (opendir(DIR, "$cgidir")) {
685                         $cgidir = C4::Context->intranetdir."/";
686         } 
687
688         my $filename = $cgidir."/localfile/modified_authorities/$authid.authid";
689         open AUTH, "> $filename";
690         print AUTH $authid;
691         close AUTH;
692 }else{
693         &merge($dbh,$authid,$record,$authid,$record);
694 }
695 return $authid;
696 }
697
698 sub AUTHdelauthority {
699         my ($dbh,$authid,$keep_biblio) = @_;
700 # if the keep_biblio is set to 1, then authority entries in biblio are preserved.
701
702 zebraopauth($dbh,$authid,"recordDelete");
703         $dbh->do("delete from auth_header where authid=$authid") ;
704
705 # FIXME : delete or not in biblio tables (depending on $keep_biblio flag)
706 }
707
708
709
710 sub AUTHfind_authtypecode {
711         my ($dbh,$authid) = @_;
712         my $sth = $dbh->prepare("select authtypecode from auth_header where authid=?");
713         $sth->execute($authid);
714         my ($authtypecode) = $sth->fetchrow;
715         return $authtypecode;
716 }
717
718
719
720 sub AUTHhtml2xml {
721         my ($tags,$subfields,$values,$indicator,$ind_tag) = @_;
722         use MARC::File::XML;
723         my $xml= MARC::File::XML::header();
724         my $prevvalue;
725         my $prevtag=-1;
726         my $first=1;
727         my $j = -1;
728         for (my $i=0;$i<=@$tags;$i++){
729
730             if ((@$tags[$i] ne $prevtag)){
731                 $j++ unless (@$tags[$i] eq "");
732                 warn "IND:".substr(@$indicator[$j],0,1).substr(@$indicator[$j],1,1)." ".@$tags[$i];
733
734                 if (!$first){
735                     $xml.="</datafield>\n";
736                     $first=1;
737                 }
738                 else {
739                     if (@$values[$i] ne "") {
740                     # leader
741                     if (@$tags[$i] eq "000") {
742                         $xml.="<leader>@$values[$i]</leader>\n";
743                         $first=1;
744                         # rest of the fixed fields
745                     } elsif (@$tags[$i] < 10) {
746                         $xml.="<controlfield tag=\"@$tags[$i]\">@$values[$i]</controlfield>\n";
747                         $first=1;
748                     }
749                     else {
750                         my $ind1 = substr(@$indicator[$j],0,1);
751                         my $ind2 = substr(@$indicator[$j],1,1);
752                         $xml.="<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
753                         $xml.="<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
754                         $first=0;
755                     }
756                     }
757                 }
758             } else {
759                 if (@$values[$i] eq "") {
760                 }
761                 else {
762                 if ($first){
763                 my $ind1 = substr(@$indicator[$j],0,1);
764                 my $ind2 = substr(@$indicator[$j],1,1);
765                 $xml.="<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
766                 $first=0;
767                 }
768                     $xml.="<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
769
770                 }
771             }
772             $prevtag = @$tags[$i];
773         }
774         $xml.= MARC::File::XML::footer();
775         warn $xml;
776         return $xml
777 }
778 sub AUTHhtml2marc {
779         my ($dbh,$rtags,$rsubfields,$rvalues,%indicators) = @_;
780         my $prevtag = -1;
781         my $record = MARC::Record->new();
782 #---- TODO : the leader is missing
783
784 #       my %subfieldlist=();
785         my $prevvalue; # if tag <10
786         my $field; # if tag >=10
787         for (my $i=0; $i< @$rtags; $i++) {
788                 # rebuild MARC::Record
789                 if (@$rtags[$i] ne $prevtag) {
790                         if ($prevtag < 10) {
791                                 if ($prevvalue) {
792                                         $record->add_fields((sprintf "%03s",$prevtag),$prevvalue);
793                                 }
794                         } else {
795                                 if ($field) {
796                                         $record->add_fields($field);
797                                 }
798                         }
799                         $indicators{@$rtags[$i]}.='  ';
800                         if (@$rtags[$i] <10) {
801                                 $prevvalue= @$rvalues[$i];
802                                 undef $field;
803                         } else {
804                                 undef $prevvalue;
805                                 $field = MARC::Field->new( (sprintf "%03s",@$rtags[$i]), substr($indicators{@$rtags[$i]},0,1),substr($indicators{@$rtags[$i]},1,1), @$rsubfields[$i] => @$rvalues[$i]);
806                         }
807                         $prevtag = @$rtags[$i];
808                 } else {
809                         if (@$rtags[$i] <10) {
810                                 $prevvalue=@$rvalues[$i];
811                         } else {
812                                 if (length(@$rvalues[$i])>0) {
813                                         $field->add_subfields(@$rsubfields[$i] => @$rvalues[$i]);
814                                 }
815                         }
816                         $prevtag= @$rtags[$i];
817                 }
818         }
819         # the last has not been included inside the loop... do it now !
820         $record->add_fields($field) if $field;
821         return $record;
822 }
823
824
825
826
827 sub FindDuplicate {
828
829         my ($record,$authtypecode)=@_;
830 #       warn "IN for ".$record->as_formatted;
831         my $dbh = C4::Context->dbh;
832 #       warn "".$record->as_formatted;
833         my $sth = $dbh->prepare("select auth_tag_to_report from auth_types where authtypecode=?");
834         $sth->execute($authtypecode);
835         my ($auth_tag_to_report) = $sth->fetchrow;
836         $sth->finish;
837         # build a request for authoritysearch
838         my (@tags, @and_or, @excluding, @operator, @value, $offset, $length);
839         if ($record->field($auth_tag_to_report)) {
840                                 push @tags, $auth_tag_to_report;
841                                 push @and_or, "";
842                                 push @excluding, "";
843                                 push @operator, "all";
844                                 push @value, $record->field($auth_tag_to_report)->as_string();
845                         }
846  
847         my ($finalresult,$nbresult) = authoritysearch($dbh,\@tags,\@and_or,\@excluding,\@operator,\@value,0,10,$authtypecode);
848         # there is at least 1 result => return the 1st one
849         if ($nbresult>0) {
850                 return @$finalresult[0]->{authid},@$finalresult[0]->{summary};
851         }
852         # no result, returns nothing
853         return;
854 }
855
856 sub getsummary{
857 ## give this a Marc record to return summary
858 my ($dbh,$record,$authid,$authtypecode)=@_;
859
860 # my $authtypecode = AUTHfind_authtypecode($dbh,$authid);
861  my $authref = getauthtype($authtypecode);
862                 my $summary = $authref->{summary};
863                 my @fields = $record->fields();
864 #               chop $tags_using_authtype;
865                 # if the library has a summary defined, use it. Otherwise, build a standard one
866                 if ($summary) {
867                         my @fields = $record->fields();
868                         foreach my $field (@fields) {
869                                 my $tag = $field->tag();
870                                 my $tagvalue = $field->as_string();
871                                 $summary =~ s/\[(.?.?.?.?)$tag\*(.*?)]/$1$tagvalue$2\[$1$tag$2]/g;
872                                 if ($tag<10) {
873                                 } else {
874                                         my @subf = $field->subfields;
875                                         for my $i (0..$#subf) {
876                                                 my $subfieldcode = $subf[$i][0];
877                                                 my $subfieldvalue = $subf[$i][1];
878                                                 my $tagsubf = $tag.$subfieldcode;
879                                                 $summary =~ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
880                                         }
881                                 }
882                         }
883                         $summary =~ s/\[(.*?)]//g;
884                         $summary =~ s/\n/<br>/g;
885                 } else {
886                         my $heading; # = $authref->{summary};
887                         my $altheading;
888                         my $seeheading;
889                         my $see;
890                         my @fields = $record->fields();
891                         if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
892                         # construct UNIMARC summary, that is quite different from MARC21 one
893                                 # accepted form
894                                 foreach my $field ($record->field('2..')) {
895                                         $heading.= $field->as_string();
896                                 }
897                                 # rejected form(s)
898                                 foreach my $field ($record->field('4..')) {
899                                         $summary.= "&nbsp;&nbsp;&nbsp;<i>".$field->as_string()."</i><br/>";
900                                         $summary.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see:</i> ".$heading."<br/>";
901                                 }
902                                 # see :
903                                 foreach my $field ($record->field('5..')) {
904                                         $summary.= "&nbsp;&nbsp;&nbsp;<i>".$field->as_string()."</i><br/>";
905                                         $summary.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see:</i> ".$heading."<br/>";
906                                 }
907                                 # // form
908                                 foreach my $field ($record->field('7..')) {
909                                         $seeheading.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see also:</i> ".$field->as_string()."<br />";     
910                                         $altheading.= "&nbsp;&nbsp;&nbsp;".$field->as_string()."<br />";
911                                         $altheading.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see also:</i> ".$heading."<br />";
912                                 }
913                                 $summary = "<b>".$heading."</b><br />".$seeheading.$altheading.$summary;        
914                         } else {
915                         # construct MARC21 summary
916                                 foreach my $field ($record->field('1..')) {
917                                         if ($record->field('100')) {
918                                                 $heading.= $field->as_string('abcdefghjklmnopqrstvxyz68');
919                                         } elsif ($record->field('110')) {
920                                                 $heading.= $field->as_string('abcdefghklmnoprstvxyz68');
921                                         } elsif ($record->field('111')) {
922                                                 $heading.= $field->as_string('acdefghklnpqstvxyz68');
923                                         } elsif ($record->field('130')) {
924                                                 $heading.= $field->as_string('adfghklmnoprstvxyz68');
925                                         } elsif ($record->field('148')) {
926                                                 $heading.= $field->as_string('abvxyz68');
927                                         } elsif ($record->field('150')) {
928                                         $heading.= $field->as_string('abvxyz68');       
929                                         } elsif ($record->field('151')) {
930                                                 $heading.= $field->as_string('avxyz68');
931                                         } elsif ($record->field('155')) {
932                                                 $heading.= $field->as_string('abvxyz68');
933                                         } elsif ($record->field('180')) {
934                                                 $heading.= $field->as_string('vxyz68');
935                                         } elsif ($record->field('181')) {
936                                                 $heading.= $field->as_string('vxyz68');
937                                         } elsif ($record->field('182')) {
938                                                 $heading.= $field->as_string('vxyz68');
939                                         } elsif ($record->field('185')) {
940                                                 $heading.= $field->as_string('vxyz68');
941                                         } else {
942                                                 $heading.= $field->as_string();
943                                         }
944                                 } #See From
945                                 foreach my $field ($record->field('4..')) {
946                                         $seeheading.= "&nbsp;&nbsp;&nbsp;".$field->as_string()."<br />";
947                                         $seeheading.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see:</i> ".$seeheading."<br />";  
948                                 } #See Also
949                                 foreach my $field ($record->field('5..')) {
950                                         $altheading.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see also:</i> ".$field->as_string()."<br />";     
951                                         $altheading.= "&nbsp;&nbsp;&nbsp;".$field->as_string()."<br />";
952                                         $altheading.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see also:</i> ".$altheading."<br />";
953                                 }
954                                 $summary.=$heading.$seeheading.$altheading;
955                         }
956                 }
957 return $summary;
958 }
959 sub merge {
960         my ($dbh,$mergefrom,$MARCfrom,$mergeto,$MARCto) = @_;
961         my $authtypecodefrom = AUTHfind_authtypecode($dbh,$mergefrom);
962         my $authtypecodeto = AUTHfind_authtypecode($dbh,$mergeto);
963         # return if authority does not exist
964         my @X = $MARCfrom->fields();
965         return if $#X == -1;
966         my @X = $MARCto->fields();
967         return if $#X == -1;
968         
969         
970         # search the tag to report
971         my $sth = $dbh->prepare("select auth_tag_to_report from auth_types where authtypecode=?");
972         $sth->execute($authtypecodefrom);
973         my ($auth_tag_to_report) = $sth->fetchrow;
974
975         my @record_to;
976         @record_to = $MARCto->field($auth_tag_to_report)->subfields() if $MARCto->field($auth_tag_to_report);
977         my @record_from;
978         @record_from = $MARCfrom->field($auth_tag_to_report)->subfields() if $MARCfrom->field($auth_tag_to_report);
979         
980         # search all biblio tags using this authority.
981         $sth = $dbh->prepare("select distinct tagfield from marc_subfield_structure where authtypecode=?");
982         $sth->execute($authtypecodefrom);
983 my @tags_using_authtype;
984         while (my ($tagfield) = $sth->fetchrow) {
985                 push @tags_using_authtype,$tagfield."9" ;
986         }
987
988         # now, find every biblio using this authority
989 ### try ZOOM search here
990 my $oConnection=C4::Context->Zconn("biblioserver");
991
992
993 my $query;
994
995 $query= "\@attr GILS 1=2057 ".$mergefrom;
996
997 my $oResult = $oConnection->search_pqf($query);
998
999 my $count=$oResult->size() if  ($oResult);
1000 my @reccache;
1001 my $z=0;
1002 while ( $z<$count ) {
1003
1004 my $rec;
1005  
1006                  $rec=$oResult->record($z);
1007
1008         
1009         my $marcdata = $rec->raw();
1010 push @reccache, $marcdata;
1011 $z++;
1012 }
1013 $oResult->destroy();
1014 foreach my $marc(@reccache){
1015
1016 my $update;
1017         my $marcrecord;                                 
1018         $marcrecord = MARC::File::USMARC::decode($marc);
1019         foreach my $tagfield (@tags_using_authtype){
1020         $tagfield=substr($tagfield,0,3);
1021                 my @tags = $marcrecord->field($tagfield);
1022                 foreach my $tag (@tags){
1023                         my $tagsubs=$tag->subfield("9");
1024 #warn "$tagfield:$tagsubs:$mergefrom";
1025                         if ($tagsubs== $mergefrom) {
1026                
1027                         $tag->update("9" =>$mergeto);
1028         foreach my $subfield (@record_to) {
1029 #               warn "$subfield,$subfield->[0],$subfield->[1]";
1030                         $tag->update($subfield->[0] =>$subfield->[1]);
1031                         }#for $subfield
1032                 }
1033                 $marcrecord->delete_field($tag);
1034                 $marcrecord->add_fields($tag);
1035                 $update=1;
1036                 }#for each tag
1037         }#foreach tagfield
1038 my $oldbiblio = MARCmarc2koha($dbh,$marcrecord,"") ;
1039                 if ($update==1){
1040                 &NEWmodbiblio($dbh,$marcrecord,$oldbiblio->{'biblionumber'},undef,"0000") ;
1041                 }
1042                 
1043 }#foreach $marc
1044 }#sub
1045 END { }       # module clean-up code here (global destructor)
1046
1047 =back
1048
1049 =head1 AUTHOR
1050
1051 Koha Developement team <info@koha.org>
1052
1053 Paul POULAIN paul.poulain@free.fr
1054
1055 =cut
1056
1057 # $Id$
1058 # $Log$
1059 # Revision 1.27  2006/07/04 14:36:51  toins
1060 # Head & rel_2_2 merged
1061 #
1062 # Revision 1.26  2006/05/20 14:32:54  tgarip1957
1063 # If an authority is modified biblios related to this authority were not updated but a list of modified authorities was written to disk. Now by defult they get modified as well unless a system preference 'dontmerge' is defined. dontmerge=1 will keep the previous behaviour.
1064 #
1065 # Authority zebra server may have different shadow settings. Support is added
1066 #
1067 # Revision 1.25  2006/05/19 18:09:39  tgarip1957
1068 # All support for auth_subfield_tables is removed. All search is now with zebra authorities. New authority structure allows multiple linking of authorities of differnet types to one another.
1069 # Authority tables are modified to be compatible with new MARC frameworks. This change is part of Authority Linking & Zebra authorities. Requires change in Mysql database. It will break head unless all changes regarding this is implemented. This warning will take place on all commits regarding this
1070 #
1071 # Revision 1.9.2.6  2005/06/07 10:02:00  tipaul
1072 # porting dictionnary search from head to 2.2. there is now a ... facing titles, author & subject, to search in biblio & authorities existing values.
1073 #
1074 # Revision 1.9.2.5  2005/05/31 14:50:46  tipaul
1075 # fix for authority merging. There was a bug on official installs
1076 #
1077 # Revision 1.9.2.4  2005/05/30 11:24:15  tipaul
1078 # fixing a bug : when a field was repeated, the last field was also repeated. (Was due to the "empty" field in html between fields : to separate fields, in html, an empty field is automatically added. in AUTHhtml2marc, this empty field was not discarded correctly)
1079 #
1080 # Revision 1.9.2.3  2005/04/28 08:45:33  tipaul
1081 # porting FindDuplicate feature for authorities from HEAD to rel_2_2, works correctly now.
1082 #
1083 # Revision 1.9.2.2  2005/02/28 14:03:13  tipaul
1084 # * adding search on "main entry" (ie $a subfield) on a given authority (the "search everywhere" field is still here).
1085 # * adding a select box to requet "contain" or "begin with" search.
1086 # * fixing some bug in authority search (related to "main entry" search)
1087 #
1088 # Revision 1.9.2.1  2005/02/24 13:12:13  tipaul
1089 # saving authority modif in a text file. This will be used soon with another script (in crontab). The script in crontab will retrieve every authorityid in the directory localfile/authorities and modify every biblio using this authority. Those modifs may be long. So they can't be done through http, because we may encounter a webserver timeout, and kill the process before end of the job.
1090 # So, it will be done through a cron job.
1091 # (/me agree we need some doc for command line scripts)
1092 #
1093 # Revision 1.9  2004/12/23 09:48:11  tipaul
1094 # Minor changes in summary "exploding" (the 3 digits AFTER the subfield were not on the right place).
1095 #
1096 # Revision 1.8  2004/11/05 10:11:39  tipaul
1097 # export auth_count_usage (bugfix)
1098 #
1099 # Revision 1.7  2004/09/23 16:13:00  tipaul
1100 # Bugfix in modification
1101 #
1102 # Revision 1.6  2004/08/18 16:00:24  tipaul
1103 # fixes for authorities management
1104 #
1105 # Revision 1.5  2004/07/05 13:37:22  doxulting
1106 # First step for working authorities
1107 #
1108 # Revision 1.4  2004/06/22 11:35:37  tipaul
1109 # removing % at the beginning of a string to avoid loooonnnngggg searchs
1110 #
1111 # Revision 1.3  2004/06/17 08:02:13  tipaul
1112 # merging tag & subfield in auth_word for better perfs
1113 #
1114 # Revision 1.2  2004/06/10 08:29:01  tipaul
1115 # MARC authority management (continued)
1116 #
1117 # Revision 1.1  2004/06/07 07:35:01  tipaul
1118 # MARC authority management package
1119 #