diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index eaac3eabf07..5036e84c34f 100755 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -37,7 +37,7 @@ class HookManager // Array with instantiated classes var $hooks=array(); - + // Array result var $resArray=array(); @@ -75,7 +75,7 @@ class HookManager // For backward compatibility if (! is_array($arraycontext)) $arraycontext=array($arraycontext); - $this->contextarray=array_merge($arraycontext,$this->contextarray); // All contexts are concatenated + $this->contextarray=array_unique(array_merge($arraycontext,$this->contextarray)); // All contexts are concatenated foreach($conf->hooks_modules as $module => $hooks) { @@ -108,7 +108,7 @@ class HookManager } /** - * Execute hooks (if the were initialized) for the given method + * Execute hooks (if they were initialized) for the given method * * @param string $method Name of method hooked ('doActions', 'printSearchForm', 'showInputField', ...) * @param array $parameters Array of parameters @@ -127,23 +127,28 @@ class HookManager $parameters['context']=join(':',$this->contextarray); dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']); - // Loop on each hook + // Loop on each hook to qualify modules that declared context + $modulealreadyexecuted=array(); $resaction=0; $resprint=''; - foreach($this->hooks as $modules) + 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 { if (! empty($modules)) { - foreach($modules as $actioninstance) + foreach($modules as $module => $actionclassinstance) { + // test to avoid to run twice a hook, when a module implements several active contexts + if (in_array($module,$modulealreadyexecuted)) continue; + $modulealreadyexecuted[$module]=$module; + $var=!$var; // Hooks that return int - if (($method == 'doActions' || $method == 'formObjectOptions') && method_exists($actioninstance,$method)) + if (($method == 'doActions' || $method == 'formObjectOptions') && method_exists($actionclassinstance,$method)) { - $resaction+=$actioninstance->$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) - if ($resaction < 0 || ! empty($actioninstance->error) || (! empty($actioninstance->errors) && count($actioninstance->errors) > 0)) + $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) + if ($resaction < 0 || ! empty($actionclassinstance->error) || (! empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0)) { - $this->error=$actioninstance->error; $this->errors=$actioninstance->errors; + $this->error=$actionclassinstance->error; $this->errors=$actionclassinstance->errors; if ($method == 'doActions') { if ($action=='add') $action='create'; // TODO this change must be inside the doActions @@ -152,10 +157,10 @@ class HookManager } } // Generic hooks that return a string (printSearchForm, printLeftBlock, formBuilddocOptions, ...) - else if (method_exists($actioninstance,$method)) + else if (method_exists($actionclassinstance,$method)) { - if (is_array($parameters) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actioninstance->module_number) continue; - $result = $actioninstance->$method($parameters, $object, $action, $this); + if (is_array($parameters) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) continue; + $result = $actionclassinstance->$method($parameters, $object, $action, $this); if (is_array($result)) $this->resArray = array_merge($this->resArray, $result); else $resprint.=$result; } diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 01a40150a05..95c93afc309 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -211,7 +211,7 @@ class FormCompany { global $conf,$langs,$user; - dol_syslog("FormCompany::select_departement selected=$selected, country_codeid=$country_codeid",LOG_DEBUG); + dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid,LOG_DEBUG); $langs->load("dict"); @@ -226,7 +226,7 @@ class FormCompany if ($country_codeid && ! is_numeric($country_codeid)) $sql .= " AND p.code = '".$country_codeid."'"; $sql .= " ORDER BY p.code, d.code_departement"; - dol_syslog("FormCompany::select_departement sql=".$sql); + dol_syslog(get_class($this)."::select_departement sql=".$sql); $result=$this->db->query($sql); if ($result) { diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 9aa346d7bad..a9b3a81142b 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -215,8 +215,8 @@ CustomerRelativeDiscountShort=Relative discount CustomerAbsoluteDiscountShort=Absolute discount CompanyHasRelativeDiscount=This customer has a default discount of %s%% CompanyHasNoRelativeDiscount=This customer has no relative discount by default -CompanyHasAbsoluteDiscount=This customer still has discount credits or deposits for %s %s -CompanyHasCreditNote=This customer still has credit notes for %s %s +CompanyHasAbsoluteDiscount=This customer still has discount credits or deposits for %s %s +CompanyHasCreditNote=This customer still has credit notes for %s %s CompanyHasNoAbsoluteDiscount=This customer has no discount credit available CustomerAbsoluteDiscountAllUsers=Absolute discounts (granted by all users) CustomerAbsoluteDiscountMy=Absolute discounts (granted by yourself) diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 4be4314a0b1..72f1e63930e 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -217,8 +217,8 @@ CustomerRelativeDiscountShort=Remise relative CustomerAbsoluteDiscountShort=Remise fixe CompanyHasRelativeDiscount=Ce client a une remise par défaut de %s%% CompanyHasNoRelativeDiscount=Ce client n'a pas de remise relative par défaut -CompanyHasAbsoluteDiscount=Ce client a %s %s de lignes de déduction disponibles (remises, acomptes...) -CompanyHasCreditNote=Ce client a %s %s d'avoirs disponibles +CompanyHasAbsoluteDiscount=Ce client a %s %s de lignes de déduction disponibles (remises, acomptes...) +CompanyHasCreditNote=Ce client a %s %s d'avoirs disponibles CompanyHasNoAbsoluteDiscount=Ce client n'a pas ou plus de remise fixe disponible CustomerAbsoluteDiscountAllUsers=Remises fixes en cours (accordées par tout utilisateur) CustomerAbsoluteDiscountMy=Remises fixes en cours (accordées personnellement) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 3e61a9dd074..0bfda0b15eb 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1310,7 +1310,7 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); $hookmanager=new HookManager($db); } - $hookmanager->initHooks(array('searchform','leftblock','toprightmenu')); + $hookmanager->initHooks(array('searchform','leftblock')); if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print "\n".'
'."\n"; else print ''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index d3b13369f2c..8527fa3ba13 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -702,7 +702,7 @@ class Societe extends CommonObject $this->state_id = $obj->fk_departement; $this->state_code = $obj->state_code; - $this->state = $obj->state; + $this->state = ($obj->state!='-'?$obj->state:''); $transcode=$langs->trans('StatusProspect'.$obj->fk_stcomm); $libelle=($transcode!='StatusProspect'.$obj->fk_stcomm?$transcode:$obj->stcomm); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index fe588f9d7af..1ec26a874d7 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -791,7 +791,7 @@ else if (empty($conf->global->SOCIETE_DISABLE_STATE)) { print ''.$langs->trans('State').''; - if ($object->country_id) $formcompany->select_departement($object->state_id,$object->country_code,'departement_id'); + if ($object->country_id) print $formcompany->select_state($object->state_id,$object->country_code,'departement_id'); else print $countrynotdefined; print ''; } @@ -1246,7 +1246,7 @@ else if (empty($conf->global->SOCIETE_DISABLE_STATE)) { print ''.$langs->trans('State').''; - $formcompany->select_departement($object->state_id,$object->country_code); + print $formcompany->select_state($object->state_id,$object->country_code); print ''; } @@ -1918,7 +1918,7 @@ else { $result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); } - + // Addresses list if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) {