Skip to content

Commit

Permalink
Admin: On update user by csv, report by mail BT#17893 - refs BT#17893
Browse files Browse the repository at this point in the history
  • Loading branch information
carlangas159 committed Oct 19, 2020
1 parent 3037fb1 commit e83347e
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions main/admin/user_update_import.php
Expand Up @@ -87,8 +87,12 @@ function validate_data($users)
*
* @param array $users List of users.
* @param bool $resetPassword Optional.
* @param bool $sendEmail Optional.
*/
function updateUsers($users, $resetPassword = false)
function updateUsers(
$users,
$resetPassword = false,
$sendEmail = false)
{
$usergroup = new UserGroup();

Expand Down Expand Up @@ -137,8 +141,9 @@ function updateUsers($users, $resetPassword = false)
$hrDeptId = $userInfo['hr_dept_id'];
$language = isset($user['Language']) ? $user['Language'] : $userInfo['language'];
//$sendEmail = isset($user['SendEmail']) ? $user['SendEmail'] : $userInfo['language'];
$sendEmail = false;
if ($resetPassword) {
//$sendEmail = false;
// see BT#17893
if ($resetPassword && $sendEmail == false) {
$sendEmail = true;
}

Expand Down Expand Up @@ -277,6 +282,13 @@ function parse_xml_data($file)
$form->addFile('import_file', get_lang('ImportFileLocation'), ['accept' => 'text/csv', 'id' => 'import_file']);
$form->addCheckBox('reset_password', '', get_lang('AutoGeneratePassword'));

$group = [
$form->createElement('radio', 'sendMail', '', get_lang('Yes'), 1),
$form->createElement('radio', 'sendMail', null, get_lang('No'), 0),
];
$form->addGroup($group, '', get_lang('SendMailToUsers'));
$defaults['sendMail'] = 0;

if ($form->validate()) {
if (Security::check_token('post')) {
Security::clear_token();
Expand Down Expand Up @@ -319,7 +331,9 @@ function parse_xml_data($file)
}
}

updateUsers($usersToUpdate, isset($formValues['reset_password']));
$sendEmail = $_POST['sendMail'] ? true : false;

updateUsers($usersToUpdate, isset($formValues['reset_password']),$sendEmail);

if (empty($errors)) {
Display::addFlash(
Expand Down Expand Up @@ -350,6 +364,7 @@ function parse_xml_data($file)
Display::display_header($tool_name);
$token = Security::get_token();

$form->setDefaults($defaults);
$form->addHidden('sec_token', $token);
$form->addButtonImport(get_lang('Import'));
$form->display();
Expand Down

0 comments on commit e83347e

Please sign in to comment.