X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=tools%2Fexport.pl;h=601e8d55adacdeba3aad5ce36a0ea1ecc0f23467;hb=5d6c092921919526ade501facb1220f8a108a08f;hp=1a055b0719e108d1d1bb35bc13e1c4994c2a35a1;hpb=e524ab07c8a0b4b812fb2afe6b95795e5a15f276;p=koha_fer diff --git a/tools/export.pl b/tools/export.pl index 1a055b0719..601e8d55ad 100755 --- a/tools/export.pl +++ b/tools/export.pl @@ -38,6 +38,7 @@ my $dont_export_items; my $deleted_barcodes; my $timestamp; my $record_type; +my $id_list_file; my $help; my $op = $query->param("op") || ''; my $filename = $query->param("filename") || 'koha.mrc'; @@ -60,12 +61,13 @@ if ( $commandline ) { 'clean' => \$clean, 'filename=s' => \$filename, 'record-type=s' => \$record_type, + 'id_list_file=s' => \$id_list_file, 'help|?' => \$help ); if ($help) { print <<_USAGE_; -export.pl [--format=format] [--date=date] [--record-type=TYPE] [--dont_export_items] [--deleted_barcodes] [--clean] --filename=outputfile +export.pl [--format=format] [--date=date] [--record-type=TYPE] [--dont_export_items] [--deleted_barcodes] [--clean] [--id_list_file=PATH] --filename=outputfile --format=FORMAT FORMAT is either 'xml' or 'marc' (default) @@ -82,6 +84,11 @@ export.pl [--format=format] [--date=date] [--record-type=TYPE] [--dont_export_it specified). Used only if TYPE is 'bibs' --clean removes NSE/NSB + + --id_list_file=PATH PATH is a path to a file containing a list of + IDs (biblionumber or authid) with one ID per line. + This list works as a filter; it is compatible with + other parameters for selecting records _USAGE_ exit; } @@ -93,6 +100,7 @@ _USAGE_ $deleted_barcodes ||= 0; $clean ||= 0; $record_type ||= "bibs"; + $id_list_file ||= 0; # Redirect stdout open STDOUT, '>', $filename if $filename; @@ -196,6 +204,19 @@ if ( $op eq "export" ) { my $starting_authid = $query->param('starting_authid'); my $ending_authid = $query->param('ending_authid'); my $authtype = $query->param('authtype'); + my $filefh; + if ($commandline) { + open $filefh,"<", $id_list_file or die "cannot open $id_list_file: $!"; + } else { + $filefh = $query->upload("id_list_file"); + } + my %id_filter; + if ($filefh) { + while (my $number=<$filefh>){ + $number=~s/[\r\n]*$//; + $id_filter{$number}=1 if $number=~/^\d+$/; + } + } if ( $record_type eq 'bibs' and not @biblionumbers ) { if ($timestamp) { @@ -308,6 +329,7 @@ if ( $op eq "export" ) { push @recordids, map { map { $$_[0] } $_ } @{ $sth->fetchall_arrayref }; + @recordids = grep { exists($id_filter{$_}) } @recordids if scalar(%id_filter); } my $xml_header_written = 0;