diff options
author | rvelices <rv-github@modusoptimus.com> | 2008-07-15 01:29:23 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2008-07-15 01:29:23 +0000 |
commit | 9c96b905ff3327ad5264b794048b6c71bbc5e4ee (patch) | |
tree | a0565907ca8d5546ffcd963c952e331e37109c9a /include/functions_rate.inc.php | |
parent | df29ffbde72e88635f454d5d6d84c5a7209460f3 (diff) |
- image rating on picture page done through ajax (tested safari/ie 6&7/ff)
git-svn-id: http://piwigo.org/svn/trunk@2435 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | include/functions_rate.inc.php | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/include/functions_rate.inc.php b/include/functions_rate.inc.php index ad3de1b2f..9bf97cbdb 100644 --- a/include/functions_rate.inc.php +++ b/include/functions_rate.inc.php @@ -36,14 +36,14 @@ function rate_picture($image_id, $rate) or !$conf['rate'] or !in_array($rate, $conf['rate_items'])) { - return; + return false; } $user_anonymous = is_autorize_status(ACCESS_CLASSIC) ? false : true; if ($user_anonymous and !$conf['rate_anonymous']) { - return; + return false; } $ip_components = explode('.', $_SERVER["REMOTE_ADDR"]); @@ -118,17 +118,20 @@ INSERT // update of images.average_rate field $query = ' -SELECT ROUND(AVG(rate),2) AS average_rate +SELECT COUNT(rate) AS count + , ROUND(AVG(rate),2) AS average + , ROUND(STD(rate),2) AS stdev FROM '.RATE_TABLE.' WHERE element_id = '.$image_id.' ;'; - $row = mysql_fetch_array(pwg_query($query)); + $row = mysql_fetch_assoc(pwg_query($query)); $query = ' UPDATE '.IMAGES_TABLE.' - SET average_rate = '.$row['average_rate'].' + SET average_rate = '.$row['average'].' WHERE id = '.$image_id.' ;'; pwg_query($query); + return $row; } ?>
\ No newline at end of file |