View | Details | Raw Unified | Return to bug 23583
Collapse All | Expand All

(-)a/C4/Items.pm (-13 / +5 lines)
Lines 49-55 BEGIN { Link Here
49
49
50
use Carp;
50
use Carp;
51
use Try::Tiny;
51
use Try::Tiny;
52
use Encode;
53
use C4::Context;
52
use C4::Context;
54
use C4::Koha;
53
use C4::Koha;
55
use C4::Biblio;
54
use C4::Biblio;
Lines 58-64 use MARC::Record; Link Here
58
use C4::ClassSource;
57
use C4::ClassSource;
59
use C4::Log;
58
use C4::Log;
60
use List::MoreUtils qw(any);
59
use List::MoreUtils qw(any);
61
use YAML::XS;
62
use DateTime::Format::MySQL;
60
use DateTime::Format::MySQL;
63
use Data::Dumper; # used as part of logging item record changes, not just for
61
use Data::Dumper; # used as part of logging item record changes, not just for
64
                  # debugging; so please don't remove this
62
                  # debugging; so please don't remove this
Lines 988-1004 sub GetHiddenItemnumbers { Link Here
988
    }
986
    }
989
    my @resultitems;
987
    my @resultitems;
990
988
991
    my $yaml = C4::Context->preference('OpacHiddenItems');
989
    my $hidingrules = C4::Context->yaml_preference('OpacHiddenItems');
992
    return () if (! $yaml =~ /\S/ );
990
993
    $yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt
991
    return
994
    my $hidingrules;
992
        unless $hidingrules;
995
    eval {
993
996
        $hidingrules = YAML::XS::Load(Encode::encode_utf8($yaml));
997
    };
998
    if ($@) {
999
        warn "Unable to parse OpacHiddenItems syspref : $@";
1000
        return ();
1001
    }
1002
    my $dbh = C4::Context->dbh;
994
    my $dbh = C4::Context->dbh;
1003
995
1004
    # For each item
996
    # For each item
(-)a/Koha/Filter/MARC/EmbedItems.pm (-6 / +2 lines)
Lines 28-40 my $biblio = Koha::Biblios->find( Link Here
28
    { prefetch => [ items, metadata ] }
28
    { prefetch => [ items, metadata ] }
29
);
29
);
30
30
31
my $opachiddenitems_rules;
31
my $rules = C4::Context->yaml_preference('OpacHiddenItems');
32
eval {
33
    my $yaml = C4::Context->preference('OpacHiddenItems') . "\n\n";
34
    $opachiddenitems_rules = YAML::XS::Load(Encode::encode_utf8($yaml));
35
};
36
32
37
my @items  = grep { !$_->hidden_in_opac({ rules => $opachiddenitems_rules }) @{$biblio->items};
33
my @items  = grep { !$_->hidden_in_opac({ rules => $rules }) @{$biblio->items};
38
my $record = $biblio->metadata->record;
34
my $record = $biblio->metadata->record;
39
35
40
my $processor = Koha::RecordProcessor->new(
36
my $processor = Koha::RecordProcessor->new(
(-)a/opac/opac-ISBDdetail.pl (-7 / +1 lines)
Lines 40-47 the items attached to the biblio Link Here
40
=cut
40
=cut
41
41
42
use Modern::Perl;
42
use Modern::Perl;
43
use YAML::XS;
44
use Encode;
45
43
46
use C4::Auth;
44
use C4::Auth;
47
use C4::Context;
45
use C4::Context;
Lines 81-91 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
81
79
82
my $patron = Koha::Patrons->find($loggedinuser);
80
my $patron = Koha::Patrons->find($loggedinuser);
83
81
84
my $opachiddenitems_rules;
82
my $opachiddenitems_rules = C4::Context->yaml_preference('OpacHiddenItems');
85
eval {
86
    my $yaml = C4::Context->preference('OpacHiddenItems') . "\n\n";
87
    $opachiddenitems_rules = YAML::XS::Load(Encode::encode_utf8($yaml));
88
};
89
83
90
unless ( $patron and $patron->category->override_hidden_items ) {
84
unless ( $patron and $patron->category->override_hidden_items ) {
91
    # only skip this check if there's a logged in user
85
    # only skip this check if there's a logged in user
(-)a/opac/opac-search.pl (-15 / +2 lines)
Lines 30-36 use Modern::Perl; Link Here
30
use C4::Context;
30
use C4::Context;
31
use List::MoreUtils q/any/;
31
use List::MoreUtils q/any/;
32
use Try::Tiny;
32
use Try::Tiny;
33
use YAML::XS;
34
use Encode;
33
use Encode;
35
34
36
use Data::Dumper; # TODO remove
35
use Data::Dumper; # TODO remove
Lines 242-258 my $cnt; Link Here
242
my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes";
241
my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes";
243
my @advanced_search_types = split(/\|/, $advanced_search_types);
242
my @advanced_search_types = split(/\|/, $advanced_search_types);
244
243
245
my $hidingrules = {};
244
my $hidingrules = C4::Context->yaml_preference('OpacHiddenItems') // {};
246
my $yaml = C4::Context->preference('OpacHiddenItems');
247
if ( $yaml =~ /\S/ ) {
248
    $yaml = "$yaml\n\n"; # YAML expects trailing newline. Surplus does not hurt.
249
    eval {
250
        $hidingrules = YAML::XS::Load(Encode::encode_utf8($yaml));
251
    };
252
    if ($@) {
253
        warn "Unable to parse OpacHiddenItems syspref : $@";
254
    }
255
}
256
245
257
my @sorted_itemtypes = sort { $itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description} } keys %$itemtypes;
246
my @sorted_itemtypes = sort { $itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description} } keys %$itemtypes;
258
foreach my $advanced_srch_type (@advanced_search_types) {
247
foreach my $advanced_srch_type (@advanced_search_types) {
Lines 811-818 for (my $i=0;$i<@servers;$i++) { Link Here
811
                $template->param(searchdesc => 1);
800
                $template->param(searchdesc => 1);
812
            }
801
            }
813
            $template->param(results_per_page =>  $results_per_page);
802
            $template->param(results_per_page =>  $results_per_page);
814
            my $hide = C4::Context->preference('OpacHiddenItems');
803
            my $hide = ($hidingrules) ? 1 : 0;
815
            $hide = ($hide =~ m/\S/) if $hide; # Just in case it has some spaces/new lines
816
            my $branch = '';
804
            my $branch = '';
817
            if (C4::Context->userenv){
805
            if (C4::Context->userenv){
818
                $branch = C4::Context->userenv->{branch};
806
                $branch = C4::Context->userenv->{branch};
819
- 

Return to bug 23583