mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-05-03 06:39:58 +03:00
issue #1615 include favorite status in image list API calls
This commit is contained in:
parent
3239296bf3
commit
231d36613c
4 changed files with 30 additions and 0 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue