Remove hook that is duplicate code with trigger.

This commit is contained in:
Laurent Destailleur 2017-02-28 11:20:33 +01:00
parent 0f22beb774
commit 9928f943a7
2 changed files with 13 additions and 37 deletions

View File

@ -1237,7 +1237,7 @@ class User extends CommonObject
*/
function update($user,$notrigger=0,$nosyncmember=0,$nosyncmemberpass=0)
{
global $conf, $langs, $hookmanager;
global $conf, $langs;
$nbrowsaffected=0;
$error=0;
@ -1412,22 +1412,14 @@ class User extends CommonObject
$action='update';
// Actions on extra fields (by external module or standard code)
// FIXME le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('userdao'));
$parameters=array('socid'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$result=$this->insertExtraFields();
if ($result < 0)
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
$error++;
}
}
else if ($reshook < 0) $error++;
if (! $error && ! $notrigger)
{

View File

@ -624,22 +624,14 @@ class UserGroup extends CommonObject
$action='create';
// Actions on extra fields (by external module or standard code)
// TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('groupdao'));
$parameters=array();
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$result=$this->insertExtraFields();
if ($result < 0)
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
$error++;
}
}
else if ($reshook < 0) $error++;
if (! $error && ! $notrigger)
{
@ -695,22 +687,14 @@ class UserGroup extends CommonObject
$action='update';
// Actions on extra fields (by external module or standard code)
// TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('groupdao'));
$parameters=array();
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$result=$this->insertExtraFields();
if ($result < 0)
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
$error++;
}
}
else if ($reshook < 0) $error++;
if (! $error && ! $notrigger)
{