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

(-)a/C4/Biblio.pm (-5 / +21 lines)
Lines 1139-1145 sub GetMarcSubfieldStructureFromKohaField { Link Here
1139
  my $record = GetMarcBiblio({
1139
  my $record = GetMarcBiblio({
1140
      biblionumber => $biblionumber,
1140
      biblionumber => $biblionumber,
1141
      embed_items  => $embeditems,
1141
      embed_items  => $embeditems,
1142
      opac         => $opac });
1142
      opac         => $opac,
1143
      borcat       => $patron_category });
1143
1144
1144
Returns MARC::Record representing a biblio record, or C<undef> if the
1145
Returns MARC::Record representing a biblio record, or C<undef> if the
1145
biblionumber doesn't exist.
1146
biblionumber doesn't exist.
Lines 1163-1168 set to true to include item information. Link Here
1163
set to true to make the result suited for OPAC view. This causes things like
1164
set to true to make the result suited for OPAC view. This causes things like
1164
OpacHiddenItems to be applied.
1165
OpacHiddenItems to be applied.
1165
1166
1167
=item C<$borcat>
1168
1169
If the OpacHiddenItemsExceptions system preference is set, this patron category
1170
can be used to make visible OPAC items which would be normally hidden.
1171
It only makes sense in combination both embed_items and opac values true.
1172
1166
=back
1173
=back
1167
1174
1168
=cut
1175
=cut
Lines 1178-1183 sub GetMarcBiblio { Link Here
1178
    my $biblionumber = $params->{biblionumber};
1185
    my $biblionumber = $params->{biblionumber};
1179
    my $embeditems   = $params->{embed_items} || 0;
1186
    my $embeditems   = $params->{embed_items} || 0;
1180
    my $opac         = $params->{opac} || 0;
1187
    my $opac         = $params->{opac} || 0;
1188
    my $borcat       = $params->{borcat} // q{};
1181
1189
1182
    if (not defined $biblionumber) {
1190
    if (not defined $biblionumber) {
1183
        carp 'GetMarcBiblio called with undefined biblionumber';
1191
        carp 'GetMarcBiblio called with undefined biblionumber';
Lines 1208-1214 sub GetMarcBiblio { Link Here
1208
        C4::Biblio::EmbedItemsInMarcBiblio({
1216
        C4::Biblio::EmbedItemsInMarcBiblio({
1209
            marc_record  => $record,
1217
            marc_record  => $record,
1210
            biblionumber => $biblionumber,
1218
            biblionumber => $biblionumber,
1211
            opac => $opac })
1219
            opac         => $opac,
1220
            borcat       => $borcat })
1212
          if ($embeditems);
1221
          if ($embeditems);
1213
1222
1214
        return $record;
1223
        return $record;
Lines 2891-2897 sub ModZebra { Link Here
2891
        marc_record  => $marc,
2900
        marc_record  => $marc,
2892
        biblionumber => $biblionumber,
2901
        biblionumber => $biblionumber,
2893
        item_numbers => $itemnumbers,
2902
        item_numbers => $itemnumbers,
2894
        opac         => $opac });
2903
        opac         => $opac,
2904
        borcat       => $patron_category });
2895
2905
2896
Given a MARC::Record object containing a bib record,
2906
Given a MARC::Record object containing a bib record,
2897
modify it to include the items attached to it as 9XX
2907
modify it to include the items attached to it as 9XX
Lines 2900-2910 if $itemnumbers is defined, only specified itemnumbers are embedded. Link Here
2900
2910
2901
If $opac is true, then opac-relevant suppressions are included.
2911
If $opac is true, then opac-relevant suppressions are included.
2902
2912
2913
If opac filtering will be done, borcat should be passed to properly
2914
override if necessary.
2915
2903
=cut
2916
=cut
2904
2917
2905
sub EmbedItemsInMarcBiblio {
2918
sub EmbedItemsInMarcBiblio {
2906
    my ($params) = @_;
2919
    my ($params) = @_;
2907
    my ($marc, $biblionumber, $itemnumbers, $opac);
2920
    my ($marc, $biblionumber, $itemnumbers, $opac, $borcat);
2908
    $marc = $params->{marc_record};
2921
    $marc = $params->{marc_record};
2909
    if ( !$marc ) {
2922
    if ( !$marc ) {
2910
        carp 'EmbedItemsInMarcBiblio: No MARC record passed';
2923
        carp 'EmbedItemsInMarcBiblio: No MARC record passed';
Lines 2913-2918 sub EmbedItemsInMarcBiblio { Link Here
2913
    $biblionumber = $params->{biblionumber};
2926
    $biblionumber = $params->{biblionumber};
2914
    $itemnumbers = $params->{item_numbers};
2927
    $itemnumbers = $params->{item_numbers};
2915
    $opac = $params->{opac};
2928
    $opac = $params->{opac};
2929
    $borcat = $params->{borcat} // q{};
2916
2930
2917
    $itemnumbers = [] unless defined $itemnumbers;
2931
    $itemnumbers = [] unless defined $itemnumbers;
2918
2932
Lines 2942-2948 sub EmbedItemsInMarcBiblio { Link Here
2942
    my @items2pass = map { $_->{item} } @items;
2956
    my @items2pass = map { $_->{item} } @items;
2943
    my @hiddenitems =
2957
    my @hiddenitems =
2944
      $opachiddenitems
2958
      $opachiddenitems
2945
      ? C4::Items::GetHiddenItemnumbers({ items => \@items2pass })
2959
      ? C4::Items::GetHiddenItemnumbers({
2960
            items  => \@items2pass,
2961
            borcat => $borcat })
2946
      : ();
2962
      : ();
2947
    # Convert to a hash for quick searching
2963
    # Convert to a hash for quick searching
2948
    my %hiddenitems = map { $_ => 1 } @hiddenitems;
2964
    my %hiddenitems = map { $_ => 1 } @hiddenitems;
(-)a/opac/opac-basket.pl (-1 / +29 lines)
Lines 18-23 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use CGI qw ( -utf8 );
20
use CGI qw ( -utf8 );
21
use List::Util qw ( none );
22
21
use C4::Koha;
23
use C4::Koha;
22
use C4::Biblio;
24
use C4::Biblio;
23
use C4::Items;
25
use C4::Items;
Lines 58-63 if (C4::Context->preference('TagsEnabled')) { Link Here
58
	}
60
	}
59
}
61
}
60
62
63
my $borcat = q{};
64
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
65
    # we need to fetch the borrower info here, so we can pass the category
66
    my $borrower = Koha::Patron->find( { borrowernumber -> $borrowernumber } );
67
    $borcat = $borrower ? $borrower->categorycode : $borcat;
68
}
69
61
my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
70
my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
62
foreach my $biblionumber ( @bibs ) {
71
foreach my $biblionumber ( @bibs ) {
63
    $template->param( biblionumber => $biblionumber );
72
    $template->param( biblionumber => $biblionumber );
Lines 65-70 foreach my $biblionumber ( @bibs ) { Link Here
65
    my $dat              = &GetBiblioData($biblionumber);
74
    my $dat              = &GetBiblioData($biblionumber);
66
    next unless $dat;
75
    next unless $dat;
67
76
77
    # No filtering on the item records needed for the record itself
78
    # since the only reason item information is grabbed is because of branchcodes.
68
    my $record = &GetMarcBiblio({ biblionumber => $biblionumber });
79
    my $record = &GetMarcBiblio({ biblionumber => $biblionumber });
69
    my $framework = &GetFrameworkCode( $biblionumber );
80
    my $framework = &GetFrameworkCode( $biblionumber );
70
    $record_processor->options({
81
    $record_processor->options({
Lines 78-84 foreach my $biblionumber ( @bibs ) { Link Here
78
    my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
89
    my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
79
    my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
90
    my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
80
    my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
91
    my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
81
    my @items            = &GetItemsInfo( $biblionumber );
92
93
    # grab all the items...
94
    my @all_items        = &GetItemsInfo( $biblionumber );
95
96
    # determine which ones should be hidden / visible
97
    my @hidden_items     = GetHiddenItemnumbers({ items => \@all_items, borcat => $borcat });
98
99
    # If every item is hidden, then the biblio should be hidden too.
100
    next if (scalar @all_items >=1 && scalar @hidden_items == scalar @all_items);
101
102
    # copy the visible ones into the items array.
103
    my @items;
104
    foreach my $item (@all_items) {
105
        if ( none { $item->{itemnumber} ne $_ } @hidden_items ) {
106
            push @items, $item;
107
        }
108
    }
109
82
    my $subtitle         = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
110
    my $subtitle         = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
83
111
84
    my $hasauthors = 0;
112
    my $hasauthors = 0;
(-)a/opac/opac-detail.pl (-1 / +3 lines)
Lines 99-105 if ( scalar @all_items >= 1 ) { Link Here
99
    }
99
    }
100
}
100
}
101
101
102
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
102
my $record = GetMarcBiblio({
103
    biblionumber => $biblionumber,
104
    opac         => 1 });
103
if ( ! $record ) {
105
if ( ! $record ) {
104
    print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
106
    print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
105
    exit;
107
    exit;
(-)a/opac/opac-downloadcart.pl (-1 / +10 lines)
Lines 49-54 my $dbh = C4::Context->dbh; Link Here
49
49
50
if ($bib_list && $format) {
50
if ($bib_list && $format) {
51
51
52
    my $borcat = q{};
53
    if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
54
        # we need to fetch the borrower info here, so we can pass the category
55
        my $borrower = Koha::Patrons->find( { borrowernumber => $borrowernumber } );
56
        $borcat = $borrower ? $borrower->categorycode : $borcat;
57
    }
58
52
    my @bibs = split( /\//, $bib_list );
59
    my @bibs = split( /\//, $bib_list );
53
60
54
    my $marcflavour = C4::Context->preference('marcflavour');
61
    my $marcflavour = C4::Context->preference('marcflavour');
Lines 70-76 if ($bib_list && $format) { Link Here
70
77
71
            my $record = GetMarcBiblio({
78
            my $record = GetMarcBiblio({
72
                biblionumber => $biblio,
79
                biblionumber => $biblio,
73
                embed_items  => 1 });
80
                embed_items  => 1,
81
                opac         => 1,
82
                borcat       => $borcat });
74
            my $framework = &GetFrameworkCode( $biblio );
83
            my $framework = &GetFrameworkCode( $biblio );
75
            $record_processor->options({
84
            $record_processor->options({
76
                interface => 'opac',
85
                interface => 'opac',
(-)a/opac/opac-downloadshelf.pl (-1 / +10 lines)
Lines 50-55 my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( Link Here
50
    }
50
    }
51
);
51
);
52
52
53
my $borcat = q{};
54
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
55
    # we need to fetch the borrower info here, so we can pass the category
56
    my $borrower = Koha::Patrons->find( { borrowernumber => $borrowernumber } );
57
    $borcat = $borrower ? $borrower->categorycode : $borcat;
58
}
59
53
my $shelfnumber = $query->param('shelfnumber');
60
my $shelfnumber = $query->param('shelfnumber');
54
my $format  = $query->param('format');
61
my $format  = $query->param('format');
55
my $context = $query->param('context');
62
my $context = $query->param('context');
Lines 83-89 if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { Link Here
83
90
84
                my $record = GetMarcBiblio({
91
                my $record = GetMarcBiblio({
85
                    biblionumber => $biblionumber,
92
                    biblionumber => $biblionumber,
86
                    embed_items  => 1 });
93
                    embed_items  => 1,
94
                    opac         => 1,
95
                    borcat       => $borcat });
87
                my $framework = &GetFrameworkCode( $biblionumber );
96
                my $framework = &GetFrameworkCode( $biblionumber );
88
                $record_processor->options({
97
                $record_processor->options({
89
                    interface => 'opac',
98
                    interface => 'opac',
(-)a/opac/opac-export.pl (-1 / +15 lines)
Lines 35-45 my $biblionumber = $query->param("bib")||0; Link Here
35
$biblionumber = int($biblionumber);
35
$biblionumber = int($biblionumber);
36
my $error = q{};
36
my $error = q{};
37
37
38
# Determine logged in user's patron category.
39
# Blank if not logged in.
40
my $userenv = C4::Context->userenv;
41
my $borcat = q{};
42
if ($userenv) {
43
    my $borrowernumber = $userenv->{'number'};
44
    if ($borrowernumber) {
45
        $borrower = Koha::Patrons->find( { borrowernumber => $borrowernumber } );
46
        $borcat = $borrower ? $borrower->categorycode : $borcat;
47
    }
48
}
49
38
my $include_items = ($format =~ /bibtex/) ? 0 : 1;
50
my $include_items = ($format =~ /bibtex/) ? 0 : 1;
39
my $marc = $biblionumber
51
my $marc = $biblionumber
40
    ? GetMarcBiblio({
52
    ? GetMarcBiblio({
41
        biblionumber => $biblionumber,
53
        biblionumber => $biblionumber,
42
        embed_items  => $include_items })
54
        embed_items  => $include_items,
55
        opac         => 1,
56
        borcat       => $borcat })
43
    : undef;
57
    : undef;
44
58
45
if(!$marc) {
59
if(!$marc) {
(-)a/opac/opac-search.pl (+2 lines)
Lines 602-607 if ($tag) { Link Here
602
    $DEBUG and printf STDERR "taglist (%s biblionumber)\nmarclist (%s records)\n", scalar(@$taglist), scalar(@marclist);
602
    $DEBUG and printf STDERR "taglist (%s biblionumber)\nmarclist (%s records)\n", scalar(@$taglist), scalar(@marclist);
603
    $results_hashref->{biblioserver}->{RECORDS} = \@marclist;
603
    $results_hashref->{biblioserver}->{RECORDS} = \@marclist;
604
    # FIXME: tag search and standard search should work together, not exclusively
604
    # FIXME: tag search and standard search should work together, not exclusively
605
    # FIXME: Because search and standard search don't work together OpacHiddenItems
606
    #        displays search results which should be hidden.
605
    # FIXME: No facets for tags search.
607
    # FIXME: No facets for tags search.
606
} elsif ($build_grouped_results) {
608
} elsif ($build_grouped_results) {
607
    eval {
609
    eval {
(-)a/opac/opac-sendbasket.pl (-1 / +5 lines)
Lines 59-64 if ( $email_add ) { Link Here
59
    });
59
    });
60
    my $email = Koha::Email->new();
60
    my $email = Koha::Email->new();
61
    my $patron = Koha::Patrons->find( $borrowernumber );
61
    my $patron = Koha::Patrons->find( $borrowernumber );
62
    my $borcat = $patron ? $patron->categorycode : q{};
62
    my $user_email = GetFirstValidEmailAddress($borrowernumber)
63
    my $user_email = GetFirstValidEmailAddress($borrowernumber)
63
    || C4::Context->preference('KohaAdminEmailAddress');
64
    || C4::Context->preference('KohaAdminEmailAddress');
64
65
Lines 89-95 if ( $email_add ) { Link Here
89
        next unless $dat;
90
        next unless $dat;
90
        my $record           = GetMarcBiblio({
91
        my $record           = GetMarcBiblio({
91
            biblionumber => $biblionumber,
92
            biblionumber => $biblionumber,
92
            embed_items  => 1 });
93
            embed_items  => 1,
94
            opac         => 1,
95
            borcat       => $borcat });
96
93
        my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
97
        my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
94
        my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
98
        my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
95
99
(-)a/opac/opac-sendshelf.pl (-5 / +9 lines)
Lines 80-85 if ( $email ) { Link Here
80
        }
80
        }
81
    );
81
    );
82
82
83
    my $patron = Koha::Patrons->find( $borrowernumber );
84
    my $borcat = $patron ? $patron->categorycode : q{};
85
83
    my $shelf = Koha::Virtualshelves->find( $shelfid );
86
    my $shelf = Koha::Virtualshelves->find( $shelfid );
84
    my $contents = $shelf->get_contents;
87
    my $contents = $shelf->get_contents;
85
    my $marcflavour         = C4::Context->preference('marcflavour');
88
    my $marcflavour         = C4::Context->preference('marcflavour');
Lines 88-98 if ( $email ) { Link Here
88
91
89
    while ( my $content = $contents->next ) {
92
    while ( my $content = $contents->next ) {
90
        my $biblionumber = $content->biblionumber;
93
        my $biblionumber = $content->biblionumber;
91
        my $fw               = GetFrameworkCode($biblionumber);
92
        my $dat              = GetBiblioData($biblionumber);
93
        my $record           = GetMarcBiblio({
94
        my $record           = GetMarcBiblio({
94
            biblionumber => $biblionumber,
95
            biblionumber => $biblionumber,
95
            embed_items  => 1 });
96
            embed_items  => 1,
97
            opac         => 1,
98
            borcat       => $borcat });
99
        next unless $record;
100
        my $fw               = GetFrameworkCode($biblionumber);
101
        my $dat              = GetBiblioData($biblionumber);
96
        my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
102
        my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
97
        my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
103
        my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
98
        my $subtitle         = GetRecordValue('subtitle', $record, $fw);
104
        my $subtitle         = GetRecordValue('subtitle', $record, $fw);
Lines 112-119 if ( $email ) { Link Here
112
        push( @results, $dat );
118
        push( @results, $dat );
113
    }
119
    }
114
120
115
    my $patron = Koha::Patrons->find( $borrowernumber );
116
117
    $template2->param(
121
    $template2->param(
118
        BIBLIO_RESULTS => \@results,
122
        BIBLIO_RESULTS => \@results,
119
        comment        => $comment,
123
        comment        => $comment,
(-)a/opac/opac-user.pl (-2 / +7 lines)
Lines 89-94 if (!$borrowernumber) { Link Here
89
89
90
# get borrower information ....
90
# get borrower information ....
91
my $borr = Koha::Patrons->find( $borrowernumber )->unblessed;
91
my $borr = Koha::Patrons->find( $borrowernumber )->unblessed;
92
# unblessed is a hash vs. object/undef. Hence the used of curly braces here.
93
my $borcat = $borr ? $borr->{categorycode} : q{};
92
94
93
my (  $today_year,   $today_month,   $today_day) = Today();
95
my (  $today_year,   $today_month,   $today_day) = Today();
94
my ($warning_year, $warning_month, $warning_day) = split /-/, $borr->{'dateexpiry'};
96
my ($warning_year, $warning_month, $warning_day) = split /-/, $borr->{'dateexpiry'};
Lines 204-210 if ($issues){ Link Here
204
        }
206
        }
205
        $issue->{'charges'} = $charges;
207
        $issue->{'charges'} = $charges;
206
        $issue->{'rentalfines'} = $rentalfines;
208
        $issue->{'rentalfines'} = $rentalfines;
207
        my $marcrecord = GetMarcBiblio({ biblionumber => $issue->{'biblionumber'} });
209
        my $marcrecord = GetMarcBiblio({
210
            biblionumber => $issue->{'biblionumber'},
211
            embed_items  => 1,
212
            opac         => 1,
213
            borcat       => $borcat });
208
        $issue->{'subtitle'} = GetRecordValue('subtitle', $marcrecord, GetFrameworkCode($issue->{'biblionumber'}));
214
        $issue->{'subtitle'} = GetRecordValue('subtitle', $marcrecord, GetFrameworkCode($issue->{'biblionumber'}));
209
        # check if item is renewable
215
        # check if item is renewable
210
        my ($status,$renewerror) = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} );
216
        my ($status,$renewerror) = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} );
211
- 

Return to bug 14385