aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2008-09-17 21:42:50 +0000
committerplegall <plg@piwigo.org>2008-09-17 21:42:50 +0000
commitc502ebd43a1b8917b8c93a7a1ee896bf4c9a7be0 (patch)
treeff4c0441e8b629bade87ed5d16ff95bc3b98c40d /include
parentc6dbaee1ecd46f2627b5922d47b42d8e5c6aed8e (diff)
improvement: webservice methode pwg.categories.getList returns the
images_max_rank for each category, based on #image_category.rank content. So that a remote client can correctly add photos with webservice method pwg.images.add. git-svn-id: http://piwigo.org/svn/trunk@2548 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r--include/ws_functions.inc.php38
1 files changed, 34 insertions, 4 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index fbc5d5283..5d12bd5f2 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -364,6 +364,20 @@ function ws_categories_getList($params, &$service)
{
global $user,$conf;
+ $query = '
+SELECT
+ category_id,
+ MAX(rank) AS max_rank
+ FROM '.IMAGE_CATEGORY_TABLE.'
+ WHERE rank IS NOT NULL
+ GROUP BY category_id
+;';
+ $max_image_rank_of = simple_hash_from_query(
+ $query,
+ 'category_id',
+ 'max_rank'
+ );
+
$where = array();
if (!$params['recursive'])
@@ -415,14 +429,30 @@ SELECT id, name, permalink, uppercats, global_rank,
{
$row[$key] = (int)$row[$key];
}
+
+ if (isset($max_image_rank_of[ $row['id'] ]))
+ {
+ $row['images_max_rank'] = $max_image_rank_of[ $row['id'] ];
+ }
+
array_push($cats, $row);
}
usort($cats, 'global_rank_compare');
return array(
- 'categories' =>
- new PwgNamedArray($cats,'category',
- array('id','url','nb_images','total_nb_images','nb_categories','date_last','max_date_last')
- )
+ 'categories' => new PwgNamedArray(
+ $cats,
+ 'category',
+ array(
+ 'id',
+ 'url',
+ 'nb_images',
+ 'total_nb_images',
+ 'nb_categories',
+ 'date_last',
+ 'max_date_last',
+ 'images_max_rank',
+ )
+ )
);
}