[Koha-cvs] koha authorities/authorities-home.pl authoritie...

Henri-Damien LAURENT laurenthdl at alinto.com
Wed Mar 28 12:39:16 CEST 2007


CVSROOT:	/cvsroot/koha
Module name:	koha
Changes by:	Henri-Damien LAURENT <hdl>	07/03/28 10:39:16

Modified files:
	authorities    : authorities-home.pl authorities.pl 
	                 blinddetail-biblio-search.pl detail.pl 
	C4             : AuthoritiesMarc.pm Biblio.pm 
	misc           : marc_into_authority.pl merge_authority.pl 
	opac           : opac-authoritiesdetail.pl 
	                 opac-authorities-home.pl 

Log message:
	removing $dbh as a parameter in AuthoritiesMarc functions
	And reporting all differences into the scripts taht relies on those functions.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/authorities/authorities-home.pl?cvsroot=koha&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/koha/authorities/authorities.pl?cvsroot=koha&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/koha/authorities/blinddetail-biblio-search.pl?cvsroot=koha&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/koha/authorities/detail.pl?cvsroot=koha&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/koha/C4/AuthoritiesMarc.pm?cvsroot=koha&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Biblio.pm?cvsroot=koha&r1=1.188&r2=1.189
http://cvs.savannah.gnu.org/viewcvs/koha/misc/marc_into_authority.pl?cvsroot=koha&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/koha/misc/merge_authority.pl?cvsroot=koha&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-authoritiesdetail.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-authorities-home.pl?cvsroot=koha&r1=1.3&r2=1.4

Patches:
Index: authorities/authorities-home.pl
===================================================================
RCS file: /cvsroot/koha/koha/authorities/authorities-home.pl,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- authorities/authorities-home.pl	9 Mar 2007 14:31:17 -0000	1.16
+++ authorities/authorities-home.pl	28 Mar 2007 10:39:16 -0000	1.17
@@ -146,7 +146,7 @@
 
 } elsif ($op eq "delete") {
 
-	&AUTHdelauthority($dbh,$authid, 1);
+	&AUTHdelauthority($authid, 1);
 
 	($template, $loggedinuser, $cookie)
 		= get_template_and_user({template_name => "authorities/authorities-home.tmpl",

Index: authorities/authorities.pl
===================================================================
RCS file: /cvsroot/koha/koha/authorities/authorities.pl,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- authorities/authorities.pl	9 Mar 2007 14:31:17 -0000	1.19
+++ authorities/authorities.pl	28 Mar 2007 10:39:16 -0000	1.20
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: authorities.pl,v 1.19 2007/03/09 14:31:17 tipaul Exp $
+# $Id: authorities.pl,v 1.20 2007/03/28 10:39:16 hdl Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -349,7 +349,7 @@
 my $authtypecode = $input->param('authtypecode');
 
 my $dbh = C4::Context->dbh;
-$authtypecode = &AUTHfind_authtypecode($dbh,$authid) if !$authtypecode;
+$authtypecode = &AUTHfind_authtypecode($authid) if !$authtypecode;
 
 
 my ($template, $loggedinuser, $cookie)
@@ -361,17 +361,17 @@
 			     debug => 1,
 			     });
 $template->param(nonav   => $nonav,index=>$myindex,authtypecode=>$authtypecode,);
-$tagslib = AUTHgettagslib($dbh,1,$authtypecode);
+$tagslib = AUTHgettagslib(1,$authtypecode);
 my $record=-1;
 my $encoding="";
-$record = AUTHgetauthority($dbh,$authid) if ($authid);
+$record = AUTHgetauthority($authid) if ($authid);
 my ($oldauthnumtagfield,$oldauthnumtagsubfield);
 my ($oldauthtypetagfield,$oldauthtypetagsubfield);
 $is_a_modif=0;
 if ($authid) {
 	$is_a_modif=1;
-	($oldauthnumtagfield,$oldauthnumtagsubfield) = &AUTHfind_marc_from_kohafield($dbh,"auth_header.authid",$authtypecode);
-	($oldauthtypetagfield,$oldauthtypetagsubfield) = &AUTHfind_marc_from_kohafield($dbh,"auth_header.authtypecode",$authtypecode);
+	($oldauthnumtagfield,$oldauthnumtagsubfield) = &AUTHfind_marc_from_kohafield("auth_header.authid",$authtypecode);
+	($oldauthtypetagfield,$oldauthtypetagsubfield) = &AUTHfind_marc_from_kohafield("auth_header.authtypecode",$authtypecode);
 }
 
 #------------------------------------------------------------------------------------------------------------------------------
@@ -399,9 +399,9 @@
 	if (!$duplicateauthid or $confirm_not_duplicate) {
 # warn "noduplicate";
 		if ($is_a_modif ) {	
-			$authid=AUTHmodauthority($dbh,$authid,$record,$authtypecode,1);		
+			$authid=AUTHmodauthority($authid,$record,$authtypecode,1);		
 		} else {
-		($authid) = AUTHaddauthority($dbh,$record,$authid,$authtypecode);
+		($authid) = AUTHaddauthority($record,$authid,$authtypecode);
 
 		}
 	# now, redirect to detail page
@@ -445,7 +445,7 @@
 
 } elsif ($op eq "delete") {
 #------------------------------------------------------------------------------------------------------------------------------
-	&AUTHdelauthority($dbh,$authid);
+	&AUTHdelauthority($authid);
 	if ($nonav){
 	print $input->redirect("auth_finder.pl");
 	}else{

Index: authorities/blinddetail-biblio-search.pl
===================================================================
RCS file: /cvsroot/koha/koha/authorities/blinddetail-biblio-search.pl,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- authorities/blinddetail-biblio-search.pl	9 Mar 2007 14:31:17 -0000	1.9
+++ authorities/blinddetail-biblio-search.pl	28 Mar 2007 10:39:16 -0000	1.10
@@ -57,13 +57,13 @@
 my $authid = $query->param('authid');
 my $index = $query->param('index');
 my $tagid = $query->param('tagid');
-my $authtypecode = &AUTHfind_authtypecode($dbh,$authid);
-my $tagslib = &AUTHgettagslib($dbh,1,$authtypecode);
+my $authtypecode = &AUTHfind_authtypecode($authid);
+my $tagslib = &AUTHgettagslib(1,$authtypecode);
 
 my $auth_type = AUTHgetauth_type($authtypecode);
  warn "XX = ".$auth_type->{auth_tag_to_report};
 
-my $record =AUTHgetauthority($dbh,$authid);
+my $record =AUTHgetauthority($authid);
   warn "record auth :".$record->as_formatted;
 # open template
 my ($template, $loggedinuser, $cookie)

Index: authorities/detail.pl
===================================================================
RCS file: /cvsroot/koha/koha/authorities/detail.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- authorities/detail.pl	9 Mar 2007 14:31:17 -0000	1.6
+++ authorities/detail.pl	28 Mar 2007 10:39:16 -0000	1.7
@@ -70,8 +70,8 @@
 
 
 
-my $authtypecode = &AUTHfind_authtypecode($dbh,$authid);
-my $tagslib = &AUTHgettagslib($dbh,1,$authtypecode);
+my $authtypecode = &AUTHfind_authtypecode($authid);
+my $tagslib = &AUTHgettagslib(1,$authtypecode);
 
 my $record;
 if (C4::Context->preference("AuthDisplayHierarchy")){
@@ -86,7 +86,7 @@
     my @loophierarchy;
     foreach my $element (@tree){
       my %cell;
-      my $elementdata = AUTHgetauthority($dbh,$element);
+      my $elementdata = AUTHgetauthority($element);
       $record= $elementdata if ($authid==$element);
       push @loophierarchy, BuildUnimarcHierarchy($elementdata,"child".$cnt, $authid);
       $cnt++;
@@ -98,7 +98,7 @@
     'loophierarchies' =>\@loophierarchies,
   );
 } else {
-  $record=AUTHgetauthority($dbh,$authid);
+  $record=AUTHgetauthority($authid);
 }
 my $count = AUTHcount_usage($authid);
 

Index: C4/AuthoritiesMarc.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/AuthoritiesMarc.pm,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- C4/AuthoritiesMarc.pm	16 Mar 2007 01:25:08 -0000	1.39
+++ C4/AuthoritiesMarc.pm	28 Mar 2007 10:39:16 -0000	1.40
@@ -55,10 +55,11 @@
  );
 
 sub AUTHfind_marc_from_kohafield {
-    my ( $dbh, $kohafield,$authtypecode ) = @_;
+  my ( $kohafield,$authtypecode ) = @_;
+  my $dbh=C4::Context->dbh;
     return 0, 0 unless $kohafield;
-$authtypecode="" unless $authtypecode;
-my $marcfromkohafield;
+  $authtypecode="" unless $authtypecode;
+  my $marcfromkohafield;
     my $sth = $dbh->prepare("select tagfield,tagsubfield from auth_subfield_structure where kohafield= ? and authtypecode=? ");
     $sth->execute($kohafield,$authtypecode);
     my ($tagfield,$tagsubfield) = $sth->fetchrow;
@@ -116,49 +117,47 @@
       $dosearch=1;
       }#if value
     }
-##Add how many queries generated
-$query= $and.$query.$q2;
-$query=' @or  @attr 7=1 @attr 1=Heading 0 '.$query if ($sortby eq "HeadingAsc");
-$query=' @or  @attr 7=2 @attr 1=Heading 0 '.$query if ($sortby eq "HeadingDsc");
-warn $query;
-
-$offset=0 unless $offset;
-my $counter = $offset;
-$length=10 unless $length;
-my @oAuth;
-my $i;
-$oAuth[0]=C4::Context->Zconn("authorityserver" , 1);
-my $Anewq= new ZOOM::Query::PQF($query,$oAuth[0]);
-# $Anewq->sortby("1=Heading i< 1=Heading-Entity i< ");
-# $Anewq->sortby("1=Heading i< 1=Heading-Entity i< ");
-my $oAResult;
+  ##Add how many queries generated
+  $query= $and.$query.$q2;
+  $query=' @or  @attr 7=1 @attr 1=Heading 0 '.$query if ($sortby eq "HeadingAsc");
+  $query=' @or  @attr 7=2 @attr 1=Heading 0 '.$query if ($sortby eq "HeadingDsc");
+  warn $query;
+  
+  $offset=0 unless $offset;
+  my $counter = $offset;
+  $length=10 unless $length;
+  my @oAuth;
+  my $i;
+  $oAuth[0]=C4::Context->Zconn("authorityserver" , 1);
+  my $Anewq= new ZOOM::Query::PQF($query,$oAuth[0]);
+  # $Anewq->sortby("1=Heading i< 1=Heading-Entity i< ");
+  # $Anewq->sortby("1=Heading i< 1=Heading-Entity i< ");
+  my $oAResult;
  $oAResult= $oAuth[0]->search($Anewq) ; 
-while (($i = ZOOM::event(\@oAuth)) != 0) {
+  while (($i = ZOOM::event(\@oAuth)) != 0) {
     my $ev = $oAuth[$i-1]->last_event();
-#    warn("Authority ", $i-1, ": event $ev (", ZOOM::event_str($ev), ")\n");
+  #    warn("Authority ", $i-1, ": event $ev (", ZOOM::event_str($ev), ")\n");
     last if $ev == ZOOM::Event::ZEND;
-}
+  }
  my($error, $errmsg, $addinfo, $diagset) = $oAuth[0]->error_x();
     if ($error) {
     warn  "oAuth error: $errmsg ($error) $addinfo $diagset\n";
     goto NOLUCK;
     }
 
-
-my $nbresults;
+  my $nbresults;
  $nbresults=$oAResult->size();
-my $nremains=$nbresults;    
+  my $nremains=$nbresults;    
     my @result = ();
     my @finalresult = ();
 
+  if ($nbresults>0){
 
-if ($nbresults>0){
-
-##Find authid and linkid fields
-##we may be searching multiple authoritytypes.
-## FIXME this assumes that all authid and linkid fields are the same for all authority types
-# my ($authidfield,$authidsubfield)=AUTHfind_marc_from_kohafield($dbh,"auth_header.authid",$authtypecode[0]);
-# my ($linkidfield,$linkidsubfield)=AUTHfind_marc_from_kohafield($dbh,"auth_header.linkid",$authtypecode[0]);
+  ##Find authid and linkid fields
+  ##we may be searching multiple authoritytypes.
+  ## FIXME this assumes that all authid and linkid fields are the same for all authority types
+  # my ($authidfield,$authidsubfield)=AUTHfind_marc_from_kohafield($dbh,"auth_header.authid",$authtypecode[0]);
+  # my ($linkidfield,$linkidsubfield)=AUTHfind_marc_from_kohafield($dbh,"auth_header.linkid",$authtypecode[0]);
   while (($counter < $nbresults) && ($counter < ($offset + $length))) {
   
     ##Here we have to extract MARC record and $authid from ZEBRA AUTHORITIES
@@ -187,8 +186,8 @@
     #     }#
     
         my $summary=getsummary($authrecord,$authid,$authtypecode);
-#         $summary="<a href='detail.pl?authid=$authid'>".$summary.".</a>" if ($intranet);
-#         $summary="<a href='detail.pl?authid=$authid'>".$summary.".</a>" if ($intranet);
+  #         $summary="<a href='detail.pl?authid=$authid'>".$summary.".</a>" if ($intranet);
+  #         $summary="<a href='detail.pl?authid=$authid'>".$summary.".</a>" if ($intranet);
     #     if ($linkid && $linksummary ne " ".$separator){
     #         $summary="<b>".$summary."</b>".$linksummary;
     #     }
@@ -207,15 +206,13 @@
         $counter++;
         push @finalresult, \%newline;
   }## while counter
-
-
   ###
    for (my $z=0; $z<@finalresult; $z++){
         my  $count=AUTHcount_usage($finalresult[$z]{authid});
         $finalresult[$z]{used}=$count;
    }# all $z's
 
-}## if nbresult
+  }## if nbresult
 NOLUCK:
 # $oAResult->destroy();
 # $oAuth[0]->destroy();
@@ -226,7 +223,8 @@
 # Creates the SQL Request
 
 sub create_request {
-    my ($dbh,$tags, $and_or, $operator, $value) = @_;
+    my ($tags, $and_or, $operator, $value) = @_;
+    my $dbh=C4::Context->dbh;
 
     my $sql_tables; # will contain marc_subfield_table as m1,...
     my $sql_where1; # will contain the "true" where
@@ -234,12 +232,10 @@
     my $nb_active=0; # will contain the number of "active" entries. and entry is active is a value is provided.
     my $nb_table=1; # will contain the number of table. ++ on each entry EXCEPT when an OR  is provided.
 
-
     for(my $i=0; $i<=@$value;$i++) {
         if (@$value[$i]) {
             $nb_active++;
             if ($nb_active==1) {
-    
                     $sql_tables = "auth_subfield_table as m$nb_table,";
                     $sql_where1 .= "( m$nb_table.subfieldvalue like '@$value[$i]' ";
                     if (@$tags[$i]) {
@@ -247,12 +243,7 @@
                             }
                     $sql_where1.=")";
                     } else {
-    
-    
-    
-    
                     $nb_table++;
-    
                     $sql_tables .= "auth_subfield_table as m$nb_table,";
                     $sql_where1 .= "@$and_or[$i] (m$nb_table.subfieldvalue   like '@$value[$i]' ";
                     if (@$tags[$i]) {
@@ -260,8 +251,6 @@
                             }
                     $sql_where1.=")";
                     $sql_where2.="m1.authid=m$nb_table.authid and ";
-    
-    
                     }
                 }
         }
@@ -283,26 +272,27 @@
 
 sub AUTHcount_usage {
     my ($authid) = @_;
-### try ZOOM search here
-my $oConnection=C4::Context->Zconn("biblioserver",1);
-my $query;
-$query= "an=".$authid;
+  ### try ZOOM search here
+  my $oConnection=C4::Context->Zconn("biblioserver",1);
+  my $query;
+  $query= "an=".$authid;
 
-my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection ));
-my $result;
-while ((my $i = ZOOM::event([ $oConnection ])) != 0) {
+  my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection ));
+  my $result;
+  while ((my $i = ZOOM::event([ $oConnection ])) != 0) {
     my $ev = $oConnection->last_event();
     if ($ev == ZOOM::Event::ZEND) {
         $result = $oResult->size();
     }
-}
-return ($result);
+  }
+  return ($result);
 }
 
 
 
 sub AUTHfind_authtypecode {
-    my ($dbh,$authid) = @_;
+  my ($authid) = @_;
+  my $dbh=C4::Context->dbh;
     my $sth = $dbh->prepare("select authtypecode from auth_header where authid=?");
     $sth->execute($authid);
     my ($authtypecode) = $sth->fetchrow;
@@ -311,7 +301,8 @@
  
 
 sub AUTHgettagslib {
-    my ($dbh,$forlibrarian,$authtypecode)= @_;
+  my ($forlibrarian,$authtypecode)= @_;
+  my $dbh=C4::Context->dbh;
     $authtypecode="" unless $authtypecode;
     my $sth;
     my $libfield = ($forlibrarian eq 1)? 'liblibrarian' : 'libopac';
@@ -323,10 +314,13 @@
     my ($total) = $sth->fetchrow;
     $authtypecode="" unless ($total >0);
     $sth= $dbh->prepare(
-"select tagfield,liblibrarian,libopac,mandatory,repeatable from auth_tag_structure where authtypecode=? order by tagfield"
+"SELECT tagfield,liblibrarian,libopac,mandatory,repeatable 
+ FROM auth_tag_structure 
+ WHERE authtypecode=? 
+ ORDER BY tagfield"
     );
 
-$sth->execute($authtypecode);
+  $sth->execute($authtypecode);
      my ( $liblibrarian, $libopac, $tag, $res, $tab, $mandatory, $repeatable );
 
     while ( ( $tag, $liblibrarian, $libopac, $mandatory, $repeatable ) = $sth->fetchrow ) {
@@ -335,7 +329,11 @@
         $res->{$tag}->{mandatory}  = $mandatory;
         $res->{$tag}->{repeatable} = $repeatable;
     }
-    $sth=      $dbh->prepare("select tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl from auth_subfield_structure where authtypecode=? order by tagfield,tagsubfield"
+  $sth=      $dbh->prepare(
+"SELECT tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl 
+FROM auth_subfield_structure 
+WHERE authtypecode=? 
+ORDER BY tagfield,tagsubfield"
     );
     $sth->execute($authtypecode);
 
@@ -374,10 +372,10 @@
 
 sub AUTHaddauthority {
 # pass the MARC::Record to this function, and it will create the records in the authority table
-    my ($dbh,$record,$authid,$authtypecode) = @_;
-
+  my ($record,$authid,$authtypecode) = @_;
+  my $dbh=C4::Context->dbh;
 #my $leadercode=AUTHfind_leader($dbh,$authtypecode);
-my $leader='         a              ';##Fixme correct leader as this one just adds utf8 to MARC21
+  my $leader='         a              ';##Fixme correct leader as this one just adds utf8 to MARC21
 #substr($leader,8,1)=$leadercode;
 #    $record->leader($leader);
 # my ($authfield,$authidsubfield)=AUTHfind_marc_from_kohafield($dbh,"auth_header.authid",$authtypecode);
@@ -394,7 +392,7 @@
   ##Both authid and authtypecode is expected to be in the same field. Modify if other requirements arise
           $record->add_fields('001',$authid) unless $record->field('001');
           $record->add_fields('152','','','b'=>$authtypecode) unless $record->field('152');
-#           $record->add_fields('100','','','b'=>$authtypecode);
+    #           $record->add_fields('100','','','b'=>$authtypecode);
           warn $record->as_formatted;
           $dbh->do("lock tables auth_header WRITE");
           $sth=$dbh->prepare("insert into auth_header (authid,datecreated,authtypecode,marc) values (?,now(),?,?)");
@@ -416,7 +414,7 @@
       $sth->finish;
     }
     $dbh->do("unlock tables");
-    zebraop($dbh,$authid,'specialUpdate',"authorityserver");
+    zebraop($authid,'specialUpdate',"authorityserver");
 
 # if ($record->field($linkidfield)){
 # my @fields=$record->field($linkidfield);
@@ -433,26 +431,28 @@
 }
 
 sub AUTHaddlink{
-my ($dbh,$linkid,$authid)=@_;
-my $record=AUTHgetauthority($dbh,$linkid);
-my $authtypecode=AUTHfind_authtypecode($dbh,$linkid);
+  my ($linkid,$authid)=@_;
+  my $dbh=C4::Context->dbh;
+  my $record=AUTHgetauthority($linkid);
+  my $authtypecode=AUTHfind_authtypecode($linkid);
 #warn "adding l:$linkid,a:$authid,auth:$authtypecode";
-$record=AUTH2marcOnefieldlink($dbh,$record,"auth_header.linkid",$authid,$authtypecode);
-$dbh->do("lock tables auth_header WRITE");
+  $record=AUTH2marcOnefieldlink($record,"auth_header.linkid",$authid,$authtypecode);
+  $dbh->do("lock tables auth_header WRITE");
     my $sth=$dbh->prepare("update auth_header set marc=? where authid=?");
     $sth->execute($record->as_usmarc,$linkid);
     $sth->finish;
     $dbh->do("unlock tables");
-    zebraop($dbh,$linkid,'specialUpdate',"authorityserver");
+  zebraop($linkid,'specialUpdate',"authorityserver");
 }
 
 sub AUTH2marcOnefieldlink {
-    my ( $dbh, $record, $kohafieldname, $newvalue,$authtypecode ) = @_;
-my $sth =      $dbh->prepare(
+  my ( $record, $kohafieldname, $newvalue,$authtypecode ) = @_;
+  my $dbh=C4::Context->dbh;
+  my $sth =      $dbh->prepare(
 "select tagfield,tagsubfield from auth_subfield_structure where authtypecode=? and kohafield=?"
     );
     $sth->execute($authtypecode,$kohafieldname);
-my  ($tagfield,$tagsubfield)=$sth->fetchrow;
+  my  ($tagfield,$tagsubfield)=$sth->fetchrow;
             $record->add_fields( $tagfield, " ", " ", $tagsubfield => $newvalue );
     return $record;
 }
@@ -460,15 +460,13 @@
 sub XMLgetauthority {
 
     # Returns MARC::XML of the authority passed in parameter.
-    my ( $dbh, $authid ) = @_;
-  
-
+  my ( $authid ) = @_;
+  my $dbh=C4::Context->dbh;
     my $sth =
       $dbh->prepare("select marc from auth_header where authid=? "  );
-    
     $sth->execute($authid);
    my ($marc)=$sth->fetchrow;
-$marc=MARC::File::USMARC::decode($marc);
+  $marc=MARC::File::USMARC::decode($marc);
  my $marcxml=$marc->as_xml_record();
  return $marcxml;
 
@@ -477,7 +475,7 @@
 
 sub AUTHfind_leader{
 ##Hard coded for NEU auth types 
-my($dbh,$authtypecode)=@_;
+my($authtypecode)=@_;
 
 my $leadercode;
 if ($authtypecode eq "AUTH"){
@@ -494,11 +492,12 @@
 
 sub AUTHgetauthority {
 # Returns MARC::Record of the biblio passed in parameter.
-    my ($dbh,$authid)=@_;
-my    $sth=$dbh->prepare("select marc from auth_header where authid=?");
+  my ($authid)=@_;
+  my $dbh=C4::Context->dbh;
+  my $sth=$dbh->prepare("select marc from auth_header where authid=?");
         $sth->execute($authid);
     my ($marc) = $sth->fetchrow;
-my $record=MARC::File::USMARC::decode($marc);
+  my $record=MARC::File::USMARC::decode($marc);
 
     return ($record);
 }
@@ -512,14 +511,15 @@
 }
 sub AUTHmodauthority {
 
-    my ($dbh,$authid,$record,$authtypecode,$merge)=@_;
-    my ($oldrecord)=&AUTHgetauthority($dbh,$authid);
+    my ($authid,$record,$authtypecode,$merge)=@_;
+    my $dbh=C4::Context->dbh;
+    my ($oldrecord)=&AUTHgetauthority($authid);
     if ($oldrecord eq $record) {
         return;
     }
 my $sth=$dbh->prepare("update auth_header set marc=? where authid=?");
 #warn find if linked records exist and delete them
-my($linkidfield,$linkidsubfield)=AUTHfind_marc_from_kohafield($dbh,"auth_header.linkid",$authtypecode);
+my($linkidfield,$linkidsubfield)=AUTHfind_marc_from_kohafield("auth_header.linkid",$authtypecode);
 
 if ($oldrecord->field($linkidfield)){
 my @fields=$oldrecord->field($linkidfield);
@@ -527,22 +527,22 @@
 my    $linkid=$field->subfield($linkidsubfield) ;
     if ($linkid){
         ##Modify the record of linked
-        my $linkrecord=AUTHgetauthority($dbh,$linkid);
-        my $linktypecode=AUTHfind_authtypecode($dbh,$linkid);
-        my ( $linkidfield2,$linkidsubfield2)=AUTHfind_marc_from_kohafield($dbh,"auth_header.linkid",$linktypecode);
+        my $linkrecord=AUTHgetauthority($linkid);
+        my $linktypecode=AUTHfind_authtypecode($linkid);
+        my ( $linkidfield2,$linkidsubfield2)=AUTHfind_marc_from_kohafield("auth_header.linkid",$linktypecode);
         my @linkfields=$linkrecord->field($linkidfield2);
             foreach my $linkfield (@linkfields){
             if ($linkfield->subfield($linkidsubfield2) eq $authid){
                 $linkrecord->delete_field($linkfield);
                 $sth->execute($linkrecord->as_usmarc,$linkid);
-                zebraop($dbh,$linkid,'specialUpdate',"authorityserver");
+                zebraop($linkid,'specialUpdate',"authorityserver");
             }
             }#foreach linkfield
     }
     }#foreach linkid
 }
 #Now rewrite the $record to table with an add
-$authid=AUTHaddauthority($dbh,$record,$authid,$authtypecode);
+$authid=AUTHaddauthority($record,$authid,$authtypecode);
 
 
 ### 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
@@ -561,23 +561,25 @@
     print AUTH $authid;
     close AUTH;
 } else {
-    &merge($dbh,$authid,$record,$authid,$record);
+    &merge($authid,$record,$authid,$record);
 }
 return $authid;
 }
 
 sub AUTHdelauthority {
-    my ($dbh,$authid,$keep_biblio) = @_;
+    my ($authid,$keep_biblio) = @_;
+    my $dbh=C4::Context->dbh;
 # if the keep_biblio is set to 1, then authority entries in biblio are preserved.
 
-zebraop($dbh,$authid,"recordDelete","authorityserver");
+zebraop($authid,"recordDelete","authorityserver");
     $dbh->do("delete from auth_header where authid=$authid") ;
 
 # FIXME : delete or not in biblio tables (depending on $keep_biblio flag)
 }
 
 sub AUTHhtml2marc {
-    my ($dbh,$rtags,$rsubfields,$rvalues,%indicators) = @_;
+    my ($rtags,$rsubfields,$rvalues,%indicators) = @_;
+    my $dbh=C4::Context->dbh;
     my $prevtag = -1;
     my $record = MARC::Record->new();
 #---- TODO : the leader is missing
@@ -773,18 +775,18 @@
   my @globalresult;
   my $dbh=C4::Context->dbh;
   my $hierarchies;
-  my $data = AUTHgetheader($dbh,$authid);
+  my $data = AUTHgetheader($authid);
   
   if ($data->{'authtrees'} and not $force){
     return $data->{'authtrees'};
   } elsif ($data->{'authtrees'}){
     $hierarchies=$data->{'authtrees'};
   } else {
-    my $record = AUTHgetauthority($dbh,$authid);
+    my $record = AUTHgetauthority($authid);
     my $found;
     foreach my $field ($record->field('550')){
       if ($field->subfield('5') && $field->subfield('5') eq 'g'){
-        my $parentrecord = AUTHgetauthority($dbh,$field->subfield('3'));
+        my $parentrecord = AUTHgetauthority($field->subfield('3'));
         my $localresult=$hierarchies;
         my $trees;
         $trees = BuildUnimarcHierarchies($field->subfield('3'));
@@ -859,9 +861,10 @@
 
 
 sub merge {
-    my ($dbh,$mergefrom,$MARCfrom,$mergeto,$MARCto) = @_;
-    my $authtypecodefrom = AUTHfind_authtypecode($dbh,$mergefrom);
-    my $authtypecodeto = AUTHfind_authtypecode($dbh,$mergeto);
+    my ($mergefrom,$MARCfrom,$mergeto,$MARCto) = @_;
+    my $dbh=C4::Context->dbh;
+    my $authtypecodefrom = AUTHfind_authtypecode($mergefrom);
+    my $authtypecodeto = AUTHfind_authtypecode($mergeto);
     # return if authority does not exist
     my @X = $MARCfrom->fields();
     return if $#X == -1;
@@ -948,8 +951,12 @@
 
 =cut
 
-# $Id: AuthoritiesMarc.pm,v 1.39 2007/03/16 01:25:08 kados Exp $
+# $Id: AuthoritiesMarc.pm,v 1.40 2007/03/28 10:39:16 hdl Exp $
 # $Log: AuthoritiesMarc.pm,v $
+# Revision 1.40  2007/03/28 10:39:16  hdl
+# removing $dbh as a parameter in AuthoritiesMarc functions
+# And reporting all differences into the scripts taht relies on those functions.
+#
 # Revision 1.39  2007/03/16 01:25:08  kados
 # Using my precrash CVS copy I did the following:
 #

Index: C4/Biblio.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Biblio.pm,v
retrieving revision 1.188
retrieving revision 1.189
diff -u -b -r1.188 -r1.189
--- C4/Biblio.pm	9 Mar 2007 14:31:47 -0000	1.188
+++ C4/Biblio.pm	28 Mar 2007 10:39:16 -0000	1.189
@@ -33,7 +33,7 @@
 use vars qw($VERSION @ISA @EXPORT);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.188 $' =~ /\d+/g; shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.189 $' =~ /\d+/g; shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); };
 
 @ISA = qw( Exporter );
 
@@ -121,6 +121,8 @@
   &checkitems
 );
 
+use MARC::Charset;
+MARC::Charset->ignore_errors(1);
 =head1 NAME
 
 C4::Biblio - acquisitions and cataloging management functions
@@ -492,7 +494,7 @@
     return $error if $error;
 
     # Delete in Zebra
-    zebraop($dbh,$biblionumber,"delete_record","biblioserver");
+    zebraop($biblionumber,"delete_record","biblioserver");
 
     # delete biblio from Koha tables and save in deletedbiblio
     $error = &_koha_delete_biblio( $dbh, $biblionumber );
@@ -1385,7 +1387,7 @@
         $biblionumber );
 #     warn $record->as_xml_record();
     $sth->finish;
-    zebraop($dbh,$biblionumber,"specialUpdate","biblioserver");
+    zebraop($biblionumber,"specialUpdate","biblioserver");
     return $biblionumber;
 }
 
@@ -3501,8 +3503,8 @@
 
 sub zebraop {
 ###Accepts a $server variable thus we can use it for biblios authorities or other zebra dbs
-    my ( $dbh, $biblionumber, $op, $server ) = @_;
-
+    my ( $biblionumber, $op, $server ) = @_;
+    my $dbh=C4::Context->dbh;
     #warn "SERVER:".$server;
 #
 # true zebraop commented until indexdata fixes zebraDB crashes (it seems they occur on multiple updates
@@ -3693,8 +3695,12 @@
 
 =cut
 
-# $Id: Biblio.pm,v 1.188 2007/03/09 14:31:47 tipaul Exp $
+# $Id: Biblio.pm,v 1.189 2007/03/28 10:39:16 hdl Exp $
 # $Log: Biblio.pm,v $
+# Revision 1.189  2007/03/28 10:39:16  hdl
+# removing $dbh as a parameter in AuthoritiesMarc functions
+# And reporting all differences into the scripts taht relies on those functions.
+#
 # Revision 1.188  2007/03/09 14:31:47  tipaul
 # rel_3_0 moved to HEAD
 #

Index: misc/marc_into_authority.pl
===================================================================
RCS file: /cvsroot/koha/koha/misc/marc_into_authority.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- misc/marc_into_authority.pl	20 May 2006 00:13:31 -0000	1.5
+++ misc/marc_into_authority.pl	28 Mar 2007 10:39:16 -0000	1.6
@@ -68,8 +68,8 @@
 while (my ($authid,$authtypecode)=$sth->fetchrow ){
  my $record = AUTHgetauthorityold($dbh,$authid);
 ##Add authid and authtypecode to record. Old records did not have these fields
-my ($authidfield,$authidsubfield)=AUTHfind_marc_from_kohafield($dbh,"auth_header.authid",$authtypecode);
-my ($authidfield,$authtypesubfield)=AUTHfind_marc_from_kohafield($dbh,"auth_header.authtypecode",$authtypecode);
+my ($authidfield,$authidsubfield)=AUTHfind_marc_from_kohafield("auth_header.authid",$authtypecode);
+my ($authidfield,$authtypesubfield)=AUTHfind_marc_from_kohafield("auth_header.authtypecode",$authtypecode);
 ##Both authid and authtypecode is expected to be in the same field. Modify if other requirements arise
 	$record->add_fields($authidfield,'','',$authidsubfield=>$authid,$authtypesubfield=>$authtypecode);
 $sth2->execute($record->as_usmarc,$authid);

Index: misc/merge_authority.pl
===================================================================
RCS file: /cvsroot/koha/koha/misc/merge_authority.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- misc/merge_authority.pl	9 Mar 2007 14:58:36 -0000	1.4
+++ misc/merge_authority.pl	28 Mar 2007 10:39:16 -0000	1.5
@@ -46,11 +46,11 @@
 # my @subf = $subfields =~ /(##\d\d\d##.)/g;
 
 $|=1; # flushes output
-my $authfrom = AUTHgetauthority($dbh,$mergefrom);
-my $authto = AUTHgetauthority($dbh,$mergeto);
+my $authfrom = AUTHgetauthority($mergefrom);
+my $authto = AUTHgetauthority($mergeto);
 
-my $authtypecodefrom = AUTHfind_authtypecode($dbh,$mergefrom);
-my $authtypecodeto = AUTHfind_authtypecode($dbh,$mergeto);
+my $authtypecodefrom = AUTHfind_authtypecode($mergefrom);
+my $authtypecodeto = AUTHfind_authtypecode($mergeto);
 
 unless ($noconfirm) {
     print "************\n";
@@ -99,13 +99,13 @@
     # delete all subfields that are in the same tag/tagorder and that are in the authority (& that are not in tab ignore in the biblio)
     # then recreate them with the new authority.
     foreach my $subfield (@record_from) {
-        &MARCdelsubfield($dbh,$bibid,$tag,$tagorder,$subfield->[0]);
+        &MARCdelsubfield($bibid,$tag,$tagorder,$subfield->[0]);
     }
     &MARCdelsubfield($dbh,$bibid,$tag,$tagorder,'9');
     foreach my $subfield (@record_to) {
-        &MARCaddsubfield($dbh,$bibid,$tag,$tag_indicator,$tagorder,$subfield->[0],$subfieldorder,$subfield->[1]);
+        &MARCaddsubfield($bibid,$tag,$tag_indicator,$tagorder,$subfield->[0],$subfieldorder,$subfield->[1]);
     }
-    &MARCaddsubfield($dbh,$bibid,$tag,$tag_indicator,$tagorder,'9',$subfieldorder,$mergeto);
+    &MARCaddsubfield($bibid,$tag,$tag_indicator,$tagorder,'9',$subfieldorder,$mergeto);
     my $biblio = GetMarcBiblio($bibid);
     print "AFTER : ".$biblio->as_formatted."\n" if $verbose;
     $nbdone++;

Index: opac/opac-authoritiesdetail.pl
===================================================================
RCS file: /cvsroot/koha/koha/opac/opac-authoritiesdetail.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- opac/opac-authoritiesdetail.pl	9 Mar 2007 15:47:41 -0000	1.2
+++ opac/opac-authoritiesdetail.pl	28 Mar 2007 10:39:16 -0000	1.3
@@ -19,7 +19,7 @@
 
 =head1 NAME
 
-etail.pl : script to show an authority in MARC format
+opac-authoritiesdetail.pl : script to show an authority in MARC format
 
 =head1 SYNOPSIS
 
@@ -54,8 +54,8 @@
 my $dbh = C4::Context->dbh;
 
 my $authid       = $query->param('authid');
-my $authtypecode = &AUTHfind_authtypecode( $dbh, $authid );
-my $tagslib      = &AUTHgettagslib( $dbh, 1, $authtypecode );
+my $authtypecode = &AUTHfind_authtypecode( $authid );
+my $tagslib      = &AUTHgettagslib( 1, $authtypecode );
 
 # open template
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
@@ -88,7 +88,7 @@
 
             #       warn "tree :$element";
             my %cell;
-            my $elementdata = AUTHgetauthority( $dbh, $element );
+            my $elementdata = AUTHgetauthority( $element );
             $record = $elementdata if ( $authid == $element );
             push @loophierarchy,
               BuildUnimarcHierarchy( $elementdata, "child" . $cnt, $authid );
@@ -103,7 +103,7 @@
     }
 }
 else {
-    $record = AUTHgetauthority( $dbh, $authid );
+    $record = AUTHgetauthority( $authid );
 }
 my $count = AUTHcount_usage($authid);
 

Index: opac/opac-authorities-home.pl
===================================================================
RCS file: /cvsroot/koha/koha/opac/opac-authorities-home.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- opac/opac-authorities-home.pl	27 Mar 2007 14:48:39 -0000	1.3
+++ opac/opac-authorities-home.pl	28 Mar 2007 10:39:16 -0000	1.4
@@ -147,7 +147,7 @@
 }
 elsif ( $op eq "delete" ) {
 
-    &AUTHdelauthority( $dbh, $authid, 1 );
+    &AUTHdelauthority( $authid, 1 );
 
     ( $template, $loggedinuser, $cookie ) = get_template_and_user(
         {





More information about the Koha-cvs mailing list