mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-24 02:11:27 +01:00
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>' . $langs->trans("DefaultBlacklistMailingStatus", $langs->transnoentitiesnoconv("No_Email")) . '</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$blacklist_setting=array(0=>$langs->trans('No'), 1=>$langs->trans('Yes'), 2=>$langs->trans('DefaultStatusEmptyMandatory'));
|
$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>';
|
||||||
print '<td class="hideonsmartphone"></td>';
|
print '<td class="hideonsmartphone"></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|||||||
@@ -847,6 +847,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td class="noemail"><label for="no_email">'.$langs->trans("No_Email").'</label></td>';
|
print '<td class="noemail"><label for="no_email">'.$langs->trans("No_Email").'</label></td>';
|
||||||
print '<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 $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 '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ function getMultidirOutput($object, $module = '')
|
|||||||
/**
|
/**
|
||||||
* Return dolibarr global constant string value
|
* 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
|
* @param string $default value to return
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1985,17 +1985,20 @@ function is_ip($ip)
|
|||||||
*/
|
*/
|
||||||
function dol_buildlogin($lastname, $firstname)
|
function dol_buildlogin($lastname, $firstname)
|
||||||
{
|
{
|
||||||
global $conf;
|
|
||||||
|
|
||||||
//$conf->global->MAIN_BUILD_LOGIN_RULE = 'f.lastname';
|
//$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
|
if (getDolGlobalString('MAIN_BUILD_LOGIN_RULE') == 'f.lastname') { // f.lastname
|
||||||
$login = strtolower(dol_string_unaccent(dol_trunc($firstname, 1, 'right', 'UTF-8', 1)));
|
$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 .= strtolower(dol_string_unaccent($lastname));
|
||||||
$login = dol_string_nospecial($login, ''); // For special names
|
$login = dol_string_nospecial($login, ''); // For special names
|
||||||
} else { // firstname.lastname
|
} else { // firstname.lastname
|
||||||
$login = strtolower(dol_string_unaccent($firstname));
|
$login = strtolower(dol_string_unaccent($firstname));
|
||||||
$login .= ($login ? '.' : '');
|
$login .= ($login ? $charforseparator : '');
|
||||||
$login .= strtolower(dol_string_unaccent($lastname));
|
$login .= strtolower(dol_string_unaccent($lastname));
|
||||||
$login = dol_string_nospecial($login, ''); // For special names
|
$login = dol_string_nospecial($login, ''); // For special names
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -938,21 +938,33 @@ if ($action == 'create' || $action == 'adduserldap') {
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
if (!empty($conf->use_javascript_ajax)) {
|
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>
|
print '<script>
|
||||||
jQuery(document).ready(function() {
|
jQuery(document).ready(function() {
|
||||||
$(".createloginauto").on("change", function(){
|
$(".createloginauto").on("keyup", function() {
|
||||||
lastname = $("#lastname").val().toLowerCase();
|
console.log(".createloginauto change: We generate login when we have a lastname");
|
||||||
firstname = $("#firstname").val().toLowerCase()[0];
|
|
||||||
|
|
||||||
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 = "";
|
login = "";
|
||||||
if(lastname) {
|
if (lastname) {
|
||||||
if(firstname) {
|
if (firstname) {
|
||||||
login = firstname + "'. getDolGlobalString("MAIN_USER_SEPARATOR_CHAR_FOR_GENERATED_LOGIN", "").'";
|
login = firstname + \''. dol_escape_js($charforseparator).'\';
|
||||||
}
|
}
|
||||||
login += lastname;
|
login += lastname;
|
||||||
}
|
}
|
||||||
console.log("We create a login from firstname and lastname");
|
|
||||||
$("#login").val(login);
|
$("#login").val(login);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user