Bugzilla – Attachment 53807 Details for
Bug 15839
Move the reviews related code to Koha::Reviews
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15839: [QA Follow-up] Error checking in opac-review.pl
Bug-15839-QA-Follow-up-Error-checking-in-opac-revi.patch (text/plain), 4.66 KB, created by
Marcel de Rooy
on 2016-07-29 09:45:07 UTC
(
hide
)
Description:
Bug 15839: [QA Follow-up] Error checking in opac-review.pl
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2016-07-29 09:45:07 UTC
Size:
4.66 KB
patch
obsolete
>From 1c5896abfba203d0988fb0693bdd31fabee2de01 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 29 Jul 2016 10:24:44 +0200 >Subject: [PATCH] Bug 15839: [QA Follow-up] Error checking in opac-review.pl >Content-Type: text/plain; charset=utf-8 > >[1] Adds a check on biblionumber. (Prevents a DBIx error.) >[2] If you have a reviewid, search on that and check results. > Add an unauthorized error in template. >[3] If you add a new review, check that there is no review yet. > If so, edit the existing one. > This supports the added FIXME on a unique constraint. > >Note: This script could receive further attention. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Tested all crud ops with opac-review.pl (incl URL manipulation). >--- > .../opac-tmpl/bootstrap/en/modules/opac-review.tt | 6 +++++ > opac/opac-review.pl | 26 ++++++++++++++------ > 2 files changed, 24 insertions(+), 8 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-review.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-review.tt >index b6f968d..7e537b6 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-review.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-review.tt >@@ -18,6 +18,12 @@ > [% IF ( ERRORS ) %] > <div class="alert"> > [% FOREACH ERROR IN ERRORS %] >+ [% IF ( ERROR.nobiblio ) %] >+ <p>Error: we cannot find this bibliographic record.</p> >+ [% END %] >+ [% IF ( ERROR.unauthorized ) %] >+ <p>Sorry, only the creator of this comment is allowed to change it.</p> >+ [% END %] > [% IF ( ERROR.scrubbed ) %] > <p>Note: your comment contained illegal markup code. It has been saved with the markup removed, as below. You can edit the comment further, or cancel to retain the comment as is.</p> > [% END %] >diff --git a/opac/opac-review.pl b/opac/opac-review.pl >index 917036b..f8e86ba 100755 >--- a/opac/opac-review.pl >+++ b/opac/opac-review.pl >@@ -32,6 +32,7 @@ use Koha::Reviews; > my $query = new CGI; > my $biblionumber = $query->param('biblionumber'); > my $review = $query->param('review'); >+my $reviewid = $query->param('reviewid'); > my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > { > template_name => "opac-review.tt", >@@ -43,11 +44,21 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > > # FIXME: need to allow user to delete their own comment(s) > >+my ( $clean, @errors, $savedreview ); > my $biblio = GetBiblioData($biblionumber); >-# FIXME biblionumber, borrowernumber should be a unique key of reviews >-my $savedreview = Koha::Reviews->search({ biblionumber => $biblionumber, borrowernumber => $borrowernumber })->next; >-my ($clean, @errors); >-if (defined $review) { >+ >+if( !$biblio ) { >+ push @errors, { nobiblio => 1 }; >+} elsif( $reviewid ) { # edit existing one, check on creator >+ $savedreview = Koha::Reviews->search({ reviewid => $reviewid, borrowernumber => $borrowernumber })->next; >+ push @errors, { unauthorized => 1 } if !$savedreview; >+} else { # this check prevents adding multiple comments >+ # FIXME biblionumber, borrowernumber should be a unique key of reviews >+ $savedreview = Koha::Reviews->search({ biblionumber => $biblionumber, borrowernumber => $borrowernumber })->next; >+ $review = $savedreview? $savedreview->review: $review; >+} >+ >+if( !@errors && defined $review ) { > if ($review !~ /\S/) { > push @errors, {empty=>1}; > } else { >@@ -70,12 +81,12 @@ if (defined $review) { > } > )->store; > } else { >- Koha::Review->new( >+ $reviewid = Koha::Review->new( > { biblionumber => $biblionumber, > borrowernumber => $borrowernumber, > review => $clean, > } >- )->store; >+ )->store->reviewid; > } > unless (@errors){ $template->param(WINDOW_CLOSE=>1); } > } >@@ -89,9 +100,8 @@ $template->param( > 'biblionumber' => $biblionumber, > 'borrowernumber' => $borrowernumber, > 'review' => $review, >- 'reviewid' => scalar $query->param('reviewid') || 0, >+ 'reviewid' => $reviewid || 0, > 'title' => $biblio->{'title'}, > ); > > output_html_with_http_headers $query, $cookie, $template->output; >- >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15839
:
48166
|
48167
|
48168
|
48169
|
48170
|
48171
|
48172
|
48173
|
48174
|
48175
|
48176
|
48280
|
48281
|
48282
|
48283
|
48284
|
48285
|
48286
|
48287
|
48288
|
48289
|
48290
|
51197
|
51198
|
51199
|
51200
|
51201
|
51202
|
51203
|
51204
|
51205
|
51206
|
51207
|
53794
|
53795
|
53796
|
53797
|
53798
|
53799
|
53800
|
53801
|
53802
|
53803
|
53804
|
53805
|
53806
| 53807