diff options
author | plegall <plg@piwigo.org> | 2005-08-15 13:05:29 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2005-08-15 13:05:29 +0000 |
commit | 6615c91e30b5bd8207460abef966f39307f9030c (patch) | |
tree | 63a7e1857e8264fba83a83836de593713654978a /include | |
parent | 38326b5c93f05731497f474b151856bb1d3b55f6 (diff) |
- bug 135 : "Count of total number of pictures". Correction reported from
development branch.
git-svn-id: http://piwigo.org/svn/branches/branch-1_4@813 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r-- | include/functions_category.inc.php | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index 9d946df4f..03e54ab90 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -155,20 +155,30 @@ SELECT name,id,date_last,nb_images,global_rank return get_html_menu_category($cats); } +/** + * returns the total number of elements viewable in the gallery by the + * connected user + * + * @return int + */ function count_user_total_images() { global $user; - $query = 'SELECT SUM(nb_images) AS total'; - $query.= ' FROM '.CATEGORIES_TABLE; - if ( count( $user['restrictions'] ) > 0 ) - $query.= ' WHERE id NOT IN ('.$user['forbidden_categories'].')'; - $query.= ';'; + $query = ' +SELECT COUNT(DISTINCT(image_id)) as total + FROM '.IMAGE_CATEGORY_TABLE; + if (count($user['restrictions']) > 0) + { + $query.= ' + WHERE category_id NOT IN ('.$user['forbidden_categories'].')'; + } + $query.= ' +;'; - $row = mysql_fetch_array( pwg_query( $query ) ); + $row = mysql_fetch_array(pwg_query($query)); - if ( !isset( $row['total'] ) ) $row['total'] = 0; - return $row['total']; + return isset($row['total']) ? $row['total'] : 0; } /** |