X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=opac%2Fopac-downloadshelf.pl;h=662eb25bd5b4e5441275129cb474b1215dfa6009;hb=b5497a5f46a32c1ab33a22539e8acfcf82e476b0;hp=ee9b0b15475e57ff243b369ce2fa6fc5d7c1f72f;hpb=a3ff0bb5cb91761677f8b3ff08fa5f12378376af;p=koha.git diff --git a/opac/opac-downloadshelf.pl b/opac/opac-downloadshelf.pl index ee9b0b1547..662eb25bd5 100755 --- a/opac/opac-downloadshelf.pl +++ b/opac/opac-downloadshelf.pl @@ -48,52 +48,58 @@ my $shelfid = $query->param('shelfid'); my $format = $query->param('format'); my $dbh = C4::Context->dbh; -if ($shelfid && $format) { - - my @shelf = GetShelf($shelfid); - my ($items, $totitems) = GetShelfContents($shelfid); - my $marcflavour = C4::Context->preference('marcflavour'); - my $output; - - # CSV - if ($format =~ /^\d+$/) { - my @biblios; - foreach (@$items) { - push @biblios, $_->{biblionumber}; - } - $output = marc2csv(\@biblios, $format); - - # Other formats - } else { - foreach my $biblio (@$items) { - my $biblionumber = $biblio->{biblionumber}; +if ( ShelfPossibleAction( (defined($borrowernumber) ? $borrowernumber : -1), $shelfid, 'view' ) ) { - my $record = GetMarcBiblio($biblionumber, 1); - next unless $record; + if ($shelfid && $format) { - if ($format eq 'iso2709') { - $output .= $record->as_usmarc(); - } - elsif ($format eq 'ris' ) { - $output .= marc2ris($record); + my ($items, $totitems) = GetShelfContents($shelfid); + my $marcflavour = C4::Context->preference('marcflavour'); + my $output; + + # CSV + if ($format =~ /^\d+$/) { + my @biblios; + foreach (@$items) { + push @biblios, $_->{biblionumber}; } - elsif ($format eq 'bibtex') { - $output .= marc2bibtex($record, $biblionumber); + $output = marc2csv(\@biblios, $format); + + # Other formats + } else { + foreach my $biblio (@$items) { + my $biblionumber = $biblio->{biblionumber}; + + my $record = GetMarcBiblio($biblionumber, 1); + next unless $record; + + if ($format eq 'iso2709') { + $output .= $record->as_usmarc(); + } + elsif ($format eq 'ris' ) { + $output .= marc2ris($record); + } + elsif ($format eq 'bibtex') { + $output .= marc2bibtex($record, $biblionumber); + } } } - } - # If it was a CSV export we change the format after the export so the file extension is fine - $format = "csv" if ($format =~ m/^\d+$/); + # If it was a CSV export we change the format after the export so the file extension is fine + $format = "csv" if ($format =~ m/^\d+$/); + + print $query->header( + -type => 'application/octet-stream', + -'Content-Transfer-Encoding' => 'binary', + -attachment=>"shelf.$format"); + print $output; - print $query->header( - -type => 'application/octet-stream', - -'Content-Transfer-Encoding' => 'binary', - -attachment=>"shelf.$format"); - print $output; + } else { + $template->param(csv_profiles => GetCsvProfilesLoop()); + $template->param(shelfid => $shelfid); + output_html_with_http_headers $query, $cookie, $template->output; + } } else { - $template->param(csv_profiles => GetCsvProfilesLoop()); - $template->param(shelfid => $shelfid); + $template->param(invalidlist => 1); output_html_with_http_headers $query, $cookie, $template->output; }