Finish removal of duplicate hook/trigger
This commit is contained in:
parent
46716f2259
commit
4475df14b4
@ -210,22 +210,11 @@ class CommandeFournisseurDispatch extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions on extra fields (by external module or standard code)
|
// Create extrafields
|
||||||
// TODO le hook fait double emploi avec le trigger !!
|
if (! $error)
|
||||||
$hookmanager->initHooks(array('commandefournisseurdispatchdao'));
|
{
|
||||||
$parameters = array('id'=>$this->id);
|
$result=$this->insertExtraFields();
|
||||||
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
if ($result < 0) $error++;
|
||||||
if (empty($reshook))
|
|
||||||
{
|
|
||||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
|
||||||
{
|
|
||||||
$result = $this->insertExtraFields();
|
|
||||||
|
|
||||||
if ($result < 0)
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit or rollback
|
// Commit or rollback
|
||||||
|
|||||||
@ -186,30 +186,25 @@ if (empty($reshook))
|
|||||||
|
|
||||||
if ($action == 'update_extras')
|
if ($action == 'update_extras')
|
||||||
{
|
{
|
||||||
// Fill array 'array_options' with data from update form
|
$object->oldcopy = dol_clone($object);
|
||||||
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute'));
|
|
||||||
if ($ret < 0) $error++;
|
|
||||||
|
|
||||||
if (!$error)
|
// Fill array 'array_options' with data from update form
|
||||||
{
|
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
|
||||||
// Actions on extra fields (by external module or standard code)
|
if ($ret < 0) $error++;
|
||||||
// TODO le hook fait double emploi avec le trigger !!
|
|
||||||
$hookmanager->initHooks(array('receptiondao'));
|
|
||||||
$parameters = array('id' => $object->id);
|
|
||||||
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
|
||||||
if (empty($reshook)) {
|
|
||||||
$result = $object->insertExtraFields();
|
|
||||||
if ($result < 0)
|
|
||||||
{
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
} elseif ($reshook < 0)
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($error)
|
if (!$error)
|
||||||
$action = 'edit_extras';
|
{
|
||||||
|
// Actions on extra fields
|
||||||
|
$result = $object->insertExtraFields('RECEPTION_MODIFY');
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($error)
|
||||||
|
$action = 'edit_extras';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create reception
|
// Create reception
|
||||||
|
|||||||
@ -305,24 +305,12 @@ class Reception extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions on extra fields (by external module or standard code)
|
// Create extrafields
|
||||||
// TODO le hook fait double emploi avec le trigger !!
|
if (! $error)
|
||||||
$action = 'add';
|
|
||||||
$hookmanager->initHooks(array('receptiondao'));
|
|
||||||
$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
|
$result=$this->insertExtraFields();
|
||||||
{
|
if ($result < 0) $error++;
|
||||||
$result = $this->insertExtraFields();
|
|
||||||
if ($result < 0)
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
elseif ($reshook < 0) $error++;
|
|
||||||
|
|
||||||
if (!$error && !$notrigger)
|
if (!$error && !$notrigger)
|
||||||
{
|
{
|
||||||
@ -330,29 +318,22 @@ class Reception extends CommonObject
|
|||||||
$result = $this->call_trigger('RECEPTION_CREATE', $user);
|
$result = $this->call_trigger('RECEPTION_CREATE', $user);
|
||||||
if ($result < 0) { $error++; }
|
if ($result < 0) { $error++; }
|
||||||
// End call triggers
|
// End call triggers
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach ($this->errors as $errmsg)
|
|
||||||
{
|
|
||||||
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
|
|
||||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
|
||||||
}
|
|
||||||
$this->db->rollback();
|
|
||||||
return -1 * $error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
foreach ($this->errors as $errmsg)
|
||||||
$this->error = $this->db->lasterror()." - sql=$sql";
|
{
|
||||||
|
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
|
||||||
|
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||||
|
}
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -3;
|
return -1 * $error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user