aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2011-06-22 13:04:45 +0000
committermistic100 <mistic@piwigo.org>2011-06-22 13:04:45 +0000
commit8d22af01b9d78f44cc9293466ac98b042239aa13 (patch)
treef64d107f943cf1d34b59a17543f8ed7f61b3238d
parent4aa401c5a43cbb3245b832bbb7767c0bb3b23ff8 (diff)
feature:2358 allow non-recursive mode for get_random_image_in_category
git-svn-id: http://piwigo.org/svn/trunk@11481 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/functions_category.inc.php17
1 files changed, 14 insertions, 3 deletions
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 067b7b798..1b9db5a4c 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -504,7 +504,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)
@@ -513,8 +513,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
(