Qual: Removed a hook that is a duplicate of trigger (CRUD event must be

enhanced by triggers, not hook).
Qual: Delete trigger must be done BEFORE delete of object, not after.
This commit is contained in:
Laurent Destailleur 2014-02-06 20:35:11 +01:00
parent e22e4fc4d7
commit cfb9150e10

View File

@ -1031,6 +1031,18 @@ class Societe extends CommonObject
{ {
$this->db->begin(); $this->db->begin();
if (! $error)
{
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('COMPANY_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
if (! $error)
{
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$static_cat = new Categorie($this->db); $static_cat = new Categorie($this->db);
$toute_categs = array(); $toute_categs = array();
@ -1053,6 +1065,7 @@ class Societe extends CommonObject
$cat->del_type($this, $type); $cat->del_type($this, $type);
} }
} }
}
// Remove contacts // Remove contacts
if (! $error) if (! $error)
@ -1096,20 +1109,6 @@ class Societe extends CommonObject
} }
} }
if (! $error)
{
// Additionnal action by hooks
// FIXME on a déjà un trigger, pourquoi rajouter un hook !!
$hookmanager->initHooks(array('thirdpartydao'));
$parameters=array(); $action='delete';
$reshook=$hookmanager->executeHooks('deleteThirdparty',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (! empty($hookmanager->error))
{
$error++;
$this->error=$hookmanager->error;
}
}
// Removed extrafields // Removed extrafields
if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
{ {
@ -1135,16 +1134,6 @@ class Societe extends CommonObject
} }
} }
if (! $error)
{
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('COMPANY_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();