X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=opac%2Fopac-review.pl;h=16ed56af963da53c24df39513452b2c517d61f21;hb=9c5e40e4923179bf0b2b630d3e09797dc4c1fdb0;hp=389175bdbf4a3274e9f1c420bc21ca1f957cc208;hpb=fc1342f73df868410e0ab670981f25ba2e1acd74;p=koha.git diff --git a/opac/opac-review.pl b/opac/opac-review.pl index 389175bdbf..16ed56af96 100755 --- a/opac/opac-review.pl +++ b/opac/opac-review.pl @@ -13,70 +13,70 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; -require Exporter; +use warnings; use CGI; use C4::Auth; use C4::Koha; -use C4::Interface::CGI::Output; -use C4::Circulation::Circ2; +use C4::Output; use C4::Review; use C4::Biblio; +use C4::Scrubber; +use C4::Debug; my $query = new CGI; my $biblionumber = $query->param('biblionumber'); -my $type = $query->param('type'); my $review = $query->param('review'); my ( $template, $borrowernumber, $cookie ) = get_template_and_user( { template_name => "opac-review.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), } ); -my $biblio = GetBiblioData( $biblionumber, 'opac' ); +# FIXME: need to allow user to delete their own comment(s) -my $savedreview = getreview( $biblionumber, $borrowernumber ); -if ( $type eq 'save' ) { - savereview( $biblionumber, $borrowernumber, $review ); +my $biblio = GetBiblioData($biblionumber); +my $savedreview = getreview($biblionumber,$borrowernumber); +my ($clean, @errors); +if (defined $review) { + if ($review !~ /\S/) { + push @errors, {empty=>1}; + } else { + $clean = C4::Scrubber->new('comment')->scrub($review); + if ($clean !~ /\S/) { + push @errors, {scrubbed_all=>1}; + } else { + if ($clean ne $review) { + push @errors, {scrubbed=>$clean}; + } + my $js_ok_review = $clean; + $js_ok_review =~ s/"/"/g; # probably redundant w/ TMPL ESCAPE=JS + $template->param(clean_review=>$js_ok_review); + if ($savedreview) { + updatereview($biblionumber, $borrowernumber, $clean); + } else { + savereview($biblionumber, $borrowernumber, $clean); + } + unless (@errors){ $template->param(WINDOW_CLOSE=>1); } + } + } } -if ( $type eq 'update' ) { - updatereview( $biblionumber, $borrowernumber, $review ); -} -if ($savedreview) { - $type = "update"; -} -else { - $type = "save"; -} -my $reviewdata = $savedreview->{'review'}; +(@errors ) and $template->param( ERRORS=>\@errors); +($cgi_debug) and $template->param(cgi_debug=>1 ); $template->param( 'biblionumber' => $biblionumber, 'borrowernumber' => $borrowernumber, - 'type' => $type, - 'review' => $reviewdata, + 'review' => $clean || $savedreview->{'review'}, + 'reviewid' => $query->param('reviewid') || 0, 'title' => $biblio->{'title'}, ); -# get the record -my $order = $query->param('order'); -my $order2 = $order; -if ( $order2 eq '' ) { - $order2 = "date_due desc"; -} -my $limit = $query->param('limit'); -if ( $limit eq 'full' ) { - $limit = 0; -} -else { - $limit = 50; -} - output_html_with_http_headers $query, $cookie, $template->output;