Lines 4-26
package C4::Review;
Link Here
|
4 |
# |
4 |
# |
5 |
# This file is part of Koha. |
5 |
# This file is part of Koha. |
6 |
# |
6 |
# |
7 |
# Koha is free software; you can redistribute it and/or modify it under the |
7 |
# Koha is free software; you can redistribute it and/or modify it |
8 |
# terms of the GNU General Public License as published by the Free Software |
8 |
# under the terms of the GNU General Public License as published by |
9 |
# Foundation; either version 2 of the License, or (at your option) any later |
9 |
# the Free Software Foundation; either version 3 of the License, or |
10 |
# version. |
10 |
# (at your option) any later version. |
11 |
# |
11 |
# |
12 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
12 |
# Koha is distributed in the hope that it will be useful, but |
13 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
15 |
# GNU General Public License for more details. |
15 |
# |
16 |
# |
16 |
# You should have received a copy of the GNU General Public License along |
17 |
# You should have received a copy of the GNU General Public License |
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
|
19 |
|
19 |
|
20 |
use strict; |
20 |
use Modern::Perl; |
21 |
use warnings; |
|
|
22 |
|
21 |
|
23 |
use C4::Context; |
22 |
use C4::Context; |
|
|
23 |
require C4::Letters; |
24 |
|
24 |
|
25 |
use vars qw($VERSION @ISA @EXPORT); |
25 |
use vars qw($VERSION @ISA @EXPORT); |
26 |
|
26 |
|
Lines 29-36
BEGIN {
Link Here
|
29 |
$VERSION = 3.07.00.049; |
29 |
$VERSION = 3.07.00.049; |
30 |
require Exporter; |
30 |
require Exporter; |
31 |
@ISA = qw(Exporter); |
31 |
@ISA = qw(Exporter); |
32 |
@EXPORT = qw(getreview savereview updatereview numberofreviews numberofreviewsbybiblionumber |
32 |
@EXPORT = qw(getreview savereview updatereview numberofreviews |
33 |
getreviews getallreviews approvereview unapprovereview deletereview); |
33 |
numberofreviewsbybiblionumber getreviews |
|
|
34 |
getallreviews approvereview unapprovereview |
35 |
deletereview SendReviewAlert); |
34 |
} |
36 |
} |
35 |
|
37 |
|
36 |
=head1 NAME |
38 |
=head1 NAME |
Lines 79-89
sub savereview {
Link Here
|
79 |
my $query = "INSERT INTO reviews (borrowernumber,biblionumber, |
81 |
my $query = "INSERT INTO reviews (borrowernumber,biblionumber, |
80 |
review,approved,datereviewed) VALUES |
82 |
review,approved,datereviewed) VALUES |
81 |
(?,?,?,0,now())"; |
83 |
(?,?,?,0,now())"; |
|
|
84 |
my $GetReviewID = q{ |
85 |
SELECT reviewid FROM reviews WHERE borrowernumber=? AND biblionumber=?; |
86 |
}; |
82 |
my $sth = $dbh->prepare($query); |
87 |
my $sth = $dbh->prepare($query); |
83 |
$sth->execute( $borrowernumber, $biblionumber, $review); |
88 |
$sth->execute( $borrowernumber, $biblionumber, $review); |
|
|
89 |
$sth = $dbh->prepare($GetReviewID); |
90 |
$sth->execute( $borrowernumber, $biblionumber ); |
91 |
my $reviewid = $sth->fetchrow(); |
84 |
|
92 |
|
85 |
unless ($sth->err()) { |
93 |
unless ($sth->err()) { |
86 |
SendReviewAlert( $review, $borrowernumber ); |
94 |
SendReviewAlert( { |
|
|
95 |
'reviewid' => $reviewid, |
96 |
'borrowernumber' => $borrowernumber, |
97 |
'biblionumber' => $biblionumber } ); |
87 |
} |
98 |
} |
88 |
} |
99 |
} |
89 |
|
100 |
|
Lines 91-101
sub updatereview {
Link Here
|
91 |
my ( $biblionumber, $borrowernumber, $review ) = @_; |
102 |
my ( $biblionumber, $borrowernumber, $review ) = @_; |
92 |
my $dbh = C4::Context->dbh; |
103 |
my $dbh = C4::Context->dbh; |
93 |
my $query = "UPDATE reviews SET review=?,datereviewed=now(),approved=0 WHERE borrowernumber=? and biblionumber=?"; |
104 |
my $query = "UPDATE reviews SET review=?,datereviewed=now(),approved=0 WHERE borrowernumber=? and biblionumber=?"; |
|
|
105 |
my $GetReviewID = q{ |
106 |
SELECT reviewid FROM reviews WHERE borrowernumber=? AND biblionumber=?; |
107 |
}; |
94 |
my $sth = $dbh->prepare($query); |
108 |
my $sth = $dbh->prepare($query); |
95 |
$sth->execute( $review, $borrowernumber, $biblionumber ); |
109 |
$sth->execute( $review, $borrowernumber, $biblionumber ); |
|
|
110 |
$sth = $dbh->prepare($GetReviewID); |
111 |
$sth->execute( $borrowernumber, $biblionumber ); |
112 |
my $reviewid = $sth->fetchrow(); |
96 |
|
113 |
|
97 |
unless ($sth->err()) { |
114 |
unless ($sth->err()) { |
98 |
SendReviewAlert( $review, $borrowernumber ); |
115 |
SendReviewAlert( { |
|
|
116 |
'reviewid' => $reviewid, |
117 |
'borrowernumber' => $borrowernumber, |
118 |
'biblionumber' => $biblionumber } ); |
99 |
} |
119 |
} |
100 |
} |
120 |
} |
101 |
|
121 |
|
Lines 196-218
sub deletereview {
Link Here
|
196 |
|
216 |
|
197 |
=head2 SendReviewAlert |
217 |
=head2 SendReviewAlert |
198 |
|
218 |
|
199 |
SendReviewAlert( $review, $borrowernumber ); |
219 |
SendReviewAlert( { 'reviewid' => $reviewid, |
|
|
220 |
'borrowernumber' => $borrowernumber, |
221 |
'biblionumber' => $biblionumber } ); |
200 |
|
222 |
|
201 |
=cut |
223 |
=cut |
202 |
|
224 |
|
203 |
sub SendReviewAlert { |
225 |
sub SendReviewAlert { |
204 |
my $review = shift; |
226 |
my $params = shift; |
205 |
my $borrowernumber = shift; |
|
|
206 |
|
227 |
|
207 |
my $moderatorEmail = C4::Context->preference('CommentModeratorsEmail'); |
228 |
my $moderatorEmail = C4::Context->preference('CommentModeratorsEmail'); |
208 |
|
|
|
209 |
return unless $moderatorEmail; |
229 |
return unless $moderatorEmail; |
210 |
|
230 |
|
|
|
231 |
my $reviewid = $params->{'reviewid'}; |
232 |
my $borrowernumber = $params->{'borrowernumber'}; |
233 |
my $biblionumber = $params->{'biblionumber'}; |
234 |
|
211 |
my $letter = C4::Letters::GetPreparedLetter ( |
235 |
my $letter = C4::Letters::GetPreparedLetter ( |
212 |
module => 'members', |
236 |
module => 'members', |
213 |
letter_code => 'COMMENT_CREATED', |
237 |
letter_code => 'COMMENT_CREATED', |
214 |
tables => { |
238 |
tables => { |
|
|
239 |
'reviews' => $reviewid, |
215 |
'borrowers' => $borrowernumber, |
240 |
'borrowers' => $borrowernumber, |
|
|
241 |
'biblio' => $biblionumber, |
242 |
'biblioitems' => $biblionumber, |
216 |
} |
243 |
} |
217 |
) or return; |
244 |
) or return; |
218 |
|
245 |
|