X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FReview.pm;h=f94dbc89872ddd995fc43fd68fd9379abc1893dd;hb=c9def9328613401f751f038653273b35b3e9d84e;hp=e08d24ccc51803a87dffdf1dec188a4d7f26d9cd;hpb=fddba9685c43dc0681047edce09b1f076ce93080;p=koha_gimpoz diff --git a/C4/Review.pm b/C4/Review.pm index e08d24ccc5..f94dbc8987 100644 --- a/C4/Review.pm +++ b/C4/Review.pm @@ -13,11 +13,13 @@ package C4::Review; # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; +use warnings; + use C4::Context; use vars qw($VERSION @ISA @EXPORT); @@ -27,7 +29,7 @@ BEGIN { $VERSION = 3.00; require Exporter; @ISA = qw(Exporter); - @EXPORT = qw(getreview savereview updatereview numberofreviews + @EXPORT = qw(getreview savereview updatereview numberofreviews numberofreviewsbybiblionumber getreviews getallreviews approvereview deletereview); } @@ -89,6 +91,15 @@ sub updatereview { } sub numberofreviews { + my $dbh = C4::Context->dbh; + my $query = + "SELECT count(*) FROM reviews WHERE approved=?"; + my $sth = $dbh->prepare($query); + $sth->execute( 1 ); + return $sth->fetchrow; +} + +sub numberofreviewsbybiblionumber { my ($biblionumber) = @_; my $dbh = C4::Context->dbh; my $query = @@ -109,12 +120,13 @@ sub getreviews { } sub getallreviews { - my ($status) = @_; + my ($status, $offset, $row_count) = @_; + my @params = ($status,($offset ? $offset : 0),($row_count ? $row_count : 20)); my $dbh = C4::Context->dbh; my $query = - "SELECT * FROM reviews WHERE approved=? order by datereviewed desc"; - my $sth = $dbh->prepare($query); - $sth->execute($status); + "SELECT * FROM reviews WHERE approved=? order by datereviewed desc LIMIT ?, ?"; + my $sth = $dbh->prepare($query) || warn $dbh->err_str; + $sth->execute(@params); return $sth->fetchall_arrayref({}); }