aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2006-03-15 02:26:25 +0000
committerrvelices <rv-github@modusoptimus.com>2006-03-15 02:26:25 +0000
commit88e3b36e2f805404e0bfd56d865e317495e9c973 (patch)
tree042d17038fedbc588e7b839aa754461e41fcc4f4 /include
parent1d22950cf6391f1037be9cd35288b36d62ea6fe5 (diff)
feature 262: new user cached information nb_total_pictures
git-svn-id: http://piwigo.org/svn/trunk@1081 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/functions_category.inc.php20
-rw-r--r--include/functions_user.inc.php12
2 files changed, 10 insertions, 22 deletions
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 0214656bc..2bc455775 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -104,26 +104,6 @@ SELECT name,id,date_last,nb_images,global_rank
}
/**
- * 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 COUNT(DISTINCT(image_id)) as total
- FROM '.IMAGE_CATEGORY_TABLE.'
- WHERE category_id NOT IN ('.$user['forbidden_categories'].')
-;';
- list($total) = mysql_fetch_array(pwg_query($query));
-
- return $total;
-}
-
-/**
* Retrieve informations about a category in the database
*
* Returns an array with following keys :
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index ea2cfbfbe..44f1a1cf7 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -188,6 +188,13 @@ SELECT ui.*, uc.*
$userdata['forbidden_categories'] =
calculate_permissions($userdata['id'], $userdata['status']);
+ $query = '
+SELECT COUNT(DISTINCT(image_id)) as total
+ FROM '.IMAGE_CATEGORY_TABLE.'
+ WHERE category_id NOT IN ('.$userdata['forbidden_categories'].')
+;';
+ list($userdata['nb_total_images']) = mysql_fetch_array(pwg_query($query));
+
// update user cache
$query = '
DELETE FROM '.USER_CACHE_TABLE.'
@@ -197,9 +204,10 @@ DELETE FROM '.USER_CACHE_TABLE.'
$query = '
INSERT INTO '.USER_CACHE_TABLE.'
- (user_id,need_update,forbidden_categories)
+ (user_id,need_update,forbidden_categories,nb_total_images)
VALUES
- ('.$userdata['id'].',\'false\',\''.$userdata['forbidden_categories'].'\')
+ ('.$userdata['id'].',\'false\',\''
+ .$userdata['forbidden_categories'].'\','.$userdata['nb_total_images'].')
;';
pwg_query($query);
}