aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/functions.inc.php4
-rw-r--r--include/ws_functions/pwg.users.php64
2 files changed, 64 insertions, 4 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 5425b797c..2f0b37c69 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -598,10 +598,10 @@ function format_date($original, $show_time=false, $show_day_name=true, $format=n
$print = '';
if ($show_day_name)
{
- $print.= $lang['day'][ $date->format('w') ];
+ $print.= $lang['day'][ $date->format('w') ].' ';
}
- $print.= ' '.$date->format('d');
+ $print.= $date->format('j');
$print.= ' '.$lang['month'][ $date->format('n') ];
$print.= ' '.$date->format('Y');
diff --git a/include/ws_functions/pwg.users.php b/include/ws_functions/pwg.users.php
index aacc92ed0..b77bf45fa 100644
--- a/include/ws_functions/pwg.users.php
+++ b/include/ws_functions/pwg.users.php
@@ -84,7 +84,9 @@ function ws_users_getList($params, &$service)
$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',
+ 'enabled_high','registration_date','registration_date_string',
+ 'registration_date_since', 'last_visit', 'last_visit_string',
+ 'last_visit_since'
));
}
else if (in_array('basics', $params['display']))
@@ -105,7 +107,7 @@ function ws_users_getList($params, &$service)
$ui_fields = array(
'status','level','language','theme','nb_image_page','recent_period','expand',
- 'show_nb_comments','show_nb_hits','enabled_high',
+ 'show_nb_comments','show_nb_hits','enabled_high','registration_date'
);
foreach ($ui_fields as $field)
{
@@ -166,6 +168,64 @@ SELECT user_id, group_id
}
}
+ if (count($users) > 0 and in_array('registration_date_string', $params['display']))
+ {
+ foreach ($users as $cur_user)
+ {
+ $users[ $cur_user['id'] ]['registration_date_string'] = format_date($cur_user['registration_date'], false, false);
+ }
+ }
+
+ if (count($users) > 0 and in_array('registration_date_since', $params['display']))
+ {
+ foreach ($users as $cur_user)
+ {
+ $users[ $cur_user['id'] ]['registration_date_since'] = time_since($cur_user['registration_date'], 'month');
+ }
+ }
+
+ if (count($users) > 0 and in_array('last_visit', $params['display']))
+ {
+ $query = '
+SELECT
+ MAX(id) as history_id
+ FROM '.HISTORY_TABLE.'
+ WHERE user_id IN ('.implode(',', array_keys($users)).')
+ GROUP BY user_id
+;';
+ $history_ids = array_from_query($query, 'history_id');
+
+ if (count($history_ids) == 0)
+ {
+ $history_ids[] = -1;
+ }
+
+ $query = '
+SELECT
+ user_id,
+ date,
+ time
+ FROM '.HISTORY_TABLE.'
+ WHERE id IN ('.implode(',', $history_ids).')
+;';
+ $result = pwg_query($query);
+ while ($row = pwg_db_fetch_assoc($result))
+ {
+ $last_visit = $row['date'].' '.$row['time'];
+ $users[ $row['user_id'] ]['last_visit'] = $last_visit;
+
+ if (in_array('last_visit_string', $params['display']))
+ {
+ $users[ $row['user_id'] ]['last_visit_string'] = format_date($last_visit, false, false);
+ }
+
+ if (in_array('last_visit_since', $params['display']))
+ {
+ $users[ $row['user_id'] ]['last_visit_since'] = time_since($last_visit, 'day');
+ }
+ }
+ }
+
return array(
'paging' => new PwgNamedStruct(
array(