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
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id;
if ($this->db->query($sql))
{
{
}
}
// Si contact, supprime lien
if ($this->contact_id)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET fk_user = null WHERE idp = $this->contact_id";
if ($this->db->query($sql))
{
{
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET fk_user = null WHERE idp = $this->contact_id";
if ($this->db->query($sql))
{
}
}
}
}
// Supprime utilisateur
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user WHERE rowid = $this->id";
$result = $this->db->query($sql);
if ($result)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('USER_DELETE',$this,$user,$lang,$conf);
if ($result < 0) $error++;
// Fin appel triggers
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('USER_DELETE',$this,$user,$lang,$conf);
if ($result < 0) $error++;
// Fin appel triggers
$this->db->commit();
return 1;
}
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
dolibarr_print_error($this->db);
return -1;
}
{
$this->db->rollback();
return -1;
}
}
/**

View File

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