mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-06-02 04:15:05 +02:00
Issue #2035 Declare new parameters
We change min and max format date, now we expect `YYYY` or `YYYY-mm`or `YYYY-mm-dd`
This commit is contained in:
@@ -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) {
|
||||
|
||||
+1
-1
@@ -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));
|
||||
|
||||
@@ -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']))
|
||||
|
||||
@@ -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.<br>
|
||||
<br>
|
||||
@@ -1129,7 +1136,8 @@ all, basics, none,<br>
|
||||
username, email, status, level, groups,<br>
|
||||
language, theme, nb_image_page, recent_period, expand, show_nb_comments, show_nb_hits,<br>
|
||||
enabled_high, registration_date, registration_date_string, registration_date_since, last_visit, last_visit_string, last_visit_since<br>
|
||||
<b>basics</b> stands for "username,email,status,level,groups"',
|
||||
<b>basics</b> stands for "username,email,status,level,groups"<br>
|
||||
<b>min_register</b> and <b>max_register</b> 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)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user