aboutsummaryrefslogtreecommitdiffstats
path: root/include/picture_rate.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2011-07-25 18:04:50 +0000
committerrvelices <rv-github@modusoptimus.com>2011-07-25 18:04:50 +0000
commit4e4dc79e5162a7d1315b12e94153443552530b9e (patch)
treefeec6972f3ff9eb108ce87fe672414b98da69a85 /include/picture_rate.inc.php
parent86bc4d1143474dcb5b9a65c1affd62d7e1b14c0c (diff)
feature 2384: improve average rating calculation (still need to update language files)
git-svn-id: http://piwigo.org/svn/trunk@11827 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/picture_rate.inc.php13
1 files changed, 5 insertions, 8 deletions
diff --git a/include/picture_rate.inc.php b/include/picture_rate.inc.php
index 2c0d9dd3f..086287c81 100644
--- a/include/picture_rate.inc.php
+++ b/include/picture_rate.inc.php
@@ -28,7 +28,8 @@
if ($conf['rate'])
{
- if ( NULL != $picture['current']['average_rate'] )
+ $rate_summary = array( 'count'=>0, 'score'=>$picture['current']['average_rate'], 'average'=>null );
+ if ( NULL != $rate_summary['score'] )
{
$query = '
SELECT COUNT(rate) AS count
@@ -36,18 +37,14 @@ SELECT COUNT(rate) AS count
FROM '.RATE_TABLE.'
WHERE element_id = '.$picture['current']['id'].'
;';
- $row = pwg_db_fetch_assoc(pwg_query($query));
+ list($rate_summary['count'], $rate_summary['average']) = pwg_db_fetch_row(pwg_query($query));
}
- else
- { // avg rate null -> no rate -> no need to query db
- $row = array( 'count'=>0, 'average'=>NULL );
- }
- $template->assign('rate_summary', $row);
+ $template->assign('rate_summary', $rate_summary);
$user_rate = null;
if ($conf['rate_anonymous'] or is_autorize_status(ACCESS_CLASSIC) )
{
- if ($row['count']>0)
+ if ($rate_summary['count']>0)
{
$query = 'SELECT rate
FROM '.RATE_TABLE.'