Bug 21533: Do not allow password recovery for administrative locked patrons
[koha.git] / opac / opac-ISBDdetail.pl
blobe4a0b3fcad6bf557d6200e9a30792a7bf9ebf17a
1 #!/usr/bin/perl
3 # Copyright 2000-2002 Katipo Communications
4 # parts copyright 2010 BibLibre
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 =head1 NAME
24 opac-ISBDdetail.pl - script to show a biblio in ISBD format
26 =head1 DESCRIPTION
28 This script needs a biblionumber as parameter
30 It shows the biblio
32 The template is in <templates_dir>/catalogue/ISBDdetail.tt.
33 this template must be divided into 11 "tabs".
35 The first 10 tabs present the biblio, the 11th one presents
36 the items attached to the biblio
38 =head1 FUNCTIONS
40 =cut
42 use Modern::Perl;
44 use C4::Auth;
45 use C4::Context;
46 use C4::Output;
47 use CGI qw ( -utf8 );
48 use C4::Biblio;
49 use C4::Items;
50 use C4::Reserves;
51 use C4::Acquisition;
52 use C4::Serials; # uses getsubscriptionfrom biblionumber
53 use C4::Koha;
54 use Koha::IssuingRules;
55 use Koha::ItemTypes;
56 use Koha::Patrons;
57 use Koha::RecordProcessor;
58 use Koha::Biblios;
60 my $query = CGI->new();
61 my $biblionumber = $query->param('biblionumber');
62 if ( !$biblionumber ) {
63 print $query->redirect('/cgi-bin/koha/errors/404.pl');
64 exit;
66 $biblionumber = int($biblionumber);
68 #open template
69 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
71 template_name => "opac-ISBDdetail.tt",
72 query => $query,
73 type => "opac",
74 authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
75 debug => 1,
80 my $biblio = Koha::Biblios->find( $biblionumber, { prefetch => [ 'metadata', 'items' ] } );
81 my $patron = Koha::Patrons->find($loggedinuser);
83 my $opachiddenitems_rules;
84 eval {
85 my $yaml = C4::Context->preference('OpacHiddenItems') . "\n\n";
86 $opachiddenitems_rules = YAML::Load($yaml);
89 unless ( $patron and $patron->category->override_hidden_items ) {
90 # only skip this check if there's a logged in user
91 # and its category overrides OpacHiddenItems
92 if ( $biblio->hidden_in_opac({ rules => $opachiddenitems_rules }) ) {
93 print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
94 exit;
98 my $record = $biblio->metadata->record;
99 my $marcflavour = C4::Context->preference("marcflavour");
101 my $record_processor = Koha::RecordProcessor->new({
102 filters => 'ViewPolicy',
103 options => {
104 interface => 'opac',
105 frameworkcode => $biblio->frameworkcode
108 $record_processor->process($record);
110 # get biblionumbers stored in the cart
111 if(my $cart_list = $query->cookie("bib_list")){
112 my @cart_list = split(/\//, $cart_list);
113 if ( grep {$_ eq $biblionumber} @cart_list) {
114 $template->param( incart => 1 );
118 # some useful variables for enhanced content;
119 # in each case, we're grabbing the first value we find in
120 # the record and normalizing it
121 my $upc = GetNormalizedUPC( $record, $marcflavour );
122 my $ean = GetNormalizedEAN( $record, $marcflavour );
123 my $oclc = GetNormalizedOCLCNumber( $record, $marcflavour );
124 my $isbn = GetNormalizedISBN( undef, $record, $marcflavour );
125 my $content_identifier_exists;
126 if ( $isbn or $ean or $oclc or $upc ) {
127 $content_identifier_exists = 1;
129 $template->param(
130 normalized_upc => $upc,
131 normalized_ean => $ean,
132 normalized_oclc => $oclc,
133 normalized_isbn => $isbn,
134 content_identifier_exists => $content_identifier_exists,
137 #coping with subscriptions
138 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
139 my $dat = TransformMarcToKoha( $record );
141 my @subscriptions = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
142 my @subs;
143 foreach my $subscription (@subscriptions) {
144 my %cell;
145 my $serials_to_display;
146 $cell{subscriptionid} = $subscription->{subscriptionid};
147 $cell{subscriptionnotes} = $subscription->{notes};
148 $cell{branchcode} = $subscription->{branchcode};
150 #get the three latest serials.
151 $serials_to_display = $subscription->{opacdisplaycount};
152 $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
153 $cell{opacdisplaycount} = $serials_to_display;
154 $cell{latestserials} =
155 GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
156 push @subs, \%cell;
159 $template->param(
160 subscriptions => \@subs,
161 subscriptionsnumber => $subscriptionsnumber,
164 my $norequests = 1;
165 my $allow_onshelf_holds;
166 my $res = GetISBDView({
167 'record' => $record,
168 'template' => 'opac',
169 'framework' => $biblio->frameworkcode
172 my $items = $biblio->items;
173 while ( my $item = $items->next ) {
174 $norequests = 0
175 if $norequests
176 && !$item->withdrawn
177 && !$item->itemlost
178 && ($item->notforloan < 0 || not $item->notforloan )
179 && !Koha::ItemTypes->find($item->effective_itemtype)->notforloan
180 && $item->itemnumber;
182 $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
183 unless $allow_onshelf_holds;
186 if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
187 $template->param( ReservableItems => 1 );
190 $template->param(
191 RequestOnOpac => C4::Context->preference("RequestOnOpac"),
192 norequests => $norequests,
193 ISBD => $res,
194 biblio => $biblio,
197 #Search for title in links
198 my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
199 my $marcissns = GetMarcISSN ( $record, $marcflavour );
200 my $issn = $marcissns->[0] || '';
202 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
203 $dat->{title} =~ s/\/+$//; # remove trailing slash
204 $dat->{title} =~ s/\s+$//; # remove trailing space
205 $search_for_title = parametrized_url(
206 $search_for_title,
208 TITLE => $dat->{title},
209 AUTHOR => $dat->{author},
210 ISBN => $isbn,
211 ISSN => $issn,
212 CONTROLNUMBER => $marccontrolnumber,
213 BIBLIONUMBER => $biblionumber,
216 $template->param('OPACSearchForTitleIn' => $search_for_title);
219 if( C4::Context->preference('ArticleRequests') ) {
220 my $itemtype = Koha::ItemTypes->find($biblio->itemtype);
221 my $artreqpossible = $patron
222 ? $biblio->can_article_request( $patron )
223 : $itemtype
224 ? $itemtype->may_article_request
225 : q{};
226 $template->param( artreqpossible => $artreqpossible );
229 output_html_with_http_headers $query, $cookie, $template->output;