From fd4d0574269892b4448081f0b72835ed457edbef Mon Sep 17 00:00:00 2001 From: rub Date: Thu, 7 Dec 2006 23:10:21 +0000 Subject: Function compute_branch_cat_data was an internal function of update_user_cache_categorie Move to global because function be redeclare when it's internal git-svn-id: http://piwigo.org/svn/trunk@1640 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_user.inc.php | 72 +++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 33 deletions(-) (limited to 'include/functions_user.inc.php') diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index e1a84e1b6..206ccf4a6 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -448,53 +448,59 @@ SELECT id } /** - * update data of user_cache_categorie + * compute data of categories branches * - * @param int user_id - * @return null + * was internal function of update_user_cache_categorie + * move to global because function be redeclare when it's internal */ -function update_user_cache_categorie($user_id, $user_forbidden_categories) +function compute_branch_cat_data(&$cats, &$list_cat_id, &$level, &$ref_level) { - function compute_branch_cat_data(&$cats, &$list_cat_id, &$level, &$ref_level) + $date = ''; + $count_images = 0; + $count_categories = 0; + do { - $date = ''; - $count_images = 0; - $count_categories = 0; - do + $cat_id = array_pop($list_cat_id); + if (!is_null($cat_id)) { - $cat_id = array_pop($list_cat_id); - if (!is_null($cat_id)) + // Count images and categories + $cats[$cat_id]['count_images'] += $count_images; + $cats[$cat_id]['count_categories'] += $count_categories; + $count_images = $cats[$cat_id]['count_images']; + $count_categories = $cats[$cat_id]['count_categories'] + 1; + + if ((empty($cats[$cat_id]['max_date_last'])) or ($cats[$cat_id]['max_date_last'] < $date)) { - // Count images and categories - $cats[$cat_id]['count_images'] += $count_images; - $cats[$cat_id]['count_categories'] += $count_categories; - $count_images = $cats[$cat_id]['count_images']; - $count_categories = $cats[$cat_id]['count_categories'] + 1; - - if ((empty($cats[$cat_id]['max_date_last'])) or ($cats[$cat_id]['max_date_last'] < $date)) - { - $cats[$cat_id]['max_date_last'] = $date; - $cats[$cat_id]['is_child_date_last'] = true; - } - else - { - $date = $cats[$cat_id]['max_date_last']; - } - $ref_level = substr_count($cats[$cat_id]['global_rank'], '.') + 1; + $cats[$cat_id]['max_date_last'] = $date; + $cats[$cat_id]['is_child_date_last'] = true; } else { - $ref_level = 0; + $date = $cats[$cat_id]['max_date_last']; } - } while ($level <= $ref_level); - - // Last cat updating must be added to list for next branch - if ($ref_level <> 0) + $ref_level = substr_count($cats[$cat_id]['global_rank'], '.') + 1; + } + else { - array_push($list_cat_id, $cat_id); + $ref_level = 0; } + } while ($level <= $ref_level); + + // Last cat updating must be added to list for next branch + if ($ref_level <> 0) + { + array_push($list_cat_id, $cat_id); } +} +/** + * update data of user_cache_categorie + * + * @param int user_id + * @return null + */ +function update_user_cache_categorie($user_id, $user_forbidden_categories) +{ // delete user cache $query = ' delete from '.USER_CACHE_CATEGORIES_TABLE.' -- cgit v1.2.3