2
0
forked from Wavyzz/dolibarr

CLOSE #4368 #4369 Add hook completeTabsHead for rewrite heads tabs menu

This commit is contained in:
Laurent Destailleur
2016-11-12 14:36:52 +01:00
parent f0eceefe48
commit 4bcc7dc8a0
2 changed files with 25 additions and 6 deletions

View File

@@ -165,6 +165,7 @@ class HookManager
'paymentsupplierinvoices',
'printAddress',
'printSearchForm',
'printTabsHead',
'formatEvent',
'addCalendarChoice',
'printObjectLine',

View File

@@ -897,8 +897,12 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi
if (! $notab) $out.="\n".'<div class="tabBar">'."\n";
$parameters=array('tabname' => $active);
$reshook=$hookmanager->executeHooks('printTabsHead',$parameters); // Note that $action and $object may have been modified by some hooks
$parameters=array('tabname' => $active, 'out' => $out);
$reshook=$hookmanager->executeHooks('printTabsHead',$parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead"
if ($reshook > 0)
{
$out = $hookmanager->resPrint;
}
return $out;
}
@@ -5335,8 +5339,9 @@ function picto_from_langcode($codelang)
}
/**
* Complete or removed entries into a head array (used to build tabs) with value added by external modules.
* Such values are declared into $conf->modules_parts['tab'].
* Complete or removed entries into a head array (used to build tabs).
* For example, with value added by external modules. Such values are declared into $conf->modules_parts['tab'].
* Or by change using hook completeTabsHead
*
* @param Conf $conf Object conf
* @param Translate $langs Object langs
@@ -5363,6 +5368,8 @@ function picto_from_langcode($codelang)
*/
function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode='add')
{
global $hookmanager;
if (isset($conf->modules_parts['tabs'][$type]) && is_array($conf->modules_parts['tabs'][$type]))
{
foreach ($conf->modules_parts['tabs'][$type] as $value)
@@ -5428,6 +5435,17 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode=
}
}
}
// No need to make a return $head. Var is modified as a reference
if (! empty($hookmanaer))
{
$parameters=array('object' => $object, 'mode' => $mode, 'head'=>$head);
$reshook=$hookmanager->executeHooks('completeTabsHead',$parameters);
if ($reshook > 0)
{
$head = $hookmanager->resArray;
}
}
}
/**