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);
26 # set the version for version checking
27 $VERSION = do { my @v = '$Revision$' =~ /\d+/g; shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); };
31 C4::Review - Perl Module containing routines for dealing with reviews of items
38 my $review=getreview($biblionumber,$borrowernumber);
39 savereview($biblionumber,$borrowernumber,$review);
40 updatereview($biblionumber,$borrowernumber,$review);
41 my $count=numberofreviews($biblionumber);
42 my $reviews=getreviews($biblionumber);
43 my $reviews=getallreviews($status);
47 Review.pm provides many routines for manipulating reviews.
54 @EXPORT = qw(getreview savereview updatereview numberofreviews
55 getreviews getallreviews approvereview deletereview);
63 $review = getreview($biblionumber,$borrowernumber);
65 Takes a borrowernumber and a biblionumber and returns the review of that biblio
71 my ( $biblionumber, $borrowernumber ) = @_;
72 my $dbh = C4::Context->dbh;
74 "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 );
103 sub numberofreviews {
104 my ($biblionumber) = @_;
105 my $dbh = C4::Context->dbh;
107 "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;
120 "SELECT * FROM reviews WHERE biblionumber=? and approved=? order by datereviewed desc";
121 my $sth = $dbh->prepare($query) || warn $dbh->err_str;
122 $sth->execute( $biblionumber, $approved );
124 while ( my $data = $sth->fetchrow_hashref() ) {
125 push @results, $data;
128 return ( \@results );
133 my $dbh = C4::Context->dbh;
135 "SELECT * FROM reviews WHERE approved=? order by datereviewed desc";
136 my $sth = $dbh->prepare($query);
137 $sth->execute($status);
139 while ( my $data = $sth->fetchrow_hashref() ) {
140 push @results, $data;
143 return ( \@results );
148 approvereview($reviewid);
150 Takes a reviewid and marks that review approved
156 my $dbh = C4::Context->dbh();
157 my $query = "UPDATE reviews
160 my $sth = $dbh->prepare($query);
161 $sth->execute( 1, $reviewid );
167 deletereview($reviewid);
169 Takes a reviewid and deletes it
175 my $dbh = C4::Context->dbh();
176 my $query = "DELETE FROM reviews
178 my $sth = $dbh->prepare($query);
179 $sth->execute($reviewid);