3 # Copyright 2006 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 my $biblionumber = $query->param('biblionumber');
33 my $review = $query->param('review');
34 my ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
36 template_name
=> "opac-review.tt",
39 authnotrequired
=> ( C4
::Context
->preference("OpacPublic") ?
1 : 0 ),
43 # FIXME: need to allow user to delete their own comment(s)
45 my $biblio = GetBiblioData
($biblionumber);
46 my $savedreview = getreview
($biblionumber,$borrowernumber);
48 if (defined $review) {
49 if ($review !~ /\S/) {
50 push @errors, {empty
=>1};
52 $clean = C4
::Scrubber
->new('comment')->scrub($review);
54 push @errors, {scrubbed_all
=>1};
56 if ($clean ne $review) {
57 push @errors, {scrubbed
=>$clean};
59 my $js_ok_review = $clean;
60 $js_ok_review =~ s/"/"/g; # probably redundant w/ TMPL ESCAPE=JS
61 $template->param(clean_review
=>$js_ok_review);
63 updatereview
($biblionumber, $borrowernumber, $clean);
65 savereview
($biblionumber, $borrowernumber, $clean);
67 unless (@errors){ $template->param(WINDOW_CLOSE
=>1); }
71 (@errors ) and $template->param( ERRORS
=>\
@errors);
72 ($cgi_debug) and $template->param(cgi_debug
=>1 );
74 'biblionumber' => $biblionumber,
75 'borrowernumber' => $borrowernumber,
76 'review' => $clean || $savedreview->{'review'},
77 'reviewid' => $query->param('reviewid') || 0,
78 'title' => $biblio->{'title'},
81 output_html_with_http_headers
$query, $cookie, $template->output;