|
Lines 22-27
use Mojo::Base 'Mojolicious::Controller';
Link Here
|
| 22 |
use Koha::Biblios; |
22 |
use Koha::Biblios; |
| 23 |
use Koha::Ratings; |
23 |
use Koha::Ratings; |
| 24 |
use Koha::RecordProcessor; |
24 |
use Koha::RecordProcessor; |
|
|
25 |
use Koha::SearchEngine::Search; |
| 25 |
use C4::Biblio qw( DelBiblio AddBiblio ModBiblio ); |
26 |
use C4::Biblio qw( DelBiblio AddBiblio ModBiblio ); |
| 26 |
use C4::Search qw( FindDuplicate ); |
27 |
use C4::Search qw( FindDuplicate ); |
| 27 |
|
28 |
|
|
Lines 144-149
sub delete {
Link Here
|
| 144 |
}; |
145 |
}; |
| 145 |
} |
146 |
} |
| 146 |
|
147 |
|
|
|
148 |
=head3 get_biblios_public |
| 149 |
|
| 150 |
Controller function that handles retrieving biblios by querying the database |
| 151 |
via the searchengine that's currently in use. Use the q_ccl query paramater. |
| 152 |
|
| 153 |
=cut |
| 154 |
|
| 155 |
sub get_biblios_public { |
| 156 |
|
| 157 |
my $c = shift->openapi->valid_input or return; |
| 158 |
|
| 159 |
my $searcher = Koha::SearchEngine::Search->new( { index => 'biblios' } ); |
| 160 |
my $query = $c->validation->param('q_ccl'); |
| 161 |
|
| 162 |
my ( $error, $results, $total_hits ) = $searcher->simple_search_compat( $query, 0, undef ); |
| 163 |
|
| 164 |
if ( !$total_hits ) { |
| 165 |
return $c->render( |
| 166 |
status => 404, |
| 167 |
openapi => { error => 'Nothing found.' } |
| 168 |
); |
| 169 |
} |
| 170 |
|
| 171 |
return try { |
| 172 |
|
| 173 |
my $patron = $c->stash('koha.user'); |
| 174 |
my $is_public = $c->stash('is_public'); |
| 175 |
my $opachiddenitems_rules = C4::Context->yaml_preference('OpacHiddenItems'); |
| 176 |
my $searchengine = C4::Context->preference('SearchEngine'); |
| 177 |
|
| 178 |
my @biblionumbers |
| 179 |
= $searchengine eq 'Zebra' |
| 180 |
? map { MARC::Record->new_from_xml( $_, 'UTF-8' )->field('999')->subfield('c') } $results->@* |
| 181 |
: map { $_->field('999')->subfield('c') } $results->@*; |
| 182 |
my @biblios = map { Koha::Biblios->find( { biblionumber => $_ } ) } @biblionumbers; |
| 183 |
my @records = map { |
| 184 |
next if ( $is_public |
| 185 |
&& !( $patron && $patron->category->override_hidden_items ) |
| 186 |
&& $_->hidden_in_opac( { rules => $opachiddenitems_rules } ) ); |
| 187 |
$_->metadata->record; |
| 188 |
} @biblios; |
| 189 |
|
| 190 |
$c->respond_to( |
| 191 |
mij => { |
| 192 |
status => 200, |
| 193 |
format => 'mij', |
| 194 |
data => '[' . ( join ',', map { $_->to_mij } @records ) . ']', |
| 195 |
}, |
| 196 |
any => { |
| 197 |
status => 406, |
| 198 |
openapi => [ 'application/marc-in-json', ] |
| 199 |
} |
| 200 |
); |
| 201 |
} |
| 202 |
catch { |
| 203 |
$c->unhandled_exception($_); |
| 204 |
}; |
| 205 |
} |
| 206 |
|
| 147 |
=head3 get_public |
207 |
=head3 get_public |
| 148 |
|
208 |
|
| 149 |
Controller function that handles retrieving a single biblio object |
209 |
Controller function that handles retrieving a single biblio object |
|
Lines 190-202
sub get_public {
Link Here
|
| 190 |
|
250 |
|
| 191 |
my $marcflavour = C4::Context->preference("marcflavour"); |
251 |
my $marcflavour = C4::Context->preference("marcflavour"); |
| 192 |
|
252 |
|
| 193 |
my $record_processor = Koha::RecordProcessor->new({ |
253 |
my $record_processor = Koha::RecordProcessor->new( |
| 194 |
filters => 'ViewPolicy', |
254 |
{ |
| 195 |
options => { |
255 |
filters => 'ViewPolicy', |
| 196 |
interface => 'opac', |
256 |
options => { |
| 197 |
frameworkcode => $biblio->frameworkcode |
257 |
interface => 'opac', |
|
|
258 |
frameworkcode => $biblio->frameworkcode |
| 259 |
} |
| 198 |
} |
260 |
} |
| 199 |
}); |
261 |
); |
|
|
262 |
|
| 200 |
# Apply framework's filtering to MARC::Record object |
263 |
# Apply framework's filtering to MARC::Record object |
| 201 |
$record_processor->process($record); |
264 |
$record_processor->process($record); |
| 202 |
|
265 |
|