2015-07-08 00:42:53 +02:00
|
|
|
/*
|
|
|
|
* Licensed under the MIT public license.
|
|
|
|
*
|
|
|
|
* Part of LdapCherry.
|
|
|
|
*
|
|
|
|
* Functions to autofill form fields from other fields.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
function lcUid(firstname, lastname){
|
2015-07-08 01:55:31 +02:00
|
|
|
var ascii_firstname = removeDiacritics(firstname).toLowerCase().replace(/[^a-z]/g, '');
|
|
|
|
var ascii_lastname = removeDiacritics(lastname).toLowerCase().replace(/[^a-z]/g, '');
|
|
|
|
return ascii_firstname.charAt(0)+ascii_lastname.substring(0,7);
|
2015-07-08 00:42:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function lcDisplayName(firstname, lastname){
|
2015-07-08 00:59:23 +02:00
|
|
|
return firstname+' '+lastname;
|
2015-07-08 00:42:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function lcMail(firstname, lastname, domain){
|
2015-07-08 01:55:31 +02:00
|
|
|
return lcUid(firstname, lastname)+domain;
|
2015-07-08 00:42:53 +02:00
|
|
|
}
|
|
|
|
|
2015-07-08 01:55:31 +02:00
|
|
|
function lcUidNumber(firstname, lastname, minuid, maxuid){
|
|
|
|
var iminuid = parseInt(minuid);
|
|
|
|
var imaxuid = parseInt(maxuid);
|
2016-06-19 01:48:50 +09:00
|
|
|
return (parseInt('0x'+sha1(firstname+lastname)) % (imaxuid - iminuid)) + iminuid;
|
2015-07-08 00:42:53 +02:00
|
|
|
}
|
|
|
|
|
2015-07-08 01:55:31 +02:00
|
|
|
function lcHomeDir(firstname, lastname, basedir){
|
|
|
|
return basedir+lcUid(firstname, lastname);
|
2015-07-08 00:42:53 +02:00
|
|
|
}
|