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