aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_user.inc.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2013-06-06 14:02:33 +0000
committerplegall <plg@piwigo.org>2013-06-06 14:02:33 +0000
commit3c74f3ff2708ac5a80d17e4cf281e368dd0b4cf0 (patch)
tree52d3170ae693bd500ccf4f015bae97ffa29035ab /include/functions_user.inc.php
parent58d51183c61623eb91dec6a3ce2a39892124f5d5 (diff)
bug 2907 fixed (only on 2.5, rvelices did a deeper rewrite for 2.6): wrong number of sub-albums
git-svn-id: http://piwigo.org/svn/branches/2.5@23075 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/functions_user.inc.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index 4f92b7d3d..50467e909 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -404,6 +404,7 @@ SELECT COUNT(DISTINCT(image_id)) as total
$user_cache_cats = get_computed_categories($userdata, null);
if ( !is_admin($userdata['status']) )
{ // for non admins we forbid categories with no image (feature 1053)
+ $uppercats_of = null;
$forbidden_ids = array();
foreach ($user_cache_cats as $cat)
{
@@ -411,6 +412,33 @@ SELECT COUNT(DISTINCT(image_id)) as total
{
$forbidden_ids[] = $cat['cat_id'];
unset( $user_cache_cats[$cat['cat_id']] );
+
+ if (empty($uppercats_of))
+ {
+ $query = '
+SELECT
+ id,
+ uppercats
+ FROM '.CATEGORIES_TABLE.'
+;';
+ $uppercats_of = simple_hash_from_query($query, 'id', 'uppercats');
+ }
+
+ // if child album is removed, we must decrease the number of
+ // sub-albums of all parent albums (to the root)
+ if (isset($uppercats_of[$cat['cat_id']]))
+ {
+ foreach (explode(',', $uppercats_of[$cat['cat_id']]) as $id)
+ {
+ // the last $id is the current album removed, it will always
+ // fail the following condition because it was removed a few
+ // lines before.
+ if (isset($user_cache_cats[$id]))
+ {
+ $user_cache_cats[$id]['count_categories']--;
+ }
+ }
+ }
}
}
if ( !empty($forbidden_ids) )