From 639c9d96fa4e5263c9d3da8b2ca19370f042feb3 Mon Sep 17 00:00:00 2001 From: Teatek <38403802+Teatek@users.noreply.github.com> Date: Wed, 5 Jul 2023 11:06:31 +0200 Subject: [PATCH] Issue #917 album photo sort order (#955) * returns an image_order for API methods pwg.categories.getList and pwg.categories.getAdminList --- include/ws_functions/pwg.categories.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/include/ws_functions/pwg.categories.php b/include/ws_functions/pwg.categories.php index ae4f31a19..734ef0401 100644 --- a/include/ws_functions/pwg.categories.php +++ b/include/ws_functions/pwg.categories.php @@ -275,7 +275,8 @@ SELECT uppercats, global_rank, id_uppercat, nb_images, count_images AS total_nb_images, representative_picture_id, user_representative_picture_id, count_images, count_categories, - date_last, max_date_last, count_categories AS nb_categories + date_last, max_date_last, count_categories AS nb_categories, + image_order FROM '. CATEGORIES_TABLE .' '.$join_type.' JOIN '. USER_CACHE_CATEGORIES_TABLE .' ON id=cat_id AND user_id='.$join_user.' @@ -399,6 +400,11 @@ SELECT representative_picture_id unset($image_id); // management of the album thumbnail -- stops here + if (empty($row['image_order'])) + { + $row['image_order'] = str_replace('ORDER BY ', '', $conf['order_by']); + } + $cats[] = $row; } usort($cats, 'global_rank_compare'); @@ -535,10 +541,10 @@ SELECT id, path, representative_ext */ function ws_categories_getAdminList($params, &$service) { - global $conf; - if (!isset($params['additional_output'])) { + if (!isset($params['additional_output'])) + { $params['additional_output'] = ""; } $params['additional_output'] = array_map('trim', explode(',', $params['additional_output'])); @@ -553,7 +559,7 @@ SELECT category_id, COUNT(*) AS counter // pwg_db_real_escape_string $query = ' -SELECT SQL_CALC_FOUND_ROWS id, name, comment, uppercats, global_rank, dir, status +SELECT SQL_CALC_FOUND_ROWS id, name, comment, uppercats, global_rank, dir, status, image_order FROM '. CATEGORIES_TABLE; if (isset($params["search"]) and $params['search'] != "") @@ -597,6 +603,11 @@ SELECT SQL_CALC_FOUND_ROWS id, name, comment, uppercats, global_rank, dir, statu ) ); + if (empty($row['image_order'])) + { + $row['image_order'] = str_replace('ORDER BY ', '', $conf['order_by']); + } + if (in_array('full_name_with_admin_links', $params['additional_output'])) { $row["full_name_with_admin_links"] = $cat_display_name;