Ignore:
Timestamp:
Jun 22, 2011, 3:04:45 PM (13 years ago)
Author:
mistic100
Message:

feature:2358 allow non-recursive mode for get_random_image_in_category

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_category.inc.php

    r11285 r11481  
    505505 * we need $category['uppercats'], $category['id'], $category['count_images']
    506506 */
    507 function get_random_image_in_category($category)
     507function get_random_image_in_category($category, $recursive=true)
    508508{
    509509  $image_id = null;
     
    514514  FROM '.CATEGORIES_TABLE.' AS c
    515515    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON ic.category_id = c.id
    516   WHERE (c.id='.$category['id'].' OR uppercats LIKE \''.$category['uppercats'].',%\')'
    517     .get_sql_condition_FandF
     516  WHERE ';
     517    if ($recursive)
     518    {
     519      $query.= '
     520    (c.id='.$category['id'].' OR uppercats LIKE \''.$category['uppercats'].',%\')';
     521    }
     522    else
     523    {
     524      $query.= '
     525    c.id='.$category['id'];
     526    }
     527    $query.= '
     528    '.get_sql_condition_FandF
    518529    (
    519530      array
Note: See TracChangeset for help on using the changeset viewer.