Doc: Doc doxygen
This commit is contained in:
parent
686ed5f144
commit
cb5ae8ff6b
@ -620,93 +620,93 @@ class User
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Crée un utilisateur en base
|
* \brief Crée l'utilisateur en base
|
||||||
* \param user Objet User
|
* \param user Objet user qui demande la creation
|
||||||
* \return int si erreur <0, si ok renvoie id compte créé
|
* \return int <0 si KO, id compte créé si OK
|
||||||
* \todo Verifier tous les appels à cette fonction et ajouter le param $user
|
* \todo Verifier tous les appels à cette fonction et ajouter le param $user
|
||||||
*/
|
*/
|
||||||
function create($user='')
|
function create($user='')
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
// Nettoyage parametres
|
// Nettoyage parametres
|
||||||
$this->login = trim($this->login);
|
$this->login = trim($this->login);
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "SELECT login FROM ".MAIN_DB_PREFIX."user";
|
$sql = "SELECT login FROM ".MAIN_DB_PREFIX."user";
|
||||||
$sql.= " WHERE login ='".addslashes($this->login)."'";
|
$sql.= " WHERE login ='".addslashes($this->login)."'";
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
|
|
||||||
if ($num)
|
if ($num)
|
||||||
{
|
{
|
||||||
$this->error = $langs->trans("ErrorLoginAlreadyExists");
|
$this->error = $langs->trans("ErrorLoginAlreadyExists");
|
||||||
return -6;
|
return -6;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user (datec,login,ldap_sid) VALUES(now(),'".addslashes($this->login)."','".$this->ldap_sid."')";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user (datec,login,ldap_sid) VALUES(now(),'".addslashes($this->login)."','".$this->ldap_sid."')";
|
||||||
$result=$this->db->query($sql);
|
$result=$this->db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$table = "".MAIN_DB_PREFIX."user";
|
$table = "".MAIN_DB_PREFIX."user";
|
||||||
$this->id = $this->db->last_insert_id($table);
|
$this->id = $this->db->last_insert_id($table);
|
||||||
|
|
||||||
// Set default rights
|
// Set default rights
|
||||||
if ($this->set_default_rights() < 0)
|
if ($this->set_default_rights() < 0)
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update minor fields
|
// Update minor fields
|
||||||
if ($this->update() < 0)
|
if ($this->update() < 0)
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
$interface = new Interfaces($this->db);
|
$interface = new Interfaces($this->db);
|
||||||
$result = $interface->run_triggers('USER_CREATE',$this,$user,$lang,$conf);
|
$result = $interface->run_triggers('USER_CREATE',$this,$user,$lang,$conf);
|
||||||
if ($result < 0) $error++;
|
if ($result < 0) $error++;
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$interface->error;
|
||||||
|
$this->db->rollback();
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
$this->db->rollback();
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$interface->error;
|
$this->error=$this->db->error();
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -3;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->error=$this->db->error();
|
|
||||||
$this->db->rollback();
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->error=$this->db->error();
|
|
||||||
$this->db->rollback();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user