diff options
author | plegall <plg@piwigo.org> | 2004-12-20 22:25:05 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2004-12-20 22:25:05 +0000 |
commit | 82cb16095cd271ba780345cd3a17af7f91e9f45d (patch) | |
tree | ae2323fd4be8e8774416c8392eed6a58e873dbea /include | |
parent | 7543485ba84b14cf928184b5c7de40772fe3c04f (diff) |
- for searching in sub-categories, use the existing get_subcat_ids function
- bug fixed : category total elements count for best rated when
$user['forbidden_categories'] is not empty
git-svn-id: http://piwigo.org/svn/trunk@652 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r-- | include/functions_category.inc.php | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index f08a2fa27..5bcf82f6a 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -511,38 +511,15 @@ function initialize_category( $calling_page = 'category' ) if ($search['fields']['cat']['mode'] == 'sub_inc') { // searching all the categories id of sub-categories - $search_cat_clauses = array(); - foreach ($search['fields']['cat']['words'] as $cat_id) - { - $local_clause = 'uppercats REGEXP \'(^|,)'.$cat_id.'(,|$)\''; - array_push($search_cat_clauses, $local_clause); - } - array_walk($search_cat_clauses, - create_function('&$s', '$s = "(".$s.")";')); - - $query = ' -SELECT DISTINCT(id) AS id - FROM '.CATEGORIES_TABLE.' - WHERE '.implode(' OR ', $search_cat_clauses).' -;'; - $result = pwg_query($query); - $cat_ids = array(); - while ($row = mysql_fetch_array($result)) - { - array_push($cat_ids, $row['id']); - } - $local_clause = 'category_id IN ('; - $local_clause.= implode(',',$cat_ids); - $local_clause.= ')'; - array_push($clauses, $local_clause); + $cat_ids = get_subcat_ids($search['fields']['cat']['words']); } else { - $local_clause = 'category_id IN ('; - $local_clause.= implode(',',$search['fields']['cat']['words']); - $local_clause.= ')'; - array_push($clauses, $local_clause); + $cat_ids = $search['fields']['cat']['words']; } + + $local_clause = 'category_id IN ('.implode(',', $cat_ids).')'; + array_push($clauses, $local_clause); } // adds brackets around where clauses @@ -685,6 +662,7 @@ SELECT COUNT(DISTINCT(id)) AS nb_total_images $query =' SELECT COUNT(1) AS count FROM '.IMAGES_TABLE.' + INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id '.$page['where'].' ;'; $row = mysql_fetch_array(pwg_query($query)); |