feature 2976: ability to set group association with pwg.users.setInfo
git-svn-id: http://piwigo.org/svn/trunk@25474 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
892fdb202e
commit
b9233b8343
2 changed files with 41 additions and 1 deletions
|
@ -516,6 +516,44 @@ UPDATE '. USER_INFOS_TABLE .' SET ';
|
||||||
pwg_query($query);
|
pwg_query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// manage association to groups
|
||||||
|
if (!empty($params['group_id']))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
DELETE
|
||||||
|
FROM '.USER_GROUP_TABLE.'
|
||||||
|
WHERE user_id IN ('.implode(',', $params['user_id']).')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
// we remove all provided groups that do not really exist
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
id
|
||||||
|
FROM '.GROUPS_TABLE.'
|
||||||
|
WHERE id IN ('.implode(',', $params['group_id']).')
|
||||||
|
;';
|
||||||
|
$group_ids = array_from_query($query, 'id');
|
||||||
|
|
||||||
|
// if only -1 (a group id that can't exist) is in the list, then no
|
||||||
|
// group is associated
|
||||||
|
|
||||||
|
if (count($group_ids) > 0)
|
||||||
|
{
|
||||||
|
$inserts = array();
|
||||||
|
|
||||||
|
foreach ($group_ids as $group_id)
|
||||||
|
{
|
||||||
|
foreach ($params['user_id'] as $user_id)
|
||||||
|
{
|
||||||
|
$inserts[] = array('user_id' => $user_id, 'group_id' => $group_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mass_inserts(USER_GROUP_TABLE, array_keys($inserts[0]), $inserts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $service->invoke('pwg.users.getList', array(
|
return $service->invoke('pwg.users.getList', array(
|
||||||
'user_id' => $params['user_id'],
|
'user_id' => $params['user_id'],
|
||||||
'display' => 'basics,'.implode(',', array_keys($updates_infos)),
|
'display' => 'basics,'.implode(',', array_keys($updates_infos)),
|
||||||
|
|
4
ws.php
4
ws.php
|
@ -884,6 +884,7 @@ enabled_high, registration_date, registration_date_string, registration_date_sin
|
||||||
'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
|
'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
|
||||||
'language' => array('flags'=>WS_PARAM_OPTIONAL),
|
'language' => array('flags'=>WS_PARAM_OPTIONAL),
|
||||||
'theme' => array('flags'=>WS_PARAM_OPTIONAL),
|
'theme' => array('flags'=>WS_PARAM_OPTIONAL),
|
||||||
|
'group_id' => array('flags'=>WS_PARAM_OPTIONAL|WS_PARAM_FORCE_ARRAY, 'type'=>WS_TYPE_INT),
|
||||||
// bellow are parameters removed in a future version
|
// bellow are parameters removed in a future version
|
||||||
'nb_image_page' => array('flags'=>WS_PARAM_OPTIONAL,
|
'nb_image_page' => array('flags'=>WS_PARAM_OPTIONAL,
|
||||||
'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE|WS_TYPE_NOTNULL),
|
'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE|WS_TYPE_NOTNULL),
|
||||||
|
@ -899,7 +900,8 @@ enabled_high, registration_date, registration_date_string, registration_date_sin
|
||||||
'type'=>WS_TYPE_BOOL),
|
'type'=>WS_TYPE_BOOL),
|
||||||
),
|
),
|
||||||
'Updates a user. Leave a field blank to keep the current value.
|
'Updates a user. Leave a field blank to keep the current value.
|
||||||
<br>"username", "password" and "email" are ignored if "user_id" is an array.',
|
<br>"username", "password" and "email" are ignored if "user_id" is an array.
|
||||||
|
<br>set "group_id" to -1 if you want to dissociate users from all groups',
|
||||||
$ws_functions_root . 'pwg.users.php',
|
$ws_functions_root . 'pwg.users.php',
|
||||||
array('admin_only'=>true, 'post_only'=>true)
|
array('admin_only'=>true, 'post_only'=>true)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue