mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-12 03:33:01 +02:00
This commit is contained in:
+48
-43
@@ -183,6 +183,8 @@ foreach ($allAlbum as $album)
|
||||
$the_place['cat'] = $album;
|
||||
}
|
||||
|
||||
$is_forbidden = array_fill_keys(@explode(',', $user['forbidden_categories']), 1);
|
||||
|
||||
//Make an ordered tree
|
||||
function cmpCat($a, $b)
|
||||
{
|
||||
@@ -195,50 +197,10 @@ function cmpCat($a, $b)
|
||||
|
||||
function assocToOrderedTree($assocT)
|
||||
{
|
||||
global $nb_photos_in, $nb_sub_photos;
|
||||
|
||||
$orderedTree = array();
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
category_id,
|
||||
COUNT(*) AS nb_photos
|
||||
FROM '.IMAGE_CATEGORY_TABLE.'
|
||||
GROUP BY category_id
|
||||
;';
|
||||
|
||||
$nb_photos_in = query2array($query, 'category_id', 'nb_photos');
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
id,
|
||||
uppercats
|
||||
FROM '.CATEGORIES_TABLE.'
|
||||
;';
|
||||
$all_categories = query2array($query, 'id', 'uppercats');
|
||||
$subcats_of = array();
|
||||
|
||||
foreach ($all_categories as $id => $uppercats)
|
||||
{
|
||||
foreach (array_slice(explode(',', $uppercats), 0, -1) as $uppercat_id)
|
||||
{
|
||||
@$subcats_of[$uppercat_id][] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
$nb_sub_photos = array();
|
||||
foreach ($subcats_of as $cat_id => $subcat_ids)
|
||||
{
|
||||
$nb_photos = 0;
|
||||
foreach ($subcat_ids as $id)
|
||||
{
|
||||
if (isset($nb_photos_in[$id]))
|
||||
{
|
||||
$nb_photos+= $nb_photos_in[$id];
|
||||
}
|
||||
}
|
||||
|
||||
$nb_sub_photos[$cat_id] = $nb_photos;
|
||||
}
|
||||
|
||||
foreach($assocT as $cat)
|
||||
{
|
||||
$orderedCat = array();
|
||||
@@ -248,7 +210,7 @@ SELECT
|
||||
$orderedCat['id'] = $cat['cat']['id'];
|
||||
$orderedCat['nb_images'] = isset($nb_photos_in[$cat['cat']['id']]) ? $nb_photos_in[$cat['cat']['id']] : 0;
|
||||
$orderedCat['last_updates'] = $cat['cat']['lastmodified'];
|
||||
$orderedCat['has_not_access'] = !cat_admin_access($cat['cat']['id']);
|
||||
$orderedCat['has_not_access'] = isset($is_forbidden[$cat['cat']['id']]);
|
||||
$orderedCat['nb_sub_photos'] = isset($nb_sub_photos[$cat['cat']['id']]) ? $nb_sub_photos[$cat['cat']['id']] : 0;
|
||||
if (isset($cat['children']))
|
||||
{
|
||||
@@ -262,6 +224,49 @@ SELECT
|
||||
return $orderedTree;
|
||||
}
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
category_id,
|
||||
COUNT(*) AS nb_photos
|
||||
FROM '.IMAGE_CATEGORY_TABLE.'
|
||||
GROUP BY category_id
|
||||
;';
|
||||
|
||||
$nb_photos_in = query2array($query, 'category_id', 'nb_photos');
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
id,
|
||||
uppercats
|
||||
FROM '.CATEGORIES_TABLE.'
|
||||
;';
|
||||
$all_categories = query2array($query, 'id', 'uppercats');
|
||||
|
||||
$subcats_of = array();
|
||||
|
||||
foreach ($all_categories as $id => $uppercats)
|
||||
{
|
||||
foreach (array_slice(explode(',', $uppercats), 0, -1) as $uppercat_id)
|
||||
{
|
||||
@$subcats_of[$uppercat_id][] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
$nb_sub_photos = array();
|
||||
foreach ($subcats_of as $cat_id => $subcat_ids)
|
||||
{
|
||||
$nb_photos = 0;
|
||||
foreach ($subcat_ids as $id)
|
||||
{
|
||||
if (isset($nb_photos_in[$id]))
|
||||
{
|
||||
$nb_photos+= $nb_photos_in[$id];
|
||||
}
|
||||
}
|
||||
|
||||
$nb_sub_photos[$cat_id] = $nb_photos;
|
||||
}
|
||||
|
||||
$template->assign(
|
||||
array(
|
||||
'album_data' => assocToOrderedTree($associatedTree),
|
||||
|
||||
Reference in New Issue
Block a user