From 757fe9a8215d7a9746b76668ea81d03d774d9f17 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Thu, 24 Oct 2013 13:38:12 +0000 Subject: feature 2976: API methods for users and groups management TODO : methods to manage albums permissions git-svn-id: http://piwigo.org/svn/trunk@25117 68402e56-0260-453c-a942-63ccdbb3a9ee --- ws.php | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 160 insertions(+), 3 deletions(-) (limited to 'ws.php') diff --git a/ws.php b/ws.php index e04c19f44..01b2ecf02 100644 --- a/ws.php +++ b/ws.php @@ -675,7 +675,7 @@ function ws_addDefaultMethods( $arr ) 'Webmaster only.', null, array('admin_only'=>true) - ); + ); $service->addMethod( 'pwg.extensions.ignoreUpdate', @@ -692,7 +692,7 @@ function ws_addDefaultMethods( $arr ) 'Webmaster only. Ignores an extension if it needs update.', null, array('admin_only'=>true) - ); + ); $service->addMethod( 'pwg.extensions.checkUpdates', @@ -701,7 +701,164 @@ function ws_addDefaultMethods( $arr ) 'Admin only. Checks if piwigo or extensions are up to date.', null, array('admin_only'=>true) - ); + ); + + $service->addMethod( + 'pwg.groups.getList', + 'ws_groups_getList', + array( + 'group_id' => array('default'=>null, + 'flags'=>WS_PARAM_FORCE_ARRAY, + 'type'=>WS_TYPE_ID), + 'name' => array('default'=>null, + 'info'=>'Use "%" as wildcard.'), + 'per_page' => array('default'=>100, + 'maxValue'=>$conf['ws_max_users_per_page'], + 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), + 'page' => array('default'=>0, + 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), + 'order' => array('default'=>'name', + 'info'=>'id, name, nb_users, is_default'), + ), + 'Admin only. Retrieves a list of all groups. The list can be filtered.', + null, + array('admin_only'=>true) + ); + + $service->addMethod( + 'pwg.groups.add', + 'ws_groups_add', + array( + 'name' => array(), + 'is_default' => array('default'=>false, + 'type'=>WS_TYPE_BOOL), + ), + 'Admin & POST only. Creates a group and returns the new group record.', + null, + array('admin_only'=>true, 'post_only'=>true) + ); + + $service->addMethod( + 'pwg.groups.delete', + 'ws_groups_delete', + array( + 'group_id' => array('flags'=>WS_PARAM_FORCE_ARRAY, + 'type'=>WS_TYPE_ID), + ), + 'Admin & POST only. Deletes a or more groups. Users and photos are not deleted.', + null, + array('admin_only'=>true, 'post_only'=>true) + ); + + $service->addMethod( + 'pwg.groups.setInfo', + 'ws_groups_setInfo', + array( + 'group_id' => array('type'=>WS_TYPE_ID), + 'name' => array('default'=>null), + 'is_default' => array('default'=>null, + 'type'=>WS_TYPE_BOOL), + ), + 'Admin & POST only. Updates a group. Leave a field blank to keep the current value.', + null, + array('admin_only'=>true, 'post_only'=>true) + ); + + $service->addMethod( + 'pwg.groups.addUser', + 'ws_groups_addUser', + array( + 'group_id' => array('type'=>WS_TYPE_ID), + 'user_id' => array('flags'=>WS_PARAM_FORCE_ARRAY, + 'type'=>WS_TYPE_ID), + ), + 'Admin only. Adds one or more users to a group.', + null, + array('admin_only'=>true) + ); + + $service->addMethod( + 'pwg.groups.deleteUser', + 'ws_groups_deleteUser', + array( + 'group_id' => array('type'=>WS_TYPE_ID), + 'user_id' => array('flags'=>WS_PARAM_FORCE_ARRAY, + 'type'=>WS_TYPE_ID), + ), + 'Admin & POST only. Removes one or more users from a group.', + null, + array('admin_only'=>true, 'post_only'=>true) + ); + + $service->addMethod( + 'pwg.users.getList', + 'ws_users_getList', + array( + 'user_id' => array('default'=>null, + 'flags'=>WS_PARAM_FORCE_ARRAY, + 'type'=>WS_TYPE_ID), + 'username' => array('default'=>null, + 'info'=>'Use "%" as wildcard.'), + 'status' => array('default'=>null, + 'flags'=>WS_PARAM_FORCE_ARRAY, + 'info'=>'guest,generic,normal,admin,webmaster'), + 'min_level' => array('default'=>0, + 'maxValue'=>max($conf['available_permission_levels']), + 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), + 'group_id' => array('default'=>null, + 'flags'=>WS_PARAM_FORCE_ARRAY, + 'type'=>WS_TYPE_ID), + 'per_page' => array('default'=>100, + 'maxValue'=>$conf['ws_max_users_per_page'], + 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), + 'page' => array('default'=>0, + 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), + 'order' => array('default'=>'id', + 'info'=>'id, username, level, email'), + ), + 'Admin only. Retrieves a list of all the users.', + null, + array('admin_only'=>true) + ); + + $service->addMethod( + 'pwg.users.add', + 'ws_users_add', + array( + 'username' => array(), + 'password' => array('default'=>null), + 'email' => array('default'=>null), + ), + 'Admin & POST only. Registers a new user.', + null, + array('admin_only'=>true, 'post_only'=>true) + ); + + $service->addMethod( + 'pwg.users.delete', + 'ws_users_delete', + array( + 'user_id' => array('flags'=>WS_PARAM_FORCE_ARRAY, + 'type'=>WS_TYPE_ID), + ), + 'Admin & POST only. Deletes on or more users. Photos owned by this user are not deleted.', + null, + array('admin_only'=>true, 'post_only'=>true) + ); + + $service->addMethod( + 'pwg.users.setInfo', + 'ws_users_setInfo', + array( + 'user_id' => array('type'=>WS_TYPE_ID), + 'username' => array('default'=>null), + 'password' => array('default'=>null), + 'email' => array('default'=>null), + ), + 'Admin & POST only. Updates a user. Leave a field blank to keep the current value.', + null, + array('admin_only'=>true, 'post_only'=>true) + ); } ?> \ No newline at end of file -- cgit v1.2.3