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

(-)a/C4/Biblio.pm (-20 / +34 lines)
Lines 1111-1120 sub GetMarcSubfieldStructureFromKohaField { Link Here
1111
=head2 GetMarcBiblio
1111
=head2 GetMarcBiblio
1112
1112
1113
  my $record = GetMarcBiblio({
1113
  my $record = GetMarcBiblio({
1114
      biblionumber => $biblionumber,
1114
      biblionumber  => $biblionumber,
1115
      embed_items  => $embeditems,
1115
      embed_items   => $embeditems,
1116
      opac         => $opac,
1116
      opac          => $opac,
1117
      borcat       => $patron_category });
1117
      borcat        => $patron_category,
1118
      patron_branch => $patron_branch });
1118
1119
1119
Returns MARC::Record representing a biblio record, or C<undef> if the
1120
Returns MARC::Record representing a biblio record, or C<undef> if the
1120
biblionumber doesn't exist.
1121
biblionumber doesn't exist.
Lines 1144-1149 If the OpacHiddenItemsExceptions system preference is set, this patron category Link Here
1144
can be used to make visible OPAC items which would be normally hidden.
1145
can be used to make visible OPAC items which would be normally hidden.
1145
It only makes sense in combination both embed_items and opac values true.
1146
It only makes sense in combination both embed_items and opac values true.
1146
1147
1148
=item C<$patron_branch>
1149
1150
If the OpacHiddenItemsLocalExceptions system preference is
1151
set, this patron branchcode can be used to make visible OPAC
1152
items which would be normally hidden.  It only makes sense in
1153
combination both embed_items and opac values true.
1154
1147
=back
1155
=back
1148
1156
1149
=cut
1157
=cut
Lines 1156-1165 sub GetMarcBiblio { Link Here
1156
        return;
1164
        return;
1157
    }
1165
    }
1158
1166
1159
    my $biblionumber = $params->{biblionumber};
1167
    my $biblionumber  = $params->{biblionumber};
1160
    my $embeditems   = $params->{embed_items} || 0;
1168
    my $embeditems    = $params->{embed_items} || 0;
1161
    my $opac         = $params->{opac} || 0;
1169
    my $opac          = $params->{opac} || 0;
1162
    my $borcat       = $params->{borcat} // q{};
1170
    my $borcat        = $params->{borcat} // q{};
1171
    my $patron_branch = $params->{patron_branch} // q{};
1163
1172
1164
    if (not defined $biblionumber) {
1173
    if (not defined $biblionumber) {
1165
        carp 'GetMarcBiblio called with undefined biblionumber';
1174
        carp 'GetMarcBiblio called with undefined biblionumber';
Lines 1188-1197 sub GetMarcBiblio { Link Here
1188
        C4::Biblio::_koha_marc_update_bib_ids( $record, $frameworkcode, $biblionumber,
1197
        C4::Biblio::_koha_marc_update_bib_ids( $record, $frameworkcode, $biblionumber,
1189
            $biblioitemnumber );
1198
            $biblioitemnumber );
1190
        C4::Biblio::EmbedItemsInMarcBiblio({
1199
        C4::Biblio::EmbedItemsInMarcBiblio({
1191
            marc_record  => $record,
1200
            marc_record   => $record,
1192
            biblionumber => $biblionumber,
1201
            biblionumber  => $biblionumber,
1193
            opac         => $opac,
1202
            opac          => $opac,
1194
            borcat       => $borcat })
1203
            borcat        => $borcat,
1204
            patron_branch => $patron_branch })
1195
          if ($embeditems);
1205
          if ($embeditems);
1196
1206
1197
        return $record;
1207
        return $record;
Lines 2771-2780 sub ModZebra { Link Here
2771
=head2 EmbedItemsInMarcBiblio
2781
=head2 EmbedItemsInMarcBiblio
2772
2782
2773
    EmbedItemsInMarcBiblio({
2783
    EmbedItemsInMarcBiblio({
2774
        marc_record  => $marc,
2784
        marc_record   => $marc,
2775
        biblionumber => $biblionumber,
2785
        biblionumber  => $biblionumber,
2776
        item_numbers => $itemnumbers,
2786
        item_numbers  => $itemnumbers,
2777
        opac         => $opac });
2787
        opac          => $opac,
2788
        borcat        => $patron_categorycode,
2789
        patron_branch => $patron_branch });
2778
2790
2779
Given a MARC::Record object containing a bib record,
2791
Given a MARC::Record object containing a bib record,
2780
modify it to include the items attached to it as 9XX
2792
modify it to include the items attached to it as 9XX
Lines 2783-2796 if $itemnumbers is defined, only specified itemnumbers are embedded. Link Here
2783
2795
2784
If $opac is true, then opac-relevant suppressions are included.
2796
If $opac is true, then opac-relevant suppressions are included.
2785
2797
2786
If opac filtering will be done, borcat should be passed to properly
2798
If opac filtering will be done, borcat and patron_branch should
2787
override if necessary.
2799
be passed to properly override if necessary.
2788
2800
2789
=cut
2801
=cut
2790
2802
2791
sub EmbedItemsInMarcBiblio {
2803
sub EmbedItemsInMarcBiblio {
2792
    my ($params) = @_;
2804
    my ($params) = @_;
2793
    my ($marc, $biblionumber, $itemnumbers, $opac, $borcat);
2805
    my ($marc, $biblionumber, $itemnumbers, $opac, $borcat, $patron_branch);
2794
    $marc = $params->{marc_record};
2806
    $marc = $params->{marc_record};
2795
    if ( !$marc ) {
2807
    if ( !$marc ) {
2796
        carp 'EmbedItemsInMarcBiblio: No MARC record passed';
2808
        carp 'EmbedItemsInMarcBiblio: No MARC record passed';
Lines 2800-2805 sub EmbedItemsInMarcBiblio { Link Here
2800
    $itemnumbers = $params->{item_numbers};
2812
    $itemnumbers = $params->{item_numbers};
2801
    $opac = $params->{opac};
2813
    $opac = $params->{opac};
2802
    $borcat = $params->{borcat} // q{};
2814
    $borcat = $params->{borcat} // q{};
2815
    $patron_branch = $params->{patron_branch} // q{};
2803
2816
2804
    $itemnumbers = [] unless defined $itemnumbers;
2817
    $itemnumbers = [] unless defined $itemnumbers;
2805
2818
Lines 2831-2837 sub EmbedItemsInMarcBiblio { Link Here
2831
      $opachiddenitems
2844
      $opachiddenitems
2832
      ? C4::Items::GetHiddenItemnumbers({
2845
      ? C4::Items::GetHiddenItemnumbers({
2833
            items  => \@items2pass,
2846
            items  => \@items2pass,
2834
            borcat => $borcat })
2847
            borcat => $borcat,
2848
            patron_branch => $patron_branch })
2835
      : ();
2849
      : ();
2836
    # Convert to a hash for quick searching
2850
    # Convert to a hash for quick searching
2837
    my %hiddenitems = map { $_ => 1 } @hiddenitems;
2851
    my %hiddenitems = map { $_ => 1 } @hiddenitems;
(-)a/C4/Items.pm (-9 / +26 lines)
Lines 1232-1256 sub get_hostitemnumbers_of { Link Here
1232
1232
1233
=head2 GetHiddenItemnumbers
1233
=head2 GetHiddenItemnumbers
1234
1234
1235
    my @itemnumbers_to_hide = GetHiddenItemnumbers({ items => \@items, borcat => $category });
1235
    my @itemnumbers_to_hide = GetHiddenItemnumbers({\
1236
        items => \@items,\
1237
        borcat => $category,\
1238
        patron_branch => $patron_branch });
1236
1239
1237
Given a list of items it checks which should be hidden from the OPAC given
1240
Given a list of items it checks which should be hidden
1238
the current configuration. Returns a list of itemnumbers corresponding to
1241
from the OPAC given the current configuration. Returns a
1239
those that should be hidden. Optionally takes a borcat parameter for certain borrower types
1242
list of itemnumbers corresponding to those that should be
1240
to be excluded
1243
hidden. Optionally takes a borcat and patron_branch parameter
1244
so certain borrowers can override this hidden functionality.
1241
1245
1242
=cut
1246
=cut
1243
1247
1244
sub GetHiddenItemnumbers {
1248
sub GetHiddenItemnumbers {
1245
    my $params = shift;
1249
    my $params = shift;
1246
    my $items = $params->{items};
1250
    my $items = $params->{items};
1247
    if (my $exceptions = C4::Context->preference('OpacHiddenItemsExceptions') and $params->{'borcat'}){
1251
    my $patron_categorycode = $params->{borcat} // q{};
1252
    if (my $exceptions = C4::Context->preference('OpacHiddenItemsExceptions') and $patron_categorycode){
1248
        foreach my $except (split(/\|/, $exceptions)){
1253
        foreach my $except (split(/\|/, $exceptions)){
1249
            if ($params->{'borcat'} eq $except){
1254
            if ($patron_categorycode eq $except){
1250
                return; # we don't hide anything for this borrower category
1255
                return; # we don't hide anything for this borrower category
1251
            }
1256
            }
1252
        }
1257
        }
1253
    }
1258
    }
1259
    my $patron_branch = $params->{'patron_branch'} // q{};
1254
    my @resultitems;
1260
    my @resultitems;
1255
1261
1256
    my $yaml = C4::Context->preference('OpacHiddenItems');
1262
    my $yaml = C4::Context->preference('OpacHiddenItems');
Lines 1266-1271 sub GetHiddenItemnumbers { Link Here
1266
    }
1272
    }
1267
    my $dbh = C4::Context->dbh;
1273
    my $dbh = C4::Context->dbh;
1268
1274
1275
    my $local_exceptions_string = C4::Context->preference('OpacHiddenItemsLocalExceptions') // q{};
1276
    my @local_exceptions = split /\|/, $local_exceptions_string;
1269
    # For each item
1277
    # For each item
1270
    foreach my $item (@$items) {
1278
    foreach my $item (@$items) {
1271
1279
Lines 1284-1291 sub GetHiddenItemnumbers { Link Here
1284
            # If the results matches the values in the yaml file
1292
            # If the results matches the values in the yaml file
1285
            if (any { $val eq $_ } @{$hidingrules->{$field}}) {
1293
            if (any { $val eq $_ } @{$hidingrules->{$field}}) {
1286
1294
1287
                # We add the itemnumber to the list
1295
                # override for branch items for patrons of that branch?
1288
                push @resultitems, $item->{'itemnumber'};
1296
                my $override = 0;
1297
                if ( $patron_branch eq $item->{'homebranch'} &&
1298
                     any { /^$patron_categorycode$/ } @local_exceptions ) {
1299
1300
                    $override = 1;
1301
                }
1302
                if ($override==0) {
1303
                    # We add the itemnumber to the list
1304
                    push @resultitems, $item->{'itemnumber'};
1305
                }
1289
1306
1290
                # If at least one rule matched for an item, no need to test the others
1307
                # If at least one rule matched for an item, no need to test the others
1291
                last;
1308
                last;
(-)a/C4/Search.pm (-1 / +1 lines)
Lines 2082-2088 sub searchResults { Link Here
2082
                    next;
2082
                    next;
2083
                }
2083
                }
2084
                # hidden based on OpacHiddenItems syspref
2084
                # hidden based on OpacHiddenItems syspref
2085
                my @hi = C4::Items::GetHiddenItemnumbers({ items=> [ $item ], borcat => $search_context->{category} });
2085
                my @hi = C4::Items::GetHiddenItemnumbers({ items=> [ $item ], borcat => $search_context->{category}, patron_branch => $search_context->{patron_branch} });
2086
                if (scalar @hi) {
2086
                if (scalar @hi) {
2087
                    push @hiddenitems, @hi;
2087
                    push @hiddenitems, @hi;
2088
                    $hideatopac_count++;
2088
                    $hideatopac_count++;
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 355-360 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
355
('opacheader','','70|10','Add HTML to be included as a custom header in the OPAC','Textarea'),
355
('opacheader','','70|10','Add HTML to be included as a custom header in the OPAC','Textarea'),
356
('OpacHiddenItems','','','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations.','Textarea'),
356
('OpacHiddenItems','','','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations.','Textarea'),
357
('OpacHiddenItemsExceptions','',NULL,'List of borrower categories, separated by |, that can see items otherwise hidden by OpacHiddenItems','Textarea'),
357
('OpacHiddenItemsExceptions','',NULL,'List of borrower categories, separated by |, that can see items otherwise hidden by OpacHiddenItems','Textarea'),
358
('OpacHiddenItemsLocalExceptions','',NULL,"List of borrower categories, separated by |, that allows logged in patrons whose branch matches the item's homebranch to see what otherwise would be hidden by OpacHiddenItems",'Textarea'),
358
('OpacHighlightedWords','1','','If Set, then queried words are higlighted in OPAC','YesNo'),
359
('OpacHighlightedWords','1','','If Set, then queried words are higlighted in OPAC','YesNo'),
359
('OPACHoldingsDefaultSortField','first_column','first_column|homebranch|holdingbranch','Default sort field for the holdings table at the OPAC','choice'),
360
('OPACHoldingsDefaultSortField','first_column','first_column|homebranch|holdingbranch','Default sort field for the holdings table at the OPAC','choice'),
360
('OPACHoldsIfAvailableAtPickup','1','','Allow to pickup up holds at libraries where the item is available','YesNo'),
361
('OPACHoldsIfAvailableAtPickup','1','','Allow to pickup up holds at libraries where the item is available','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+3 lines)
Lines 595-600 OPAC: Link Here
595
            - pref: OpacHiddenItemsExceptions
595
            - pref: OpacHiddenItemsExceptions
596
            - List of borrower categories, separated by |, that can see items otherwise hidden by <tt>OpacHiddenItems</tt>
596
            - List of borrower categories, separated by |, that can see items otherwise hidden by <tt>OpacHiddenItems</tt>
597
        -
597
        -
598
            - pref: OpacHiddenItemsLocalExceptions
599
            - List of borrower categories, separated by |, that allows logged in patrons whose branch matches an item's homebranch to see items otherwise hidden by <tt>OpacHiddenItems</tt>
600
        -
598
            - pref: OpacAllowPublicListCreation
601
            - pref: OpacAllowPublicListCreation
599
              default: 1
602
              default: 1
600
              choices:
603
              choices:
(-)a/opac/opac-ISBDdetail.pl (-4 / +9 lines)
Lines 80-94 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
80
80
81
my $patron = Koha::Patrons->find( $loggedinuser );
81
my $patron = Koha::Patrons->find( $loggedinuser );
82
my $borcat = q{};
82
my $borcat = q{};
83
my $patron_branch = q{};
83
if ( $patron && C4::Context->preference('OpacHiddenItemsExceptions') ) {
84
if ( $patron && C4::Context->preference('OpacHiddenItemsExceptions') ) {
84
    $borcat = $patron->categorycode;
85
    $borcat = $patron->categorycode;
85
}
86
}
87
if ( $patron && C4::Context->preference('OpacHiddenItemsLocalExceptions') ) {
88
    $patron_branch = $patron->branchcode;
89
}
86
90
87
my $record = GetMarcBiblio({
91
my $record = GetMarcBiblio({
88
    biblionumber => $biblionumber,
92
    biblionumber  => $biblionumber,
89
    embed_items  => 1,
93
    embed_items   => 1,
90
    opac         => 1,
94
    opac          => 1,
91
    borcat       => $borcat });
95
    borcat        => $borcat,
96
    patron_branch => $patron_branch });
92
if ( ! $record ) {
97
if ( ! $record ) {
93
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
98
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
94
    exit;
99
    exit;
(-)a/opac/opac-MARCdetail.pl (-4 / +9 lines)
Lines 86-101 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
86
86
87
my $patron = Koha::Patrons->find( $loggedinuser );
87
my $patron = Koha::Patrons->find( $loggedinuser );
88
my $borcat = q{};
88
my $borcat = q{};
89
my $patron_branch = q{};
89
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
90
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
90
    # we need to fetch the borrower info here, so we can pass the category
91
    # we need to fetch the borrower info here, so we can pass the category
91
    $borcat = $patron ? $patron->categorycode : $borcat;
92
    $borcat = $patron ? $patron->categorycode : $borcat;
92
}
93
}
94
if ( C4::Context->preference('OpacHiddenItemsLocalExceptions') ) {
95
    $patron_branch = $patron ? $patron->branchcode : $patron_branch;
96
}
93
97
94
my $record = GetMarcBiblio({
98
my $record = GetMarcBiblio({
95
    biblionumber => $biblionumber,
99
    biblionumber  => $biblionumber,
96
    embed_items  => 1,
100
    embed_items   => 1,
97
    opac         => 1,
101
    opac          => 1,
98
    borcat       => $borcat });
102
    borcat        => $borcat,
103
    patron_branch => $patron_branch });
99
if ( ! $record ) {
104
if ( ! $record ) {
100
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
105
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
101
    exit;
106
    exit;
(-)a/opac/opac-basket.pl (-2 / +6 lines)
Lines 58-69 if (C4::Context->preference('TagsEnabled')) { Link Here
58
	}
58
	}
59
}
59
}
60
60
61
my $patron = Koha::Patrons->find($borrowernumber);
61
my $borcat = q{};
62
my $borcat = q{};
63
my $patron_branch = q{};
62
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
64
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
63
    # we need to fetch the borrower info here, so we can pass the category
65
    # we need to fetch the borrower info here, so we can pass the category
64
    my $patron = Koha::Patrons->find($borrowernumber);
65
    $borcat = $patron ? $patron->categorycode : $borcat;
66
    $borcat = $patron ? $patron->categorycode : $borcat;
66
}
67
}
68
if ( C4::Context->preference('OpacHiddenItemsLocalExceptions') ) {
69
    $patron_branch = $patron ? $patron->branchcode : $patron_branch;
70
}
67
71
68
my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
72
my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
69
foreach my $biblionumber ( @bibs ) {
73
foreach my $biblionumber ( @bibs ) {
Lines 92-98 foreach my $biblionumber ( @bibs ) { Link Here
92
    my @all_items        = &GetItemsInfo( $biblionumber );
96
    my @all_items        = &GetItemsInfo( $biblionumber );
93
97
94
    # determine which ones should be hidden / visible
98
    # determine which ones should be hidden / visible
95
    my @hidden_items     = GetHiddenItemnumbers({ items => \@all_items, borcat => $borcat });
99
    my @hidden_items     = GetHiddenItemnumbers({ items => \@all_items, borcat => $borcat, patron_branch => $patron_branch });
96
100
97
    # If every item is hidden, then the biblio should be hidden too.
101
    # If every item is hidden, then the biblio should be hidden too.
98
    next if (scalar @all_items >= 1 && scalar @hidden_items == scalar @all_items);
102
    next if (scalar @all_items >= 1 && scalar @hidden_items == scalar @all_items);
(-)a/opac/opac-detail.pl (-2 / +7 lines)
Lines 86-94 my @all_items = GetItemsInfo($biblionumber); Link Here
86
my @hiddenitems;
86
my @hiddenitems;
87
my $patron = Koha::Patrons->find( $borrowernumber );
87
my $patron = Koha::Patrons->find( $borrowernumber );
88
our $borcat= q{};
88
our $borcat= q{};
89
our $patron_branch = q{};
89
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
90
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
90
    $borcat = $patron ? $patron->categorycode : q{};
91
    $borcat = $patron ? $patron->categorycode : q{};
91
}
92
}
93
if ( C4::Context->preference('OpacHiddenItemsLocalExceptions') ) {
94
    $patron_branch = $patron ? $patron->branchcode : q{};
95
}
92
96
93
my $record = GetMarcBiblio({
97
my $record = GetMarcBiblio({
94
    biblionumber => $biblionumber,
98
    biblionumber => $biblionumber,
Lines 100-106 if ( ! $record ) { Link Here
100
104
101
if ( scalar @all_items >= 1 ) {
105
if ( scalar @all_items >= 1 ) {
102
    push @hiddenitems,
106
    push @hiddenitems,
103
      GetHiddenItemnumbers( { items => \@all_items, borcat => $borcat } );
107
      GetHiddenItemnumbers( { items => \@all_items, borcat => $borcat, patron_branch => $patron_branch } );
104
108
105
    if (scalar @hiddenitems == scalar @all_items ) {
109
    if (scalar @hiddenitems == scalar @all_items ) {
106
        print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
110
        print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
Lines 242-248 if ($session->param('busc')) { Link Here
242
        my @newresults;
246
        my @newresults;
243
        my $search_context = {
247
        my $search_context = {
244
            'interface' => 'opac',
248
            'interface' => 'opac',
245
            'category'  => $borcat
249
            'category'  => $borcat,
250
            'patron_branch' => $patron_branch
246
        };
251
        };
247
        for (my $i=0;$i<@servers;$i++) {
252
        for (my $i=0;$i<@servers;$i++) {
248
            my $server = $servers[$i];
253
            my $server = $servers[$i];
(-)a/opac/opac-downloadcart.pl (-6 / +11 lines)
Lines 49-59 my $dbh = C4::Context->dbh; Link Here
49
49
50
if ($bib_list && $format) {
50
if ($bib_list && $format) {
51
51
52
    my $patron = Koha::Patrons->find( { borrowernumber => $borrowernumber } );
52
    my $borcat = q{};
53
    my $borcat = q{};
54
    my $patron_branch = q{};
53
    if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
55
    if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
54
        # we need to fetch the borrower info here, so we can pass the category
56
        # we need to fetch the borrower info here, so we can pass the category
55
        my $borrower = Koha::Patrons->find( { borrowernumber => $borrowernumber } );
57
        $borcat = $patron ? $patron->categorycode : $borcat;
56
        $borcat = $borrower ? $borrower->categorycode : $borcat;
58
    }
59
    if ( C4::Context->preference('OpacHiddenItemsLocalExceptions') ) {
60
        $patron_branch = $patron ? $patron->branchcode : $patron_branch;
57
    }
61
    }
58
62
59
    my @bibs = split( /\//, $bib_list );
63
    my @bibs = split( /\//, $bib_list );
Lines 76-85 if ($bib_list && $format) { Link Here
76
        foreach my $biblio (@bibs) {
80
        foreach my $biblio (@bibs) {
77
81
78
            my $record = GetMarcBiblio({
82
            my $record = GetMarcBiblio({
79
                biblionumber => $biblio,
83
                biblionumber  => $biblio,
80
                embed_items  => 1,
84
                embed_items   => 1,
81
                opac         => 1,
85
                opac          => 1,
82
                borcat       => $borcat });
86
                borcat        => $borcat,
87
                patron_branch => $patron_branch });
83
            my $framework = &GetFrameworkCode( $biblio );
88
            my $framework = &GetFrameworkCode( $biblio );
84
            $record_processor->options({
89
            $record_processor->options({
85
                interface => 'opac',
90
                interface => 'opac',
(-)a/opac/opac-downloadshelf.pl (-2 / +6 lines)
Lines 50-60 my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( Link Here
50
    }
50
    }
51
);
51
);
52
52
53
my $patron = Koha::Patrons->find( { borrowernumber => $borrowernumber } );
53
my $borcat = q{};
54
my $borcat = q{};
55
my $patron_branch = q{};
54
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
56
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
55
    # we need to fetch the borrower info here, so we can pass the category
57
    # we need to fetch the borrower info here, so we can pass the category
56
    my $borrower = Koha::Patrons->find( { borrowernumber => $borrowernumber } );
58
    $borcat = $patron ? $patron->categorycode : $borcat;
57
    $borcat = $borrower ? $borrower->categorycode : $borcat;
59
}
60
if ( C4::Context->preference('OpacHiddenItemsLocalExceptions') ) {
61
    $patron_branch = $patron ? $patron->branchcode : $patron_branch;
58
}
62
}
59
63
60
my $shelfnumber = $query->param('shelfnumber');
64
my $shelfnumber = $query->param('shelfnumber');
(-)a/opac/opac-export.pl (-7 / +13 lines)
Lines 38-59 my $error = q{}; Link Here
38
# Determine logged in user's patron category.
38
# Determine logged in user's patron category.
39
# Blank if not logged in.
39
# Blank if not logged in.
40
my $userenv = C4::Context->userenv;
40
my $userenv = C4::Context->userenv;
41
my $borrowernumber;
42
my $patron;
41
my $borcat = q{};
43
my $borcat = q{};
44
my $patron_branch = q{};
45
42
if ($userenv) {
46
if ($userenv) {
43
    my $borrowernumber = $userenv->{'number'};
47
    $borrowernumber = $userenv->{'number'};
44
    if ($borrowernumber) {
48
    if ($borrowernumber) {
45
        my $borrower = Koha::Patrons->find( { borrowernumber => $borrowernumber } );
49
        $patron = Koha::Patrons->find( { borrowernumber => $borrowernumber } );
46
        $borcat = $borrower ? $borrower->categorycode : $borcat;
47
    }
50
    }
48
}
51
}
52
$borcat = $patron ? $patron->categorycode : $borcat;
53
$patron_branch = $patron ? $patron->branchcode : $patron_branch;
49
54
50
my $include_items = ($format =~ /bibtex/) ? 0 : 1;
55
my $include_items = ($format =~ /bibtex/) ? 0 : 1;
51
my $marc = $biblionumber
56
my $marc = $biblionumber
52
    ? GetMarcBiblio({
57
    ? GetMarcBiblio({
53
        biblionumber => $biblionumber,
58
        biblionumber  => $biblionumber,
54
        embed_items  => $include_items,
59
        embed_items   => $include_items,
55
        opac         => 1,
60
        opac          => 1,
56
        borcat       => $borcat })
61
        borcat        => $borcat,
62
        patron_branch => $patron_branch })
57
    : undef;
63
    : undef;
58
64
59
if(!$marc) {
65
if(!$marc) {
(-)a/opac/opac-search.pl (+3 lines)
Lines 632-637 $search_context->{'interface'} = 'opac'; Link Here
632
if (C4::Context->preference('OpacHiddenItemsExceptions')){
632
if (C4::Context->preference('OpacHiddenItemsExceptions')){
633
    $search_context->{'category'} = $patron ? $patron->categorycode : q{};
633
    $search_context->{'category'} = $patron ? $patron->categorycode : q{};
634
}
634
}
635
if (C4::Context->preference('OpacHiddenItemsLocalExceptions')){
636
    $search_context->{'patron_branch'} = $patron ? $patron->branchcode : q{};
637
}
635
638
636
for (my $i=0;$i<@servers;$i++) {
639
for (my $i=0;$i<@servers;$i++) {
637
    my $server = $servers[$i];
640
    my $server = $servers[$i];
(-)a/opac/opac-sendbasket.pl (-4 / +6 lines)
Lines 60-65 if ( $email_add ) { Link Here
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 $borcat = $patron ? $patron->categorycode : q{};
63
    my $patron_branch = $patron ? $patron->branchcode : q{};
63
    my $user_email = $patron->first_valid_email_address
64
    my $user_email = $patron->first_valid_email_address
64
    || C4::Context->preference('KohaAdminEmailAddress');
65
    || C4::Context->preference('KohaAdminEmailAddress');
65
66
Lines 89-98 if ( $email_add ) { Link Here
89
        my $dat              = GetBiblioData($biblionumber);
90
        my $dat              = GetBiblioData($biblionumber);
90
        next unless $dat;
91
        next unless $dat;
91
        my $record           = GetMarcBiblio({
92
        my $record           = GetMarcBiblio({
92
            biblionumber => $biblionumber,
93
            biblionumber  => $biblionumber,
93
            embed_items  => 1,
94
            embed_items   => 1,
94
            opac         => 1,
95
            opac          => 1,
95
            borcat       => $borcat });
96
            borcat        => $borcat,
97
            patron_branch => $patron_branch });
96
        my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
98
        my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
97
        my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
99
        my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
98
100
(-)a/opac/opac-sendshelf.pl (-4 / +6 lines)
Lines 81-86 if ( $email ) { Link Here
81
81
82
    my $patron = Koha::Patrons->find( $borrowernumber );
82
    my $patron = Koha::Patrons->find( $borrowernumber );
83
    my $borcat = $patron ? $patron->categorycode : q{};
83
    my $borcat = $patron ? $patron->categorycode : q{};
84
    my $patron_branch = $patron ? $patron->branchcode : q{};
84
85
85
    my $shelf = Koha::Virtualshelves->find( $shelfid );
86
    my $shelf = Koha::Virtualshelves->find( $shelfid );
86
    my $contents = $shelf->get_contents;
87
    my $contents = $shelf->get_contents;
Lines 91-100 if ( $email ) { Link Here
91
    while ( my $content = $contents->next ) {
92
    while ( my $content = $contents->next ) {
92
        my $biblionumber = $content->biblionumber;
93
        my $biblionumber = $content->biblionumber;
93
        my $record           = GetMarcBiblio({
94
        my $record           = GetMarcBiblio({
94
            biblionumber => $biblionumber,
95
            biblionumber  => $biblionumber,
95
            embed_items  => 1,
96
            embed_items   => 1,
96
            opac         => 1,
97
            opac          => 1,
97
            borcat       => $borcat });
98
            borcat        => $borcat,
99
            patron_branch => $patron_branch });
98
        next unless $record;
100
        next unless $record;
99
        my $fw               = GetFrameworkCode($biblionumber);
101
        my $fw               = GetFrameworkCode($biblionumber);
100
        my $dat              = GetBiblioData($biblionumber);
102
        my $dat              = GetBiblioData($biblionumber);
(-)a/opac/opac-tags.pl (-9 / +14 lines)
Lines 228-237 if ($is_ajax) { Link Here
228
my $results = [];
228
my $results = [];
229
my $my_tags = [];
229
my $my_tags = [];
230
my $borcat  = q{};
230
my $borcat  = q{};
231
my $patron_branch  = q{};
231
232
232
if ($loggedinuser) {
233
if ($loggedinuser) {
233
    my $patron = Koha::Patrons->find( { borrowernumber => $loggedinuser } );
234
    my $patron = Koha::Patrons->find( { borrowernumber => $loggedinuser } );
234
    $borcat = $patron ? $patron->categorycode : $borcat;
235
    $borcat = $patron ? $patron->categorycode : $borcat;
236
    $patron_branch = $patron ? $patron->branchcode : $patron_branch;
235
    my $should_hide = C4::Context->preference('OpacHiddenItems') // q{};
237
    my $should_hide = C4::Context->preference('OpacHiddenItems') // q{};
236
    $should_hide = ( $should_hide =~ /\S/ ) ? 1 : 0;
238
    $should_hide = ( $should_hide =~ /\S/ ) ? 1 : 0;
237
    $my_tags = get_tag_rows({borrowernumber=>$loggedinuser});
239
    $my_tags = get_tag_rows({borrowernumber=>$loggedinuser});
Lines 240-249 if ($loggedinuser) { Link Here
240
        $tag->{visible} = 0;
242
        $tag->{visible} = 0;
241
        my $biblio = Koha::Biblios->find( $tag->{biblionumber} );
243
        my $biblio = Koha::Biblios->find( $tag->{biblionumber} );
242
        my $record = &GetMarcBiblio({
244
        my $record = &GetMarcBiblio({
243
            biblionumber => $tag->{biblionumber},
245
            biblionumber  => $tag->{biblionumber},
244
            embed_items  => 1,
246
            embed_items   => 1,
245
            opac         => 1,
247
            opac          => 1,
246
            borcat       => $borcat });
248
            borcat        => $borcat,
249
            patron_branch => $patron_branch });
247
        next unless $record;
250
        next unless $record;
248
        my $hidden_items = undef;
251
        my $hidden_items = undef;
249
        my @hidden_itemnumbers;
252
        my @hidden_itemnumbers;
Lines 252-258 if ($loggedinuser) { Link Here
252
            @all_items = GetItemsInfo( $tag->{biblionumber} );
255
            @all_items = GetItemsInfo( $tag->{biblionumber} );
253
            @hidden_itemnumbers = GetHiddenItemnumbers({
256
            @hidden_itemnumbers = GetHiddenItemnumbers({
254
                items => \@all_items,
257
                items => \@all_items,
255
                borcat => $borcat });
258
                borcat => $borcat,
259
                patron_branch => $patron_branch });
256
            $hidden_items = \@hidden_itemnumbers;
260
            $hidden_items = \@hidden_itemnumbers;
257
        }
261
        }
258
        next if ( $should_hide && scalar @all_items == scalar @hidden_itemnumbers );
262
        next if ( $should_hide && scalar @all_items == scalar @hidden_itemnumbers );
Lines 310-319 if ($add_op) { Link Here
310
        if (grep { $_->{term} eq $my_tag->{term} } @$results) {
314
        if (grep { $_->{term} eq $my_tag->{term} } @$results) {
311
            if (! $my_tag->{visible} ) {
315
            if (! $my_tag->{visible} ) {
312
                my $check_biblio = GetMarcBiblio({
316
                my $check_biblio = GetMarcBiblio({
313
                    biblionumber => $my_tag->{biblionumber},
317
                    biblionumber  => $my_tag->{biblionumber},
314
                    embed_items  => 1,
318
                    embed_items   => 1,
315
                    opac         => 1,
319
                    opac          => 1,
316
                    borcat       => $borcat });
320
                    borcat        => $borcat,
321
                    patron_branch => $patron_branch });
317
                if ($check_biblio) {
322
                if ($check_biblio) {
318
                    push @filtered_results, $my_tag;
323
                    push @filtered_results, $my_tag;
319
                }
324
                }
(-)a/opac/opac-user.pl (-5 / +6 lines)
Lines 92-97 my $patron = Koha::Patrons->find( $borrowernumber ); Link Here
92
my $borr = $patron->unblessed;
92
my $borr = $patron->unblessed;
93
# unblessed is a hash vs. object/undef. Hence the use of curly braces here.
93
# unblessed is a hash vs. object/undef. Hence the use of curly braces here.
94
my $borcat = $borr ? $borr->{categorycode} : q{};
94
my $borcat = $borr ? $borr->{categorycode} : q{};
95
my $patron_branch = $borr ? $borr->{branchcode} : q{};
95
96
96
my (  $today_year,   $today_month,   $today_day) = Today();
97
my (  $today_year,   $today_month,   $today_day) = Today();
97
my ($warning_year, $warning_month, $warning_day) = split /-/, $borr->{'dateexpiry'};
98
my ($warning_year, $warning_month, $warning_day) = split /-/, $borr->{'dateexpiry'};
Lines 213-222 if ( $pending_checkouts->count ) { # Useless test Link Here
213
        $issue->{rentalfines} = $rental_fines->total_outstanding;
214
        $issue->{rentalfines} = $rental_fines->total_outstanding;
214
215
215
        my $marcrecord = GetMarcBiblio({
216
        my $marcrecord = GetMarcBiblio({
216
            biblionumber => $issue->{'biblionumber'},
217
            biblionumber  => $issue->{'biblionumber'},
217
            embed_items  => 1,
218
            embed_items   => 1,
218
            opac         => 1,
219
            opac          => 1,
219
            borcat       => $borcat });
220
            borcat        => $borcat,
221
            patron_branch => $patron_branch });
220
        $issue->{'subtitle'} = GetRecordValue('subtitle', $marcrecord, GetFrameworkCode($issue->{'biblionumber'}));
222
        $issue->{'subtitle'} = GetRecordValue('subtitle', $marcrecord, GetFrameworkCode($issue->{'biblionumber'}));
221
        # check if item is renewable
223
        # check if item is renewable
222
        my ($status,$renewerror) = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} );
224
        my ($status,$renewerror) = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} );
223
- 

Return to bug 10589