aboutsummaryrefslogtreecommitdiffstats
path: root/include/ws_functions.inc.php
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2013-10-28 17:53:36 +0000
committermistic100 <mistic@piwigo.org>2013-10-28 17:53:36 +0000
commit1996dadfe7253b3c2bcb946cb76d6f24b0a67f04 (patch)
tree334802a559bf3ccf4f8abcac0831771e0353915d /include/ws_functions.inc.php
parent492a65418a68023314ff036668e3aedc8f0bef02 (diff)
feature 2976: add 'display' parameter for pwg.users.getList
git-svn-id: http://piwigo.org/svn/trunk@25196 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/ws_functions.inc.php')
-rw-r--r--include/ws_functions.inc.php79
1 files changed, 69 insertions, 10 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