@@ -85,11 +85,12 @@ function validate_data($users)
85
85
* @param bool $resetPassword Optional.
86
86
* @param bool $sendEmail Optional.
87
87
*/
88
- function updateUsers (
88
+ function _updateUsers (
89
89
$ users ,
90
90
$ resetPassword = false ,
91
- $ sendEmail = false )
92
- {
91
+ $ sendEmail = false ,
92
+ $ askNewPassword = false
93
+ ){
93
94
$ usergroup = new UserGroup ();
94
95
$ extraFieldValue = new ExtraFieldValue ('user ' );
95
96
if (is_array ($ users )) {
@@ -150,6 +151,10 @@ function updateUsers(
150
151
if ($ resetPassword && $ sendEmail == false ) {
151
152
$ sendEmail = true ;
152
153
}
154
+ $ extra = [];
155
+ if ($ askNewPassword ) {
156
+ $ extra ['ask_new_password ' ] = 1 ;
157
+ }
153
158
154
159
UserManager::update_user (
155
160
$ user_id ,
@@ -167,7 +172,7 @@ function updateUsers(
167
172
$ active ,
168
173
$ creatorId ,
169
174
$ hrDeptId ,
170
- null ,
175
+ $ extra ,
171
176
$ language ,
172
177
'' ,
173
178
$ sendEmail ,
@@ -290,6 +295,14 @@ function parse_xml_data($file)
290
295
$ form ->addHeader ($ tool_name );
291
296
$ form ->addFile ('import_file ' , get_lang ('ImportFileLocation ' ), ['accept ' => 'text/csv ' , 'id ' => 'import_file ' ]);
292
297
$ form ->addCheckBox ('reset_password ' , '' , get_lang ('AutoGeneratePassword ' ));
298
+ if (api_get_configuration_value ('force_renew_password_at_first_login ' ) == true ) {
299
+ $ form ->addElement (
300
+ 'checkbox ' ,
301
+ 'ask_new_password ' ,
302
+ '' ,
303
+ get_lang ('FirstLoginForceUsersToChangePassword ' )
304
+ );
305
+ }
293
306
294
307
$ group = [
295
308
$ form ->createElement ('radio ' , 'sendMail ' , '' , get_lang ('Yes ' ), 1 ),
@@ -341,7 +354,9 @@ function parse_xml_data($file)
341
354
}
342
355
343
356
$ sendEmail = $ _POST ['sendMail ' ] ? true : false ;
344
- updateUsers ($ usersToUpdate , isset ($ formValues ['reset_password ' ]), $ sendEmail );
357
+ $ askNewPassword = isset ($ formValues ['ask_new_password ' ]);
358
+
359
+ _updateUsers ($ usersToUpdate , isset ($ formValues ['reset_password ' ]), $ sendEmail , $ askNewPassword );
345
360
346
361
if (empty ($ errors )) {
347
362
Display::addFlash (
0 commit comments