diff --git a/admin/themes/default/js/user_list.js b/admin/themes/default/js/user_list.js
index ae7c26206..bdfa1244d 100644
--- a/admin/themes/default/js/user_list.js
+++ b/admin/themes/default/js/user_list.js
@@ -648,9 +648,9 @@ function advanced_filter_hide() {
let months = [];
function getDateStr(date) {
- let date_arr = date.split(' ');
- let curr_month = months[parseInt(date_arr[0]) - 1];
- return curr_month + " " + date_arr[1]
+ let date_arr = date.split('-');
+ let curr_month = months[parseInt(date_arr[1]) - 1];
+ return curr_month + " " + date_arr[0]
}
function setupRegisterDates(register_dates) {
diff --git a/admin/user_list.php b/admin/user_list.php
index 197be7450..069f8e1a7 100644
--- a/admin/user_list.php
+++ b/admin/user_list.php
@@ -53,7 +53,7 @@ $result = pwg_query($query);
$register_dates = array();
while ($row = pwg_db_fetch_assoc($result))
{
- $register_dates[] = $row['registration_month'].' '.$row['registration_year'];
+ $register_dates[] = $row['registration_year'].'-'.sprintf('%02u', $row['registration_month']);
}
$template->assign('register_dates', implode(',' , $register_dates));
diff --git a/include/ws_functions/pwg.users.php b/include/ws_functions/pwg.users.php
index fe5000860..f6442e5fa 100644
--- a/include/ws_functions/pwg.users.php
+++ b/include/ws_functions/pwg.users.php
@@ -68,20 +68,22 @@ function ws_users_getList($params, &$service)
if (!empty($params['min_register'])) {
- list($min_register_month, $min_register_year) = explode(' ', $params["min_register"]);
- if (strlen($min_register_month) == 1) {
- $min_register_month = "0".$min_register_month;
- }
- $where_clauses[] = 'ui.registration_date >= \''.$min_register_year.'-'.$min_register_month.'-01 00:00:00\'';
+ $date_tokens = explode('-', $params['min_register']);
+ $min_register_year = $date_tokens[0];
+ $min_register_month = $date_tokens[1] ?? 1;
+ $min_register_day = $date_tokens[2] ?? 1;
+ $min_date = sprintf('%u-%02u-%02u', $min_register_year, $min_register_month, $min_register_day);
+ $where_clauses[] = 'ui.registration_date >= \''.$min_date.' 00:00:00\'';
}
if (!empty($params['max_register'])) {
- list($max_register_month, $max_register_year) = explode(' ', $params["max_register"]);
- if (strlen($max_register_month) == 1) {
- $max_register_month = "0".$max_register_month;
- }
- $where_clauses[] = 'ui.registration_date <= adddate(\''.$max_register_year.'-'.$max_register_month.'-01 00:00:00\', interval 1 month)';
+ $max_date_tokens = explode('-', $params['max_register']);
+ $max_register_year = $max_date_tokens[0];
+ $max_register_month = $max_date_tokens[1] ?? 12;
+ $max_register_day = $max_date_tokens[2] ?? date('t', strtotime($max_register_year.'-'.$max_register_month.'-1'));
+ $max_date = sprintf('%u-%02u-%02u', $max_register_year, $max_register_month, $max_register_day);
+ $where_clauses[] = 'ui.registration_date <= \''.$max_date.' 23:59:59\'';
}
if (!empty($params['status']))
diff --git a/ws.php b/ws.php
index cea5a5f43..2ee49565e 100644
--- a/ws.php
+++ b/ws.php
@@ -1118,9 +1118,16 @@ function ws_addDefaultMethods( $arr )
'order' => array('default'=>'id',
'info'=>'id, username, level, email'),
'exclude' => array('flags'=>WS_PARAM_OPTIONAL|WS_PARAM_FORCE_ARRAY,
- 'type'=>WS_TYPE_ID),
+ 'type'=>WS_TYPE_ID,
+ 'info'=>'Expects a user_id as value.'),
'display' => array('default'=>'basics',
'info'=>'Comma saparated list (see method description)'),
+ 'filter' => array('flags'=>WS_PARAM_OPTIONAL,
+ 'info'=>'Filter by username, email, group'),
+ 'min_register' => array('flags'=>WS_PARAM_OPTIONAL,
+ 'info'=>'See method description'),
+ 'max_register' => array('flags'=>WS_PARAM_OPTIONAL,
+ 'info'=>'See method description'),
),
'Retrieves a list of all the users.
@@ -1129,7 +1136,8 @@ all, basics, none,
username, email, status, level, groups,
language, theme, nb_image_page, recent_period, expand, show_nb_comments, show_nb_hits,
enabled_high, registration_date, registration_date_string, registration_date_since, last_visit, last_visit_string, last_visit_since
-basics stands for "username,email,status,level,groups"',
+basics stands for "username,email,status,level,groups"
+min_register and max_register filter users by their registration date expecting format "YYYY" or "YYYY-mm" or "YYYY-mm-dd".',
$ws_functions_root . 'pwg.users.php',
array('admin_only'=>true)
);