parent
c70bdabeda
commit
e4ad082214
@ -23,6 +23,8 @@ For users:
|
|||||||
- Fix: [ bug #1465, #1466 ] Product triggers problem
|
- Fix: [ bug #1465, #1466 ] Product triggers problem
|
||||||
- Fix: [ bug #1508 ] STOCK_MOVEMENT does not show trigger error message
|
- Fix: [ bug #1508 ] STOCK_MOVEMENT does not show trigger error message
|
||||||
- Fix: [ bug #1501 ] DEPLACEMENT_CREATE trigger do not intercept trigger action
|
- Fix: [ bug #1501 ] DEPLACEMENT_CREATE trigger do not intercept trigger action
|
||||||
|
- Fix: [ bug #1506, #1507 ] ECM trigger error problem
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
For translators:
|
For translators:
|
||||||
|
|||||||
@ -232,6 +232,20 @@ class InterfaceDemo
|
|||||||
|
|
||||||
//Stock mouvement
|
//Stock mouvement
|
||||||
elseif ($action == 'STOCK_MOVEMENT')
|
elseif ($action == 'STOCK_MOVEMENT')
|
||||||
|
{
|
||||||
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
//MYECMDIR
|
||||||
|
elseif ($action == 'MYECMDIR_DELETE')
|
||||||
|
{
|
||||||
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
}
|
||||||
|
elseif ($action == 'MYECMDIR_CREATE')
|
||||||
|
{
|
||||||
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
}
|
||||||
|
elseif ($action == 'MYECMDIR_MODIFY')
|
||||||
{
|
{
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -152,12 +152,10 @@ class EcmDirectory // extends CommonObject
|
|||||||
$result=dol_mkdir($dir);
|
$result=dol_mkdir($dir);
|
||||||
if ($result < 0) { $error++; $this->error="ErrorFailedToCreateDir"; }
|
if ($result < 0) { $error++; $this->error="ErrorFailedToCreateDir"; }
|
||||||
|
|
||||||
// Appel des triggers
|
// Call trigger
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
$result=$this->call_trigger('MYECMDIR_CREATE',$user);
|
||||||
$interface=new Interfaces($this->db);
|
if ($result < 0) { $error++; }
|
||||||
$result=$interface->run_triggers('MYECMDIR_CREATE',$this,$user,$langs,$conf);
|
// End call triggers
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
|
||||||
// Fin appel triggers
|
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
@ -219,12 +217,10 @@ class EcmDirectory // extends CommonObject
|
|||||||
|
|
||||||
if (! $error && ! $notrigger)
|
if (! $error && ! $notrigger)
|
||||||
{
|
{
|
||||||
// Appel des triggers
|
// Call trigger
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
$result=$this->call_trigger('MYECMDIR_MODIFY',$user);
|
||||||
$interface=new Interfaces($this->db);
|
if ($result < 0) { $error++; }
|
||||||
$result=$interface->run_triggers('MYECMDIR_MODIFY',$this,$user,$langs,$conf);
|
// End call triggers
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
|
||||||
// Fin appel triggers
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
@ -352,6 +348,17 @@ class EcmDirectory // extends CommonObject
|
|||||||
$this->error="Error ".$this->db->lasterror();
|
$this->error="Error ".$this->db->lasterror();
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Call trigger
|
||||||
|
$result=$this->call_trigger('MYECMDIR_DELETE',$user);
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
// End call triggers
|
||||||
|
}
|
||||||
|
|
||||||
if ($mode != 'databaseonly')
|
if ($mode != 'databaseonly')
|
||||||
{
|
{
|
||||||
@ -371,16 +378,6 @@ class EcmDirectory // extends CommonObject
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
|
||||||
{
|
|
||||||
// Appel des triggers
|
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
|
||||||
$interface=new Interfaces($this->db);
|
|
||||||
$result=$interface->run_triggers('MYECMDIR_DELETE',$this,$user,$langs,$conf);
|
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
|
||||||
// Fin appel triggers
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error) return 1;
|
if (! $error) return 1;
|
||||||
else return -1;
|
else return -1;
|
||||||
}
|
}
|
||||||
@ -697,4 +694,37 @@ class EcmDirectory // extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call trigger based on this instance
|
||||||
|
*
|
||||||
|
* NB: Error from trigger are stacked in errors
|
||||||
|
* NB2: if trigger fail, action should be canceled.
|
||||||
|
* NB3: Should be deleted if EcmDirectory extend CommonObject
|
||||||
|
*
|
||||||
|
* @param string $trigger_name trigger's name to execute
|
||||||
|
* @param User $user Object user
|
||||||
|
* @return int Result of run_triggers
|
||||||
|
*/
|
||||||
|
function call_trigger($trigger_name, $user)
|
||||||
|
{
|
||||||
|
global $langs,$conf;
|
||||||
|
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers($trigger_name,$this,$user,$langs,$conf);
|
||||||
|
if ($result < 0) {
|
||||||
|
if (!empty($this->errors))
|
||||||
|
{
|
||||||
|
$this->errors=array_merge($this->errors,$interface->errors);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->errors=$interface->errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user