Fix: User creation must use same rule if from contact and from member.

This commit is contained in:
Laurent Destailleur 2011-01-05 17:43:58 +00:00
parent 64457363ce
commit 901d5e235a
3 changed files with 26 additions and 8 deletions

View File

@ -1020,6 +1020,12 @@ if ($rowid && $action != 'edit')
if ($_GET["action"] == 'create_user')
{
$login=$adh->login;
if (empty($login))
{
// Full firstname and name separated with a dot : firstname.name
include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php');
$login=dol_buildlogin($adh->nom,$adh->prenom);
}
if (empty($login)) $login=strtolower(substr($adh->prenom, 0, 4)) . strtolower(substr($adh->nom, 0, 4));
// Create a form array

View File

@ -23,7 +23,7 @@
/**
* \file htdocs/contact/fiche.php
* \ingroup societe
* \brief Onglet general d'un contact
* \brief Card of a contact
* \version $Id$
*/
@ -757,11 +757,10 @@ else
if ($_GET["action"] == 'create_user')
{
// Full firstname and name separated with a dot : firstname.name
// TODO add function
$login=strtolower(dol_string_unaccent($object->prenom)) .'.'. strtolower(dol_string_unaccent($object->nom));
$login=dol_string_nospecial($login,''); // For special names
// Full firstname and name separated with a dot : firstname.name
include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php');
$login=dol_buildlogin($object->nom,$object->prenom);
// Create a form array
$formquestion=array(array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login));

View File

@ -1099,8 +1099,8 @@ function getListOfModels($db,$type)
}
/**
* \brief This function evaluates a string that should be a valid IPv4
* \return It returns 0 if $ip is not a valid IPv4
* This function evaluates a string that should be a valid IPv4
* @return It returns 0 if $ip is not a valid IPv4
* It returns 1 if $ip is a valid IPv4 and is a public IP
* It returns 2 if $ip is a valid IPv4 and is a private lan IP
*/
@ -1115,3 +1115,16 @@ function is_ip($ip)
return 1;
}
/**
* Build a login from lastname, firstname
* @param lastname Lastname
* @param firstname Firstname
* @return string
*/
function dol_buildlogin($lastname,$firstname)
{
$login=strtolower(dol_string_unaccent($firstname)) .'.'. strtolower(dol_string_unaccent($lastname));
$login=dol_string_nospecial($login,''); // For special names
return $login;
}