aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2008-09-21 20:42:17 +0000
committerplegall <plg@piwigo.org>2008-09-21 20:42:17 +0000
commit0283203cce1eea428179166099bd3238c710c301 (patch)
treee044338bff64a0bca285c71fe3f2781b0a4f257c /include
parenta49da1d48035569fae1b6f336ef038fbaa5f3bc8 (diff)
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
Diffstat (limited to '')
-rw-r--r--include/ws_functions.inc.php56
1 files changed, 56 insertions, 0 deletions
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)