From 80b8e97ce804002bc55db95e2ad09199c119d1a0 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Wed, 22 Jun 2011 16:00:56 +0000 Subject: merge r11481 from trunk feature:2358 allow non-recursive mode for get_random_image_in_category git-svn-id: http://piwigo.org/svn/branches/2.2@11486 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_category.inc.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index 44cefb0b5..eeb0358eb 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -501,7 +501,7 @@ function get_display_images_count($cat_nb_images, $cat_count_images, $cat_count_ * * we need $category['uppercats'], $category['id'], $category['count_images'] */ -function get_random_image_in_category($category) +function get_random_image_in_category($category, $recursive=true) { $image_id = null; if ($category['count_images']>0) @@ -510,8 +510,19 @@ function get_random_image_in_category($category) SELECT image_id FROM '.CATEGORIES_TABLE.' AS c INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON ic.category_id = c.id - WHERE (c.id='.$category['id'].' OR uppercats LIKE \''.$category['uppercats'].',%\')' - .get_sql_condition_FandF + WHERE '; + if ($recursive) + { + $query.= ' + (c.id='.$category['id'].' OR uppercats LIKE \''.$category['uppercats'].',%\')'; + } + else + { + $query.= ' + c.id='.$category['id']; + } + $query.= ' + '.get_sql_condition_FandF ( array ( -- cgit v1.2.3