From be797aa3da9b4a16010efeab33f40862864222d2 Mon Sep 17 00:00:00 2001 From: plegall Date: Thu, 24 Feb 2011 11:30:30 +0000 Subject: bug 937: problem on empty albums (visible for admins) with a representative_picture_id defined. git-svn-id: http://piwigo.org/svn/trunk@9365 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/category_cats.inc.php | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php index 8e48927c9..4271ad9be 100644 --- a/include/category_cats.inc.php +++ b/include/category_cats.inc.php @@ -205,23 +205,17 @@ SELECT id, path, tn_ext, level { if ($row['id'] == $category['representative_picture_id']) { - if ($category['count_images']>0) + // searching a random representant among elements in sub-categories + $image_id = get_random_image_in_category($category); + + if (isset($image_id) and !in_array($image_id, $image_ids)) { - // searching a random representant among elements in sub-categories - $image_id = get_random_image_in_category($category); - - if (isset($image_id)) - { - if (!in_array($image_id, $image_ids)) - { - array_push($new_image_ids, $image_id); - } - - $user_representative_updates_for[ $user['id'].'#'.$category['id'] ] = $image_id; - - $category['representative_picture_id'] = $image_id; - } + array_push($new_image_ids, $image_id); } + + $user_representative_updates_for[ $user['id'].'#'.$category['id'] ] = $image_id; + + $category['representative_picture_id'] = $image_id; } } unset($category); @@ -287,6 +281,11 @@ if (count($categories) > 0) foreach ($categories as $category) { + if (0 == $category['count_images']) + { + continue; + } + $category['name'] = trigger_event( 'render_category_name', $category['name'], -- cgit v1.2.3