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

(-)a/C4/Biblio.pm (-7 / +40 lines)
Lines 1166-1172 sub GetMarcSubfieldStructureFromKohaField { Link Here
1166
  my $record = GetMarcBiblio({
1166
  my $record = GetMarcBiblio({
1167
      biblionumber => $biblionumber,
1167
      biblionumber => $biblionumber,
1168
      embed_items  => $embeditems,
1168
      embed_items  => $embeditems,
1169
      opac         => $opac });
1169
      opac         => $opac,
1170
      borcat       => $patron_category });
1170
1171
1171
Returns MARC::Record representing a biblio record, or C<undef> if the
1172
Returns MARC::Record representing a biblio record, or C<undef> if the
1172
biblionumber doesn't exist.
1173
biblionumber doesn't exist.
Lines 1190-1195 set to true to include item information. Link Here
1190
set to true to make the result suited for OPAC view. This causes things like
1191
set to true to make the result suited for OPAC view. This causes things like
1191
OpacHiddenItems to be applied.
1192
OpacHiddenItems to be applied.
1192
1193
1194
=item C<$borcat>
1195
1196
If the OpacHiddenItemsExceptions system preference is set, this patron category
1197
can be used to make visible OPAC items which would be normally hidden.
1198
It only makes sense in combination both embed_items and opac values true.
1199
1193
=back
1200
=back
1194
1201
1195
=cut
1202
=cut
Lines 1205-1210 sub GetMarcBiblio { Link Here
1205
    my $biblionumber = $params->{biblionumber};
1212
    my $biblionumber = $params->{biblionumber};
1206
    my $embeditems   = $params->{embed_items} || 0;
1213
    my $embeditems   = $params->{embed_items} || 0;
1207
    my $opac         = $params->{opac} || 0;
1214
    my $opac         = $params->{opac} || 0;
1215
    my $borcat       = $params->{borcat} // q{};
1208
1216
1209
    if (not defined $biblionumber) {
1217
    if (not defined $biblionumber) {
1210
        carp 'GetMarcBiblio called with undefined biblionumber';
1218
        carp 'GetMarcBiblio called with undefined biblionumber';
Lines 1232-1238 sub GetMarcBiblio { Link Here
1232
1240
1233
        C4::Biblio::_koha_marc_update_bib_ids( $record, $frameworkcode, $biblionumber,
1241
        C4::Biblio::_koha_marc_update_bib_ids( $record, $frameworkcode, $biblionumber,
1234
            $biblioitemnumber );
1242
            $biblioitemnumber );
1235
        C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, undef, $opac )
1243
        C4::Biblio::EmbedItemsInMarcBiblio({
1244
            marc_record  => $record,
1245
            biblionumber => $biblionumber,
1246
            opac         => $opac,
1247
            borcat       => $borcat })
1236
          if ($embeditems);
1248
          if ($embeditems);
1237
1249
1238
        return $record;
1250
        return $record;
Lines 2793-2799 sub ModZebra { Link Here
2793
2805
2794
=head2 EmbedItemsInMarcBiblio
2806
=head2 EmbedItemsInMarcBiblio
2795
2807
2796
    EmbedItemsInMarcBiblio($marc, $biblionumber, $itemnumbers, $opac);
2808
    EmbedItemsInMarcBiblio({
2809
        marc_record  => $marc,
2810
        biblionumber => $biblionumber,
2811
        item_numbers => $itemnumbers,
2812
        opac         => $opac });
2797
2813
2798
Given a MARC::Record object containing a bib record,
2814
Given a MARC::Record object containing a bib record,
2799
modify it to include the items attached to it as 9XX
2815
modify it to include the items attached to it as 9XX
Lines 2802-2815 if $itemnumbers is defined, only specified itemnumbers are embedded. Link Here
2802
2818
2803
If $opac is true, then opac-relevant suppressions are included.
2819
If $opac is true, then opac-relevant suppressions are included.
2804
2820
2821
If opac filtering will be done, borcat should be passed to properly
2822
override if necessary.
2823
2805
=cut
2824
=cut
2806
2825
2807
sub EmbedItemsInMarcBiblio {
2826
sub EmbedItemsInMarcBiblio {
2808
    my ($marc, $biblionumber, $itemnumbers, $opac) = @_;
2827
    my ($params) = @_;
2828
    my ($marc, $biblionumber, $itemnumbers, $opac, $borcat);
2829
    $marc = $params->{marc_record};
2809
    if ( !$marc ) {
2830
    if ( !$marc ) {
2810
        carp 'EmbedItemsInMarcBiblio: No MARC record passed';
2831
        carp 'EmbedItemsInMarcBiblio: No MARC record passed';
2811
        return;
2832
        return;
2812
    }
2833
    }
2834
    $biblionumber = $params->{biblionumber};
2835
    $itemnumbers = $params->{item_numbers};
2836
    $opac = $params->{opac};
2837
    $borcat = $params->{borcat} // q{};
2813
2838
2814
    $itemnumbers = [] unless defined $itemnumbers;
2839
    $itemnumbers = [] unless defined $itemnumbers;
2815
2840
Lines 2820-2839 sub EmbedItemsInMarcBiblio { Link Here
2820
    my $dbh = C4::Context->dbh;
2845
    my $dbh = C4::Context->dbh;
2821
    my $sth = $dbh->prepare("SELECT itemnumber FROM items WHERE biblionumber = ?");
2846
    my $sth = $dbh->prepare("SELECT itemnumber FROM items WHERE biblionumber = ?");
2822
    $sth->execute($biblionumber);
2847
    $sth->execute($biblionumber);
2823
    my @item_fields;
2824
    my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber", $frameworkcode );
2848
    my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber", $frameworkcode );
2825
    my @items;
2849
2850
    my @item_fields; # Array holding the actual MARC data for items to be included.
2851
    my @items;       # Array holding items which are both in the list ($itenumbers)
2852
                     # and on this biblionumber.
2853
2854
    # Flag indicating if there is potential hiding.
2826
    my $opachiddenitems = $opac
2855
    my $opachiddenitems = $opac
2827
      && ( C4::Context->preference('OpacHiddenItems') !~ /^\s*$/ );
2856
      && ( C4::Context->preference('OpacHiddenItems') !~ /^\s*$/ );
2857
2828
    require C4::Items;
2858
    require C4::Items;
2829
    while ( my ($itemnumber) = $sth->fetchrow_array ) {
2859
    while ( my ($itemnumber) = $sth->fetchrow_array ) {
2830
        next if @$itemnumbers and not grep { $_ == $itemnumber } @$itemnumbers;
2860
        next if @$itemnumbers and not grep { $_ == $itemnumber } @$itemnumbers;
2831
        my $i = $opachiddenitems ? C4::Items::GetItem($itemnumber) : undef;
2861
        my $i = $opachiddenitems ? C4::Items::GetItem($itemnumber) : undef;
2832
        push @items, { itemnumber => $itemnumber, item => $i };
2862
        push @items, { itemnumber => $itemnumber, item => $i };
2833
    }
2863
    }
2864
    my @items2pass = map { $_->{item} } @items;
2834
    my @hiddenitems =
2865
    my @hiddenitems =
2835
      $opachiddenitems
2866
      $opachiddenitems
2836
      ? C4::Items::GetHiddenItemnumbers( map { $_->{item} } @items )
2867
      ? C4::Items::GetHiddenItemnumbers({
2868
            items  => \@items2pass,
2869
            borcat => $borcat })
2837
      : ();
2870
      : ();
2838
    # Convert to a hash for quick searching
2871
    # Convert to a hash for quick searching
2839
    my %hiddenitems = map { $_ => 1 } @hiddenitems;
2872
    my %hiddenitems = map { $_ => 1 } @hiddenitems;
(-)a/C4/Record.pm (-1 / +4 lines)
Lines 473-479 sub marcrecord2csv { Link Here
473
    # Getting the record
473
    # Getting the record
474
    my $record = GetMarcBiblio({ biblionumber => $biblio });
474
    my $record = GetMarcBiblio({ biblionumber => $biblio });
475
    return unless $record;
475
    return unless $record;
476
    C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblio, $itemnumbers );
476
    C4::Biblio::EmbedItemsInMarcBiblio({
477
        marc_record  => $record,
478
        biblionumber => $biblio,
479
        item_numbers => $itemnumbers });
477
    # Getting the framework
480
    # Getting the framework
478
    my $frameworkcode = GetFrameworkCode($biblio);
481
    my $frameworkcode = GetFrameworkCode($biblio);
479
482
(-)a/C4/Search.pm (-3 / +3 lines)
Lines 1900-1906 sub searchResults { Link Here
1900
    my ($bibliotag,$bibliosubf)=GetMarcFromKohaField('biblio.biblionumber','');
1900
    my ($bibliotag,$bibliosubf)=GetMarcFromKohaField('biblio.biblionumber','');
1901
1901
1902
    # set stuff for XSLT processing here once, not later again for every record we retrieved
1902
    # set stuff for XSLT processing here once, not later again for every record we retrieved
1903
    my $interface = $search_context eq 'opac' ? 'OPAC' : '';
1903
    my $interface = $is_opac ? 'OPAC' : '';
1904
    my $xslsyspref = $interface . "XSLTResultsDisplay";
1904
    my $xslsyspref = $interface . "XSLTResultsDisplay";
1905
    my $xslfile = C4::Context->preference($xslsyspref);
1905
    my $xslfile = C4::Context->preference($xslsyspref);
1906
    my $lang   = $xslfile ? C4::Languages::getlanguage()  : undef;
1906
    my $lang   = $xslfile ? C4::Languages::getlanguage()  : undef;
Lines 2202-2208 sub searchResults { Link Here
2202
					$other_items->{$key}->{count}++ if $item->{$hbranch};
2202
					$other_items->{$key}->{count}++ if $item->{$hbranch};
2203
					$other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
2203
					$other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
2204
					$other_items->{$key}->{description} = $item->{description};
2204
					$other_items->{$key}->{description} = $item->{description};
2205
					$other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype} }->{imageurl} );
2205
                    $other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype} }->{imageurl} );
2206
                }
2206
                }
2207
                # item is available
2207
                # item is available
2208
                else {
2208
                else {
Lines 2213-2219 sub searchResults { Link Here
2213
                    	$available_items->{$prefix}->{$_} = $item->{$_};
2213
                    	$available_items->{$prefix}->{$_} = $item->{$_};
2214
					}
2214
					}
2215
					$available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} };
2215
					$available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} };
2216
					$available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype} }->{imageurl} );
2216
                    $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype} }->{imageurl} );
2217
                }
2217
                }
2218
            }
2218
            }
2219
        }    # notforloan, item level and biblioitem level
2219
        }    # notforloan, item level and biblioitem level
(-)a/Koha/BiblioUtils/Iterator.pm (-1 / +3 lines)
Lines 108-114 sub next { Link Here
108
          if ( !defined($bibnum) );
108
          if ( !defined($bibnum) );
109
109
110
        # TODO this should really be in Koha::BiblioUtils or something similar.
110
        # TODO this should really be in Koha::BiblioUtils or something similar.
111
        C4::Biblio::EmbedItemsInMarcBiblio( $marc, $bibnum );
111
        C4::Biblio::EmbedItemsInMarcBiblio({
112
            marc_record  => $marc,
113
            biblionumber => $bibnum });
112
    }
114
    }
113
115
114
    if (wantarray) {
116
    if (wantarray) {
(-)a/Koha/Exporter/Record.pm (-1 / +4 lines)
Lines 70-76 sub _get_biblio_for_export { Link Here
70
    return if $@ or not defined $record;
70
    return if $@ or not defined $record;
71
71
72
    if ($export_items) {
72
    if ($export_items) {
73
        C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, $itemnumbers );
73
        C4::Biblio::EmbedItemsInMarcBiblio({
74
            marc_record  => $record,
75
            biblionumber => $biblionumber,
76
            item_numbers => $itemnumbers });
74
        if ($only_export_items_for_branches && @$only_export_items_for_branches) {
77
        if ($only_export_items_for_branches && @$only_export_items_for_branches) {
75
            my %export_items_for_branches = map { $_ => 1 } @$only_export_items_for_branches;
78
            my %export_items_for_branches = map { $_ => 1 } @$only_export_items_for_branches;
76
            my ( $homebranchfield, $homebranchsubfield ) = GetMarcFromKohaField( 'items.homebranch', '' );    # Should be GetFrameworkCode( $biblionumber )?
79
            my ( $homebranchfield, $homebranchsubfield ) = GetMarcFromKohaField( 'items.homebranch', '' );    # Should be GetFrameworkCode( $biblionumber )?
(-)a/cataloguing/additem.pl (-1 / +3 lines)
Lines 734-740 my @big_array; Link Here
734
#---- finds where items.itemnumber is stored
734
#---- finds where items.itemnumber is stored
735
my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField("items.itemnumber", $frameworkcode);
735
my (  $itemtagfield,   $itemtagsubfield) = &GetMarcFromKohaField("items.itemnumber", $frameworkcode);
736
my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField("items.homebranch", $frameworkcode);
736
my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField("items.homebranch", $frameworkcode);
737
C4::Biblio::EmbedItemsInMarcBiblio($temp, $biblionumber);
737
C4::Biblio::EmbedItemsInMarcBiblio({
738
    marc_record  => $temp,
739
    biblionumber => $biblionumber });
738
my @fields = $temp->fields();
740
my @fields = $temp->fields();
739
741
740
742
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt (+2 lines)
Lines 126-131 Link Here
126
                                <thead><tr><th>&nbsp;</th><th>Term</th><th>Title</th><th>Date added</th></tr></thead>
126
                                <thead><tr><th>&nbsp;</th><th>Term</th><th>Title</th><th>Date added</th></tr></thead>
127
                                <tbody>
127
                                <tbody>
128
                                    [% FOREACH MY_TAG IN MY_TAGS %]
128
                                    [% FOREACH MY_TAG IN MY_TAGS %]
129
                                        [% IF MY_TAG.visible %]
129
                                        <tr>
130
                                        <tr>
130
                                            <td>
131
                                            <td>
131
                                                <input type="checkbox" name="del[% MY_TAG.tag_id %]" value="del[% MY_TAG.tag_id %]">
132
                                                <input type="checkbox" name="del[% MY_TAG.tag_id %]" value="del[% MY_TAG.tag_id %]">
Lines 163-168 Link Here
163
                                                </span>
164
                                                </span>
164
                                            </td>
165
                                            </td>
165
                                        </tr>
166
                                        </tr>
167
                                        [% END %]
166
                                    [% END %]
168
                                    [% END %]
167
                                </tbody>
169
                                </tbody>
168
                            </table>
170
                            </table>
(-)a/misc/migration_tools/build_oai_sets.pl (-1 / +3 lines)
Lines 127-133 foreach my $res (@$results) { Link Here
127
        next;
127
        next;
128
    }
128
    }
129
    if($embed_items) {
129
    if($embed_items) {
130
        C4::Biblio::EmbedItemsInMarcBiblio($record, $biblionumber);
130
        C4::Biblio::EmbedItemsInMarcBiblio({
131
            marc_record  => $record,
132
            biblionumber => $biblionumber });
131
    }
133
    }
132
134
133
    my @biblio_sets = CalcOAISetsBiblio($record, $mappings);
135
    my @biblio_sets = CalcOAISetsBiblio($record, $mappings);
(-)a/opac/opac-ISBDdetail.pl (-35 / +40 lines)
Lines 58-63 use Koha::RecordProcessor; Link Here
58
58
59
59
60
my $query = CGI->new();
60
my $query = CGI->new();
61
62
my $biblionumber = $query->param('biblionumber');
63
if ( ! $biblionumber ) {
64
    print $query->redirect('/cgi-bin/koha/errors/404.pl');
65
    exit;
66
}
67
$biblionumber = int($biblionumber);
68
69
#open template
61
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
70
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
62
    {
71
    {
63
        template_name   => "opac-ISBDdetail.tt",
72
        template_name   => "opac-ISBDdetail.tt",
Lines 68-114 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
68
    }
77
    }
69
);
78
);
70
79
71
my $biblionumber = $query->param('biblionumber');
80
my $borcat = q{};
72
$biblionumber = int($biblionumber);
81
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
73
82
    # we need to fetch the borrower info here, so we can pass the category
74
# get biblionumbers stored in the cart
83
    my $borrower = Koha::Patrons->find( { borrowernumber => $loggedinuser } );
75
if(my $cart_list = $query->cookie("bib_list")){
84
    $borcat = $borrower ? $borrower->categorycode : $borcat;
76
    my @cart_list = split(/\//, $cart_list);
77
    if ( grep {$_ eq $biblionumber} @cart_list) {
78
        $template->param( incart => 1 );
79
    }
80
}
81
82
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
83
84
my $marcflavour      = C4::Context->preference("marcflavour");
85
86
my @items = GetItemsInfo($biblionumber);
87
if (scalar @items >= 1) {
88
    my $borcat;
89
    if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
90
91
        # we need to fetch the borrower info here, so we can pass the category
92
        my $borrower = GetMember( borrowernumber => $borrowernumber );
93
        $borcat = $borrower->{categorycode};
94
    }
95
96
    my @hiddenitems = GetHiddenItemnumbers( { items => \@items, borcat => $borcat });
97
98
    if (scalar @hiddenitems == scalar @items ) {
99
        print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
100
        exit;
101
    }
102
}
85
}
103
86
104
my $record = GetMarcBiblio({
87
my $record = GetMarcBiblio({
105
    biblionumber => $biblionumber,
88
    biblionumber => $biblionumber,
106
    embed_items  => 1 });
89
    embed_items  => 1,
90
    opac         => 1,
91
    borcat       => $borcat });
107
if ( ! $record ) {
92
if ( ! $record ) {
108
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
93
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
109
    exit;
94
    exit;
110
}
95
}
111
my $framework = GetFrameworkCode( $biblionumber );
96
97
my @all_items = GetItemsInfo($biblionumber);
98
my $framework = &GetFrameworkCode( $biblionumber );
99
my ($tag_itemnumber, $subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$framework);
100
my @nonhiddenitems = $record->field($tag_itemnumber);
101
if (scalar @all_items >= 1 && scalar @nonhiddenitems == 0) {
102
    print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
103
    exit;
104
}
105
112
my $record_processor = Koha::RecordProcessor->new({
106
my $record_processor = Koha::RecordProcessor->new({
113
    filters => 'ViewPolicy',
107
    filters => 'ViewPolicy',
114
    options => {
108
    options => {
Lines 118-123 my $record_processor = Koha::RecordProcessor->new({ Link Here
118
});
112
});
119
$record_processor->process($record);
113
$record_processor->process($record);
120
114
115
# get biblionumbers stored in the cart
116
if(my $cart_list = $query->cookie("bib_list")){
117
    my @cart_list = split(/\//, $cart_list);
118
    if ( grep {$_ eq $biblionumber} @cart_list) {
119
        $template->param( incart => 1 );
120
    }
121
}
122
123
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
124
125
my $marcflavour      = C4::Context->preference("marcflavour");
126
121
# some useful variables for enhanced content;
127
# some useful variables for enhanced content;
122
# in each case, we're grabbing the first value we find in
128
# in each case, we're grabbing the first value we find in
123
# the record and normalizing it
129
# the record and normalizing it
Lines 139-145 $template->param( Link Here
139
145
140
#coping with subscriptions
146
#coping with subscriptions
141
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
147
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
142
my $dbh = C4::Context->dbh;
143
my $dat                 = TransformMarcToKoha( $record );
148
my $dat                 = TransformMarcToKoha( $record );
144
149
145
my @subscriptions       = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
150
my @subscriptions       = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
Lines 175-181 my $res = GetISBDView({ Link Here
175
180
176
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
181
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
177
my $patron = Koha::Patrons->find( $loggedinuser );
182
my $patron = Koha::Patrons->find( $loggedinuser );
178
for my $itm (@items) {
183
for my $itm (@all_items) {
179
    $norequests = 0
184
    $norequests = 0
180
      if $norequests
185
      if $norequests
181
        && !$itm->{'withdrawn'}
186
        && !$itm->{'withdrawn'}
(-)a/opac/opac-MARCdetail.pl (-44 / +39 lines)
Lines 61-106 use Koha::Biblios; Link Here
61
use Koha::Patrons;
61
use Koha::Patrons;
62
use Koha::RecordProcessor;
62
use Koha::RecordProcessor;
63
63
64
my $query = new CGI;
64
my $query = CGI->new();
65
66
my $dbh = C4::Context->dbh;
67
65
68
my $biblionumber = $query->param('biblionumber');
66
my $biblionumber = $query->param('biblionumber');
69
if ( ! $biblionumber ) {
67
if ( ! $biblionumber ) {
70
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
68
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
71
    exit;
69
    exit;
72
}
70
}
71
$biblionumber = int($biblionumber);
72
73
# open template
74
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
75
    {
76
        template_name   => "opac-MARCdetail.tt",
77
        query           => $query,
78
        type            => "opac",
79
        authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
80
        debug           => 1,
81
    }
82
);
83
84
my $borcat = q{};
85
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
86
    # we need to fetch the borrower info here, so we can pass the category
87
    my $borrower = Koha::Patrons->find( { borrowernumber => $loggedinuser } );
88
    $borcat = $borrower ? $borrower->categorycode : $borcat;
89
}
73
90
74
my $record = GetMarcBiblio({
91
my $record = GetMarcBiblio({
75
    biblionumber => $biblionumber,
92
    biblionumber => $biblionumber,
76
    embed_items  => 1 });
93
    embed_items  => 1,
94
    opac         => 1,
95
    borcat       => $borcat });
77
if ( ! $record ) {
96
if ( ! $record ) {
78
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
97
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
79
    exit;
98
    exit;
80
}
99
}
81
100
82
my @all_items = GetItemsInfo($biblionumber);
101
my @all_items = GetItemsInfo($biblionumber);
83
my @items2hide;
84
if (scalar @all_items >= 1) {
85
    my $borcat;
86
    if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
87
88
        # we need to fetch the borrower info here, so we can pass the category
89
        my $borrower = GetMember( borrowernumber => $borrowernumber );
90
        $borcat = $borrower->{categorycode};
91
    }
92
    push @items2hide, GetHiddenItemnumbers({ items => \@all_items, borcat => $botcat });
93
94
    if (scalar @items2hide == scalar @all_items ) {
95
        print $query->redirect("/cgi-bin/koha/errors/404.pl");
96
        exit;
97
    }
98
}
99
100
my $framework = &GetFrameworkCode( $biblionumber );
102
my $framework = &GetFrameworkCode( $biblionumber );
101
my $tagslib = &GetMarcStructure( 0, $framework );
102
my ($tag_itemnumber,$subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$framework);
103
my ($tag_itemnumber,$subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$framework);
103
my $biblio = Koha::Biblios->find( $biblionumber );
104
my @nonhiddenitems = $record->field($tag_itemnumber);
105
if (scalar @all_items >= 1 && scalar @nonhiddenitems == 0) {
106
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
107
    exit;
108
}
104
109
105
my $record_processor = Koha::RecordProcessor->new({
110
my $record_processor = Koha::RecordProcessor->new({
106
    filters => 'ViewPolicy',
111
    filters => 'ViewPolicy',
Lines 111-133 my $record_processor = Koha::RecordProcessor->new({ Link Here
111
});
116
});
112
$record_processor->process($record);
117
$record_processor->process($record);
113
118
114
# open template
115
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
116
    {
117
        template_name   => "opac-MARCdetail.tt",
118
        query           => $query,
119
        type            => "opac",
120
        authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
121
        debug           => 1,
122
    }
123
);
124
125
my ($bt_tag,$bt_subtag) = GetMarcFromKohaField('biblio.title',$framework);
126
$template->param(
127
    bibliotitle => $biblio->title,
128
) if $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} <= 0 && # <=0 OPAC visible.
129
     $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8;   # except -8;
130
131
# get biblionumbers stored in the cart
119
# get biblionumbers stored in the cart
132
if(my $cart_list = $query->cookie("bib_list")){
120
if(my $cart_list = $query->cookie("bib_list")){
133
    my @cart_list = split(/\//, $cart_list);
121
    my @cart_list = split(/\//, $cart_list);
Lines 136-141 if(my $cart_list = $query->cookie("bib_list")){ Link Here
136
    }
124
    }
137
}
125
}
138
126
127
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
128
129
my $biblio = Koha::Biblios->find( $biblionumber );
130
my $tagslib = &GetMarcStructure( 0, $framework );
131
my ($bt_tag,$bt_subtag) = GetMarcFromKohaField('biblio.title',$framework);
132
$template->param(
133
    bibliotitle => $biblio->title,
134
) if $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} <= 0 && # <=0 OPAC visible.
135
     $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8;   # except -8;
136
139
my $allow_onshelf_holds;
137
my $allow_onshelf_holds;
140
my $patron = Koha::Patrons->find( $loggedinuser );
138
my $patron = Koha::Patrons->find( $loggedinuser );
141
for my $itm (@all_items) {
139
for my $itm (@all_items) {
Lines 144-150 for my $itm (@all_items) { Link Here
144
}
142
}
145
143
146
$template->param( 'AllowOnShelfHolds' => $allow_onshelf_holds );
144
$template->param( 'AllowOnShelfHolds' => $allow_onshelf_holds );
147
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
148
145
149
# adding the $RequestOnOpac param
146
# adding the $RequestOnOpac param
150
my $RequestOnOpac;
147
my $RequestOnOpac;
Lines 274-279 for ( my $tabloop = 0 ; $tabloop <= 9 ; $tabloop++ ) { Link Here
274
# loop through each tag
271
# loop through each tag
275
# warning : we may have differents number of columns in each row. Thus, we first build a hash, complete it if necessary
272
# warning : we may have differents number of columns in each row. Thus, we first build a hash, complete it if necessary
276
# then construct template.
273
# then construct template.
274
# $record has already had all the item fields filtered above.
277
my @fields = $record->fields();
275
my @fields = $record->fields();
278
my %witness
276
my %witness
279
  ; #---- stores the list of subfields used at least once, with the "meaning" of the code
277
  ; #---- stores the list of subfields used at least once, with the "meaning" of the code
Lines 281-289 my @item_subfield_codes; Link Here
281
my @item_loop;
279
my @item_loop;
282
foreach my $field (@fields) {
280
foreach my $field (@fields) {
283
    next if ( $field->tag() < 10 );
281
    next if ( $field->tag() < 10 );
284
    next if ( ( $field->tag() eq $tag_itemnumber ) &&
285
              ( any { $field->subfield($subtag_itemnumber) eq $_ }
286
                   @items2hide) );
287
    my @subf = $field->subfields;
282
    my @subf = $field->subfields;
288
    my $item;
283
    my $item;
289
284
(-)a/opac/opac-basket.pl (-1 / +27 lines)
Lines 58-63 if (C4::Context->preference('TagsEnabled')) { Link Here
58
	}
58
	}
59
}
59
}
60
60
61
my $borcat = q{};
62
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
63
    # we need to fetch the borrower info here, so we can pass the category
64
    my $borrower = Koha::Patron->find( { borrowernumber -> $borrowernumber } );
65
    $borcat = $borrower ? $borrower->categorycode : $borcat;
66
}
67
61
my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
68
my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
62
foreach my $biblionumber ( @bibs ) {
69
foreach my $biblionumber ( @bibs ) {
63
    $template->param( biblionumber => $biblionumber );
70
    $template->param( biblionumber => $biblionumber );
Lines 65-70 foreach my $biblionumber ( @bibs ) { Link Here
65
    my $dat              = &GetBiblioData($biblionumber);
72
    my $dat              = &GetBiblioData($biblionumber);
66
    next unless $dat;
73
    next unless $dat;
67
74
75
    # No filtering on the item records needed for the record itself
76
    # since the only reason item information is grabbed is because of branchcodes.
68
    my $record = &GetMarcBiblio({ biblionumber => $biblionumber });
77
    my $record = &GetMarcBiblio({ biblionumber => $biblionumber });
69
    my $framework = &GetFrameworkCode( $biblionumber );
78
    my $framework = &GetFrameworkCode( $biblionumber );
70
    $record_processor->options({
79
    $record_processor->options({
Lines 78-84 foreach my $biblionumber ( @bibs ) { Link Here
78
    my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
87
    my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
79
    my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
88
    my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
80
    my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
89
    my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
81
    my @items            = &GetItemsInfo( $biblionumber );
90
91
    # grab all the items...
92
    my @all_items        = &GetItemsInfo( $biblionumber );
93
94
    # determine which ones should be hidden / visible
95
    my @hidden_items     = GetHiddenItemnumbers({ items => \@all_items, borcat => $borcat });
96
97
    # 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);
99
100
    # copy the visible ones into the items array.
101
    my @items;
102
    foreach my $item (@all_items) {
103
        if ( none { $item->{itemnumber} ne $_ } @hidden_items ) {
104
            push @items, $item;
105
        }
106
    }
107
82
    my $subtitle         = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
108
    my $subtitle         = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
83
109
84
    my $hasauthors = 0;
110
    my $hasauthors = 0;
(-)a/opac/opac-detail.pl (-5 / +11 lines)
Lines 81-93 $biblionumber = int($biblionumber); Link Here
81
81
82
my @all_items = GetItemsInfo($biblionumber);
82
my @all_items = GetItemsInfo($biblionumber);
83
my @hiddenitems;
83
my @hiddenitems;
84
my $borcat = q{};
84
if ( scalar @all_items >= 1 ) {
85
if ( scalar @all_items >= 1 ) {
85
    my $borcat;
86
    if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
86
    if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
87
87
88
        # we need to fetch the borrower info here, so we can pass the category
88
        # we need to fetch the borrower info here, so we can pass the category
89
        my $borrower = GetMember( borrowernumber => $borrowernumber );
89
        my $borrower = Koha::Patrons->find( { borrowernumber => $borrowernumber } );
90
        $borcat = $borrower->{categorycode};
90
        $borcat = $borrower ? $borrower->categorycode : $borcat;
91
    }
91
    }
92
92
93
    push @hiddenitems,
93
    push @hiddenitems,
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;
Lines 235-244 if ($session->param('busc')) { Link Here
235
        };
237
        };
236
        my $hits;
238
        my $hits;
237
        my @newresults;
239
        my @newresults;
240
        my $search_context = {
241
            'interface' => 'opac',
242
            'category'  => $borcat
243
        };
238
        for (my $i=0;$i<@servers;$i++) {
244
        for (my $i=0;$i<@servers;$i++) {
239
            my $server = $servers[$i];
245
            my $server = $servers[$i];
240
            $hits = $results_hashref->{$server}->{"hits"};
246
            $hits = $results_hashref->{$server}->{"hits"};
241
            @newresults = searchResults({ 'interface' => 'opac' }, '', $hits, $results_per_page, $offset, $arrParamsBusc->{'scan'}, $results_hashref->{$server}->{"RECORDS"});
247
            @newresults = searchResults( $search_context, '', $hits, $results_per_page, $offset, $arrParamsBusc->{'scan'}, $results_hashref->{$server}->{"RECORDS"});
242
        }
248
        }
243
        return \@newresults;
249
        return \@newresults;
244
    }#searchAgain
250
    }#searchAgain
(-)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
        my $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 (-3 / +5 lines)
Lines 51-58 use C4::Koha; Link Here
51
use C4::Tags qw(get_tags);
51
use C4::Tags qw(get_tags);
52
use C4::SocialData;
52
use C4::SocialData;
53
use C4::External::OverDrive;
53
use C4::External::OverDrive;
54
use C4::Members qw(GetMember);
55
54
55
use Koha::Libraries;
56
use Koha::ItemTypes;
56
use Koha::ItemTypes;
57
use Koha::LibraryCategories;
57
use Koha::LibraryCategories;
58
use Koha::Ratings;
58
use Koha::Ratings;
Lines 595-600 if ($tag) { Link Here
595
    $DEBUG and printf STDERR "taglist (%s biblionumber)\nmarclist (%s records)\n", scalar(@$taglist), scalar(@marclist);
595
    $DEBUG and printf STDERR "taglist (%s biblionumber)\nmarclist (%s records)\n", scalar(@$taglist), scalar(@marclist);
596
    $results_hashref->{biblioserver}->{RECORDS} = \@marclist;
596
    $results_hashref->{biblioserver}->{RECORDS} = \@marclist;
597
    # FIXME: tag search and standard search should work together, not exclusively
597
    # FIXME: tag search and standard search should work together, not exclusively
598
    # FIXME: Because search and standard search don't work together OpacHiddenItems
599
    #        displays search results which should be hidden.
598
    # FIXME: No facets for tags search.
600
    # FIXME: No facets for tags search.
599
} elsif ($build_grouped_results) {
601
} elsif ($build_grouped_results) {
600
    eval {
602
    eval {
Lines 625-632 my $search_context = {}; Link Here
625
$search_context->{'interface'} = 'opac';
627
$search_context->{'interface'} = 'opac';
626
if (C4::Context->preference('OpacHiddenItemsExceptions')){
628
if (C4::Context->preference('OpacHiddenItemsExceptions')){
627
    # we need to fetch the borrower info here, so we can pass the category
629
    # we need to fetch the borrower info here, so we can pass the category
628
    my $borrower = GetMember( borrowernumber => $borrowernumber );
630
    my $borrower = Koha::Patrons->find( { borrowernumber => $borrowernumber } );
629
    $search_context->{'category'} = $borrower->{'categorycode'};
631
    $search_context->{'category'} = $borrower ? $borrower->categorycode : q{};
630
}
632
}
631
633
632
for (my $i=0;$i<@servers;$i++) {
634
for (my $i=0;$i<@servers;$i++) {
(-)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 = $patron->first_valid_email_address
63
    my $user_email = $patron->first_valid_email_address
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-tags.pl (-2 / +44 lines)
Lines 41-46 use C4::Debug; Link Here
41
use C4::Output qw(:html :ajax pagination_bar);
41
use C4::Output qw(:html :ajax pagination_bar);
42
use C4::Scrubber;
42
use C4::Scrubber;
43
use C4::Biblio;
43
use C4::Biblio;
44
use C4::Items qw(GetItemsInfo GetHiddenItemnumbers);
44
use C4::Tags qw(add_tag get_approval_rows get_tag_rows remove_tag stratify_tags);
45
use C4::Tags qw(add_tag get_approval_rows get_tag_rows remove_tag stratify_tags);
45
use C4::XSLT;
46
use C4::XSLT;
46
47
Lines 226-238 if ($is_ajax) { Link Here
226
227
227
my $results = [];
228
my $results = [];
228
my $my_tags = [];
229
my $my_tags = [];
230
my $borcat  = q{};
229
231
230
if ($loggedinuser) {
232
if ($loggedinuser) {
233
    my $patron = Koha::Patrons->find( { borrowernumber => $loggedinuser } );
234
    $borcat = $patron ? $patron->categorycode : $borcat;
235
    my $should_hide = C4::Context->preference('OpacHiddenItems') // q{};
236
    $should_hide = ( $should_hide =~ /\S/ ) ? 1 : 0;
231
    $my_tags = get_tag_rows({borrowernumber=>$loggedinuser});
237
    $my_tags = get_tag_rows({borrowernumber=>$loggedinuser});
232
    my $my_approved_tags = get_approval_rows({ approved => 1 });
238
    my $my_approved_tags = get_approval_rows({ approved => 1 });
233
    foreach my $tag (@$my_tags) {
239
    foreach my $tag (@$my_tags) {
240
        $tag->{visible} = 0;
234
        my $biblio = Koha::Biblios->find( $tag->{biblionumber} );
241
        my $biblio = Koha::Biblios->find( $tag->{biblionumber} );
235
        my $record = &GetMarcBiblio({ biblionumber => $tag->{biblionumber} });
242
        my $record = &GetMarcBiblio({
243
            biblionumber => $tag->{biblionumber},
244
            embed_items  => 1,
245
            opac         => 1,
246
            borcat       => $borcat });
247
        next unless $record;
248
        my $hidden_items = undef;
249
        my @hidden_itemnumbers;
250
        my @all_items;
251
        if ($should_hide) {
252
            @all_items = GetItemsInfo( $tag->{biblionumber} );
253
            @hidden_itemnumbers = GetHiddenItemnumbers({
254
                items => \@all_items,
255
                borcat => $borcat });
256
            $hidden_items = \@hidden_itemnumbers;
257
        }
258
        next if ( $should_hide && scalar @all_items == scalar @hidden_itemnumbers );
236
        $tag->{subtitle} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $tag->{biblionumber} ) );
259
        $tag->{subtitle} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $tag->{biblionumber} ) );
237
        $tag->{title} = $biblio->title;
260
        $tag->{title} = $biblio->title;
238
        $tag->{author} = $biblio->author;
261
        $tag->{author} = $biblio->author;
Lines 244-250 if ($loggedinuser) { Link Here
244
        if ( $xslfile ) {
267
        if ( $xslfile ) {
245
            $tag->{XSLTBloc} = XSLTParse4Display(
268
            $tag->{XSLTBloc} = XSLTParse4Display(
246
                    $tag->{ biblionumber }, $record, "OPACXSLTResultsDisplay",
269
                    $tag->{ biblionumber }, $record, "OPACXSLTResultsDisplay",
247
                    1, undef, $sysxml, $xslfile, $lang
270
                    1, $hidden_items, $sysxml, $xslfile, $lang
248
            );
271
            );
249
        }
272
        }
250
273
Lines 252-257 if ($loggedinuser) { Link Here
252
        $date =~ /\s+(\d{2}\:\d{2}\:\d{2})/;
275
        $date =~ /\s+(\d{2}\:\d{2}\:\d{2})/;
253
        $tag->{time_created_display} = $1;
276
        $tag->{time_created_display} = $1;
254
        $tag->{approved} = ( grep { $_->{term} eq $tag->{term} and $_->{approved} } @$my_approved_tags );
277
        $tag->{approved} = ( grep { $_->{term} eq $tag->{term} and $_->{approved} } @$my_approved_tags );
278
        $tag->{visible} = 1;
255
    }
279
    }
256
}
280
}
257
281
Lines 281-286 if ($add_op) { Link Here
281
		$arghash->{biblionumber} = $arg;
305
		$arghash->{biblionumber} = $arg;
282
	}
306
	}
283
	$results = get_approval_rows($arghash);
307
	$results = get_approval_rows($arghash);
308
    my @filtered_results;
309
    foreach my $my_tag (@$my_tags) {
310
        if (grep { $_->{term} eq $my_tag->{term} } @$results) {
311
            if (! $my_tag->{visible} ) {
312
                my $check_biblio = GetMarcBiblio({
313
                    biblionumber => $my_tag->{biblionumber},
314
                    embed_itesm  => 1,
315
                    opac         => 1,
316
                    borcat       => $borcat });
317
                if ($check_biblio) {
318
                    push @filtered_results, $my_tag;
319
                }
320
            } else {
321
                push @filtered_results, $my_tag;
322
            }
323
        }
324
    }
325
    $results = \@filtered_results;
284
    stratify_tags(10, $results); # work out the differents sizes for things
326
    stratify_tags(10, $results); # work out the differents sizes for things
285
	my $count = scalar @$results;
327
	my $count = scalar @$results;
286
	$template->param(TAGLOOP_COUNT => $count, mine => $mine);
328
	$template->param(TAGLOOP_COUNT => $count, mine => $mine);
(-)a/opac/opac-user.pl (-1 / +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 use 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'} );
(-)a/t/db_dependent/ILSDI_Services.t (-1 / +41 lines)
Lines 19-25 use Modern::Perl; Link Here
19
19
20
use CGI qw ( -utf8 );
20
use CGI qw ( -utf8 );
21
21
22
use Test::More tests => 3;
22
use Test::More tests => 4;
23
use Test::MockModule;
23
use Test::MockModule;
24
use t::lib::Mocks;
24
use t::lib::Mocks;
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
Lines 105-110 subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes Link Here
105
    $schema->resultset( 'BorrowerAttributeType' )->delete_all;
105
    $schema->resultset( 'BorrowerAttributeType' )->delete_all;
106
    $schema->resultset( 'Category' )->delete_all;
106
    $schema->resultset( 'Category' )->delete_all;
107
    $schema->resultset( 'Item' )->delete_all; # 'Branch' deps. on this
107
    $schema->resultset( 'Item' )->delete_all; # 'Branch' deps. on this
108
    $schema->resultset( 'Club' )->delete_all;
108
    $schema->resultset( 'Branch' )->delete_all;
109
    $schema->resultset( 'Branch' )->delete_all;
109
110
110
    # Configure Koha to enable ILS-DI server and extended attributes:
111
    # Configure Koha to enable ILS-DI server and extended attributes:
Lines 198-200 subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes Link Here
198
    $schema->storage->txn_rollback;
199
    $schema->storage->txn_rollback;
199
};
200
};
200
201
202
203
# This is a stub, as it merely is for triggering the GetMarcBiblio call.
204
subtest 'GetRecords' => sub {
205
206
    plan tests => 1;
207
208
    $schema->storage->txn_begin;
209
210
    my $biblio = $builder->build({
211
        source => 'Biblio',
212
        value  => {
213
            title => 'Title 1',    },
214
    });
215
216
    my $item = $builder->build({
217
        source => 'Item',
218
        value  => {
219
            biblionumber => $biblio->{biblionumber},
220
        },
221
    });
222
223
    my $biblioitem = $builder->build({
224
        source => 'Biblioitem',
225
        value  => {
226
            biblionumber => $biblio->{biblionumber},
227
            itemnumber   => $item->{itemnumber},
228
        },
229
    });
230
231
    my $query = CGI->new({
232
        'schema' => 'MARCXML',
233
        'id'     => [ $biblio->{biblionumber} ]
234
    });
235
236
    my $result = C4::ILSDI::Services::GetRecords($query);
237
    ok($result,'There is a result');
238
239
    $schema->storage->txn_rollback;
240
}
(-)a/t/db_dependent/Items.t (-13 / +39 lines)
Lines 109-115 subtest 'General Add, Get and Del tests' => sub { Link Here
109
109
110
subtest 'GetHiddenItemnumbers tests' => sub {
110
subtest 'GetHiddenItemnumbers tests' => sub {
111
111
112
    plan tests => 9;
112
    plan tests => 11;
113
113
114
    # This sub is controlled by the OpacHiddenItems system preference.
114
    # This sub is controlled by the OpacHiddenItems system preference.
115
115
Lines 159-170 subtest 'GetHiddenItemnumbers tests' => sub { Link Here
159
    push @items, GetItem( $item2_itemnumber );
159
    push @items, GetItem( $item2_itemnumber );
160
160
161
    # Empty OpacHiddenItems
161
    # Empty OpacHiddenItems
162
    C4::Context->set_preference('OpacHiddenItems','');
162
    t::lib::Mocks::mock_preference('OpacHiddenItems','');
163
    ok( !defined( GetHiddenItemnumbers( { items => \@items } ) ),
163
    ok( !defined( GetHiddenItemnumbers( { items => \@items } ) ),
164
        "Hidden items list undef if OpacHiddenItems empty");
164
        "Hidden items list undef if OpacHiddenItems empty");
165
165
166
    # Blank spaces
166
    # Blank spaces
167
    C4::Context->set_preference('OpacHiddenItems','  ');
167
    t::lib::Mocks::mock_preference('OpacHiddenItems','  ');
168
    ok( scalar GetHiddenItemnumbers( { items => \@items } ) == 0,
168
    ok( scalar GetHiddenItemnumbers( { items => \@items } ) == 0,
169
        "Hidden items list empty if OpacHiddenItems only contains blanks");
169
        "Hidden items list empty if OpacHiddenItems only contains blanks");
170
170
Lines 180-186 subtest 'GetHiddenItemnumbers tests' => sub { Link Here
180
    $opachiddenitems = "
180
    $opachiddenitems = "
181
        withdrawn: [1,0]";
181
        withdrawn: [1,0]";
182
    t::lib::Mocks::mock_preference( 'OpacHiddenItems', $opachiddenitems );
182
    t::lib::Mocks::mock_preference( 'OpacHiddenItems', $opachiddenitems );
183
    C4::Context->set_preference( 'OpacHiddenItems', $opachiddenitems );
184
    @hidden = GetHiddenItemnumbers( { items => \@items } );
183
    @hidden = GetHiddenItemnumbers( { items => \@items } );
185
    ok( scalar @hidden == 2, "Two items hidden");
184
    ok( scalar @hidden == 2, "Two items hidden");
186
    is_deeply( \@hidden, \@itemnumbers, "withdrawn=1 and withdrawn=0 hidden");
185
    is_deeply( \@hidden, \@itemnumbers, "withdrawn=1 and withdrawn=0 hidden");
Lines 195-200 subtest 'GetHiddenItemnumbers tests' => sub { Link Here
195
    ok( scalar @hidden == 2, "Two items hidden");
194
    ok( scalar @hidden == 2, "Two items hidden");
196
    is_deeply( \@hidden, \@itemnumbers, "withdrawn=1 and homebranch library2 hidden");
195
    is_deeply( \@hidden, \@itemnumbers, "withdrawn=1 and homebranch library2 hidden");
197
196
197
    # Override hidden with patron category
198
    t::lib::Mocks::mock_preference( 'OpacHiddenItemsExceptions', 'S' );
199
    @hidden = GetHiddenItemnumbers( { items => \@items, borcat => 'PT' } );
200
    ok( scalar @hidden == 2, "Two items still hidden");
201
    @hidden = GetHiddenItemnumbers( { items => \@items, borcat => 'S' } );
202
    ok( scalar @hidden == 0, "Two items not hidden");
203
198
    # Valid OpacHiddenItems, empty list
204
    # Valid OpacHiddenItems, empty list
199
    @items = ();
205
    @items = ();
200
    @hidden = GetHiddenItemnumbers( { items => \@items } );
206
    @hidden = GetHiddenItemnumbers( { items => \@items } );
Lines 514-520 subtest 'Koha::Item(s) tests' => sub { Link Here
514
};
520
};
515
521
516
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub {
522
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub {
517
    plan tests => 7;
523
    plan tests => 8;
518
524
519
    $schema->storage->txn_begin();
525
    $schema->storage->txn_begin();
520
526
Lines 565-582 subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub { Link Here
565
    my $record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
571
    my $record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
566
    warning_is { C4::Biblio::EmbedItemsInMarcBiblio() }
572
    warning_is { C4::Biblio::EmbedItemsInMarcBiblio() }
567
    { carped => 'EmbedItemsInMarcBiblio: No MARC record passed' },
573
    { carped => 'EmbedItemsInMarcBiblio: No MARC record passed' },
568
      'Should crap is no record passed.';
574
      'Should carp is no record passed.';
569
575
570
    C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber );
576
    C4::Biblio::EmbedItemsInMarcBiblio({
577
        marc_record  => $record,
578
        biblionumber => $biblionumber });
571
    my @items = $record->field($itemfield);
579
    my @items = $record->field($itemfield);
572
    is( scalar @items, $number_of_items, 'Should return all items' );
580
    is( scalar @items, $number_of_items, 'Should return all items' );
573
581
574
    C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber,
582
    my $marc_with_items = C4::Biblio::GetMarcBiblio({
575
        [ $itemnumbers[1], $itemnumbers[3] ] );
583
        biblionumber => $biblionumber,
584
        embed_items  => 1 });
585
    is_deeply( $record, $marc_with_items, 'A direct call to GetMarcBiblio with items matches');
586
587
    C4::Biblio::EmbedItemsInMarcBiblio({
588
        marc_record  => $record,
589
        biblionumber => $biblionumber,
590
        item_numbers => [ $itemnumbers[1], $itemnumbers[3] ] });
576
    @items = $record->field($itemfield);
591
    @items = $record->field($itemfield);
577
    is( scalar @items, 2, 'Should return all items present in the list' );
592
    is( scalar @items, 2, 'Should return all items present in the list' );
578
593
579
    C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, undef, 1 );
594
    C4::Biblio::EmbedItemsInMarcBiblio({
595
        marc_record  => $record,
596
        biblionumber => $biblionumber,
597
        opac         => 1 });
580
    @items = $record->field($itemfield);
598
    @items = $record->field($itemfield);
581
    is( scalar @items, $number_of_items, 'Should return all items for opac' );
599
    is( scalar @items, $number_of_items, 'Should return all items for opac' );
582
600
Lines 584-596 subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub { Link Here
584
        homebranch: ['$library1->{branchcode}']";
602
        homebranch: ['$library1->{branchcode}']";
585
    t::lib::Mocks::mock_preference( 'OpacHiddenItems', $opachiddenitems );
603
    t::lib::Mocks::mock_preference( 'OpacHiddenItems', $opachiddenitems );
586
604
587
    C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber );
605
    C4::Biblio::EmbedItemsInMarcBiblio({
606
        marc_record  => $record,
607
        biblionumber => $biblionumber });
588
    @items = $record->field($itemfield);
608
    @items = $record->field($itemfield);
589
    is( scalar @items,
609
    is( scalar @items,
590
        $number_of_items,
610
        $number_of_items,
591
        'Even with OpacHiddenItems set, all items should have been embedded' );
611
        'Even with OpacHiddenItems set, all items should have been embedded' );
592
612
593
    C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, undef, 1 );
613
    C4::Biblio::EmbedItemsInMarcBiblio({
614
        marc_record  => $record,
615
        biblionumber => $biblionumber,
616
        opac         => 1 });
594
    @items = $record->field($itemfield);
617
    @items = $record->field($itemfield);
595
    is(
618
    is(
596
        scalar @items,
619
        scalar @items,
Lines 601-607 subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub { Link Here
601
    $opachiddenitems = "
624
    $opachiddenitems = "
602
        homebranch: ['$library1->{branchcode}', '$library2->{branchcode}']";
625
        homebranch: ['$library1->{branchcode}', '$library2->{branchcode}']";
603
    t::lib::Mocks::mock_preference( 'OpacHiddenItems', $opachiddenitems );
626
    t::lib::Mocks::mock_preference( 'OpacHiddenItems', $opachiddenitems );
604
    C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, undef, 1 );
627
    C4::Biblio::EmbedItemsInMarcBiblio({
628
        marc_record  => $record,
629
        biblionumber => $biblionumber,
630
        opac         => 1 });
605
    @items = $record->field($itemfield);
631
    @items = $record->field($itemfield);
606
    is(
632
    is(
607
        scalar @items,
633
        scalar @items,
(-)a/t/db_dependent/Koha/BiblioUtils/Iterator.t (+76 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
#
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 3;
21
22
use_ok('Koha::BiblioUtils');
23
use_ok('Koha::BiblioUtils::Iterator');
24
25
use C4::Biblio;
26
use C4::Items;
27
use DBI;
28
use t::lib::TestBuilder;
29
use t::lib::Mocks;
30
31
my $schema = Koha::Database->new()->schema();
32
$schema->storage->txn_begin();
33
34
# Delete issues to prevent foreign constraint failures.
35
# blank all biblios, biblioitems, and items.
36
$schema->resultset('Issue')->delete();
37
$schema->resultset('Biblio')->delete();
38
39
my $location = 'My Location';
40
my $builder = t::lib::TestBuilder->new;
41
my $library = $builder->build({
42
    source => 'Branch',
43
});
44
my $itemtype = $builder->build({
45
   source => 'Itemtype',
46
});
47
48
# Create a biblio instance for testing
49
t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
50
my ($bibnum, $bibitemnum) = get_biblio();
51
52
# Add an item.
53
my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode}, location => $location, itype => $itemtype->{itemtype} } , $bibnum);
54
55
my $rs = $schema->resultset('Biblioitem')->search({});
56
my $iterator = Koha::BiblioUtils::Iterator->new($rs, items => 1 );
57
my $record = $iterator->next();
58
my $expected_tags = [ 100, 245, 952, 999 ];
59
my @result_tags = map { $_->tag() } $record->field('...');
60
my @sorted_tags = sort @result_tags;
61
is_deeply(\@sorted_tags,$expected_tags, "Got the same tags as expected");
62
63
$schema->storage->txn_rollback();
64
65
# Helper method to set up a Biblio.
66
sub get_biblio {
67
    my ( $frameworkcode ) = @_;
68
    $frameworkcode //= '';
69
    my $bib = MARC::Record->new();
70
    $bib->append_fields(
71
        MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'),
72
        MARC::Field->new('245', ' ', ' ', a => 'Silence in the library'),
73
    );
74
    my ($bibnum, $bibitemnum) = AddBiblio($bib, $frameworkcode);
75
    return ($bibnum, $bibitemnum);
76
}
(-)a/t/db_dependent/Labels/t_Label.t (+147 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright (C) 2017  Mark Tompsett
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Test::More tests => 3;
23
use t::lib::TestBuilder;
24
25
use MARC::Record;
26
use MARC::Field;
27
use Data::Dumper;
28
29
use C4::Biblio;
30
use C4::Items;
31
use C4::Labels::Layout;
32
33
use Koha::Database;
34
35
use_ok('C4::Labels::Label');
36
37
my $database = Koha::Database->new();
38
my $schema   = $database->schema();
39
$schema->storage->txn_begin();
40
41
my $batch_id;
42
my ( $llx, $lly ) = ( 0, 0 );
43
my $frameworkcode = q{};
44
45
## Setup Test
46
my $builder = t::lib::TestBuilder->new;
47
48
# Add branch
49
my $branch_1 = $builder->build( { source => 'Branch' } )->{branchcode};
50
51
# Add categories
52
my $category_1 = $builder->build( { source => 'Category' } )->{categorycode};
53
54
# Add an item type
55
my $itemtype =
56
  $builder->build( { source => 'Itemtype', value => { notforloan => undef } } )
57
  ->{itemtype};
58
59
C4::Context->set_userenv( undef, undef, undef, undef, undef, undef, $branch_1 );
60
61
# Create a helper biblio
62
my $bib   = MARC::Record->new();
63
my $title = 'Silence in the library';
64
if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
65
    $bib->append_fields(
66
        MARC::Field->new( '600', q{}, '1', a => 'Moffat, Steven' ),
67
        MARC::Field->new( '200', q{}, q{}, a => $title ),
68
    );
69
}
70
else {
71
    $bib->append_fields(
72
        MARC::Field->new( '100', q{}, q{}, a => 'Moffat, Steven' ),
73
        MARC::Field->new( '245', q{}, q{}, a => $title ),
74
    );
75
}
76
my ($bibnum) = AddBiblio( $bib, $frameworkcode );
77
78
# Create a helper item instance for testing
79
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem(
80
    {
81
        homebranch    => $branch_1,
82
        holdingbranch => $branch_1,
83
        itype         => $itemtype
84
    },
85
    $bibnum
86
);
87
88
# Modify item; setting barcode.
89
my $testbarcode = '97531';
90
ModItem( { barcode => $testbarcode }, $bibnum, $itemnumber );
91
92
my $layout = C4::Labels::Layout->new( layout_name => 'TEST' );
93
94
my $dummy_template_values = {
95
    creator          => 'Labels',
96
    profile_id       => 0,
97
    template_code    => 'Avery 5160 | 1 x 2-5/8',
98
    template_desc    => '3 columns, 10 rows of labels',
99
    page_width       => 8.5,
100
    page_height      => 11,
101
    label_width      => 2.63,
102
    label_height     => 1,
103
    top_text_margin  => 0.139,
104
    left_text_margin => 0.0417,
105
    top_margin       => 0.35,
106
    left_margin      => 0.23,
107
    cols             => 3,
108
    rows             => 10,
109
    col_gap          => 0.13,
110
    row_gap          => 0,
111
    units            => 'INCH',
112
    template_stat    => 1,
113
};
114
115
my $label = C4::Labels::Label->new(
116
    batch_id         => $batch_id,
117
    item_number      => $itemnumber,
118
    llx              => $llx,
119
    lly              => $lly,
120
    width            => $dummy_template_values->{'label_width'},
121
    height           => $dummy_template_values->{'label_height'},
122
    top_text_margin  => $dummy_template_values->{'top_text_margin'},
123
    left_text_margin => $dummy_template_values->{'left_text_margin'},
124
    barcode_type     => $layout->get_attr('barcode_type'),
125
    printing_type    => 'BIB',
126
    guidebox         => $layout->get_attr('guidebox'),
127
    oblique_title    => $layout->get_attr('oblique_title'),
128
    font             => $layout->get_attr('font'),
129
    font_size        => $layout->get_attr('font_size'),
130
    callnum_split    => $layout->get_attr('callnum_split'),
131
    justify          => $layout->get_attr('text_justify'),
132
    format_string    => $layout->get_attr('format_string'),
133
    text_wrap_cols   => $layout->get_text_wrap_cols(
134
        label_width      => $dummy_template_values->{'label_width'},
135
        left_text_margin => $dummy_template_values->{'left_text_margin'}
136
    ),
137
);
138
139
my $label_text = $label->create_label();
140
ok( defined $label_text, 'Label Text Value defined.' );
141
142
my $label_csv_data = $label->csv_data();
143
ok( defined $label_csv_data, 'Label CSV Data defined' );
144
145
$schema->storage->txn_rollback();
146
147
1;
(-)a/t/db_dependent/Record/marcrecord2csv.t (-2 / +6 lines)
Lines 1-7 Link Here
1
#!/usr/bin/perl;
1
#!/usr/bin/perl;
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use Test::More tests => 11;
4
use Test::More tests => 12;
5
use Test::MockModule;
5
use Test::MockModule;
6
use MARC::Record;
6
use MARC::Record;
7
use MARC::Field;
7
use MARC::Field;
Lines 29-35 my $csv_content = q(Title=245$a|Author=245$c|Subject=650$a); Link Here
29
my $csv_profile_id_1 = insert_csv_profile({ csv_content => $csv_content });
29
my $csv_profile_id_1 = insert_csv_profile({ csv_content => $csv_content });
30
my $csv = Text::CSV::Encoded->new();
30
my $csv = Text::CSV::Encoded->new();
31
31
32
my $csv_output = C4::Record::marcrecord2csv( $biblionumber, $csv_profile_id_1, 1, $csv );
32
# Test bad biblionumber case
33
my $csv_output = C4::Record::marcrecord2csv( -1, $csv_profile_id_1, 1, $csv );
34
ok (! defined $csv_output, 'Bad biblionumber gives undef as expected.');
35
36
$csv_output = C4::Record::marcrecord2csv( $biblionumber, $csv_profile_id_1, 1, $csv );
33
37
34
is( $csv_output, q[Title|Author|Subject
38
is( $csv_output, q[Title|Author|Subject
35
"The art of computer programming,The art of another title"|"Donald E. Knuth.,Donald E. Knuth. II"|"Computer programming.,Computer algorithms."
39
"The art of computer programming,The art of another title"|"Donald E. Knuth.,Donald E. Knuth. II"|"Computer programming.,Computer algorithms."
(-)a/t/db_dependent/Search.t (-1 / +38 lines)
Lines 22-27 use utf8; Link Here
22
use YAML;
22
use YAML;
23
23
24
use C4::Debug;
24
use C4::Debug;
25
use C4::XSLT;
25
require C4::Context;
26
require C4::Context;
26
27
27
# work around spurious wide character warnings
28
# work around spurious wide character warnings
Lines 99-104 our $QueryFuzzy = 0; Link Here
99
our $UseQueryParser = 0;
100
our $UseQueryParser = 0;
100
our $SearchEngine = 'Zebra';
101
our $SearchEngine = 'Zebra';
101
our $marcflavour = 'MARC21';
102
our $marcflavour = 'MARC21';
103
our $htdocs = File::Spec->rel2abs(dirname($0));
104
my @htdocs = split /\//, $htdocs;
105
$htdocs[-2] = 'koha-tmpl';
106
$htdocs[-1] = 'opac-tmpl';
107
$htdocs = join '/', @htdocs;
102
our $contextmodule = new Test::MockModule('C4::Context');
108
our $contextmodule = new Test::MockModule('C4::Context');
103
$contextmodule->mock('preference', sub {
109
$contextmodule->mock('preference', sub {
104
    my ($self, $pref) = @_;
110
    my ($self, $pref) = @_;
Lines 140-145 $contextmodule->mock('preference', sub { Link Here
140
        return '';
146
        return '';
141
    } elsif ($pref eq 'template') {
147
    } elsif ($pref eq 'template') {
142
        return 'prog';
148
        return 'prog';
149
    } elsif ($pref eq 'OPACXSLTResultsDisplay') {
150
        return C4::XSLT::_get_best_default_xslt_filename($htdocs, 'bootstrap','en',$marcflavour . 'slim2OPACResults.xsl');
151
    } elsif ($pref eq 'BiblioDefaultView') {
152
        return 'normal';
153
    } elsif ($pref eq 'IdRef') {
154
        return '0';
155
    } elsif ($pref eq 'IntranetBiblioDefaultView') {
156
        return 'normal';
157
    } elsif ($pref eq 'OPACBaseURL') {
158
        return 'http://library.mydnsname.org';
159
    } elsif ($pref eq 'OPACResultsLibrary') {
160
        return 'homebranch';
161
    } elsif ($pref eq 'OpacSuppression') {
162
        return '0';
163
    } elsif ($pref eq 'OPACURLOpenInNewWindow') {
164
        return '0';
165
    } elsif ($pref eq 'TraceCompleteSubfields') {
166
        return '0';
167
    } elsif ($pref eq 'TraceSubjectSubdivisions') {
168
        return '0';
169
    } elsif ($pref eq 'TrackClicks') {
170
        return '0';
171
    } elsif ($pref eq 'URLLinkText') {
172
        return q{};
173
    } elsif ($pref eq 'UseAuthoritiesForTracings') {
174
        return '1';
175
    } elsif ($pref eq 'UseControlNumber') {
176
        return '0';
177
    } elsif ($pref eq 'UseICU') {
178
        return '0';
179
    } elsif ($pref eq 'viewISBD') {
180
        return '1';
143
    } else {
181
    } else {
144
        warn "The syspref $pref was requested but I don't know what to say; this indicates that the test requires updating"
182
        warn "The syspref $pref was requested but I don't know what to say; this indicates that the test requires updating"
145
            unless $pref =~ m/(XSLT|item|branch|holding|image)/i;
183
            unless $pref =~ m/(XSLT|item|branch|holding|image)/i;
146
- 

Return to bug 14385