aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/ws_functions.inc.php27
-rw-r--r--tools/piwigo_remote.pl20
-rw-r--r--ws.php7
3 files changed, 54 insertions, 0 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 203367356..0e4b1a8c2 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -1192,6 +1192,33 @@ function ws_tags_getList($params, &$service)
return array('tags' => new PwgNamedArray($tags, 'tag', array('id','url_name','url', 'counter' )) );
}
+/**
+ * returns the list of tags 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_tags_getAdminList($params, &$service)
+{
+ if (!is_admin())
+ {
+ return new PwgError(401, 'Access denied');
+ }
+
+ $tags = get_all_tags();
+ return array(
+ 'tags' => new PwgNamedArray(
+ $tags,
+ 'tag',
+ array(
+ 'name',
+ 'id',
+ 'url_name',
+ )
+ )
+ );
+}
/**
* returns a list of images for tags (web service method)
diff --git a/tools/piwigo_remote.pl b/tools/piwigo_remote.pl
index 3c611fed0..02e447eab 100644
--- a/tools/piwigo_remote.pl
+++ b/tools/piwigo_remote.pl
@@ -116,6 +116,26 @@ if ($opt{action} eq 'pwg.tags.list') {
print $t;
}
+if ($opt{action} eq 'pwg.tags.getAdminList') {
+ $query = pwg_ws_get_query(
+ method => 'pwg.tags.getAdminList'
+ );
+
+ $result = $ua->get($query);
+ my $tags = from_json($result->content)->{result}{tags};
+
+ foreach my $tag (@{$tags}) {
+ # print join(',', keys %{$tag}), "\n"; exit();
+ printf(
+ '{%u} %s ',
+ $tag->{id},
+ $tag->{name}
+ );
+ }
+
+ print "\n";
+}
+
if ($opt{action} eq 'pwg.categories.add') {
$form = {
method => 'pwg.categories.add',
diff --git a/ws.php b/ws.php
index 5fdccff3a..b98d21e65 100644
--- a/ws.php
+++ b/ws.php
@@ -211,6 +211,13 @@ function ws_addDefaultMethods( $arr )
),
'administration method only'
);
+
+ $service->addMethod(
+ 'pwg.tags.getAdminList',
+ 'ws_tags_getAdminList',
+ array(),
+ 'administration method only'
+ );
}
add_event_handler('ws_add_methods', 'ws_addDefaultMethods');