3 # Copyright 2000-2002 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.
25 use vars
qw($VERSION @ISA @EXPORT);
28 # set the version for version checking
29 $VERSION = 3.07.00.049;
32 @EXPORT = qw(getreview savereview updatereview numberofreviews numberofreviewsbybiblionumber
33 getreviews getallreviews approvereview unapprovereview deletereview);
38 C4::Review - Perl Module containing routines for dealing with reviews of items
44 my $review=getreview($biblionumber,$borrowernumber);
45 savereview($biblionumber,$borrowernumber,$review);
46 updatereview($biblionumber,$borrowernumber,$review);
47 my $count=numberofreviews($status);
48 my $count=numberofreviewsbybiblionumber($biblionumber);
49 my $reviews=getreviews($biblionumber);
50 my $reviews=getallreviews($status);
54 Review.pm provides many routines for manipulating reviews.
60 $review = getreview($biblionumber,$borrowernumber);
62 Takes a borrowernumber and a biblionumber and returns the review of that biblio
67 my ( $biblionumber, $borrowernumber ) = @_;
68 my $dbh = C4
::Context
->dbh;
70 "SELECT * FROM reviews WHERE biblionumber=? and borrowernumber=?";
71 my $sth = $dbh->prepare($query);
72 $sth->execute( $biblionumber, $borrowernumber );
73 return $sth->fetchrow_hashref();
77 my ( $biblionumber, $borrowernumber, $review ) = @_;
78 my $dbh = C4
::Context
->dbh;
79 my $query = "INSERT INTO reviews (borrowernumber,biblionumber,
80 review,approved,datereviewed) VALUES
82 my $sth = $dbh->prepare($query);
83 $sth->execute( $borrowernumber, $biblionumber, $review);
87 my ( $biblionumber, $borrowernumber, $review ) = @_;
88 my $dbh = C4
::Context
->dbh;
89 my $query = "UPDATE reviews SET review=?,datereviewed=now(),approved=0 WHERE borrowernumber=? and biblionumber=?";
90 my $sth = $dbh->prepare($query);
91 $sth->execute( $review, $borrowernumber, $biblionumber );
96 my $status = (defined($param) ?
$param : 1);
97 my $dbh = C4
::Context
->dbh;
99 "SELECT count(*) FROM reviews WHERE approved=?";
100 my $sth = $dbh->prepare($query);
101 $sth->execute( $status );
102 return $sth->fetchrow;
105 sub numberofreviewsbybiblionumber
{
106 my ($biblionumber) = @_;
107 my $dbh = C4
::Context
->dbh;
109 "SELECT count(*) FROM reviews WHERE biblionumber=? and approved=?";
110 my $sth = $dbh->prepare($query);
111 $sth->execute( $biblionumber, 1 );
112 return $sth->fetchrow;
116 my ( $biblionumber, $approved ) = @_;
117 my $dbh = C4
::Context
->dbh;
119 "SELECT * FROM reviews WHERE biblionumber=? and approved=? order by datereviewed desc";
120 my $sth = $dbh->prepare($query) || warn $dbh->err_str;
121 $sth->execute( $biblionumber, $approved );
122 return $sth->fetchall_arrayref({});
126 my ($status, $offset, $row_count) = @_;
127 my @params = ($status,($offset ?
$offset : 0),($row_count ?
$row_count : 20));
128 my $dbh = C4
::Context
->dbh;
130 "SELECT * FROM reviews WHERE approved=? order by datereviewed desc LIMIT ?, ?";
131 my $sth = $dbh->prepare($query) || warn $dbh->err_str;
132 $sth->execute(@params);
133 return $sth->fetchall_arrayref({});
138 approvereview($reviewid);
140 Takes a reviewid and marks that review approved
146 my $dbh = C4
::Context
->dbh();
147 my $query = "UPDATE reviews
150 my $sth = $dbh->prepare($query);
151 $sth->execute( 1, $reviewid );
154 =head2 unapprovereview
156 unapprovereview($reviewid);
158 Takes a reviewid and marks that review as not approved
162 sub unapprovereview
{
164 my $dbh = C4
::Context
->dbh();
165 my $query = "UPDATE reviews
168 my $sth = $dbh->prepare($query);
169 $sth->execute( 0, $reviewid );
174 deletereview($reviewid);
176 Takes a reviewid and deletes it
182 my $dbh = C4
::Context
->dbh();
183 my $query = "DELETE FROM reviews
185 my $sth = $dbh->prepare($query);
186 $sth->execute($reviewid);