Qual: More complete error management into delete methods
This commit is contained in:
parent
6fcc32b326
commit
938dc92ab6
@ -704,7 +704,7 @@ class Adherent extends CommonObject
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Suppression options
|
// Remove extrafields
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_extrafields WHERE fk_object = ".$rowid;
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_extrafields WHERE fk_object = ".$rowid;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::delete sql=".$sql);
|
dol_syslog(get_class($this)."::delete sql=".$sql);
|
||||||
|
|||||||
@ -1041,9 +1041,22 @@ class Societe extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove third party
|
// Remove extrafields
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_extrafields WHERE fk_object = ".$id;
|
||||||
|
dol_syslog(get_class($this)."::delete sql=".$sql);
|
||||||
|
if (! $this->db->query($sql))
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error = $this->db->lasterror();
|
||||||
|
dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove third party
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe";
|
||||||
$sql.= " WHERE rowid = " . $id;
|
$sql.= " WHERE rowid = " . $id;
|
||||||
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
|
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
|
||||||
@ -1051,7 +1064,7 @@ class Societe extends CommonObject
|
|||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
$this->error = $this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
dol_syslog(get_class($this)."::delete erreur -3 ".$this->error, LOG_ERR);
|
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2569,7 +2582,7 @@ class Societe extends CommonObject
|
|||||||
$this->idprof5='idprof5';
|
$this->idprof5='idprof5';
|
||||||
$this->idprof6='idprof6';
|
$this->idprof6='idprof6';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if localtax define for company
|
* Check if localtax define for company
|
||||||
* Used to build previews or test instances.
|
* Used to build previews or test instances.
|
||||||
@ -2580,11 +2593,11 @@ class Societe extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function hasLocalTax($localTaxNum) {
|
function hasLocalTax($localTaxNum) {
|
||||||
global $user,$langs,$conf;
|
global $user,$langs,$conf;
|
||||||
|
|
||||||
// check parameter
|
// check parameter
|
||||||
if ($localTaxNum != 1 && $localTaxNum != 2)
|
if ($localTaxNum != 1 && $localTaxNum != 2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Search local taxes
|
// Search local taxes
|
||||||
$sql = "SELECT t.localtax1, t.localtax2";
|
$sql = "SELECT t.localtax1, t.localtax2";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
|
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
|
||||||
@ -2600,7 +2613,7 @@ class Societe extends CommonObject
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
return ($this->db->num_rows($resql) > 0);
|
return ($this->db->num_rows($resql) > 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -689,33 +689,61 @@ class User extends CommonObject
|
|||||||
|
|
||||||
// Supprime droits
|
// Supprime droits
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id;
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id;
|
||||||
if ($this->db->query($sql))
|
if (! $error && ! $this->db->query($sql))
|
||||||
{
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error = $this->db->lasterror();
|
||||||
|
dol_syslog(get_class($this)."::delete error -1 ".$this->error, LOG_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove group
|
// Remove group
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user WHERE fk_user = ".$this->id;
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user WHERE fk_user = ".$this->id;
|
||||||
if ($this->db->query($sql))
|
if (! $error && ! $this->db->query($sql))
|
||||||
{
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error = $this->db->lasterror();
|
||||||
|
dol_syslog(get_class($this)."::delete error -2 ".$this->error, LOG_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si contact, supprime lien
|
// Si contact, supprime lien
|
||||||
if ($this->contact_id)
|
if ($this->contact_id)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET fk_user_creat = null WHERE rowid = ".$this->contact_id;
|
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET fk_user_creat = null WHERE rowid = ".$this->contact_id;
|
||||||
if ($this->db->query($sql))
|
if (! $error && ! $this->db->query($sql))
|
||||||
{
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error = $this->db->lasterror();
|
||||||
|
dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Supprime utilisateur
|
// Remove extrafields
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user WHERE rowid = $this->id";
|
if (! $error)
|
||||||
$result = $this->db->query($sql);
|
{
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_extrafields WHERE fk_object = ".$this->id;
|
||||||
|
dol_syslog(get_class($this)."::delete sql=".$sql);
|
||||||
|
if (! $this->db->query($sql))
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error = $this->db->lasterror();
|
||||||
|
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($result)
|
// Remove user
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->id;
|
||||||
|
dol_syslog(get_class($this)."::delete sql=".$sql);
|
||||||
|
if (! $this->db->query($sql))
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error = $this->db->lasterror();
|
||||||
|
dol_syslog(get_class($this)."::delete error -5 ".$this->error, LOG_ERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
{
|
{
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user