Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mistic100 committed Jun 22, 2011
1 parent 4aa401c commit 8d22af0
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions include/functions_category.inc.php
Expand Up @@ -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)
Expand All @@ -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
(
Expand Down

0 comments on commit 8d22af0

Please sign in to comment.