Bug 20805: Update child to adult patron process broken on several patron-related...
[koha.git] / C4 / Breeding.pm
index d1dbbcb..324bb7c 100644 (file)
@@ -5,18 +5,18 @@ package C4::Breeding;
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use strict;
 use warnings;
@@ -31,11 +31,9 @@ use C4::Languages;
 use Koha::Database;
 use Koha::XSLT_Handler;
 
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 BEGIN {
-       # set the version for version checking
-    $VERSION = 3.07.00.049;
        require Exporter;
        @ISA = qw(Exporter);
     @EXPORT = qw(&BreedingSearch &Z3950Search &Z3950SearchAuth);
@@ -318,7 +316,7 @@ sub _do_xslt_proc {
     if( !$xslh->err ) {
         return MARC::Record->new_from_xml($xml, 'UTF-8');
     } else {
-        return ( $marc, 'xslt_err' ); #original record in case of errors
+        return ( $marc, $xslh->err ); #original record in case of errors
     }
 }
 
@@ -334,9 +332,7 @@ sub _add_rowdata {
         date2 => 'biblioitems.publicationyear', #UNIMARC
     );
     foreach my $k (keys %fetch) {
-        my ($t, $f)= split '\.', $fetch{$k};
-        $row= C4::Biblio::TransformMarcToKohaOneField($t, $f, $record, $row);
-        $row->{$k}= $row->{$f} if $k ne $f;
+        $row->{$k} = C4::Biblio::TransformMarcToKohaOneField( $fetch{$k}, $record );
     }
     $row->{date}//= $row->{date2};
     $row->{isbn}=_isbn_replace($row->{isbn});
@@ -430,9 +426,8 @@ sub ImportBreedingAuth {
     my $batch_id = GetZ3950BatchId($filename);
     my $searchbreeding = $dbh->prepare("select import_record_id from import_auths where control_number=? and authorized_heading=?");
 
-#     $encoding = C4::Context->preference("marcflavour") unless $encoding;
-    my $marc_type = C4::Context->preference('marcflavour');
-    $marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC');
+    my $marcflavour = C4::Context->preference('marcflavour');
+    my $marc_type = $marcflavour eq 'UNIMARC' ? 'UNIMARCAUTH' : $marcflavour;
 
     # fields used for import results
     my $imported=0;
@@ -521,6 +516,7 @@ sub Z3950SearchAuth {
     my $subject= $pars->{subject};
     my $subjectsubdiv= $pars->{subjectsubdiv};
     my $srchany= $pars->{srchany};
+    my $authid= $pars->{authid};
 
     my $show_next       = 0;
     my $total_pages     = 0;
@@ -545,8 +541,8 @@ sub Z3950SearchAuth {
     my $query;
     my $nterms=0;
 
-    my $marc_type = C4::Context->preference('marcflavour');
-    $marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC');
+    my $marcflavour = C4::Context->preference('marcflavour');
+    my $marc_type = $marcflavour eq 'UNIMARC' ? 'UNIMARCAUTH' : $marcflavour;
 
     if ($nameany) {
         $query .= " \@attr 1=1002 \"$nameany\" "; #Any name (this includes personal, corporate, meeting/conference authors, and author names in subject headings)
@@ -619,7 +615,7 @@ sub Z3950SearchAuth {
             $oConnection[$s] = create ZOOM::Connection($option1);
             $oConnection[$s]->connect( $server->{host}, $server->{port} );
             $serverhost[$s] = $server->{host};
-            $servername[$s] = $server->{name};
+            $servername[$s] = $server->{servername};
             $encoding[$s]   = ($server->{encoding}?$server->{encoding}:"iso-5426");
             $s++;
         }    ## while fetch
@@ -673,11 +669,12 @@ sub Z3950SearchAuth {
                             $row_data{server}       = $servername[$k];
                             $row_data{breedingid}   = $breedingid;
                             $row_data{heading}      = $heading;
+                            $row_data{authid}       = $authid;
                             $row_data{heading_code}      = $heading_authtype_code;
                             push( @breeding_loop, \%row_data );
                         }
                         else {
-                            push(@breeding_loop,{'server'=>$servername[$k],'title'=>join(': ',$oConnection[$k]->error_x()),'breedingid'=>-1});
+                            push(@breeding_loop,{'server'=>$servername[$k],'title'=>join(': ',$oConnection[$k]->error_x()),'breedingid'=>-1,'authid'=>-1});
                         }
                     }
                 }    #if $numresults