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 with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
24 use vars qw($VERSION @ISA @EXPORT);
30 C4::Review - Perl Module containing routines for dealing with reviews of items
37 my $review=getreview($biblionumber,$borrowernumber);
38 savereview($biblionumber,$borrowernumber,$review);
39 updatereview($biblionumber,$borrowernumber,$review);
40 my $count=numberofreviews($biblionumber);
41 my $reviews=getreviews($biblionumber);
42 my $reviews=getallreviews($status);
46 Review.pm provides many routines for manipulating reviews.
55 @EXPORT = qw(getreview savereview updatereview numberofreviews
56 getreviews getallreviews );
64 $review = getreview($biblionumber,$borrowernumber);
66 Takes a borrowernumber and a biblionumber and returns the review of that biblio
72 my ($biblionumber,$borrowernumber) = @_;
73 my $dbh=C4::Context->dbh;
74 my $query="SELECT * FROM reviews WHERE biblionumber=? and borrowernumber=?";
75 my $sth=$dbh->prepare($query);
76 $sth->execute($biblionumber,$borrowernumber);
77 my $review = $sth->fetchrow_hashref();
83 my ($biblionumber,$borrowernumber,$review) = @_;
84 my $dbh=C4::Context->dbh;
85 my $query="INSERT INTO reviews (borrowernumber,biblionumber,
86 review,approved,datereviewed) VALUES
88 my $sth=$dbh->prepare($query);
89 $sth->execute($borrowernumber,$biblionumber,$review,0);
94 my ($biblionumber,$borrowernumber,$review) = @_;
95 my $dbh=C4::Context->dbh;
96 my $query="UPDATE reviews SET review=?,datereviewed=now(),approved=?
97 WHERE borrowernumber=? and biblionumber=?";
98 my $sth=$dbh->prepare($query);
99 $sth->execute($review,0,$borrowernumber,$biblionumber);
104 sub numberofreviews {
105 my ($biblionumber)=@_;
106 my $dbh=C4::Context->dbh;
107 my $query="SELECT count(*) FROM reviews WHERE biblionumber=? and approved=?";
108 my $sth=$dbh->prepare($query);
109 $sth->execute($biblionumber,1);
110 my $count=$sth->fetchrow_hashref;
113 return ($count->{'count(*)'});
117 my ($biblionumber,$approved)=@_;
118 my $dbh=C4::Context->dbh;
119 my $query="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);
123 while (my $data=$sth->fetchrow_hashref()){
132 my $dbh=C4::Context->dbh;
133 my $query="SELECT * FROM reviews WHERE approved=? order by datereviewed desc";
134 my $sth=$dbh->prepare($query);
135 $sth->execute($status);
137 while (my $data=$sth->fetchrow_hashref()){