fixes #2018 prevent matching tags/albums to show private content

This commit is contained in:
plegall
2023-10-05 12:11:23 +02:00
parent 018d2b031b
commit b01bf6ef3d
2 changed files with 30 additions and 15 deletions

View File

@@ -37,7 +37,7 @@ function get_nb_available_tags()
*
* @return array [id, name, counter, url_name]
*/
function get_available_tags()
function get_available_tags($tag_ids=array())
{
// we can find top fatter tags among reachable images
$query = '
@@ -45,14 +45,24 @@ SELECT tag_id, COUNT(DISTINCT(it.image_id)) AS counter
FROM '.IMAGE_CATEGORY_TABLE.' ic
INNER JOIN '.IMAGE_TAG_TABLE.' it
ON ic.image_id=it.image_id
WHERE 1=1
'.get_sql_condition_FandF(
array(
'forbidden_categories' => 'category_id',
'visible_categories' => 'category_id',
'visible_images' => 'ic.image_id'
),
' WHERE '
).'
' AND '
);
if (is_array($tag_ids) and count($tag_ids) > 0)
{
$query .= '
AND tag_id IN ('.implode(',', $tag_ids).')
';
}
$query .= '
GROUP BY tag_id
;';
$tag_counters = query2array($query, 'tag_id', 'counter');