From c5a7dfbabb36c3af7bda87de84ab6c738b860a09 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 29 Sep 2014 14:40:02 +0200 Subject: [PATCH] Fix: Add current context for avoid method execution in bad context, you can add this test in your method : eg if($currentcontext != 'formfile') return; --- htdocs/core/class/hookmanager.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 9d8ce90e812..52dc25dd452 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2010-2014 Regis Houssin * Copyright (C) 2010-2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -152,7 +152,7 @@ class HookManager $modulealreadyexecuted=array(); $resaction=0; $error=0; $result=''; $this->resPrint=''; $this->resArray=array(); - foreach($this->hooks as $modules) // this->hooks is an array with context as key and value is an array of modules that handle this context + foreach($this->hooks as $context => $modules) // this->hooks is an array with context as key and value is an array of modules that handle this context { if (! empty($modules)) { @@ -166,6 +166,8 @@ class HookManager // test to avoid to run twice a hook, when a module implements several active contexts if (in_array($module,$modulealreadyexecuted)) continue; $modulealreadyexecuted[$module]=$module; + // Add current context for avoid method execution in bad context, you can add this test in your method : eg if($currentcontext != 'formfile') return; + $parameters['currentcontext'] = $context; // Hooks that must return int (hooks with type 'addreplace') if ($hooktype == 'addreplace') {