aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/ws_functions.inc.php22
-rw-r--r--tools/piwigo_remote.pl16
-rw-r--r--ws.php10
3 files changed, 48 insertions, 0 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 09f6440d4..203367356 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -1335,4 +1335,26 @@ LIMIT '.$params['per_page']*$params['page'].','.$params['per_page'];
)
);
}
+
+function ws_categories_add($params, &$service)
+{
+ if (!is_admin())
+ {
+ return new PwgError(401, 'Access denied');
+ }
+
+ include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+
+ $creation_output = create_virtual_category(
+ $params['name'],
+ $params['parent']
+ );
+
+ if (isset($creation_output['error']))
+ {
+ return new PwgError(500, $creation_output['error']);
+ }
+
+ return $creation_output;
+}
?>
diff --git a/tools/piwigo_remote.pl b/tools/piwigo_remote.pl
index 30b8743b4..3c611fed0 100644
--- a/tools/piwigo_remote.pl
+++ b/tools/piwigo_remote.pl
@@ -116,6 +116,22 @@ if ($opt{action} eq 'pwg.tags.list') {
print $t;
}
+if ($opt{action} eq 'pwg.categories.add') {
+ $form = {
+ method => 'pwg.categories.add',
+ name => $opt{define}{name},
+ parent => $opt{define}{parent},
+ };
+
+ my $response = $ua->post(
+ $conf{base_url}.'/ws.php?format=json',
+ $form
+ );
+
+ use Data::Dumper;
+ print Dumper(from_json($response->content));
+}
+
$query = pwg_ws_get_query(
method => 'pwg.session.logout'
);
diff --git a/ws.php b/ws.php
index 6aa7b3f64..5fdccff3a 100644
--- a/ws.php
+++ b/ws.php
@@ -201,6 +201,16 @@ function ws_addDefaultMethods( $arr )
array(),
'administration method only'
);
+
+ $service->addMethod(
+ 'pwg.categories.add',
+ 'ws_categories_add',
+ array(
+ 'name' => array(),
+ 'parent' => array('default' => null),
+ ),
+ 'administration method only'
+ );
}
add_event_handler('ws_add_methods', 'ws_addDefaultMethods');