Merge pull request #24372 from Hystepik/develop#1

New : Creation of login from lastname and firstname
This commit is contained in:
Laurent Destailleur 2023-03-29 14:13:21 +02:00 committed by GitHub
commit fccd517acb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -893,7 +893,7 @@ if ($action == 'create' || $action == 'adduserldap') {
print '<input type="hidden" id="lastname" name="lastname" value="'.dol_escape_htmltag($ldap_lastname).'">';
print $ldap_lastname;
} else {
print '<input class="minwidth100 maxwidth150onsmartphone" type="text" id="lastname" name="lastname" value="'.dol_escape_htmltag(GETPOST('lastname', 'alphanohtml')).'">';
print '<input class="minwidth100 maxwidth150onsmartphone createloginauto" type="text" id="lastname" name="lastname" value="'.dol_escape_htmltag(GETPOST('lastname', 'alphanohtml')).'">';
}
print '</td></tr>';
@ -904,7 +904,7 @@ if ($action == 'create' || $action == 'adduserldap') {
print '<input type="hidden" name="firstname" value="'.dol_escape_htmltag($ldap_firstname).'">';
print $ldap_firstname;
} else {
print '<input class="minwidth100 maxwidth150onsmartphone" type="text" name="firstname" value="'.dol_escape_htmltag(GETPOST('firstname', 'alphanohtml')).'">';
print '<input id="firstname" class="minwidth100 maxwidth150onsmartphone createloginauto" type="text" name="firstname" value="'.dol_escape_htmltag(GETPOST('firstname', 'alphanohtml')).'">';
}
print '</td></tr>';
@ -918,10 +918,28 @@ if ($action == 'create' || $action == 'adduserldap') {
print '<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_loginsmb).'">';
print $ldap_loginsmb;
} else {
print '<input class="maxwidth200 maxwidth150onsmartphone" maxsize="24" type="text" name="login" value="'.dol_escape_htmltag(GETPOST('login', 'alphanohtml')).'">';
print '<input id="login" class="maxwidth200 maxwidth150onsmartphone" maxsize="24" type="text" name="login" value="'.dol_escape_htmltag(GETPOST('login', 'alphanohtml')).'">';
}
print '</td></tr>';
if (!empty($conf->use_javascript_ajax)) {
print '<script>
jQuery(document).ready(function() {
$(".createloginauto").on("change", function(){
lastname = $("#lastname").val();
firstname = $("#firstname").val();
if($(this).attr("id") == "firstname"){
firstname = firstname.toLowerCase();
firstname = firstname[0];
}
lastname = lastname.toLowerCase();
console.log("We create a login from firstname and lastname");
$("#login").val(firstname+lastname);
})
});
</script>';
}
$generated_password = '';
if (empty($ldap_sid)) { // ldap_sid is for activedirectory
$generated_password = getRandomPassword(false);