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';
'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)
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;
}
$deleted_barcodes ||= 0;
$clean ||= 0;
$record_type ||= "bibs";
+ $id_list_file ||= 0;
# Redirect stdout
open STDOUT, '>', $filename if $filename;
my $limit_ind_branch =
( C4::Context->preference('IndependentBranches')
&& C4::Context->userenv
- && !( C4::Context->userenv->{flags} & 1 )
+ && !C4::Context->IsSuperLibrarian()
&& C4::Context->userenv->{branch} ) ? 1 : 0;
my $branch = $query->param("branch") || '';
if ( C4::Context->preference("IndependentBranches")
&& C4::Context->userenv
- && !( C4::Context->userenv->{flags} & 1 ) )
+ && !C4::Context->IsSuperLibrarian() )
{
$branch = C4::Context->userenv->{'branch'};
}
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) {
push @recordids, map {
map { $$_[0] } $_
} @{ $sth->fetchall_arrayref };
+ @recordids = grep { exists($id_filter{$_}) } @recordids if scalar(%id_filter);
}
my $xml_header_written = 0;
print "\n";
}
else {
+ my (@result_build_tag) = MARC::File::USMARC::_build_tag_directory($record);
+ if ($result_build_tag[2] > 99999) {
+ warn "record (number $recordid) length ".$result_build_tag[2]." is larger than the MARC spec allows (99999 bytes)";
+ next;
+ }
print $record->as_usmarc();
}
}