synch fr & en
[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::Koha;
23 use MARC::Record;
24 use C4::Biblio;
25 use C4::Search;
26
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     &GetTagsLabels
35     &GetAuthType
36     &GetAuthTypeCode
37     &GetAuthMARCFromKohaField 
38     &AUTHhtml2marc
39
40     &AddAuthority
41     &ModAuthority
42     &DelAuthority
43     &GetAuthority
44     &GetAuthorityXML
45     
46     &CountUsage
47     &CountUsageChildren
48     &SearchAuthorities
49     
50     &BuildSummary
51     &BuildUnimarcHierarchies
52     &BuildUnimarcHierarchy
53     
54     &merge
55     &FindDuplicateAuthority
56  );
57
58 =head2 GetAuthMARCFromKohaField 
59
60 =over 4
61
62 ( $tag, $subfield ) = &GetAuthMARCFromKohaField ($kohafield,$authtypecode);
63 returns tag and subfield linked to kohafield
64
65 Comment :
66 Suppose Kohafield is only linked to ONE subfield
67 =back
68
69 =cut
70 sub GetAuthMARCFromKohaField {
71 #AUTHfind_marc_from_kohafield
72   my ( $kohafield,$authtypecode ) = @_;
73   my $dbh=C4::Context->dbh;
74   return 0, 0 unless $kohafield;
75   $authtypecode="" unless $authtypecode;
76   my $marcfromkohafield;
77   my $sth = $dbh->prepare("select tagfield,tagsubfield from auth_subfield_structure where kohafield= ? and authtypecode=? ");
78   $sth->execute($kohafield,$authtypecode);
79   my ($tagfield,$tagsubfield) = $sth->fetchrow;
80     
81   return  ($tagfield,$tagsubfield);
82 }
83
84 =head2 SearchAuthorities 
85
86 =over 4
87
88 (\@finalresult, $nbresults)= &SearchAuthorities($tags, $and_or, $excluding, $operator, $value, $offset,$length,$authtypecode,$sortby)
89 returns ref to array result and count of results returned
90
91 =back
92
93 =cut
94 sub SearchAuthorities {
95     my ($tags, $and_or, $excluding, $operator, $value, $offset,$length,$authtypecode,$sortby) = @_;
96 #     warn "CALL : $tags, $and_or, $excluding, $operator, $value, $offset,$length,$authtypecode,$sortby";
97     my $dbh=C4::Context->dbh;
98     if (C4::Context->preference('NoZebra')) {
99     
100         #
101         # build the query
102         #
103         my $query;
104         my @auths=split / /,$authtypecode ;
105         foreach my  $auth (@auths){
106             $query .="AND auth_type= $auth ";
107         }
108         $query =~ s/^AND //;
109         my $dosearch;
110         for(my $i = 0 ; $i <= $#{$value} ; $i++)
111         {
112             if (@$value[$i]){
113                 if (@$tags[$i] eq "mainmainentry") {
114                     $query .=" AND mainmainentry";
115                 }elsif (@$tags[$i] eq "mainentry") {
116                     $query .=" AND mainentry";
117                 } else {
118                     $query .=" AND ";
119                 }
120                 if (@$operator[$i] eq 'is') {
121                     $query.=(@$tags[$i]?"=":""). '"'.@$value[$i].'"';
122                 }elsif (@$operator[$i] eq "="){
123                     $query.=(@$tags[$i]?"=":""). '"'.@$value[$i].'"';
124                 }elsif (@$operator[$i] eq "start"){
125                     $query.=(@$tags[$i]?"=":"").'"'.@$value[$i].'%"';
126                 } else {
127                     $query.=(@$tags[$i]?"=":"").'"'.@$value[$i].'%"';
128                 }
129                 $dosearch=1;
130             }#if value
131         }
132         #
133         # do the query (if we had some search term
134         #
135         if ($dosearch) {
136 #             warn "QUERY : $query";
137             my $result = C4::Search::NZanalyse($query,'authorityserver');
138 #             warn "result : $result";
139             my %result;
140             foreach (split /;/,$result) {
141                 my ($authid,$title) = split /,/,$_;
142                 # hint : the result is sorted by title.biblionumber because we can have X biblios with the same title
143                 # and we don't want to get only 1 result for each of them !!!
144                 # hint & speed improvement : we can order without reading the record
145                 # so order, and read records only for the requested page !
146                 $result{$title.$authid}=$authid;
147             }
148             # sort the hash and return the same structure as GetRecords (Zebra querying)
149             my @finalresult = ();
150             my $numbers=0;
151             if ($sortby eq 'HeadingDsc') { # sort by mainmainentry desc
152                 foreach my $key (sort {$b cmp $a} (keys %result)) {
153                     push @finalresult, $result{$key};
154 #                     warn "push..."$#finalresult;
155                     $numbers++;
156                 }
157             } else { # sort by mainmainentry ASC
158                 foreach my $key (sort (keys %result)) {
159                     push @finalresult, $result{$key};
160 #                     warn "push..."$#finalresult;
161                     $numbers++;
162                 }
163             }
164             # limit the $results_per_page to result size if it's more
165             $length = $numbers-1 if $numbers < $length;
166             # for the requested page, replace authid by the complete record
167             # speed improvement : avoid reading too much things
168             for (my $counter=$offset;$counter<=$offset+$length;$counter++) {
169 #                 $finalresult[$counter] = GetAuthority($finalresult[$counter])->as_usmarc;
170                 my $separator=C4::Context->preference('authoritysep');
171                 my $authrecord = MARC::File::USMARC::decode(GetAuthority($finalresult[$counter])->as_usmarc);
172                 my $authid=$authrecord->field('001')->data(); 
173                 my $summary=BuildSummary($authrecord,$authid,$authtypecode);
174                 my $query_auth_tag = "SELECT auth_tag_to_report FROM auth_types WHERE authtypecode=?";
175                 my $sth = $dbh->prepare($query_auth_tag);
176                 $sth->execute($authtypecode);
177                 my $auth_tag_to_report = $sth->fetchrow;
178                 my %newline;
179                 $newline{used}=CountUsage($authid);
180                 $newline{summary} = $summary;
181                 $newline{authid} = $authid;
182                 $newline{even} = $counter % 2;
183                 $finalresult[$counter]= \%newline;
184             }
185             return (\@finalresult, $numbers);
186         } else {
187             return;
188         }
189     } else {
190         my $query;
191         my $attr;
192             # the marclist may contain "mainentry". In this case, search the tag_to_report, that depends on
193             # the authtypecode. Then, search on $a of this tag_to_report
194             # also store main entry MARC tag, to extract it at end of search
195         my $mainentrytag;
196         ##first set the authtype search and may be multiple authorities
197         my $n=0;
198         my @authtypecode;
199         my @auths=split / /,$authtypecode ;
200         foreach my  $auth (@auths){
201             $query .=" \@attr 1=Authority/format-id \@attr 5=100 ".$auth; ##No truncation on authtype
202             push @authtypecode ,$auth;
203             $n++;
204         }
205         if ($n>1){
206             $query= "\@or ".$query;
207         }
208         
209         my $dosearch;
210         my $and;
211         my $q2;
212         for(my $i = 0 ; $i <= $#{$value} ; $i++)
213         {
214             if (@$value[$i]){
215             ##If mainentry search $a tag
216                 if (@$tags[$i] eq "mainmainentry") {
217                 $attr =" \@attr 1=Heading ";
218                 }elsif (@$tags[$i] eq "mainentry") {
219                 $attr =" \@attr 1=Heading-Entity ";
220                 }else{
221                 $attr =" \@attr 1=Any ";
222                 }
223                 if (@$operator[$i] eq 'is') {
224                     $attr.=" \@attr 4=1  \@attr 5=100 ";##Phrase, No truncation,all of subfield field must match
225                 }elsif (@$operator[$i] eq "="){
226                     $attr.=" \@attr 4=107 ";           #Number Exact match
227                 }elsif (@$operator[$i] eq "start"){
228                     $attr.=" \@attr 4=1 \@attr 5=1 ";#Phrase, Right truncated
229                 } else {
230                     $attr .=" \@attr 5=1  ";## Word list, right truncated, anywhere
231                 }
232                 $and .=" \@and " ;
233                 $attr =$attr."\"".@$value[$i]."\"";
234                 $q2 .=$attr;
235             $dosearch=1;
236             }#if value
237         }
238         ##Add how many queries generated
239         $query= $and.$query.$q2;
240         ## Adding order
241         $query=' @or  @attr 7=1 @attr 1=Heading 0 @or  @attr 7=1 @attr 1=Heading-Entity 1'.$query if ($sortby eq "HeadingAsc");
242         $query=' @or  @attr 7=2 @attr 1=Heading 0 @or  @attr 7=1 @attr 1=Heading-Entity 1'.$query if ($sortby eq "HeadingDsc");
243         
244         $offset=0 unless $offset;
245         my $counter = $offset;
246         $length=10 unless $length;
247         my @oAuth;
248         my $i;
249         $oAuth[0]=C4::Context->Zconn("authorityserver" , 1);
250         my $Anewq= new ZOOM::Query::PQF($query,$oAuth[0]);
251         my $oAResult;
252         $oAResult= $oAuth[0]->search($Anewq) ; 
253         while (($i = ZOOM::event(\@oAuth)) != 0) {
254             my $ev = $oAuth[$i-1]->last_event();
255             last if $ev == ZOOM::Event::ZEND;
256         }
257         my($error, $errmsg, $addinfo, $diagset) = $oAuth[0]->error_x();
258         if ($error) {
259             warn  "oAuth error: $errmsg ($error) $addinfo $diagset\n";
260             goto NOLUCK;
261         }
262         
263         my $nbresults;
264         $nbresults=$oAResult->size();
265         my $nremains=$nbresults;    
266         my @result = ();
267         my @finalresult = ();
268         
269         if ($nbresults>0){
270         
271         ##Find authid and linkid fields
272         ##we may be searching multiple authoritytypes.
273         ## FIXME this assumes that all authid and linkid fields are the same for all authority types
274         # my ($authidfield,$authidsubfield)=GetAuthMARCFromKohaField($dbh,"auth_header.authid",$authtypecode[0]);
275         # my ($linkidfield,$linkidsubfield)=GetAuthMARCFromKohaField($dbh,"auth_header.linkid",$authtypecode[0]);
276             while (($counter < $nbresults) && ($counter < ($offset + $length))) {
277             
278             ##Here we have to extract MARC record and $authid from ZEBRA AUTHORITIES
279             my $rec=$oAResult->record($counter);
280             my $marcdata=$rec->raw();
281             my $authrecord;
282             my $separator=C4::Context->preference('authoritysep');
283             $authrecord = MARC::File::USMARC::decode($marcdata);
284             my $authid=$authrecord->field('001')->data(); 
285             my $summary=BuildSummary($authrecord,$authid,$authtypecode);
286             my $query_auth_tag = "SELECT auth_tag_to_report FROM auth_types WHERE authtypecode=?";
287             my $sth = $dbh->prepare($query_auth_tag);
288             $sth->execute($authtypecode);
289             my $auth_tag_to_report = $sth->fetchrow;
290             my %newline;
291             $newline{summary} = $summary;
292             $newline{authid} = $authid;
293             $newline{even} = $counter % 2;
294             $counter++;
295             push @finalresult, \%newline;
296             }## while counter
297         ###
298         for (my $z=0; $z<@finalresult; $z++){
299                 my  $count=CountUsage($finalresult[$z]{authid});
300                 $finalresult[$z]{used}=$count;
301         }# all $z's
302         
303         }## if nbresult
304         NOLUCK:
305         # $oAResult->destroy();
306         # $oAuth[0]->destroy();
307         
308         return (\@finalresult, $nbresults);
309     }
310 }
311
312 =head2 CountUsage 
313
314 =over 4
315
316 $count= &CountUsage($authid)
317 counts Usage of Authid in bibliorecords. 
318
319 =back
320
321 =cut
322 sub CountUsage {
323     my ($authid) = @_;
324     if (C4::Context->preference('NoZebra')) {
325         # Read the index Koha-Auth-Number for this authid and count the lines
326         my $result = C4::Search::NZanalyse("an=$authid");
327         return scalar split /;/,$result;
328     } else {
329         ### ZOOM search here
330         my $oConnection=C4::Context->Zconn("biblioserver",1);
331         my $query;
332         $query= "an=".$authid;
333         my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection ));
334         my $result;
335         while ((my $i = ZOOM::event([ $oConnection ])) != 0) {
336             my $ev = $oConnection->last_event();
337             if ($ev == ZOOM::Event::ZEND) {
338                 $result = $oResult->size();
339             }
340         }
341         return ($result);
342     }
343 }
344
345 =head2 CountUsageChildren 
346
347 =over 4
348
349 $count= &CountUsageChildren($authid)
350 counts Usage of narrower terms of Authid in bibliorecords.
351
352 =back
353
354 =cut
355 sub CountUsageChildren {
356   my ($authid) = @_;
357 }
358
359 =head2 GetAuthTypeCode
360
361 =over 4
362
363 $authtypecode= &GetAuthTypeCode($authid)
364 returns authtypecode of an authid
365
366 =back
367
368 =cut
369 sub GetAuthTypeCode {
370 #AUTHfind_authtypecode
371   my ($authid) = @_;
372   my $dbh=C4::Context->dbh;
373   my $sth = $dbh->prepare("select authtypecode from auth_header where authid=?");
374   $sth->execute($authid);
375   my ($authtypecode) = $sth->fetchrow;
376   return $authtypecode;
377 }
378  
379 =head2 GetTagsLabels
380
381 =over 4
382
383 $tagslabel= &GetTagsLabels($forlibrarian,$authtypecode)
384 returns a ref to hashref of authorities tag and subfield structure.
385
386 tagslabel usage : 
387 $tagslabel->{$tag}->{$subfield}->{'attribute'}
388 where attribute takes values in :
389   lib
390   tab
391   mandatory
392   repeatable
393   authorised_value
394   authtypecode
395   value_builder
396   kohafield
397   seealso
398   hidden
399   isurl
400   link
401
402 =back
403
404 =cut
405 sub GetTagsLabels {
406   my ($forlibrarian,$authtypecode)= @_;
407   my $dbh=C4::Context->dbh;
408   $authtypecode="" unless $authtypecode;
409   my $sth;
410   my $libfield = ($forlibrarian eq 1)? 'liblibrarian' : 'libopac';
411
412
413   # check that authority exists
414   $sth=$dbh->prepare("select count(*) from auth_tag_structure where authtypecode=?");
415   $sth->execute($authtypecode);
416   my ($total) = $sth->fetchrow;
417   $authtypecode="" unless ($total >0);
418   $sth= $dbh->prepare(
419 "SELECT tagfield,liblibrarian,libopac,mandatory,repeatable 
420  FROM auth_tag_structure 
421  WHERE authtypecode=? 
422  ORDER BY tagfield"
423     );
424
425   $sth->execute($authtypecode);
426   my ( $liblibrarian, $libopac, $tag, $res, $tab, $mandatory, $repeatable );
427
428   while ( ( $tag, $liblibrarian, $libopac, $mandatory, $repeatable ) = $sth->fetchrow ) {
429         $res->{$tag}->{lib}        = ($forlibrarian or !$libopac)?$liblibrarian:$libopac;
430         $res->{$tag}->{tab}        = " ";            # XXX
431         $res->{$tag}->{mandatory}  = $mandatory;
432         $res->{$tag}->{repeatable} = $repeatable;
433   }
434   $sth=      $dbh->prepare(
435 "SELECT tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl 
436 FROM auth_subfield_structure 
437 WHERE authtypecode=? 
438 ORDER BY tagfield,tagsubfield"
439     );
440     $sth->execute($authtypecode);
441
442     my $subfield;
443     my $authorised_value;
444     my $value_builder;
445     my $kohafield;
446     my $seealso;
447     my $hidden;
448     my $isurl;
449     my $link;
450
451     while (
452         ( $tag,         $subfield,   $liblibrarian,   , $libopac,      $tab,
453         $mandatory,     $repeatable, $authorised_value, $authtypecode,
454         $value_builder, $kohafield,  $seealso,          $hidden,
455         $isurl,            $link )
456         = $sth->fetchrow
457       )
458     {
459         $res->{$tag}->{$subfield}->{lib}              = ($forlibrarian or !$libopac)?$liblibrarian:$libopac;
460         $res->{$tag}->{$subfield}->{tab}              = $tab;
461         $res->{$tag}->{$subfield}->{mandatory}        = $mandatory;
462         $res->{$tag}->{$subfield}->{repeatable}       = $repeatable;
463         $res->{$tag}->{$subfield}->{authorised_value} = $authorised_value;
464         $res->{$tag}->{$subfield}->{authtypecode}     = $authtypecode;
465         $res->{$tag}->{$subfield}->{value_builder}    = $value_builder;
466         $res->{$tag}->{$subfield}->{kohafield}        = $kohafield;
467         $res->{$tag}->{$subfield}->{seealso}          = $seealso;
468         $res->{$tag}->{$subfield}->{hidden}           = $hidden;
469         $res->{$tag}->{$subfield}->{isurl}            = $isurl;
470         $res->{$tag}->{$subfield}->{link}            = $link;
471     }
472     return $res;
473 }
474
475 =head2 AddAuthority
476
477 =over 4
478
479 $authid= &AddAuthority($record, $authid,$authtypecode)
480 returns authid of the newly created authority
481
482 Either Create Or Modify existing authority.
483
484 =back
485
486 =cut
487 sub AddAuthority {
488 # pass the MARC::Record to this function, and it will create the records in the authority table
489   my ($record,$authid,$authtypecode) = @_;
490   my $dbh=C4::Context->dbh;
491   my $leader='         a              ';##Fixme correct leader as this one just adds utf8 to MARC21
492
493 # if authid empty => true add, find a new authid number
494   if (!$authid) {
495     my $sth=$dbh->prepare("select max(authid) from auth_header");
496     $sth->execute;
497     ($authid)=$sth->fetchrow;
498     $authid=$authid+1;
499   ##Insert the recordID in MARC record 
500   ##Both authid and authtypecode is expected to be in the same field. Modify if other requirements arise
501     $record->add_fields('001',$authid) unless $record->field('001');
502     $record->add_fields('152','','','b'=>$authtypecode) unless $record->field('152');
503 #     warn $record->as_formatted;
504     $dbh->do("lock tables auth_header WRITE");
505     $sth=$dbh->prepare("insert into auth_header (authid,datecreated,authtypecode,marc,marcxml) values (?,now(),?,?,?)");
506     $sth->execute($authid,$authtypecode,$record->as_usmarc,$record->as_xml);
507     $sth->finish;
508   }else{
509       $record->add_fields('001',$authid) unless ($record->field('001'));
510       $record->add_fields('100',$authid) unless ($record->field('100'));
511       $record->add_fields('152','','','b'=>$authtypecode) unless ($record->field('152'));
512       $dbh->do("lock tables auth_header WRITE");
513       my $sth=$dbh->prepare("update auth_header set marc=?,marcxml=? where authid=?");
514       $sth->execute($record->as_usmarc,$record->as_xml,$authid);
515       $sth->finish;
516   }
517   $dbh->do("unlock tables");
518   ModZebra($authid,'specialUpdate',"authorityserver",$record);
519   return ($authid);
520 }
521
522
523 =head2 DelAuthority
524
525 =over 4
526
527 $authid= &DelAuthority($authid)
528 Deletes $authid
529
530 =back
531
532 =cut
533
534
535 sub DelAuthority {
536     my ($authid) = @_;
537     my $dbh=C4::Context->dbh;
538
539     ModZebra($authid,"recordDelete","authorityserver",GetAuthority($authid));
540     $dbh->do("delete from auth_header where authid=$authid") ;
541
542 }
543
544 sub ModAuthority {
545   my ($authid,$record,$authtypecode,$merge)=@_;
546   my $dbh=C4::Context->dbh;
547   my ($oldrecord)=&GetAuthority($authid);
548   if ($oldrecord eq $record) {
549       return;
550   }
551   my $sth=$dbh->prepare("update auth_header set marc=? where authid=?");
552   #Now rewrite the $record to table with an add
553   $authid=AddAuthority($record,$authid,$authtypecode);
554
555
556 ### 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
557 ### they should have a system preference "dontmerge=1" otherwise by default biblios will be updated
558 ### the $merge flag is now depreceated and will be removed at code cleaning
559   if (C4::Context->preference('dontmerge') ){
560   # save the file in localfile/modified_authorities
561       my $cgidir = C4::Context->intranetdir ."/cgi-bin";
562       unless (opendir(DIR,"$cgidir")) {
563               $cgidir = C4::Context->intranetdir."/";
564       }
565   
566       my $filename = $cgidir."/localfile/modified_authorities/$authid.authid";
567       open AUTH, "> $filename";
568       print AUTH $authid;
569       close AUTH;
570   } else {
571       &merge($authid,$record,$authid,$record);
572   }
573   return $authid;
574 }
575
576 =head2 GetAuthorityXML 
577
578 =over 4
579
580 $marcxml= &GetAuthorityXML( $authid)
581 returns xml form of record $authid
582
583 =back
584
585 =cut
586 sub GetAuthorityXML {
587   # Returns MARC::XML of the authority passed in parameter.
588   my ( $authid ) = @_;
589   my $dbh=C4::Context->dbh;
590   my $sth =
591       $dbh->prepare("select marc from auth_header where authid=? "  );
592   $sth->execute($authid);
593   my ($marc)=$sth->fetchrow;
594   $marc=MARC::File::USMARC::decode($marc);
595   my $marcxml=$marc->as_xml_record();
596   return $marcxml;
597
598 }
599
600 =head2 GetAuthority 
601
602 =over 4
603
604 $record= &GetAuthority( $authid)
605 Returns MARC::Record of the authority passed in parameter.
606
607 =back
608
609 =cut
610 sub GetAuthority {
611   my ($authid)=@_;
612   my $dbh=C4::Context->dbh;
613   my $sth=$dbh->prepare("select marc from auth_header where authid=?");
614   $sth->execute($authid);
615   my ($marc) = $sth->fetchrow;
616   my $record=MARC::File::USMARC::decode($marc);
617   return ($record);
618 }
619
620 =head2 GetAuthType 
621
622 =over 4
623
624 $result= &GetAuthType( $authtypecode)
625 If $authtypecode is not "" then 
626   Returns hashref to authtypecode information
627 else 
628   returns ref to array of hashref information of all Authtypes
629
630 =back
631
632 =cut
633 sub GetAuthType {
634     my ($authtypecode) = @_;
635     my $dbh=C4::Context->dbh;
636     my $sth;
637     if ($authtypecode){
638       $sth=$dbh->prepare("select * from auth_types where authtypecode=?");
639       $sth->execute($authtypecode);
640     } else {
641       $sth=$dbh->prepare("select * from auth_types");
642       $sth->execute;
643     }
644     my $res=$sth->fetchall_arrayref({});
645     if (scalar(@$res)==1){
646       return $res->[0];
647     } else {
648       return $res;
649     }
650 }
651
652
653 sub AUTHhtml2marc {
654     my ($rtags,$rsubfields,$rvalues,%indicators) = @_;
655     my $dbh=C4::Context->dbh;
656     my $prevtag = -1;
657     my $record = MARC::Record->new();
658 #---- TODO : the leader is missing
659
660 #     my %subfieldlist=();
661     my $prevvalue; # if tag <10
662     my $field; # if tag >=10
663     for (my $i=0; $i< @$rtags; $i++) {
664         # rebuild MARC::Record
665         if (@$rtags[$i] ne $prevtag) {
666             if ($prevtag < 10) {
667                 if ($prevvalue) {
668                     $record->add_fields((sprintf "%03s",$prevtag),$prevvalue);
669                 }
670             } else {
671                 if ($field) {
672                     $record->add_fields($field);
673                 }
674             }
675             $indicators{@$rtags[$i]}.='  ';
676             if (@$rtags[$i] <10) {
677                 $prevvalue= @$rvalues[$i];
678                 undef $field;
679             } else {
680                 undef $prevvalue;
681                 $field = MARC::Field->new( (sprintf "%03s",@$rtags[$i]), substr($indicators{@$rtags[$i]},0,1),substr($indicators{@$rtags[$i]},1,1), @$rsubfields[$i] => @$rvalues[$i]);
682             }
683             $prevtag = @$rtags[$i];
684         } else {
685             if (@$rtags[$i] <10) {
686                 $prevvalue=@$rvalues[$i];
687             } else {
688                 if (length(@$rvalues[$i])>0) {
689                     $field->add_subfields(@$rsubfields[$i] => @$rvalues[$i]);
690                 }
691             }
692             $prevtag= @$rtags[$i];
693         }
694     }
695     # the last has not been included inside the loop... do it now !
696     $record->add_fields($field) if $field;
697     return $record;
698 }
699
700 =head2 FindDuplicateAuthority
701
702 =over 4
703
704 $record= &FindDuplicateAuthority( $record, $authtypecode)
705 return $authid,Summary if duplicate is found.
706
707 Comments : an improvement would be to return All the records that match.
708
709 =back
710
711 =cut
712
713 sub FindDuplicateAuthority {
714
715     my ($record,$authtypecode)=@_;
716 #    warn "IN for ".$record->as_formatted;
717     my $dbh = C4::Context->dbh;
718 #    warn "".$record->as_formatted;
719     my $sth = $dbh->prepare("select auth_tag_to_report from auth_types where authtypecode=?");
720     $sth->execute($authtypecode);
721     my ($auth_tag_to_report) = $sth->fetchrow;
722     $sth->finish;
723 #     warn "record :".$record->as_formatted."  auth_tag_to_report :$auth_tag_to_report";
724     # build a request for SearchAuthorities
725     my $query='at='.$authtypecode.' ';
726     map {$query.= " and he=\"".$_->[1]."\"" if ($_->[0]=~/[A-z]/)}  $record->field($auth_tag_to_report)->subfields() if $record->field($auth_tag_to_report);
727     my ($error,$results)=SimpleSearch($query,"authorityserver");
728     # there is at least 1 result => return the 1st one
729     if (@$results>0) {
730       my $marcrecord = MARC::File::USMARC::decode($results->[0]);
731       return $marcrecord->field('001')->data,BuildSummary($marcrecord,$marcrecord->field('001')->data,$authtypecode);
732     }
733     # no result, returns nothing
734     return;
735 }
736
737 =head2 BuildSummary
738
739 =over 4
740
741 $text= &BuildSummary( $record, $authid, $authtypecode)
742 return HTML encoded Summary
743
744 Comment : authtypecode can be infered from both record and authid.
745 Moreover, authid can also be inferred from $record.
746 Would it be interesting to delete those things.
747
748 =back
749
750 =cut
751
752 sub BuildSummary{
753 ## give this a Marc record to return summary
754   my ($record,$authid,$authtypecode)=@_;
755   my $dbh=C4::Context->dbh;
756   my $authref = GetAuthType($authtypecode);
757   my $summary = $authref->{summary};
758   my @fields = $record->fields();
759   my $reported_tag;
760   # if the library has a summary defined, use it. Otherwise, build a standard one
761   if ($summary) {
762     my @fields = $record->fields();
763     #             $reported_tag = '$9'.$result[$counter];
764     foreach my $field (@fields) {
765       my $tag = $field->tag();
766       my $tagvalue = $field->as_string();
767       $summary =~ s/\[(.?.?.?.?)$tag\*(.*?)]/$1$tagvalue$2\[$1$tag$2]/g;
768       if ($tag<10) {
769         if ($tag eq '001') {
770           $reported_tag.='$3'.$field->data();
771         }
772       } else {
773         my @subf = $field->subfields;
774         for my $i (0..$#subf) {
775           my $subfieldcode = $subf[$i][0];
776           my $subfieldvalue = $subf[$i][1];
777           my $tagsubf = $tag.$subfieldcode;
778           $summary =~ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
779         }
780       }
781     }
782     $summary =~ s/\[(.*?)]//g;
783     $summary =~ s/\n/<br>/g;
784     } else {
785       my $heading; # = $authref->{summary};
786       my $altheading;
787       my $seeheading;
788       my $see;
789       my @fields = $record->fields();
790       if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
791       # construct UNIMARC summary, that is quite different from MARC21 one
792           # accepted form
793           foreach my $field ($record->field('2..')) {
794               $heading.= $field->as_string();
795           }
796           # rejected form(s)
797           foreach my $field ($record->field('4..')) {
798               $summary.= "&nbsp;&nbsp;&nbsp;<i>".$field->as_string()."</i><br/>";
799               $summary.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see:</i> ".$heading."<br/>";
800           }
801           # see :
802           foreach my $field ($record->field('5..')) {
803               $summary.= "&nbsp;&nbsp;&nbsp;<i>".$field->as_string()."</i><br/>";
804               $summary.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see:</i> ".$heading."<br/>";
805           }
806           # // form
807           foreach my $field ($record->field('7..')) {
808               $seeheading.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see also:</i> ".$field->as_string()."<br />";
809               $altheading.= "&nbsp;&nbsp;&nbsp;".$field->as_string()."<br />";
810               $altheading.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see also:</i> ".$heading."<br />";
811           }
812           $summary = "<b>".$heading."</b><br />".$seeheading.$altheading.$summary;
813       } else {
814       # construct MARC21 summary
815           foreach my $field ($record->field('1..')) {
816               if ($record->field('100')) {
817                   $heading.= $field->as_string('abcdefghjklmnopqrstvxyz68');
818               } elsif ($record->field('110')) {
819                                       $heading.= $field->as_string('abcdefghklmnoprstvxyz68');
820               } elsif ($record->field('111')) {
821                                       $heading.= $field->as_string('acdefghklnpqstvxyz68');
822               } elsif ($record->field('130')) {
823                                       $heading.= $field->as_string('adfghklmnoprstvxyz68');
824               } elsif ($record->field('148')) {
825                                       $heading.= $field->as_string('abvxyz68');
826               } elsif ($record->field('150')) {
827           #    $heading.= $field->as_string('abvxyz68');
828           $heading.= $field->as_formatted();
829               my $tag=$field->tag();
830               $heading=~s /^$tag//g;
831               $heading =~s /\_/\$/g;
832               } elsif ($record->field('151')) {
833                                       $heading.= $field->as_string('avxyz68');
834               } elsif ($record->field('155')) {
835                                       $heading.= $field->as_string('abvxyz68');
836               } elsif ($record->field('180')) {
837                                       $heading.= $field->as_string('vxyz68');
838               } elsif ($record->field('181')) {
839                                       $heading.= $field->as_string('vxyz68');
840               } elsif ($record->field('182')) {
841                                       $heading.= $field->as_string('vxyz68');
842               } elsif ($record->field('185')) {
843                                       $heading.= $field->as_string('vxyz68');
844               } else {
845                   $heading.= $field->as_string();
846               }
847           } #See From
848           foreach my $field ($record->field('4..')) {
849               $seeheading.= "&nbsp;&nbsp;&nbsp;".$field->as_string()."<br />";
850               $seeheading.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see:</i> ".$seeheading."<br />";
851           } #See Also
852           foreach my $field ($record->field('5..')) {
853               $altheading.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see also:</i> ".$field->as_string()."<br />";
854               $altheading.= "&nbsp;&nbsp;&nbsp;".$field->as_string()."<br />";
855               $altheading.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>see also:</i> ".$altheading."<br />";
856           }
857           $summary.=$heading.$seeheading.$altheading;
858       }
859     }
860 return $summary;
861 }
862
863 =head2 BuildUnimarcHierarchies
864
865 =over 4
866
867 $text= &BuildUnimarcHierarchies( $authid, $force)
868 return text containing trees for hierarchies
869 for them to be stored in auth_header
870
871 Example of text:
872 122,1314,2452;1324,2342,3,2452
873
874 =back
875
876 =cut
877 sub BuildUnimarcHierarchies{
878   my $authid = shift @_;
879 #   warn "authid : $authid";
880   my $force = shift @_;
881   my @globalresult;
882   my $dbh=C4::Context->dbh;
883   my $hierarchies;
884   my $data = GetHeaderAuthority($authid);
885   if ($data->{'authtrees'} and not $force){
886     return $data->{'authtrees'};
887   } elsif ($data->{'authtrees'}){
888     $hierarchies=$data->{'authtrees'};
889   } else {
890     my $record = GetAuthority($authid);
891     my $found;
892     foreach my $field ($record->field('550')){
893       if ($field->subfield('5') && $field->subfield('5') eq 'g'){
894         my $parentrecord = GetAuthority($field->subfield('3'));
895         my $localresult=$hierarchies;
896         my $trees;
897         $trees = BuildUnimarcHierarchies($field->subfield('3'));
898         my @trees;
899         if ($trees=~/;/){
900            @trees = split(/;/,$trees);
901         } else {
902            push @trees, $trees;
903         }
904         foreach (@trees){
905           $_.= ",$authid";
906         }
907         @globalresult = (@globalresult,@trees);
908         $found=1;
909       }
910       $hierarchies=join(";",@globalresult);
911     }
912     #Unless there is no ancestor, I am alone.
913     $hierarchies="$authid" unless ($hierarchies);
914   }
915   AddAuthorityTrees($authid,$hierarchies);
916   return $hierarchies;
917 }
918
919 =head2 BuildUnimarcHierarchy
920
921 =over 4
922
923 $ref= &BuildUnimarcHierarchy( $record, $class,$authid)
924 return a hashref in order to display hierarchy for record and final Authid $authid
925
926 "loopparents"
927 "loopchildren"
928 "class"
929 "loopauthid"
930 "current_value"
931 "value"
932
933 "ifparents"  
934 "ifchildren" 
935 Those two latest ones should disappear soon.
936
937 =back
938
939 =cut
940 sub BuildUnimarcHierarchy{
941   my $record = shift @_;
942   my $class = shift @_;
943   my $authid_constructed = shift @_;
944   my $authid=$record->subfield('250','3');
945   my %cell;
946   my $parents=""; my $children="";
947   my (@loopparents,@loopchildren);
948   foreach my $field ($record->field('550')){
949     if ($field->subfield('5') && $field->subfield('a')){
950       if ($field->subfield('5') eq 'h'){
951         push @loopchildren, { "childauthid"=>$field->subfield('3'),"childvalue"=>$field->subfield('a')};
952       }elsif ($field->subfield('5') eq 'g'){
953         push @loopparents, { "parentauthid"=>$field->subfield('3'),"parentvalue"=>$field->subfield('a')};
954       }
955           # brothers could get in there with an else
956     }
957   }
958   $cell{"ifparents"}=1 if (scalar(@loopparents)>0);
959   $cell{"ifchildren"}=1 if (scalar(@loopchildren)>0);
960   $cell{"loopparents"}=\@loopparents if (scalar(@loopparents)>0);
961   $cell{"loopchildren"}=\@loopchildren if (scalar(@loopchildren)>0);
962   $cell{"class"}=$class;
963   $cell{"loopauthid"}=$authid;
964   $cell{"current_value"} =1 if $authid eq $authid_constructed;
965   $cell{"value"}=$record->subfield('250',"a");
966   return \%cell;
967 }
968
969 =head2 GetHeaderAuthority
970
971 =over 4
972
973 $ref= &GetHeaderAuthority( $authid)
974 return a hashref in order auth_header table data
975
976 =back
977
978 =cut
979 sub GetHeaderAuthority{
980   my $authid = shift @_;
981   my $sql= "SELECT * from auth_header WHERE authid = ?";
982   my $dbh=C4::Context->dbh;
983   my $rq= $dbh->prepare($sql);
984   $rq->execute($authid);
985   my $data= $rq->fetchrow_hashref;
986   return $data;
987 }
988
989 =head2 AddAuthorityTrees
990
991 =over 4
992
993 $ref= &AddAuthorityTrees( $authid, $trees)
994 return success or failure
995
996 =back
997
998 =cut
999
1000 sub AddAuthorityTrees{
1001   my $authid = shift @_;
1002   my $trees = shift @_;
1003   my $sql= "UPDATE IGNORE auth_header set authtrees=? WHERE authid = ?";
1004   my $dbh=C4::Context->dbh;
1005   my $rq= $dbh->prepare($sql);
1006   return $rq->execute($trees,$authid);
1007 }
1008
1009 =head2 merge
1010
1011 =over 4
1012
1013 $ref= &merge(mergefrom,$MARCfrom,$mergeto,$MARCto)
1014
1015
1016 Could add some feature : Migrating from a typecode to an other for instance.
1017 Then we should add some new parameter : bibliotargettag, authtargettag
1018
1019 =back
1020
1021 =cut
1022 sub merge {
1023     my ($mergefrom,$MARCfrom,$mergeto,$MARCto) = @_;
1024     my $dbh=C4::Context->dbh;
1025     my $authtypecodefrom = GetAuthTypeCode($mergefrom);
1026     my $authtypecodeto = GetAuthTypeCode($mergeto);
1027     # return if authority does not exist
1028     my @X = $MARCfrom->fields();
1029     return if $#X == -1;
1030     @X = $MARCto->fields();
1031     return if $#X == -1;
1032     # search the tag to report
1033     my $sth = $dbh->prepare("select auth_tag_to_report from auth_types where authtypecode=?");
1034     $sth->execute($authtypecodefrom);
1035     my ($auth_tag_to_report) = $sth->fetchrow;
1036     
1037     my @record_to;
1038     @record_to = $MARCto->field($auth_tag_to_report)->subfields() if $MARCto->field($auth_tag_to_report);
1039     my @record_from;
1040     @record_from = $MARCfrom->field($auth_tag_to_report)->subfields() if $MARCfrom->field($auth_tag_to_report);
1041     
1042     # search all biblio tags using this authority.
1043     $sth = $dbh->prepare("select distinct tagfield from marc_subfield_structure where authtypecode=?");
1044     $sth->execute($authtypecodefrom);
1045     my @tags_using_authtype;
1046     while (my ($tagfield) = $sth->fetchrow) {
1047         push @tags_using_authtype,$tagfield."9" ;
1048     }
1049
1050     if (C4::Context->preference('NoZebra')) {
1051         warn "MERGE TO DO";
1052     } else {
1053         # now, find every biblio using this authority
1054         my $oConnection=C4::Context->Zconn("biblioserver");
1055         my $query;
1056         $query= "an= ".$mergefrom;
1057         my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection ));
1058         my $count=$oResult->size() if  ($oResult);
1059         my @reccache;
1060         my $z=0;
1061         while ( $z<$count ) {
1062         my $rec;
1063                 $rec=$oResult->record($z);
1064             my $marcdata = $rec->raw();
1065         push @reccache, $marcdata;
1066         $z++;
1067         }
1068         $oResult->destroy();
1069         foreach my $marc(@reccache){
1070             my $update;
1071             my $marcrecord;
1072             $marcrecord = MARC::File::USMARC::decode($marc);
1073             foreach my $tagfield (@tags_using_authtype){
1074             $tagfield=substr($tagfield,0,3);
1075             my @tags = $marcrecord->field($tagfield);
1076             foreach my $tag (@tags){
1077                 my $tagsubs=$tag->subfield("9");
1078             #warn "$tagfield:$tagsubs:$mergefrom";
1079                 if ($tagsubs== $mergefrom) {
1080                 $tag->update("9" =>$mergeto);
1081                 foreach my $subfield (@record_to) {
1082             #        warn "$subfield,$subfield->[0],$subfield->[1]";
1083                     $tag->update($subfield->[0] =>$subfield->[1]);
1084                 }#for $subfield
1085                 }
1086                 $marcrecord->delete_field($tag);
1087                 $marcrecord->add_fields($tag);
1088                 $update=1;
1089             }#for each tag
1090             }#foreach tagfield
1091             my $oldbiblio = TransformMarcToKoha($dbh,$marcrecord,"") ;
1092             if ($update==1){
1093             &ModBiblio($marcrecord,$oldbiblio->{'biblionumber'},GetFrameworkCode($oldbiblio->{'biblionumber'})) ;
1094             }
1095             
1096         }#foreach $marc
1097     }
1098   # now, find every other authority linked with this authority
1099 #   my $oConnection=C4::Context->Zconn("authorityserver");
1100 #   my $query;
1101 # # att 9210               Auth-Internal-authtype
1102 # # att 9220               Auth-Internal-LN
1103 # # ccl.properties to add for authorities
1104 #   $query= "= ".$mergefrom;
1105 #   my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection ));
1106 #   my $count=$oResult->size() if  ($oResult);
1107 #   my @reccache;
1108 #   my $z=0;
1109 #   while ( $z<$count ) {
1110 #   my $rec;
1111 #           $rec=$oResult->record($z);
1112 #       my $marcdata = $rec->raw();
1113 #   push @reccache, $marcdata;
1114 #   $z++;
1115 #   }
1116 #   $oResult->destroy();
1117 #   foreach my $marc(@reccache){
1118 #     my $update;
1119 #     my $marcrecord;
1120 #     $marcrecord = MARC::File::USMARC::decode($marc);
1121 #     foreach my $tagfield (@tags_using_authtype){
1122 #       $tagfield=substr($tagfield,0,3);
1123 #       my @tags = $marcrecord->field($tagfield);
1124 #       foreach my $tag (@tags){
1125 #         my $tagsubs=$tag->subfield("9");
1126 #     #warn "$tagfield:$tagsubs:$mergefrom";
1127 #         if ($tagsubs== $mergefrom) {
1128 #           $tag->update("9" =>$mergeto);
1129 #           foreach my $subfield (@record_to) {
1130 #     #        warn "$subfield,$subfield->[0],$subfield->[1]";
1131 #             $tag->update($subfield->[0] =>$subfield->[1]);
1132 #           }#for $subfield
1133 #         }
1134 #         $marcrecord->delete_field($tag);
1135 #         $marcrecord->add_fields($tag);
1136 #         $update=1;
1137 #       }#for each tag
1138 #     }#foreach tagfield
1139 #     my $authoritynumber = TransformMarcToKoha($dbh,$marcrecord,"") ;
1140 #     if ($update==1){
1141 #       &ModAuthority($marcrecord,$authoritynumber,GetAuthTypeCode($authoritynumber)) ;
1142 #     }
1143
1144 #   }#foreach $marc
1145 }#sub
1146 END { }       # module clean-up code here (global destructor)
1147
1148 =back
1149
1150 =head1 AUTHOR
1151
1152 Koha Developement team <info@koha.org>
1153
1154 Paul POULAIN paul.poulain@free.fr
1155
1156 =cut
1157
1158 # $Id$
1159 # $Log$
1160 # Revision 1.47  2007/06/06 13:08:35  tipaul
1161 # bugfixes (various), handling utf-8 without guessencoding (as suggested by joshua, fixing some zebra config files -for french but should be interesting for other languages-
1162 #
1163 # Revision 1.46  2007/05/10 14:45:15  tipaul
1164 # Koha NoZebra :
1165 # - support for authorities
1166 # - some bugfixes in ordering and "CCL" parsing
1167 # - support for authorities <=> biblios walking
1168 #
1169 # Seems I can do what I want now, so I consider its done, except for bugfixes that will be needed i m sure !
1170 #
1171 # Revision 1.45  2007/04/06 14:48:45  hdl
1172 # Code Cleaning : AuthoritiesMARC.
1173 #
1174 # Revision 1.44  2007/04/05 12:17:55  btoumi
1175 # add "sort by" with heading-entity in authorities search
1176 #
1177 # Revision 1.43  2007/03/30 11:59:16  tipaul
1178 # some cleaning (minor, the main one will come later) : removing some unused subs
1179 #
1180 # Revision 1.42  2007/03/29 16:45:53  tipaul
1181 # Code cleaning of Biblio.pm (continued)
1182 #
1183 # All subs have be cleaned :
1184 # - removed useless
1185 # - merged some
1186 # - reordering Biblio.pm completly
1187 # - using only naming conventions
1188 #
1189 # Seems to have broken nothing, but it still has to be heavily tested.
1190 # Note that Biblio.pm is now much more efficient than previously & probably more reliable as well.
1191 #
1192 # Revision 1.41  2007/03/29 13:30:31  tipaul
1193 # Code cleaning :
1194 # == Biblio.pm cleaning (useless) ==
1195 # * some sub declaration dropped
1196 # * removed modbiblio sub
1197 # * removed moditem sub
1198 # * removed newitems. It was used only in finishrecieve. Replaced by a TransformKohaToMarc+AddItem, that is better.
1199 # * removed MARCkoha2marcItem
1200 # * removed MARCdelsubfield declaration
1201 # * removed MARCkoha2marcBiblio
1202 #
1203 # == Biblio.pm cleaning (naming conventions) ==
1204 # * MARCgettagslib renamed to GetMarcStructure
1205 # * MARCgetitems renamed to GetMarcItem
1206 # * MARCfind_frameworkcode renamed to GetFrameworkCode
1207 # * MARCmarc2koha renamed to TransformMarcToKoha
1208 # * MARChtml2marc renamed to TransformHtmlToMarc
1209 # * MARChtml2xml renamed to TranformeHtmlToXml
1210 # * zebraop renamed to ModZebra
1211 #
1212 # == MARC=OFF ==
1213 # * removing MARC=OFF related scripts (in cataloguing directory)
1214 # * removed checkitems (function related to MARC=off feature, that is completly broken in head. If someone want to reintroduce it, hard work coming...)
1215 # * removed getitemsbybiblioitem (used only by MARC=OFF scripts, that is removed as well)
1216 #
1217 # Revision 1.40  2007/03/28 10:39:16  hdl
1218 # removing $dbh as a parameter in AuthoritiesMarc functions
1219 # And reporting all differences into the scripts taht relies on those functions.
1220 #
1221 # Revision 1.39  2007/03/16 01:25:08  kados
1222 # Using my precrash CVS copy I did the following:
1223 #
1224 # cvs -z3 -d:ext:kados@cvs.savannah.nongnu.org:/sources/koha co -P koha
1225 # find koha.precrash -type d -name "CVS" -exec rm -v {} \;
1226 # cp -r koha.precrash/* koha/
1227 # cd koha/
1228 # cvs commit
1229 #
1230 # This should in theory put us right back where we were before the crash
1231 #
1232 # Revision 1.39  2007/03/12 22:16:31  kados
1233 # chcking for field before calling subfields
1234 #
1235 # Revision 1.38  2007/03/09 14:31:47  tipaul
1236 # rel_3_0 moved to HEAD
1237 #
1238 # Revision 1.28.2.17  2007/02/05 13:16:08  hdl
1239 # Removing Link from AuthoritiesMARC summary (caused a problem owed to the API differences between opac and intranet)
1240 # + removing $dbh in SearchAuthorities
1241 # + adding links in templates on summaries to go to full view.
1242 # (no more links in popup authorities. or should we add it ?)
1243 #
1244 # Revision 1.28.2.16  2007/02/02 18:07:42  hdl
1245 # Sorting and searching for exact term now works.
1246 #
1247 # Revision 1.28.2.15  2007/01/24 10:17:47  hdl
1248 # FindDuplicate Now works.
1249 # Be AWARE that it needs a change ccl.properties.
1250 #
1251 # Revision 1.28.2.14  2007/01/10 14:40:11  hdl
1252 # Adding Authorities tree.
1253 #
1254 # Revision 1.28.2.13  2007/01/09 15:18:09  hdl
1255 # Adding an to ccl.properties to allow ccl search for authority-numbers.
1256 # Fixing Some problems with the previous modification to allow pqf search to work for more than one page.
1257 # Using search for an= for an authority-Number.
1258 #
1259 # Revision 1.28.2.12  2007/01/09 13:51:31  hdl
1260 # Bug Fixing : CountUsage used *synchronous* connection where biblio used ****asynchronous**** one.
1261 # First try to get it work.
1262 #
1263 # Revision 1.28.2.11  2007/01/05 14:37:26  btoumi
1264 # bug fix : remove wrong field in sql syntaxe from auth_subfield_structure table
1265 #
1266 # Revision 1.28.2.10  2007/01/04 13:11:08  tipaul
1267 # commenting 2 zconn destroy
1268 #
1269 # Revision 1.28.2.9  2006/12/22 15:09:53  toins
1270 # removing C4::Database;
1271 #
1272 # Revision 1.28.2.8  2006/12/20 17:13:19  hdl
1273 # modifying use of GILS into use of @attr 1=Koha-Auth-Number
1274 #
1275 # Revision 1.28.2.7  2006/12/18 16:45:38  tipaul
1276 # FIXME upcased
1277 #
1278 # Revision 1.28.2.6  2006/12/07 16:45:43  toins
1279 # removing warn compilation. (perl -wc)
1280 #
1281 # Revision 1.28.2.5  2006/12/06 14:19:59  hdl
1282 # ABugFixing : Authority count  Management.
1283 #
1284 # Revision 1.28.2.4  2006/11/17 13:18:58  tipaul
1285 # code cleaning : removing use of "bib", and replacing with "biblionumber"
1286 #
1287 # WARNING : I tried to do carefully, but there are probably some mistakes.
1288 # So if you encounter a problem you didn't have before, look for this change !!!
1289 # anyway, I urge everybody to use only "biblionumber", instead of "bib", "bi", "biblio" or anything else. will be easier to maintain !!!
1290 #
1291 # Revision 1.28.2.3  2006/11/17 11:17:30  tipaul
1292 # code cleaning : removing use of "bib", and replacing with "biblionumber"
1293 #
1294 # WARNING : I tried to do carefully, but there are probably some mistakes.
1295 # So if you encounter a problem you didn't have before, look for this change !!!
1296 # anyway, I urge everybody to use only "biblionumber", instead of "bib", "bi", "biblio" or anything else. will be easier to maintain !!!
1297 #
1298 # Revision 1.28.2.2  2006/10/12 22:04:47  hdl
1299 # Authorities working with zebra.
1300 # zebra Configuration files are comitted next.