aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_category.inc.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2005-03-31 21:53:24 +0000
committerplegall <plg@piwigo.org>2005-03-31 21:53:24 +0000
commitfdc5ce0a556df37b126d759ccdd0800115306998 (patch)
treeb520e6ad4523eb7b71f7870d6f79c57a1fa843ef /include/functions_category.inc.php
parent26b44267d5f3adc1cdf450d2f0c16eaf52648a07 (diff)
- apply category name and element name separation in calendar special
category - change method of counting total number of viewable pictures : pictures linked to more than one category are not counted twice. git-svn-id: http://piwigo.org/svn/trunk@761 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/functions_category.inc.php26
1 files changed, 18 insertions, 8 deletions
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 9c4e1ebab..00a379b9f 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;
}
/**