Fix: Message d'erreur plus parlant lorsque l'utilisateur ne peut etre effacé

This commit is contained in:
Regis Houssin 2007-05-28 16:04:57 +00:00
parent e8046c2186
commit 832c7cc4c0
2 changed files with 32 additions and 26 deletions

View File

@ -600,42 +600,41 @@ class User
// 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 ($this->db->query($sql))
{ {
} }
// 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 = null WHERE idp = $this->contact_id"; $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET fk_user = null WHERE idp = $this->contact_id";
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
} }
} }
// Supprime utilisateur // Supprime utilisateur
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user WHERE rowid = $this->id"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."user WHERE rowid = $this->id";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
// 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_DELETE',$this,$user,$lang,$conf); $result=$interface->run_triggers('USER_DELETE',$this,$user,$lang,$conf);
if ($result < 0) $error++; if ($result < 0) $error++;
// Fin appel triggers // Fin appel triggers
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->db->rollback(); $this->db->rollback();
dolibarr_print_error($this->db); return -1;
return -1; }
}
} }
/** /**

View File

@ -111,9 +111,16 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
{ {
$edituser = new User($db, $_GET["id"]); $edituser = new User($db, $_GET["id"]);
$edituser->id=$_GET["id"]; $edituser->id=$_GET["id"];
$edituser->delete(); $result = $edituser->delete();
Header("Location: index.php"); if ($result < 0)
exit; {
$message='<div class="error">'.$langs->trans("UserCannotBeDelete").'</div>';
}
else
{
Header("Location: index.php");
exit;
}
} }
} }