Lines 4321-4326
sub GetTopIssues {
Link Here
|
4321 |
FROM biblio b |
4321 |
FROM biblio b |
4322 |
LEFT JOIN items i ON (i.biblionumber = b.biblionumber) |
4322 |
LEFT JOIN items i ON (i.biblionumber = b.biblionumber) |
4323 |
LEFT JOIN biblioitems bi ON (bi.biblionumber = b.biblionumber) |
4323 |
LEFT JOIN biblioitems bi ON (bi.biblionumber = b.biblionumber) |
|
|
4324 |
LEFT JOIN biblio_metadata bm ON (bm.biblionumber = b.biblionumber) |
4324 |
}; |
4325 |
}; |
4325 |
|
4326 |
|
4326 |
my (@where_strs, @where_args); |
4327 |
my (@where_strs, @where_args); |
Lines 4347-4352
sub GetTopIssues {
Link Here
|
4347 |
push @where_args, $newness; |
4348 |
push @where_args, $newness; |
4348 |
} |
4349 |
} |
4349 |
|
4350 |
|
|
|
4351 |
my $opachiddenitems_rules = C4::Context->yaml_preference('OpacHiddenItems'); |
4352 |
if ( $opachiddenitems_rules ){ |
4353 |
#NOTE: OpacHiddenItemsHidesRecord isn't relevant here since the bib won't appear if there is no items to appear anyway |
4354 |
my $userenv = C4::Context->userenv; |
4355 |
my $logged_in_user = Koha::Patrons->find( $userenv->{number} ) if $userenv; |
4356 |
my $logged_in_categorycode = $logged_in_user->categorycode if $logged_in_user; |
4357 |
my $hide_items = 1; |
4358 |
if (my $exceptions = C4::Context->preference('OpacHiddenItemsExceptions') && $logged_in_categorycode){ |
4359 |
foreach my $except (split(/\|/, $exceptions)){ |
4360 |
if ( $except eq $logged_in_categorycode ){ |
4361 |
$hide_items = 0; |
4362 |
last; |
4363 |
} |
4364 |
} |
4365 |
} |
4366 |
if ($hide_items){ |
4367 |
my %where = (); |
4368 |
my @keys = keys %$opachiddenitems_rules; |
4369 |
foreach my $key (@keys){ |
4370 |
#NOTE: Add "i." table alias to field names |
4371 |
#NOTE: Generate SQL::Abstract data structure |
4372 |
$where{ "i." . $key } = { '!=' => [ -and => @{$opachiddenitems_rules->{$key}} ] }; |
4373 |
} |
4374 |
if (%where){ |
4375 |
require SQL::Abstract; |
4376 |
my $sql = SQL::Abstract->new; |
4377 |
my ($stmt, @bind) = $sql->where(\%where); |
4378 |
if ($stmt){ |
4379 |
$stmt =~ s/^ WHERE //; |
4380 |
push(@where_strs,$stmt); |
4381 |
push(@where_args,@bind); |
4382 |
} |
4383 |
} |
4384 |
} |
4385 |
} |
4386 |
|
4387 |
if ( C4::Context->preference('OpacSuppression') ){ |
4388 |
my $hide_items = 1; |
4389 |
if (C4::Context->preference('OpacSuppressionByIPRange')) { |
4390 |
my $IPAddress = $ENV{'REMOTE_ADDR'}; |
4391 |
my $IPRange = C4::Context->preference('OpacSuppressionByIPRange'); |
4392 |
if ($IPAddress =~ /^$IPRange/){ |
4393 |
$hide_items = 0; |
4394 |
} |
4395 |
} |
4396 |
if ($hide_items){ |
4397 |
my $stmt = q#( ExtractValue(bm.metadata,'//datafield[@tag="942"]/subfield[@code="n"]') <> ? )#; |
4398 |
push(@where_strs, $stmt); |
4399 |
push(@where_args, 1); |
4400 |
} |
4401 |
} |
4402 |
|
4350 |
if (@where_strs) { |
4403 |
if (@where_strs) { |
4351 |
$query .= 'WHERE ' . join(' AND ', @where_strs); |
4404 |
$query .= 'WHERE ' . join(' AND ', @where_strs); |
4352 |
} |
4405 |
} |
4353 |
- |
|
|