Fix: Hook is a replaceadd hook.
This commit is contained in:
parent
393cecb1c2
commit
a22d39adfb
@ -131,7 +131,7 @@ class HookManager
|
|||||||
// Define type of hook ('output', 'returnvalue' or 'addreplace')
|
// Define type of hook ('output', 'returnvalue' or 'addreplace')
|
||||||
$hooktype='output';
|
$hooktype='output';
|
||||||
if (preg_match('/^pdf_/',$method)) $hooktype='returnvalue'; // pdf_xxx except pdf_writelinedesc are returnvalue hooks. When there is 2 hooks of this type, only last one win.
|
if (preg_match('/^pdf_/',$method)) $hooktype='returnvalue'; // pdf_xxx except pdf_writelinedesc are returnvalue hooks. When there is 2 hooks of this type, only last one win.
|
||||||
if ($method == 'doActions' || $method == 'formObjectOptions' || $method == 'pdf_writelinedesc') $hooktype='addreplace';
|
if (in_array($method,array('doActions','formObjectOptions','pdf_writelinedesc','paymentsupplierinvoices'))) $hooktype='addreplace';
|
||||||
|
|
||||||
// Loop on each hook to qualify modules that declared context
|
// Loop on each hook to qualify modules that declared context
|
||||||
$modulealreadyexecuted=array();
|
$modulealreadyexecuted=array();
|
||||||
@ -150,7 +150,7 @@ class HookManager
|
|||||||
// test to avoid to run twice a hook, when a module implements several active contexts
|
// test to avoid to run twice a hook, when a module implements several active contexts
|
||||||
if (in_array($module,$modulealreadyexecuted)) continue;
|
if (in_array($module,$modulealreadyexecuted)) continue;
|
||||||
$modulealreadyexecuted[$module]=$module;
|
$modulealreadyexecuted[$module]=$module;
|
||||||
// Hooks that return int
|
// Hooks that return int (doActions, formObjectOptions, pdf_writelinedesc, paymentsupplierinvoices)
|
||||||
if ($hooktype == 'addreplace')
|
if ($hooktype == 'addreplace')
|
||||||
{
|
{
|
||||||
$resaction += $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
|
$resaction += $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
|
||||||
@ -159,7 +159,7 @@ class HookManager
|
|||||||
$error++;
|
$error++;
|
||||||
$this->error=$actionclassinstance->error; $this->errors=array_merge($this->errors, (array) $actionclassinstance->errors);
|
$this->error=$actionclassinstance->error; $this->errors=array_merge($this->errors, (array) $actionclassinstance->errors);
|
||||||
|
|
||||||
// TODO remove this. Change must be inside the method if required
|
// TODO remove this. Change must be inside the method of hook if required
|
||||||
if ($method == 'doActions')
|
if ($method == 'doActions')
|
||||||
{
|
{
|
||||||
if ($action=='add') $action='create';
|
if ($action=='add') $action='create';
|
||||||
@ -170,7 +170,7 @@ class HookManager
|
|||||||
// Generic hooks that return a string (printSearchForm, printLeftBlock, printTopRightMenu, formAddObjectLine, formBuilddocOptions, ...)
|
// Generic hooks that return a string (printSearchForm, printLeftBlock, printTopRightMenu, formAddObjectLine, formBuilddocOptions, ...)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO. this should be done into the method by returning nothing
|
// TODO. this should be done into the method of hook by returning nothing
|
||||||
if (is_array($parameters) && ! empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) continue;
|
if (is_array($parameters) && ! empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) continue;
|
||||||
|
|
||||||
$result = $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
|
$result = $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user