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