mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-08 09:43:01 +02:00
issue #1615 include favorite status in image list API calls
This commit is contained in:
@@ -77,6 +77,7 @@ SELECT id, name, permalink, image_order
|
||||
$order_by = $cats[ $params['cat_id'][0] ]['image_order'];
|
||||
}
|
||||
$order_by = empty($order_by) ? $conf['order_by'] : 'ORDER BY '.$order_by;
|
||||
$favorite_ids = get_user_favorites();
|
||||
|
||||
$query = '
|
||||
SELECT SQL_CALC_FOUND_ROWS i.*, GROUP_CONCAT(category_id) AS cat_ids
|
||||
@@ -93,6 +94,7 @@ SELECT SQL_CALC_FOUND_ROWS i.*, GROUP_CONCAT(category_id) AS cat_ids
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$image = array();
|
||||
$image['is_favorite'] = isset($favorite_ids[ $row['id'] ]);
|
||||
foreach (array('id', 'width', 'height', 'hit') as $k)
|
||||
{
|
||||
if (isset($row[$k]))
|
||||
|
||||
@@ -646,10 +646,12 @@ SELECT *
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
$image_ids = array_flip($image_ids);
|
||||
$favorite_ids = get_user_favorites();
|
||||
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$image = array();
|
||||
$image['is_favorite'] = isset($favorite_ids[ $row['id'] ]);
|
||||
foreach (array('id', 'width', 'height', 'hit') as $k)
|
||||
{
|
||||
if (isset($row[$k]))
|
||||
|
||||
@@ -134,6 +134,7 @@ SELECT image_id, GROUP_CONCAT(tag_id) AS tag_ids
|
||||
if (!empty($image_ids))
|
||||
{
|
||||
$rank_of = array_flip($image_ids);
|
||||
$favorite_ids = get_user_favorites();
|
||||
|
||||
$query = '
|
||||
SELECT *
|
||||
@@ -146,6 +147,7 @@ SELECT *
|
||||
{
|
||||
$image = array();
|
||||
$image['rank'] = $rank_of[ $row['id'] ];
|
||||
$image['is_favorite'] = isset($favorite_ids[ $row['id'] ]);
|
||||
|
||||
foreach (array('id', 'width', 'height', 'hit') as $k)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user