|
Lines 77-96
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Link Here
|
| 77 |
); |
77 |
); |
| 78 |
|
78 |
|
| 79 |
my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0; |
79 |
my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0; |
| 80 |
$biblionumber = int($biblionumber); |
|
|
| 81 |
|
80 |
|
| 82 |
my @all_items = GetItemsInfo($biblionumber); |
81 |
my $external = $query->param('externalsource'); #is this record present in the db, or has come from external |
|
|
82 |
|
| 83 |
my $record; |
| 84 |
my @all_items; |
| 83 |
my @hiddenitems; |
85 |
my @hiddenitems; |
| 84 |
if (scalar @all_items >= 1) { |
|
|
| 85 |
push @hiddenitems, GetHiddenItemnumbers(@all_items); |
| 86 |
|
86 |
|
| 87 |
if (scalar @hiddenitems == scalar @all_items ) { |
87 |
# Move this to a module |
| 88 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early |
88 |
sub convert_od_marc { |
| 89 |
exit; |
89 |
# neeeds to work for other than marc21 too |
| 90 |
} |
90 |
my $data = shift; |
|
|
91 |
my $marc = MARC::Record->new(); |
| 92 |
$marc->add_fields( |
| 93 |
[ 245, "1", " ", a => $data->{title}, b => $data->{subtitle} ], |
| 94 |
[ 100, "", "", a => $data->{'author'} ], |
| 95 |
[ 260, "", "", a => $data->{'publisher'} ], |
| 96 |
[ 999, "", "", c => $data->{'id'} ], |
| 97 |
[ 999, "", "", d => $data->{'id'} ], |
| 98 |
); |
| 99 |
return $marc; |
| 100 |
} |
| 101 |
|
| 102 |
if ( $external && $external eq 'overdrive' ) { |
| 103 |
# We are looking at a record from overdrive, not a marc record in Koha |
| 104 |
require Koha::ExternalContent::OverDrive; |
| 105 |
import Koha::ExternalContent::OverDrive; |
| 106 |
require WebService::ILS::OverDrive::Library; |
| 107 |
import WebService::ILS::OverDrive::Library; |
| 108 |
my $client_id = C4::Context->preference('OverDriveClientKey'); |
| 109 |
my $client_secret = C4::Context->preference('OverDriveClientSecret'); |
| 110 |
my $library_id = C4::Context->preference('OverDriveLibraryID'); |
| 111 |
my $od_client = WebService::ILS::OverDrive::Library->new( |
| 112 |
{ |
| 113 |
test => 1, |
| 114 |
client_id => $client_id, |
| 115 |
client_secret => $client_secret, |
| 116 |
library_id => $library_id |
| 117 |
} |
| 118 |
); |
| 119 |
my $data = $od_client->item_metadata($biblionumber); |
| 120 |
$record = convert_od_marc($data); |
| 91 |
} |
121 |
} |
|
|
122 |
else { |
| 123 |
# Normal record in Koha |
| 124 |
$biblionumber = int($biblionumber); |
| 125 |
@all_items = GetItemsInfo($biblionumber); |
| 126 |
@hiddenitems; |
| 127 |
if (scalar @all_items >= 1) { |
| 128 |
push @hiddenitems, GetHiddenItemnumbers(@all_items); |
| 129 |
|
| 130 |
if (scalar @hiddenitems == scalar @all_items ) { |
| 131 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early |
| 132 |
exit; |
| 133 |
} |
| 134 |
} |
| 92 |
|
135 |
|
| 93 |
my $record = GetMarcBiblio($biblionumber); |
136 |
my $record = GetMarcBiblio($biblionumber); |
|
|
137 |
} |
| 94 |
if ( ! $record ) { |
138 |
if ( ! $record ) { |
| 95 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early |
139 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early |
| 96 |
exit; |
140 |
exit; |
| 97 |
- |
|
|