Qual: Removed TODO. Now all password generation use the password generator module.
This commit is contained in:
parent
e7d3f8159a
commit
d1ed609684
@ -671,16 +671,8 @@ if ($action == 'create')
|
|||||||
// Password
|
// Password
|
||||||
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
|
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
|
||||||
{
|
{
|
||||||
$generated_password='';
|
include_once(DOL_DOCUMENT_ROOT.'/lib/security.lib.php');
|
||||||
if ($conf->global->USER_PASSWORD_GENERATED)
|
$generated_password=getRandomPassword('');
|
||||||
{
|
|
||||||
$nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED);
|
|
||||||
$nomfichier=$nomclass.".class.php";
|
|
||||||
//print DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomclass;
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomfichier);
|
|
||||||
$genhandler=new $nomclass($db,$conf,$langs,$user);
|
|
||||||
$generated_password=$genhandler->getNewGeneratedPassword();
|
|
||||||
}
|
|
||||||
print '<tr><td><span class="fieldrequired">'.$langs->trans("Password").'</span></td><td>';
|
print '<tr><td><span class="fieldrequired">'.$langs->trans("Password").'</span></td><td>';
|
||||||
print '<input size="30" maxsize="32" type="text" name="password" value="'.$generated_password.'">';
|
print '<input size="30" maxsize="32" type="text" name="password" value="'.$generated_password.'">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -31,11 +31,11 @@ require_once(DOL_DOCUMENT_ROOT."/lib/agenda.lib.php");
|
|||||||
if (!$user->admin)
|
if (!$user->admin)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
|
$langs->load("users");
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
|
|
||||||
$action=$_POST["action"];
|
$action=GETPOST("action");
|
||||||
|
|
||||||
|
|
||||||
// List of all events supported by triggers
|
// List of all events supported by triggers
|
||||||
|
|||||||
@ -531,13 +531,20 @@ class Account extends CommonObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a bank account into memory from database
|
* Load a bank account into memory from database
|
||||||
* @param id Id du compte a recuperer
|
* @param id Id of bank account to get
|
||||||
* @param ref Ref du compte a recuperer
|
* @param ref Ref of bank account to get
|
||||||
|
* @param ref_ext External ref of bank account to get
|
||||||
*/
|
*/
|
||||||
function fetch($id,$ref='')
|
function fetch($id,$ref='',$ref_ext='')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
|
if (empty($id) && empty($ref) && empty($ref_ext))
|
||||||
|
{
|
||||||
|
$this->error="ErrorBadParameters";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant, ba.clos, ba.rappro, ba.url,";
|
$sql = "SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant, ba.clos, ba.rappro, ba.url,";
|
||||||
$sql.= " ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,";
|
$sql.= " ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,";
|
||||||
$sql.= " ba.domiciliation, ba.proprio, ba.adresse_proprio, ba.fk_departement, ba.fk_pays,";
|
$sql.= " ba.domiciliation, ba.proprio, ba.adresse_proprio, ba.fk_departement, ba.fk_pays,";
|
||||||
@ -1091,7 +1098,7 @@ class AccountLine extends CommonObject
|
|||||||
|
|
||||||
if ($this->rappro)
|
if ($this->rappro)
|
||||||
{
|
{
|
||||||
// Protection pour eviter tout suppression d'une ligne consolid<69>e
|
// Protection to avoid any delete of consolidated lines
|
||||||
$this->error="DeleteNotPossibleLineIsConsolidated";
|
$this->error="DeleteNotPossibleLineIsConsolidated";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -334,15 +334,8 @@ class ActionsContactCardCommon
|
|||||||
$generated_password='';
|
$generated_password='';
|
||||||
if (! $ldap_sid)
|
if (! $ldap_sid)
|
||||||
{
|
{
|
||||||
if ($conf->global->USER_PASSWORD_GENERATED)
|
include_once(DOL_DOCUMENT_ROOT.'/lib/security.lib.php');
|
||||||
{
|
$generated_password=getRandomPassword('');
|
||||||
$nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED);
|
|
||||||
$nomfichier=$nomclass.".class.php";
|
|
||||||
//print DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomclass;
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomfichier);
|
|
||||||
$genhandler=new $nomclass($this->db,$conf,$langs,$user);
|
|
||||||
$generated_password=$genhandler->getNewGeneratedPassword();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$password=$generated_password;
|
$password=$generated_password;
|
||||||
|
|
||||||
|
|||||||
@ -490,6 +490,7 @@ class Contact extends CommonObject
|
|||||||
$this->fk_pays = $obj->fk_pays;
|
$this->fk_pays = $obj->fk_pays;
|
||||||
$this->pays_code = $obj->fk_pays?$obj->pays_code:'';
|
$this->pays_code = $obj->fk_pays?$obj->pays_code:'';
|
||||||
$this->pays = ($obj->fk_pays > 0)?$langs->transnoentities("Country".$obj->pays_code):$langs->transnoentities("SelectCountry");
|
$this->pays = ($obj->fk_pays > 0)?$langs->transnoentities("Country".$obj->pays_code):$langs->transnoentities("SelectCountry");
|
||||||
|
$this->country = ($obj->fk_pays > 0)?$langs->transnoentities("Country".$obj->pays_code):$langs->transnoentities("SelectCountry");
|
||||||
|
|
||||||
$this->socid = $obj->fk_soc;
|
$this->socid = $obj->fk_soc;
|
||||||
$this->socname = $obj->socname;
|
$this->socname = $obj->socname;
|
||||||
@ -788,12 +789,12 @@ class Contact extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoie nom clicable (avec eventuellement le picto)
|
* Return name of contact with link (and eventually picto)
|
||||||
* \param withpicto Inclut le picto dans le lien
|
* Use $this->id, $this->name, $this->firstname, this->civilite_id
|
||||||
* \param option Sur quoi pointe le lien
|
* @param withpicto Include picto with link
|
||||||
* \param maxlen Longueur max libelle
|
* @param option Where the link point to
|
||||||
* \return string Chaine avec URL
|
* @param maxlen Max length of
|
||||||
* \remarks Utilise $this->id, $this->name et $this->firstname
|
* @return string String with URL
|
||||||
*/
|
*/
|
||||||
function getNomUrl($withpicto=0,$option='',$maxlen=0)
|
function getNomUrl($withpicto=0,$option='',$maxlen=0)
|
||||||
{
|
{
|
||||||
@ -816,6 +817,31 @@ class Contact extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return full address of contact
|
||||||
|
* @param withcountry 1=Add country into address string
|
||||||
|
* @param sep Separator to use to build string
|
||||||
|
* @return string Full address string
|
||||||
|
*/
|
||||||
|
function getFullAddress($withcountry=0,$sep="\n")
|
||||||
|
{
|
||||||
|
$ret='';
|
||||||
|
if (in_array($this->country,array('us')))
|
||||||
|
{
|
||||||
|
$ret.=($this->address?$this->address.$sep:'');
|
||||||
|
$ret.=trim($this->zip.' '.$this->town);
|
||||||
|
if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ret.=($this->address?$this->address.$sep:'');
|
||||||
|
$ret.=trim($this->zip.' '.$this->town);
|
||||||
|
if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
|
||||||
|
}
|
||||||
|
return trim($ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return label of a civility contact
|
* Return label of a civility contact
|
||||||
* @return string Translated name of civility
|
* @return string Translated name of civility
|
||||||
|
|||||||
@ -759,15 +759,8 @@ else
|
|||||||
$generated_password='';
|
$generated_password='';
|
||||||
if (! $ldap_sid) // TODO ldap_sid ?
|
if (! $ldap_sid) // TODO ldap_sid ?
|
||||||
{
|
{
|
||||||
if ($conf->global->USER_PASSWORD_GENERATED)
|
include_once(DOL_DOCUMENT_ROOT.'/lib/security.lib.php');
|
||||||
{
|
$generated_password=getRandomPassword('');
|
||||||
$nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED);
|
|
||||||
$nomfichier=$nomclass.".class.php";
|
|
||||||
//print DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomclass;
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomfichier);
|
|
||||||
$genhandler=new $nomclass($db,$conf,$langs,$user);
|
|
||||||
$generated_password=$genhandler->getNewGeneratedPassword();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$password=$generated_password;
|
$password=$generated_password;
|
||||||
|
|
||||||
|
|||||||
38
htdocs/includes/modules/security/generate/README
Executable file
38
htdocs/includes/modules/security/generate/README
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
README (english)
|
||||||
|
------------------------------------
|
||||||
|
Adding your own password generator module
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
If you want to add your own password generator module. This is steps to follow
|
||||||
|
to add you own password generator:
|
||||||
|
|
||||||
|
|
||||||
|
***** STEP 1 *****
|
||||||
|
|
||||||
|
Copy file
|
||||||
|
htdocs/includes/modules/security/modGeneratePassNone.class.php
|
||||||
|
into
|
||||||
|
htdocs/includes/modules/mailings/modMyGenerator.class.php
|
||||||
|
|
||||||
|
You can choose value of your choice instead of "myGenerator" in name
|
||||||
|
of new file.
|
||||||
|
|
||||||
|
|
||||||
|
***** STEP 2 *****
|
||||||
|
|
||||||
|
Edit this file modMyGenerator.class.php and change following text:
|
||||||
|
|
||||||
|
"class modGeneratePassNone" into "class modMyGenerator"
|
||||||
|
"function modGeneratePassNone" into "function modMyGenerator"
|
||||||
|
|
||||||
|
Then add code inside the "getDecription" function.
|
||||||
|
Then add code inside the "getExample" function.
|
||||||
|
Then add code inside the "getNewGeneratedPassword" function.
|
||||||
|
Then add code inside the "validatePassword" function.
|
||||||
|
|
||||||
|
|
||||||
|
***** STEP 3 *****
|
||||||
|
|
||||||
|
Once this file has been edited, you can go to the Dolibarr security setup,
|
||||||
|
choose tab "passwords", you will see a new line generator in the "Rules to generate passwords" area.
|
||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -43,11 +43,11 @@ class modGeneratePassNone extends ModeleGenPassword
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Constructeur
|
* \brief Constructor
|
||||||
* \param db Handler d'acc<EFBFBD>s base
|
* \param db Database handler
|
||||||
* \param conf Handler de conf
|
* \param conf Handler de conf
|
||||||
* \param lang Handler de langue
|
* \param lang Handler de langue
|
||||||
* \param user Handler du user connect<EFBFBD>
|
* \param user Handler du user connecte
|
||||||
*/
|
*/
|
||||||
function modGeneratePassNone($db, $conf, $langs, $user)
|
function modGeneratePassNone($db, $conf, $langs, $user)
|
||||||
{
|
{
|
||||||
@ -61,8 +61,8 @@ class modGeneratePassNone extends ModeleGenPassword
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoi la description du module
|
* Return description of module
|
||||||
* \return string Texte descripif
|
* @return string Description of text
|
||||||
*/
|
*/
|
||||||
function getDescription()
|
function getDescription()
|
||||||
{
|
{
|
||||||
@ -71,8 +71,8 @@ class modGeneratePassNone extends ModeleGenPassword
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoie exemple de mot de passe g<EFBFBD>n<EFBFBD>r<EFBFBD> par cette r<EFBFBD>gle
|
* Return an example of password generated by this module
|
||||||
* \return string Exemple
|
* @return string Example of password
|
||||||
*/
|
*/
|
||||||
function getExample()
|
function getExample()
|
||||||
{
|
{
|
||||||
@ -80,8 +80,8 @@ class modGeneratePassNone extends ModeleGenPassword
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Build new password
|
* Build new password
|
||||||
* \return string Return a new generated password
|
* @return string Return a new generated password
|
||||||
*/
|
*/
|
||||||
function getNewGeneratedPassword()
|
function getNewGeneratedPassword()
|
||||||
{
|
{
|
||||||
@ -89,8 +89,8 @@ class modGeneratePassNone extends ModeleGenPassword
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Validate a password
|
* Validate a password
|
||||||
* \return int 0 if KO, >0 if OK
|
* @return int 0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function validatePassword($password)
|
function validatePassword($password)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -43,8 +43,8 @@ class modGeneratePassStandard extends ModeleGenPassword
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Constructeur
|
* \brief Constructor
|
||||||
* \param db Handler d'acces base
|
* \param db Database handler
|
||||||
* \param conf Handler de conf
|
* \param conf Handler de conf
|
||||||
* \param lang Handler de langue
|
* \param lang Handler de langue
|
||||||
* \param user Handler du user connecte
|
* \param user Handler du user connecte
|
||||||
@ -61,8 +61,8 @@ class modGeneratePassStandard extends ModeleGenPassword
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoi la description du module
|
* Return description of module
|
||||||
* \return string Texte descripif
|
* @return string Description of module
|
||||||
*/
|
*/
|
||||||
function getDescription()
|
function getDescription()
|
||||||
{
|
{
|
||||||
@ -71,8 +71,8 @@ class modGeneratePassStandard extends ModeleGenPassword
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoie exemple de mot de passe genere par cette regle
|
* Return an example of password generated by this module
|
||||||
* \return string Exemple
|
* @return string Example of password
|
||||||
*/
|
*/
|
||||||
function getExample()
|
function getExample()
|
||||||
{
|
{
|
||||||
@ -80,8 +80,8 @@ class modGeneratePassStandard extends ModeleGenPassword
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Build new password
|
* Build new password
|
||||||
* \return string Return a new generated password
|
* @return string Return a new generated password
|
||||||
*/
|
*/
|
||||||
function getNewGeneratedPassword()
|
function getNewGeneratedPassword()
|
||||||
{
|
{
|
||||||
@ -115,8 +115,8 @@ class modGeneratePassStandard extends ModeleGenPassword
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Validate a password
|
* Validate a password
|
||||||
* \return int 0 if KO, >0 if OK
|
* @return int 0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function validatePassword($password)
|
function validatePassword($password)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
/**
|
/**
|
||||||
* \file htdocs/includes/modules/security/generate/modules_genpassword.php
|
* \file htdocs/includes/modules/security/generate/modules_genpassword.php
|
||||||
* \ingroup core
|
* \ingroup core
|
||||||
* \brief Fichier contenant la classe m<EFBFBD>re de generation des mots de passe
|
* \brief File with parent class for password generating classes
|
||||||
* \version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
require_once(DOL_DOCUMENT_ROOT.'/lib/functions.lib.php');
|
require_once(DOL_DOCUMENT_ROOT.'/lib/functions.lib.php');
|
||||||
|
|||||||
@ -536,4 +536,26 @@ function dol_efc_config()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a generated password using default module
|
||||||
|
* @return string New value for password
|
||||||
|
*/
|
||||||
|
function getRandomPassword()
|
||||||
|
{
|
||||||
|
global $db,$conf,$langs,$user;
|
||||||
|
|
||||||
|
$generated_password='';
|
||||||
|
if ($conf->global->USER_PASSWORD_GENERATED)
|
||||||
|
{
|
||||||
|
$nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED);
|
||||||
|
$nomfichier=$nomclass.".class.php";
|
||||||
|
//print DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomclass;
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomfichier);
|
||||||
|
$genhandler=new $nomclass($db,$conf,$langs,$user);
|
||||||
|
$generated_password=$genhandler->getNewGeneratedPassword();
|
||||||
|
unset($genhandler);
|
||||||
|
}
|
||||||
|
return $generated_password;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -1397,17 +1397,26 @@ class Societe extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return full address of a third party (TODO in format of its country)
|
* Return full address of third party
|
||||||
* @param withcountry Add country
|
* @param withcountry 1=Add country into address string
|
||||||
* @param nobr Do not use br
|
* @param sep Separator to use to build string
|
||||||
* @return string Full address string
|
* @return string Full address string
|
||||||
*/
|
*/
|
||||||
function getFullAddress($withcountry=0,$sep="\n")
|
function getFullAddress($withcountry=0,$sep="\n")
|
||||||
{
|
{
|
||||||
$ret='';
|
$ret='';
|
||||||
|
if (in_array($this->country,array('us')))
|
||||||
|
{
|
||||||
$ret.=($this->address?$this->address.$sep:'');
|
$ret.=($this->address?$this->address.$sep:'');
|
||||||
$ret.=trim($this->zip.' '.$this->town);
|
$ret.=trim($this->zip.' '.$this->town);
|
||||||
if ($withcountry) $ret.=($this->pays?$sep.$this->pays:'');
|
if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ret.=($this->address?$this->address.$sep:'');
|
||||||
|
$ret.=trim($this->zip.' '.$this->town);
|
||||||
|
if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
|
||||||
|
}
|
||||||
return trim($ret);
|
return trim($ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1196,12 +1196,11 @@ class User extends CommonObject
|
|||||||
|
|
||||||
dol_syslog("User::setPassword user=".$user->id." password=".preg_replace('/./i','*',$password)." changelater=".$changelater." notrigger=".$notrigger." nosyncmember=".$nosyncmember, LOG_DEBUG);
|
dol_syslog("User::setPassword user=".$user->id." password=".preg_replace('/./i','*',$password)." changelater=".$changelater." notrigger=".$notrigger." nosyncmember=".$nosyncmember, LOG_DEBUG);
|
||||||
|
|
||||||
// Si nouveau mot de passe non communique, on genere par module
|
// If new password not provided, we generate one
|
||||||
if (! $password)
|
if (! $password)
|
||||||
{
|
{
|
||||||
// TODO Mettre appel au module de generation de mot de passe
|
include_once(DOL_DOCUMENT_ROOT.'/lib/security.lib.php');
|
||||||
$password=creer_pass_aleatoire_1('');
|
$password=getRandomPassword('');
|
||||||
//$password=creer_pass_aleatoire_2('');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crypte avec md5
|
// Crypte avec md5
|
||||||
@ -1646,12 +1645,12 @@ class User extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
|
* Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
|
||||||
* \param info Info string loaded by _load_ldap_info
|
* @param info Info string loaded by _load_ldap_info
|
||||||
* \param mode 0=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb)
|
* @param mode 0=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb)
|
||||||
* 1=
|
* 1=
|
||||||
* 2=Return key only (uid=qqq)
|
* 2=Return key only (uid=qqq)
|
||||||
* \return string DN
|
* @return string DN
|
||||||
*/
|
*/
|
||||||
function _load_ldap_dn($info,$mode=0)
|
function _load_ldap_dn($info,$mode=0)
|
||||||
{
|
{
|
||||||
@ -1664,14 +1663,8 @@ class User extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Initialise tableau info (tableau des attributs LDAP)
|
* Initialize the info array (array of LDAP values) that will be used to call LDAP functions
|
||||||
* \return array Tableau info des attributs
|
* @return array Tableau info des attributs
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Initialize the info array (array of LDAP values) that will be used to call LDAP functions
|
|
||||||
* \return array Tableau info des attributs
|
|
||||||
*/
|
*/
|
||||||
function _load_ldap_info()
|
function _load_ldap_info()
|
||||||
{
|
{
|
||||||
@ -1741,7 +1734,7 @@ class User extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Initialise le user avec valeurs fictives aleatoire
|
* Initialize user with default values
|
||||||
*/
|
*/
|
||||||
function initAsSpecimen()
|
function initAsSpecimen()
|
||||||
{
|
{
|
||||||
@ -1774,44 +1767,8 @@ class User extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Charge la liste ->entrepots[] des entrepots pour l'utilisateur
|
* Load info of user object
|
||||||
* \return int 0 si ok, <> 0 si erreur
|
* @param id id of user to load
|
||||||
*/
|
|
||||||
/* deprecated
|
|
||||||
function load_entrepots()
|
|
||||||
{
|
|
||||||
$err=0;
|
|
||||||
$this->entrepots = array();
|
|
||||||
$sql = "SELECT e.rowid,ue.consult,ue.send,e.label";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."user_entrepot as ue,".MAIN_DB_PREFIX."entrepot as e";
|
|
||||||
$sql.= " WHERE fk_user = '".$this->id."'";
|
|
||||||
$sql .= " AND e.statut = 1";
|
|
||||||
$sql .= " AND e.rowid = ue.fk_entrepot";
|
|
||||||
|
|
||||||
if ( $this->db->query($sql) )
|
|
||||||
{
|
|
||||||
$i=0;
|
|
||||||
while ($obj = $this->db->fetch_object($result) )
|
|
||||||
{
|
|
||||||
$this->entrepots[$i]['id'] = $obj->consult;
|
|
||||||
$this->entrepots[$i]['consult'] = $obj->consult;
|
|
||||||
$this->entrepots[$i]['send'] = $obj->send;
|
|
||||||
$this->entrepots[$i]['label'] = $obj->label;
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$err++;
|
|
||||||
dol_print_error($this->db);
|
|
||||||
}
|
|
||||||
return $err;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \brief Charge les informations d'ordre info dans l'objet user
|
|
||||||
* \param id id du user a charger
|
|
||||||
*/
|
*/
|
||||||
function info($id)
|
function info($id)
|
||||||
{
|
{
|
||||||
@ -1846,8 +1803,8 @@ class User extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return number of mass Emailing received by this contacts with its email
|
* Return number of mass Emailing received by this contacts with its email
|
||||||
* \return int Number of EMailings
|
* @return int Number of EMailings
|
||||||
*/
|
*/
|
||||||
function getNbOfEMailings()
|
function getNbOfEMailings()
|
||||||
{
|
{
|
||||||
@ -1872,9 +1829,9 @@ class User extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return number of existing users
|
* Return number of existing users
|
||||||
* \param limitToActive limit to active users
|
* @param limitToActive limit to active users
|
||||||
* \return int Number of users
|
* @return int Number of users
|
||||||
*/
|
*/
|
||||||
function getNbOfUsers($limitToActive=0)
|
function getNbOfUsers($limitToActive=0)
|
||||||
{
|
{
|
||||||
@ -1903,52 +1860,4 @@ class User extends CommonObject
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Fonction pour creer un mot de passe aleatoire en minuscule
|
|
||||||
* \param sel Donnee aleatoire
|
|
||||||
* \return string Mot de passe
|
|
||||||
*/
|
|
||||||
function creer_pass_aleatoire_1($sel = "")
|
|
||||||
{
|
|
||||||
$longueur = 8;
|
|
||||||
|
|
||||||
return strtolower(substr(md5(uniqid(mt_rand())),0,$longueur));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Fonction pour creer un mot de passe aleatoire melangeant majuscule,
|
|
||||||
* minuscule, chiffre et alpha et caracteres speciaux
|
|
||||||
* \remarks La fonction a ete prise sur http://www.uzine.net/spip
|
|
||||||
* \param sel Donnee aleatoire
|
|
||||||
* \return string Mot de passe
|
|
||||||
*/
|
|
||||||
function creer_pass_aleatoire_2($sel = "")
|
|
||||||
{
|
|
||||||
$longueur=8;
|
|
||||||
|
|
||||||
$seed = (double) (microtime() + 1) * time();
|
|
||||||
srand($seed);
|
|
||||||
|
|
||||||
for ($i = 0; $i < $longueur; $i++)
|
|
||||||
{
|
|
||||||
if (!$s)
|
|
||||||
{
|
|
||||||
if (!$s) $s = mt_rand();
|
|
||||||
$s = substr(md5(uniqid($s).$sel), 0, 16);
|
|
||||||
}
|
|
||||||
$r = unpack("Cr", pack("H2", $s.$s));
|
|
||||||
$x = $r['r'] & 63;
|
|
||||||
if ($x < 10) $x = chr($x + 48);
|
|
||||||
else if ($x < 36) $x = chr($x + 55);
|
|
||||||
else if ($x < 62) $x = chr($x + 61);
|
|
||||||
else if ($x == 63) $x = '/';
|
|
||||||
else $x = '.';
|
|
||||||
$pass .= $x;
|
|
||||||
$s = substr($s, 2);
|
|
||||||
}
|
|
||||||
return $pass;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -618,17 +618,10 @@ if (($action == 'create') || ($action == 'adduserldap'))
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
$generated_password='';
|
$generated_password='';
|
||||||
if (!$ldap_sid)
|
if (! $ldap_sid)
|
||||||
{
|
{
|
||||||
if ($conf->global->USER_PASSWORD_GENERATED)
|
include_once(DOL_DOCUMENT_ROOT.'/lib/security.lib.php');
|
||||||
{
|
$generated_password=getRandomPassword('');
|
||||||
$nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED);
|
|
||||||
$nomfichier=$nomclass.".class.php";
|
|
||||||
//print DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomclass;
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomfichier);
|
|
||||||
$genhandler=new $nomclass($db,$conf,$langs,$user);
|
|
||||||
$generated_password=$genhandler->getNewGeneratedPassword();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$password=$generated_password;
|
$password=$generated_password;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user