From 0283203cce1eea428179166099bd3238c710c301 Mon Sep 17 00:00:00 2001 From: plegall Date: Sun, 21 Sep 2008 20:42:17 +0000 Subject: new: webservice method pwg.categories.getAdminList was added so that pLoader can see the list of categories as you can see in the administration interface : not filtered by individual permissions. git-svn-id: http://piwigo.org/svn/trunk@2563 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/ws_functions.inc.php | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'include') diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php index 4440b15ac..6b64f15ce 100644 --- a/include/ws_functions.inc.php +++ b/include/ws_functions.inc.php @@ -436,6 +436,62 @@ SELECT id, name, permalink, uppercats, global_rank, ); } +/** + * returns the list of categories as you can see them in administration (web + * service method). + * + * Only admin can run this method and permissions are not taken into + * account. + */ +function ws_categories_getAdminList($params, &$service) +{ + if (!is_admin()) + { + return new PwgError(401, 'Access denied'); + } + + $query = ' +SELECT + category_id, + COUNT(*) AS counter + FROM '.IMAGE_CATEGORY_TABLE.' + GROUP BY category_id +;'; + $nb_images_of = simple_hash_from_query($query, 'category_id', 'counter'); + + $query = ' +SELECT + id, + name, + uppercats, + global_rank + FROM '.CATEGORIES_TABLE.' +;'; + $result = pwg_query($query); + $cats = array(); + + while ($row = mysql_fetch_assoc($result)) + { + $id = $row['id']; + $row['nb_images'] = isset($nb_images_of[$id]) ? $nb_images_of[$id] : 0; + array_push($cats, $row); + } + + usort($cats, 'global_rank_compare'); + return array( + 'categories' => new PwgNamedArray( + $cats, + 'category', + array( + 'id', + 'nb_images', + 'name', + 'uppercats', + 'global_rank', + ) + ) + ); +} /** * returns detailed information for an element (web service method) -- cgit v1.2.3