Fix: Meilleure gestion erreur

This commit is contained in:
Laurent Destailleur 2007-10-02 18:16:29 +00:00
parent 8794b464b4
commit fbe28b2bc7
2 changed files with 24 additions and 23 deletions

View File

@ -446,7 +446,8 @@ if (! session_id() || ! isset($_SESSION["dol_login"]))
session_name($sessionname);
session_start();
$langs->load('main');
$_SESSION["loginmesg"]=$langs->trans("ErrorCantLoadUserFromDolibarrDatabase",$login);
if ($result == 0) $_SESSION["loginmesg"]=$langs->trans("ErrorCantLoadUserFromDolibarrDatabase",$login);
if ($result < 0) $_SESSION["loginmesg"]=$user->error;
header('Location: '.DOL_URL_ROOT.'/index.php');
exit;
}
@ -457,7 +458,7 @@ else
// Remarks: On ne sauvegarde pas objet user car pose pb dans certains cas mal identifiés
$login=$_SESSION["dol_login"];
dolibarr_syslog("This is an already user logged session. _SESSION['dol_login']=".$login);
$user->fetch($login);
$result=$user->fetch($login);
$login=$user->login;
}

View File

@ -115,7 +115,7 @@ class User
/**
* \brief Charge un objet user avec toutes ces caractéristiques depuis un id ou login
* \param login Si défini, login a utiliser pour recherche
* \return int <0 si ko, >0 si ok
* \return int <0 if KO, 0 not found, >0 if OK
*/
function fetch($login='')
{
@ -197,10 +197,10 @@ class User
else
{
$this->error="USERNOTFOUND";
dolibarr_syslog("User::fetch Error -2, fails to get user - ".$this->error." - sql=".$sql);
dolibarr_syslog("User::fetch Error 0, fails to get user - ".$this->error." - sql=".$sql);
$this->db->free($result);
return -2;
return 0;
}
}
else
@ -924,18 +924,18 @@ class User
dolibarr_syslog("User::update notrigger=".$notrigger.", nosyncmember=".$nosyncmember);
// Nettoyage parametres
$this->nom = addslashes(trim($this->nom));
$this->prenom = addslashes(trim($this->prenom));
$this->nom = trim($this->nom);
$this->prenom = trim($this->prenom);
$this->fullname = $this->prenom." ".$this->nom;
$this->login = addslashes(trim($this->login));
$this->login = trim($this->login);
$this->pass = trim($this->pass);
$this->office_phone = trim($this->office_phone);
$this->office_fax = trim($this->office_fax);
$this->user_mobile = trim($this->user_mobile);
$this->email = addslashes(trim($this->email));
$this->note = addslashes(trim($this->note));
$this->webcal_login = addslashes(trim($this->webcal_login));
$this->phenix_login = addslashes(trim($this->phenix_login));
$this->email = trim($this->email);
$this->note = trim($this->note);
$this->webcal_login = trim($this->webcal_login);
$this->phenix_login = trim($this->phenix_login);
if ($this->phenix_pass != $this->phenix_pass_crypted)
{
$this->phenix_pass = md5(trim($this->phenix_pass));
@ -946,18 +946,18 @@ class User
// Mise a jour autres infos
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET";
$sql.= " name = '".$this->nom."'";
$sql.= ", firstname = '".$this->prenom."'";
$sql.= ", login = '".$this->login."'";
$sql.= " name = '".addslashes($this->nom)."'";
$sql.= ", firstname = '".addslashes($this->prenom)."'";
$sql.= ", login = '".addslashes($this->login)."'";
$sql.= ", admin = ".$this->admin;
$sql.= ", office_phone = '".$this->office_phone."'";
$sql.= ", office_fax = '".$this->office_fax."'";
$sql.= ", user_mobile = '".$this->user_mobile."'";
$sql.= ", email = '".$this->email."'";
$sql.= ", webcal_login = '".$this->webcal_login."'";
$sql.= ", phenix_login = '".$this->phenix_login."'";
$sql.= ", phenix_pass = '".$this->phenix_pass."'";
$sql.= ", note = '".$this->note."'";
$sql.= ", office_phone = '".addslashes($this->office_phone)."'";
$sql.= ", office_fax = '".addslashes($this->office_fax)."'";
$sql.= ", user_mobile = '".addslashes($this->user_mobile)."'";
$sql.= ", email = '".addslashes($this->email)."'";
$sql.= ", webcal_login = '".addslashes($this->webcal_login)."'";
$sql.= ", phenix_login = '".addslashes($this->phenix_login)."'";
$sql.= ", phenix_pass = '".addslashes($this->phenix_pass)."'";
$sql.= ", note = '".addslashes($this->note)."'";
$sql.= " WHERE rowid = ".$this->id;
dolibarr_syslog("User::update sql=".$sql);