Bug - 5511: Added new system preference: SessionRestrictionByIP
[koha.git] / opac / opac-readingrecord.pl
blob0e2d89f2650c8fb4b3c4feef498978f1c495c304
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
8 # version.
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 use strict;
20 use warnings;
22 use CGI qw ( -utf8 );
24 use C4::Auth;
25 use C4::Koha;
26 use C4::Biblio;
27 use C4::Circulation;
28 use C4::Members;
29 use Koha::DateUtils;
30 use MARC::Record;
32 use C4::Output;
33 use C4::Charset qw(StripNonXmlChars);
35 my $query = new CGI;
37 # if opacreadinghistory is disabled, leave immediately
38 if ( ! C4::Context->preference('opacreadinghistory') ) {
39 print $query->redirect("/cgi-bin/koha/errors/404.pl");
40 exit;
43 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
45 template_name => "opac-readingrecord.tt",
46 query => $query,
47 type => "opac",
48 authnotrequired => 0,
49 flagsrequired => { borrow => 1 },
50 debug => 1,
54 # get borrower information ....
55 my ( $borr ) = GetMemberDetails( $borrowernumber );
57 $template->param(%{$borr});
59 my $itemtypes = GetItemTypes();
61 # get the record
62 my $order = $query->param('order') || '';
63 if ( $order eq 'title' ) {
64 $template->param( orderbytitle => 1 );
66 elsif ( $order eq 'author' ) {
67 $template->param( orderbyauthor => 1 );
69 else {
70 $order = "date_due desc";
71 $template->param( orderbydate => 1 );
75 my $limit = $query->param('limit');
76 $limit = ( $limit eq 'full' ) ? 0 : 50;
78 my $issues = GetAllIssues( $borrowernumber, $order, $limit );
80 my $itype_attribute =
81 ( C4::Context->preference('item-level_itypes') ) ? 'itype' : 'itemtype';
83 my $opac_summary_html = C4::Context->preference('OPACMySummaryHTML');
84 foreach my $issue ( @{$issues} ) {
85 $issue->{normalized_isbn} = GetNormalizedISBN( $issue->{isbn} );
86 if ( $issue->{$itype_attribute} ) {
87 $issue->{description} =
88 $itemtypes->{ $issue->{$itype_attribute} }->{description};
89 $issue->{imageurl} =
90 getitemtypeimagelocation( 'opac',
91 $itemtypes->{ $issue->{$itype_attribute} }->{imageurl} );
93 if ( $issue->{marcxml} ) {
94 my $marcxml = StripNonXmlChars( $issue->{marcxml} );
95 my $marc_rec =
96 MARC::Record::new_from_xml( $marcxml, 'utf8',
97 C4::Context->preference('marcflavour') );
98 $issue->{subtitle} =
99 GetRecordValue( 'subtitle', $marc_rec, $issue->{frameworkcode} );
101 # My Summary HTML
102 if ($opac_summary_html) {
103 my $my_summary_html = $opac_summary_html;
104 $issue->{author}
105 ? $my_summary_html =~ s/{AUTHOR}/$issue->{author}/g
106 : $my_summary_html =~ s/{AUTHOR}//g;
107 my $title = $issue->{title};
108 $title =~ s/\/+$//; # remove trailing slash
109 $title =~ s/\s+$//; # remove trailing space
110 $title
111 ? $my_summary_html =~ s/{TITLE}/$title/g
112 : $my_summary_html =~ s/{TITLE}//g;
113 $issue->{normalized_isbn}
114 ? $my_summary_html =~ s/{ISBN}/$issue->{normalized_isbn}/g
115 : $my_summary_html =~ s/{ISBN}//g;
116 $issue->{biblionumber}
117 ? $my_summary_html =~ s/{BIBLIONUMBER}/$issue->{biblionumber}/g
118 : $my_summary_html =~ s/{BIBLIONUMBER}//g;
119 $issue->{MySummaryHTML} = $my_summary_html;
123 if (C4::Context->preference('BakerTaylorEnabled')) {
124 $template->param(
125 JacketImages=>1,
126 BakerTaylorEnabled => 1,
127 BakerTaylorImageURL => &image_url(),
128 BakerTaylorLinkURL => &link_url(),
129 BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
133 BEGIN {
134 if (C4::Context->preference('BakerTaylorEnabled')) {
135 require C4::External::BakerTaylor;
136 import C4::External::BakerTaylor qw(&image_url &link_url);
140 for(qw(AmazonCoverImages GoogleJackets)) { # BakerTaylorEnabled handled above
141 C4::Context->preference($_) or next;
142 $template->param($_=>1);
143 $template->param(JacketImages=>1);
146 $template->param(
147 READING_RECORD => $issues,
148 limit => $limit,
149 readingrecview => 1,
150 OPACMySummaryHTML => $opac_summary_html ? 1 : 0,
153 output_html_with_http_headers $query, $cookie, $template->output;