forked from Wavyzz/dolibarr
FIX Use of MAIN_BUILD_LOGIN_RULE and
MAIN_USER_SEPARATOR_CHAR_FOR_GENERATED_LOGIN
This commit is contained in:
@@ -184,7 +184,7 @@ print '<tr class="oddeven">';
|
||||
print '<td>' . $langs->trans("DefaultBlacklistMailingStatus", $langs->transnoentitiesnoconv("No_Email")) . '</td>';
|
||||
print '<td>';
|
||||
$blacklist_setting=array(0=>$langs->trans('No'), 1=>$langs->trans('Yes'), 2=>$langs->trans('DefaultStatusEmptyMandatory'));
|
||||
print $form->selectarray("MAILING_CONTACT_DEFAULT_BULK_STATUS", $blacklist_setting, $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS);
|
||||
print $form->selectarray("MAILING_CONTACT_DEFAULT_BULK_STATUS", $blacklist_setting, getDolGlobalString('MAILING_CONTACT_DEFAULT_BULK_STATUS'));
|
||||
print '</td>';
|
||||
print '<td class="hideonsmartphone"></td>';
|
||||
print '</tr>';
|
||||
|
||||
@@ -847,6 +847,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
||||
print '<tr>';
|
||||
print '<td class="noemail"><label for="no_email">'.$langs->trans("No_Email").'</label></td>';
|
||||
print '<td>';
|
||||
// Default value is in MAILING_CONTACT_DEFAULT_BULK_STATUS that you can modify in setup of module emailing
|
||||
print $form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'int') : getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS')), 1, false, (getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2));
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@@ -144,7 +144,7 @@ function getMultidirOutput($object, $module = '')
|
||||
/**
|
||||
* Return dolibarr global constant string value
|
||||
*
|
||||
* @param string $key key to return value, return '' if not set
|
||||
* @param string $key key to return value, return $default if not set
|
||||
* @param string $default value to return
|
||||
* @return string
|
||||
*/
|
||||
|
||||
@@ -1985,17 +1985,20 @@ function is_ip($ip)
|
||||
*/
|
||||
function dol_buildlogin($lastname, $firstname)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
//$conf->global->MAIN_BUILD_LOGIN_RULE = 'f.lastname';
|
||||
$charforseparator = getDolGlobalString("MAIN_USER_SEPARATOR_CHAR_FOR_GENERATED_LOGIN", '.');
|
||||
if ($charforseparator == 'none') {
|
||||
$charforseparator = '';
|
||||
}
|
||||
|
||||
if (getDolGlobalString('MAIN_BUILD_LOGIN_RULE') == 'f.lastname') { // f.lastname
|
||||
$login = strtolower(dol_string_unaccent(dol_trunc($firstname, 1, 'right', 'UTF-8', 1)));
|
||||
$login .= ($login ? '.' : '');
|
||||
$login .= ($login ? $charforseparator : '');
|
||||
$login .= strtolower(dol_string_unaccent($lastname));
|
||||
$login = dol_string_nospecial($login, ''); // For special names
|
||||
} else { // firstname.lastname
|
||||
$login = strtolower(dol_string_unaccent($firstname));
|
||||
$login .= ($login ? '.' : '');
|
||||
$login .= ($login ? $charforseparator : '');
|
||||
$login .= strtolower(dol_string_unaccent($lastname));
|
||||
$login = dol_string_nospecial($login, ''); // For special names
|
||||
}
|
||||
|
||||
@@ -938,21 +938,33 @@ if ($action == 'create' || $action == 'adduserldap') {
|
||||
print '</td></tr>';
|
||||
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
// Add code to generate the login when creating a new user.
|
||||
// Best rule to generate would be to use the same rule than dol_buildlogin() but currently it is a PHP function not available in js.
|
||||
// TODO Implement a dol_buildlogin in javascript.
|
||||
$charforseparator = getDolGlobalString("MAIN_USER_SEPARATOR_CHAR_FOR_GENERATED_LOGIN", '.');
|
||||
if ($charforseparator == 'none') {
|
||||
$charforseparator = '';
|
||||
}
|
||||
print '<script>
|
||||
jQuery(document).ready(function() {
|
||||
$(".createloginauto").on("change", function(){
|
||||
lastname = $("#lastname").val().toLowerCase();
|
||||
firstname = $("#firstname").val().toLowerCase()[0];
|
||||
$(".createloginauto").on("keyup", function() {
|
||||
console.log(".createloginauto change: We generate login when we have a lastname");
|
||||
|
||||
console.log("We generate login intell we have a valid lastname");
|
||||
lastname = $("#lastname").val().toLowerCase();
|
||||
';
|
||||
if (getDolGlobalString('MAIN_BUILD_LOGIN_RULE') == 'f.lastname') {
|
||||
print ' firstname = $("#firstname").val().toLowerCase()[0];';
|
||||
} else {
|
||||
print ' firstname = $("#firstname").val().toLowerCase();';
|
||||
}
|
||||
print '
|
||||
login = "";
|
||||
if (lastname) {
|
||||
if (firstname) {
|
||||
login = firstname + "'. getDolGlobalString("MAIN_USER_SEPARATOR_CHAR_FOR_GENERATED_LOGIN", "").'";
|
||||
login = firstname + \''. dol_escape_js($charforseparator).'\';
|
||||
}
|
||||
login += lastname;
|
||||
}
|
||||
console.log("We create a login from firstname and lastname");
|
||||
$("#login").val(login);
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user