View | Details | Raw Unified | Return to bug 15839
Collapse All | Expand All

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-review.tt (+6 lines)
Lines 18-23 Link Here
18
                        [% IF ( ERRORS ) %]
18
                        [% IF ( ERRORS ) %]
19
                            <div class="alert">
19
                            <div class="alert">
20
                                [% FOREACH ERROR IN ERRORS %]
20
                                [% FOREACH ERROR IN ERRORS %]
21
                                    [% IF ( ERROR.nobiblio ) %]
22
                                        <p>Error: we cannot find this bibliographic record.</p>
23
                                    [% END %]
24
                                    [% IF ( ERROR.unauthorized ) %]
25
                                        <p>Sorry, only the creator of this comment is allowed to change it.</p>
26
                                    [% END %]
21
                                    [% IF ( ERROR.scrubbed ) %]
27
                                    [% IF ( ERROR.scrubbed ) %]
22
                                        <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>
28
                                        <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>
23
                                    [% END %]
29
                                    [% END %]
(-)a/opac/opac-review.pl (-9 / +18 lines)
Lines 32-37 use Koha::Reviews; Link Here
32
my $query        = new CGI;
32
my $query        = new CGI;
33
my $biblionumber = $query->param('biblionumber');
33
my $biblionumber = $query->param('biblionumber');
34
my $review       = $query->param('review');
34
my $review       = $query->param('review');
35
my $reviewid     = $query->param('reviewid');
35
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
36
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
36
    {
37
    {
37
        template_name   => "opac-review.tt",
38
        template_name   => "opac-review.tt",
Lines 43-53 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
43
44
44
# FIXME: need to allow user to delete their own comment(s)
45
# FIXME: need to allow user to delete their own comment(s)
45
46
47
my ( $clean, @errors, $savedreview );
46
my $biblio = GetBiblioData($biblionumber);
48
my $biblio = GetBiblioData($biblionumber);
47
# FIXME biblionumber, borrowernumber should be a unique key of reviews
49
48
my $savedreview = Koha::Reviews->search({ biblionumber => $biblionumber, borrowernumber => $borrowernumber })->next;
50
if( !$biblio ) {
49
my ($clean, @errors);
51
    push @errors, { nobiblio => 1 };
50
if (defined $review) {
52
} elsif( $reviewid ) { # edit existing one, check on creator
53
    $savedreview = Koha::Reviews->search({ reviewid => $reviewid, borrowernumber => $borrowernumber })->next;
54
    push @errors, { unauthorized => 1 } if !$savedreview;
55
} else { # this check prevents adding multiple comments
56
    # FIXME biblionumber, borrowernumber should be a unique key of reviews
57
    $savedreview = Koha::Reviews->search({ biblionumber => $biblionumber, borrowernumber => $borrowernumber })->next;
58
    $review = $savedreview? $savedreview->review: $review;
59
}
60
61
if( !@errors && defined $review ) {
51
	if ($review !~ /\S/) {
62
	if ($review !~ /\S/) {
52
		push @errors, {empty=>1};
63
		push @errors, {empty=>1};
53
	} else {
64
	} else {
Lines 70-81 if (defined $review) { Link Here
70
                    }
81
                    }
71
                )->store;
82
                )->store;
72
            } else {
83
            } else {
73
                Koha::Review->new(
84
                $reviewid = Koha::Review->new(
74
                    {   biblionumber   => $biblionumber,
85
                    {   biblionumber   => $biblionumber,
75
                        borrowernumber => $borrowernumber,
86
                        borrowernumber => $borrowernumber,
76
                        review         => $clean,
87
                        review         => $clean,
77
                    }
88
                    }
78
                )->store;
89
                )->store->reviewid;
79
            }
90
            }
80
			unless (@errors){ $template->param(WINDOW_CLOSE=>1); }
91
			unless (@errors){ $template->param(WINDOW_CLOSE=>1); }
81
		}
92
		}
Lines 89-97 $template->param( Link Here
89
    'biblionumber'   => $biblionumber,
100
    'biblionumber'   => $biblionumber,
90
    'borrowernumber' => $borrowernumber,
101
    'borrowernumber' => $borrowernumber,
91
    'review'         => $review,
102
    'review'         => $review,
92
	'reviewid'       => scalar $query->param('reviewid') || 0,
103
    'reviewid'       => $reviewid || 0,
93
    'title'          => $biblio->{'title'},
104
    'title'          => $biblio->{'title'},
94
);
105
);
95
106
96
output_html_with_http_headers $query, $cookie, $template->output;
107
output_html_with_http_headers $query, $cookie, $template->output;
97
98
- 

Return to bug 15839