Lines 59-65
use C4::Koha;
Link Here
|
59 |
use List::MoreUtils qw( any uniq ); |
59 |
use List::MoreUtils qw( any uniq ); |
60 |
use Koha::Biblios; |
60 |
use Koha::Biblios; |
61 |
use Koha::IssuingRules; |
61 |
use Koha::IssuingRules; |
62 |
use Koha::Items; |
|
|
63 |
use Koha::ItemTypes; |
62 |
use Koha::ItemTypes; |
64 |
use Koha::Patrons; |
63 |
use Koha::Patrons; |
65 |
use Koha::RecordProcessor; |
64 |
use Koha::RecordProcessor; |
Lines 84-122
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Link Here
|
84 |
} |
83 |
} |
85 |
); |
84 |
); |
86 |
|
85 |
|
87 |
my $patron = Koha::Patrons->find( $loggedinuser ); |
86 |
my $biblio = Koha::Biblios->find( $biblionumber, { prefetch => [ 'metadata', 'items' ] } ); |
88 |
my $borcat = q{}; |
|
|
89 |
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) { |
90 |
# we need to fetch the borrower info here, so we can pass the category |
91 |
$borcat = $patron ? $patron->categorycode : $borcat; |
92 |
} |
93 |
|
87 |
|
94 |
my $record = GetMarcBiblio({ |
88 |
unless ( $biblio ) { |
95 |
biblionumber => $biblionumber, |
|
|
96 |
embed_items => 1, |
97 |
opac => 1, |
98 |
borcat => $borcat }); |
99 |
if ( ! $record ) { |
100 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); |
89 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); |
101 |
exit; |
90 |
exit; |
102 |
} |
91 |
} |
103 |
|
92 |
|
104 |
my @all_items = GetItemsInfo($biblionumber); |
93 |
my $patron = Koha::Patrons->find( $loggedinuser ); |
105 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
94 |
|
106 |
my $framework = $biblio ? $biblio->frameworkcode : q{}; |
95 |
my $opachiddenitems_rules; |
107 |
my $tagslib = &GetMarcStructure( 0, $framework ); |
96 |
eval { |
108 |
my ($tag_itemnumber,$subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$framework); |
97 |
my $yaml = C4::Context->preference('OpacHiddenItems') . "\n\n"; |
109 |
my @nonhiddenitems = $record->field($tag_itemnumber); |
98 |
$opachiddenitems_rules = YAML::Load($yaml); |
110 |
if (scalar @all_items >= 1 && scalar @nonhiddenitems == 0) { |
99 |
}; |
111 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); |
100 |
|
112 |
exit; |
101 |
unless ( $patron and $patron->category->override_hidden_items ) { |
|
|
102 |
# only skip this check if there's a logged in user |
103 |
# and its category overrides OpacHiddenItems |
104 |
if ( $biblio->hidden_in_opac({ rules => $opachiddenitems_rules }) ) { |
105 |
print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early |
106 |
exit; |
107 |
} |
113 |
} |
108 |
} |
114 |
|
109 |
|
|
|
110 |
my $record = $biblio->metadata->record; |
111 |
my $marcflavour = C4::Context->preference("marcflavour"); |
112 |
|
115 |
my $record_processor = Koha::RecordProcessor->new({ |
113 |
my $record_processor = Koha::RecordProcessor->new({ |
116 |
filters => 'ViewPolicy', |
114 |
filters => 'ViewPolicy', |
117 |
options => { |
115 |
options => { |
118 |
interface => 'opac', |
116 |
interface => 'opac', |
119 |
frameworkcode => $framework |
117 |
frameworkcode => $biblio->frameworkcode |
120 |
} |
118 |
} |
121 |
}); |
119 |
}); |
122 |
$record_processor->process($record); |
120 |
$record_processor->process($record); |
Lines 128-145
if(my $cart_list = $query->cookie("bib_list")){
Link Here
|
128 |
$template->param( incart => 1 ); |
126 |
$template->param( incart => 1 ); |
129 |
} |
127 |
} |
130 |
} |
128 |
} |
131 |
|
129 |
my $tagslib = &GetMarcStructure( 0, $biblio->frameworkcode ); |
132 |
my ($bt_tag,$bt_subtag) = GetMarcFromKohaField('biblio.title',$framework); |
130 |
my ($bt_tag,$bt_subtag) = GetMarcFromKohaField('biblio.title',$biblio->frameworkcode); |
133 |
$template->param( |
131 |
$template->param( |
134 |
bibliotitle => $biblio->title, |
132 |
bibliotitle => $biblio->title, |
135 |
) if $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} <= 0 && # <=0 OPAC visible. |
133 |
) if $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} <= 0 && # <=0 OPAC visible. |
136 |
$tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8; # except -8; |
134 |
$tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8; # except -8; |
137 |
|
135 |
|
138 |
my $allow_onshelf_holds; |
136 |
my $allow_onshelf_holds; |
139 |
for my $itm (@all_items) { |
137 |
my $items = $biblio->items; |
140 |
my $item = Koha::Items->find( $itm->{itemnumber} ); |
138 |
while ( my $item = $items->next ) { |
141 |
$allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } ); |
139 |
$allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) |
142 |
last if $allow_onshelf_holds; |
140 |
unless $allow_onshelf_holds; |
143 |
} |
141 |
} |
144 |
|
142 |
|
145 |
if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { |
143 |
if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { |
Lines 307-313
foreach my $field (@fields) {
Link Here
|
307 |
push @item_loop, $item if $item; |
305 |
push @item_loop, $item if $item; |
308 |
} |
306 |
} |
309 |
my ( $holdingbrtagf, $holdingbrtagsubf ) = |
307 |
my ( $holdingbrtagf, $holdingbrtagsubf ) = |
310 |
&GetMarcFromKohaField( "items.holdingbranch", $framework ); |
308 |
&GetMarcFromKohaField( "items.holdingbranch", $biblio->frameworkcode ); |
311 |
@item_loop = |
309 |
@item_loop = |
312 |
sort { ($a->{$holdingbrtagsubf}||'') cmp ($b->{$holdingbrtagsubf}||'') } @item_loop; |
310 |
sort { ($a->{$holdingbrtagsubf}||'') cmp ($b->{$holdingbrtagsubf}||'') } @item_loop; |
313 |
|
311 |
|
Lines 326-332
if ( C4::Context->preference("OPACISBD") ) {
Link Here
|
326 |
} |
324 |
} |
327 |
|
325 |
|
328 |
#Search for title in links |
326 |
#Search for title in links |
329 |
my $marcflavour = C4::Context->preference("marcflavour"); |
|
|
330 |
my $dat = TransformMarcToKoha( $record ); |
327 |
my $dat = TransformMarcToKoha( $record ); |
331 |
my $isbn = GetNormalizedISBN(undef,$record,$marcflavour); |
328 |
my $isbn = GetNormalizedISBN(undef,$record,$marcflavour); |
332 |
my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour); |
329 |
my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour); |
333 |
- |
|
|