mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-05-05 04:52:47 +02:00
- 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
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user