Merge pull request #18297 from cfoellmann/hook-menu
NEW add hook 'menuLeftMenuItems' to filter the leftmenu items
This commit is contained in:
commit
0c024ca96b
@ -193,6 +193,7 @@ class HookManager
|
|||||||
'getFormatedSupplierRef',
|
'getFormatedSupplierRef',
|
||||||
'getIdProfUrl',
|
'getIdProfUrl',
|
||||||
'getInputIdProf',
|
'getInputIdProf',
|
||||||
|
'menuLeftMenuItems',
|
||||||
'moveUploadedFile',
|
'moveUploadedFile',
|
||||||
'moreHtmlStatus',
|
'moreHtmlStatus',
|
||||||
'pdf_build_address',
|
'pdf_build_address',
|
||||||
|
|||||||
@ -690,7 +690,8 @@ function print_end_menu_array()
|
|||||||
*/
|
*/
|
||||||
function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null, $type_user = 0)
|
function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null, $type_user = 0)
|
||||||
{
|
{
|
||||||
global $user, $conf, $langs, $dolibarr_main_db_name, $mysoc;
|
|
||||||
|
global $user, $conf, $langs, $dolibarr_main_db_name, $mysoc, $hookmanager;
|
||||||
|
|
||||||
//var_dump($tabMenu);
|
//var_dump($tabMenu);
|
||||||
|
|
||||||
@ -1958,6 +1959,28 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allow the $menu_array of the menu to be manipulated by modules
|
||||||
|
$parameters = array(
|
||||||
|
'mainmenu' => $mainmenu,
|
||||||
|
);
|
||||||
|
$hook_items = $menu_array;
|
||||||
|
$reshook = $hookmanager->executeHooks('menuLeftMenuItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
|
if (is_numeric($reshook)) {
|
||||||
|
if ($reshook == 0 && !empty($hookmanager->results)) {
|
||||||
|
$menu_array[] = $hookmanager->results; // add
|
||||||
|
} elseif ($reshook == 1) {
|
||||||
|
$menu_array = $hookmanager->results; // replace
|
||||||
|
}
|
||||||
|
|
||||||
|
// @todo Sort menu items by 'position' value
|
||||||
|
// $position = array();
|
||||||
|
// foreach ($menu_array as $key => $row) {
|
||||||
|
// $position[$key] = $row['position'];
|
||||||
|
// }
|
||||||
|
// array_multisort($position, SORT_ASC, $menu_array);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO Use the position property in menu_array to reorder the $menu_array
|
// TODO Use the position property in menu_array to reorder the $menu_array
|
||||||
//var_dump($menu_array);
|
//var_dump($menu_array);
|
||||||
/*$new_menu_array = array();
|
/*$new_menu_array = array();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user