Admin: Add option to export last login in user export - refs BT#21021

pull/4884/head
Yannick Warnier 2 years ago
parent cff73e7d70
commit 9472790435
  1. 10
      main/admin/user_export.php

@ -56,6 +56,7 @@ $form->addElement('radio', 'file_type', get_lang('OutputFileType'), 'XML', 'xml'
$form->addElement('radio', 'file_type', null, 'CSV', 'csv');
$form->addElement('radio', 'file_type', null, 'XLS', 'xls');
$form->addElement('checkbox', 'addcsvheader', get_lang('AddCSVHeader'), get_lang('YesAddCSVHeader'), '1');
$form->addElement('checkbox', 'addlastlogin', get_lang('IncludeLastLogin'), get_lang('IncludeLastLogin'), '1');
$form->addElement('select', 'course_code', get_lang('OnlyUsersFromCourse'), $courses);
$form->addElement('select', 'course_session', get_lang('OnlyUsersFromCourseSession'), $coursesSessions);
$form->addButtonExport(get_lang('Export'));
@ -95,7 +96,8 @@ if ($form->validate()) {
u.phone AS Phone,
u.registration_date AS RegistrationDate,
u.active AS Active,
u.expiration_date
u.expiration_date,
u.last_login AS LastLogin
";
if (strlen($course_code) > 0) {
$sql .= " FROM $user_table u, $course_user_table cu
@ -151,6 +153,9 @@ if ($form->validate()) {
'Active',
'ExpirationDate',
];
if ($export['addlastlogin'] == '1') {
$data[0][] = 'LastLogin';
}
} else {
$data[] = [
'UserId',
@ -167,6 +172,9 @@ if ($form->validate()) {
'Active',
'ExpirationDate',
];
if ($export['addlastlogin'] == '1') {
$data[0][] = 'LastLogin';
}
}
foreach ($extra_fields as $extra) {

Loading…
Cancel
Save