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

(-)a/opac/opac-ISBDdetail.pl (-1 / +1 lines)
Lines 84-90 my $opachiddenitems_rules = C4::Context->yaml_preference('OpacHiddenItems'); Link Here
84
unless ( $patron and $patron->category->override_hidden_items ) {
84
unless ( $patron and $patron->category->override_hidden_items ) {
85
    # only skip this check if there's a logged in user
85
    # only skip this check if there's a logged in user
86
    # and its category overrides OpacHiddenItems
86
    # and its category overrides OpacHiddenItems
87
    if ( C4::Context->preference('OpacHiddenItemsHidesRecord') && $biblio->hidden_in_opac({ rules => $opachiddenitems_rules }) ) {
87
    if ( $biblio->hidden_in_opac({ rules => $opachiddenitems_rules }) ) {
88
        print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
88
        print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
89
        exit;
89
        exit;
90
    }
90
    }
(-)a/opac/opac-MARCdetail.pl (-10 / +12 lines)
Lines 102-118 if ( ! $record ) { Link Here
102
    exit;
102
    exit;
103
}
103
}
104
104
105
my @all_items = GetItemsInfo($biblionumber);
106
my $biblio = Koha::Biblios->find( $biblionumber );
105
my $biblio = Koha::Biblios->find( $biblionumber );
107
my $framework = $biblio ? $biblio->frameworkcode : q{};
106
unless ( $patron and $patron->category->override_hidden_items ) {
108
my $tagslib = &GetMarcStructure( 0, $framework );
107
    # only skip this check if there's a logged in user
109
my ($tag_itemnumber,$subtag_itemnumber) = &GetMarcFromKohaField( 'items.itemnumber' );
108
    # and its category overrides OpacHiddenItems
110
my @nonhiddenitems = $record->field($tag_itemnumber);
109
    if ( $biblio->hidden_in_opac({ rules => C4::Context->yaml_preference('OpacHiddenItems') }) ) {
111
if ( C4::Context->preference('OpacHiddenItemsHidesRecord') && scalar @all_items >= 1 && scalar @nonhiddenitems == 0 ) {
110
        print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
112
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
111
        exit;
113
    exit;
112
    }
114
}
113
}
115
114
115
my $framework = $biblio ? $biblio->frameworkcode : q{};
116
my $tagslib   = &GetMarcStructure( 0, $framework );
117
116
my $record_processor = Koha::RecordProcessor->new({
118
my $record_processor = Koha::RecordProcessor->new({
117
    filters => 'ViewPolicy',
119
    filters => 'ViewPolicy',
118
    options => {
120
    options => {
Lines 137-144 $template->param( Link Here
137
     $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8;   # except -8;
139
     $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8;   # except -8;
138
140
139
my $allow_onshelf_holds;
141
my $allow_onshelf_holds;
140
for my $itm (@all_items) {
142
my $items = $biblio->items;
141
    my $item = Koha::Items->find( $itm->{itemnumber} );
143
while ( my $item = $items->next ) {
142
    $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
144
    $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
143
    last if $allow_onshelf_holds;
145
    last if $allow_onshelf_holds;
144
}
146
}
(-)a/opac/opac-basket.pl (-1 / +4 lines)
Lines 66-71 if ( C4::Context->preference('OpacHiddenItemsExceptions') ) { Link Here
66
}
66
}
67
67
68
my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
68
my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
69
my $rules = C4::Context->yaml_preference('OpacHiddenItems');
70
69
foreach my $biblionumber ( @bibs ) {
71
foreach my $biblionumber ( @bibs ) {
70
    $template->param( biblionumber => $biblionumber );
72
    $template->param( biblionumber => $biblionumber );
71
73
Lines 96-102 foreach my $biblionumber ( @bibs ) { Link Here
96
    my @hidden_items     = GetHiddenItemnumbers({ items => \@all_items, borcat => $borcat });
98
    my @hidden_items     = GetHiddenItemnumbers({ items => \@all_items, borcat => $borcat });
97
99
98
    # If every item is hidden, then the biblio should be hidden too.
100
    # If every item is hidden, then the biblio should be hidden too.
99
    next if ( C4::Context->preference('OpacHiddenItemsHidesRecord') && scalar @all_items >= 1 && scalar @hidden_items == scalar @all_items);
101
    next
102
      if $biblio->hidden_in_opac({ rules => $rules });
100
103
101
    # copy the visible ones into the items array.
104
    # copy the visible ones into the items array.
102
    my @items;
105
    my @items;
(-)a/opac/opac-detail.pl (-12 / +7 lines)
Lines 89-98 if( $specific_item ) { Link Here
89
}
89
}
90
my @hiddenitems;
90
my @hiddenitems;
91
my $patron = Koha::Patrons->find( $borrowernumber );
91
my $patron = Koha::Patrons->find( $borrowernumber );
92
our $borcat= q{};
93
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
94
    $borcat = $patron ? $patron->categorycode : q{};
95
}
96
92
97
my $record = GetMarcBiblio({
93
my $record = GetMarcBiblio({
98
    biblionumber => $biblionumber,
94
    biblionumber => $biblionumber,
Lines 102-118 if ( ! $record ) { Link Here
102
    exit;
98
    exit;
103
}
99
}
104
100
105
if ( scalar @all_items >= 1 ) {
101
my $biblio = Koha::Biblios->find( $biblionumber );
106
    push @hiddenitems,
102
unless ( $patron and $patron->category->override_hidden_items ) {
107
      GetHiddenItemnumbers( { items => \@all_items, borcat => $borcat } );
103
    # only skip this check if there's a logged in user
108
104
    # and its category overrides OpacHiddenItems
109
    if ( C4::Context->preference('OpacHiddenItemsHidesRecord') && scalar @hiddenitems == scalar @all_items ) {
105
    if ( $biblio->hidden_in_opac({ rules => C4::Context->yaml_preference('OpacHiddenItems') }) ) {
110
        print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
106
        print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
111
        exit;
107
        exit;
112
    }
108
    }
113
}
109
}
114
110
115
my $biblio = Koha::Biblios->find( $biblionumber );
116
my $framework = $biblio ? $biblio->frameworkcode : q{};
111
my $framework = $biblio ? $biblio->frameworkcode : q{};
117
my $record_processor = Koha::RecordProcessor->new({
112
my $record_processor = Koha::RecordProcessor->new({
118
    filters => 'ViewPolicy',
113
    filters => 'ViewPolicy',
Lines 280-286 if ($session->param('busc')) { Link Here
280
        my @newresults;
275
        my @newresults;
281
        my $search_context = {
276
        my $search_context = {
282
            'interface' => 'opac',
277
            'interface' => 'opac',
283
            'category'  => $borcat
278
            'category'  => ($patron) ? $patron->categorycode : q{}
284
        };
279
        };
285
        for (my $i=0;$i<@servers;$i++) {
280
        for (my $i=0;$i<@servers;$i++) {
286
            my $server = $servers[$i];
281
            my $server = $servers[$i];
(-)a/opac/opac-tags.pl (-4 / +10 lines)
Lines 233-240 my $borcat = q{}; Link Here
233
if ($loggedinuser) {
233
if ($loggedinuser) {
234
    my $patron = Koha::Patrons->find( { borrowernumber => $loggedinuser } );
234
    my $patron = Koha::Patrons->find( { borrowernumber => $loggedinuser } );
235
    $borcat = $patron ? $patron->categorycode : $borcat;
235
    $borcat = $patron ? $patron->categorycode : $borcat;
236
    my $should_hide = C4::Context->preference('OpacHiddenItems') // q{};
236
    my $rules = C4::Context->yaml_preference('OpacHiddenItems');
237
    $should_hide = ( $should_hide =~ /\S/ ) ? 1 : 0;
237
    my $should_hide = ( $rules ) ? 1 : 0;
238
    $my_tags = get_tag_rows({borrowernumber=>$loggedinuser});
238
    $my_tags = get_tag_rows({borrowernumber=>$loggedinuser});
239
    my $my_approved_tags = get_approval_rows({ approved => 1 });
239
    my $my_approved_tags = get_approval_rows({ approved => 1 });
240
240
Lines 270-276 if ($loggedinuser) { Link Here
270
                borcat => $borcat });
270
                borcat => $borcat });
271
            $hidden_items = \@hidden_itemnumbers;
271
            $hidden_items = \@hidden_itemnumbers;
272
        }
272
        }
273
        next if ( C4::Context->preference('OpacHiddenItemsHidesRecord') && $should_hide && scalar @all_items == scalar @hidden_itemnumbers );
273
        next
274
          if (
275
            (
276
                !$patron
277
                or ( $patron and !$patron->category->override_hidden_items )
278
            )
279
            and $biblio->hidden_in_opac( { rules => $rules } )
280
          );
274
        $tag->{title} = $biblio->title;
281
        $tag->{title} = $biblio->title;
275
        $tag->{subtitle} = $biblio->subtitle;
282
        $tag->{subtitle} = $biblio->subtitle;
276
        $tag->{medium} = $biblio->medium;
283
        $tag->{medium} = $biblio->medium;
277
- 

Return to bug 18989