aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/ws_functions.inc.php79
-rw-r--r--ws.php7
2 files changed, 74 insertions, 12 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index eb162ec3a..b86fe6fd6 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -3448,14 +3448,70 @@ function ws_users_getList($params, &$service)
$where_clauses[] = 'ug.group_id IN('. implode(',', $params['group_id']) .')';
}
+ $display = array('u.'.$conf['user_fields']['id'] => 'id');
+
+ if ($params['display'] != 'none')
+ {
+ $params['display'] = explode(',', $params['display']);
+
+ if (in_array('all', $params['display']))
+ {
+ $params['display'] = array_merge($params['display'], array(
+ 'username','email','status','level','groups','language','theme',
+ 'nb_image_page','recent_period','expand','show_nb_comments','show_nb_hits',
+ 'enabled_high',
+ ));
+ }
+ else if (in_array('basics', $params['display']))
+ {
+ $params['display'] = array_merge($params['display'], array(
+ 'username','email','status','level','groups',
+ ));
+ }
+
+ if (in_array('username', $params['display']))
+ {
+ $display['u.'.$conf['user_fields']['username']] = 'username';
+ }
+ if (in_array('email', $params['display']))
+ {
+ $display['u.'.$conf['user_fields']['email']] = 'email';
+ }
+
+ $ui_fields = array(
+ 'status','level','language','theme','nb_image_page','recent_period','expand',
+ 'show_nb_comments','show_nb_hits','enabled_high',
+ );
+ foreach ($ui_fields as $field)
+ {
+ if (in_array($field, $params['display']))
+ {
+ $display['ui.'.$field] = $field;
+ }
+ }
+ }
+ else
+ {
+ $params['display'] = array();
+ }
+
$query = '
-SELECT DISTINCT
- u.'.$conf['user_fields']['id'].' AS id,
- u.'.$conf['user_fields']['username'].' AS username,
- u.'.$conf['user_fields']['email'].' AS email,
- ui.status,
- ui.level,
- "" AS groups
+SELECT DISTINCT ';
+
+ $first = true;
+ foreach ($display as $field => $name)
+ {
+ if (!$first) $query.= ', ';
+ else $first = false;
+ $query.= $field .' AS '. $name;
+ }
+ if (in_array('groups', $params['display']))
+ {
+ if (!$first) $query.= ', ';
+ $query.= '"" AS groups';
+ }
+
+ $query.= '
FROM '.USERS_TABLE.' AS u
INNER JOIN '.USER_INFOS_TABLE.' AS ui
ON u.'.$conf['user_fields']['id'].' = ui.user_id
@@ -3470,7 +3526,7 @@ SELECT DISTINCT
$users = hash_from_query($query, 'id');
- if (count($users) > 0)
+ if ( count($users) > 0 and in_array('groups', $params['display']) )
{
$query = '
SELECT user_id, group_id
@@ -3618,7 +3674,7 @@ function ws_users_setInfo($params, &$service)
{
return new PwgError(403, 'Only webmasters can grant "webmaster" status');
}
- if ( !in_array($params['status'], array('generic','normal','admin','webmaster')) )
+ if ( !in_array($params['status'], array('guest','generic','normal','admin','webmaster')) )
{
return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid status');
}
@@ -3732,7 +3788,10 @@ UPDATE '. USER_INFOS_TABLE .' SET ';
pwg_query($query);
}
- return $service->invoke('pwg.users.getList', array('user_id' => $params['user_id']));
+ return $service->invoke('pwg.users.getList', array(
+ 'user_id' => $params['user_id'],
+ 'display' => 'basics,'.implode(',', array_keys($updates_infos)),
+ ));
}
?> \ No newline at end of file
diff --git a/ws.php b/ws.php
index 959722a26..f60203762 100644
--- a/ws.php
+++ b/ws.php
@@ -811,8 +811,11 @@ function ws_addDefaultMethods( $arr )
'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
'order' => array('default'=>'id',
'info'=>'id, username, level, email'),
+ 'display' => array('default'=>'basics',
+ 'info'=>'all,basics,none,username,email,status,level,groups,language,theme,nb_image_page,recent_period,expand,show_nb_comments,show_nb_hits,enabled_high'),
),
- '<b>Admin only.</b> Retrieves a list of all the users.',
+ '<b>Admin only.</b> Retrieves a list of all the users.
+<br>"display" controls which data are returned, "basics" stands for "username,email,status,level,groups"',
null,
array('admin_only'=>true)
);
@@ -852,7 +855,7 @@ function ws_addDefaultMethods( $arr )
'password' => array('flags'=>WS_PARAM_OPTIONAL),
'email' => array('flags'=>WS_PARAM_OPTIONAL),
'status' => array('flags'=>WS_PARAM_OPTIONAL,
- 'info'=>'generic,normal,admin'),
+ 'info'=>'guest,generic,normal,admin,webmaster'),
'level'=> array('flags'=>WS_PARAM_OPTIONAL,
'maxValue'=>max($conf['available_permission_levels']),
'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),