diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 5e24ee03fa4..4750e0924dd 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -193,6 +193,7 @@ class HookManager 'getFormatedSupplierRef', 'getIdProfUrl', 'getInputIdProf', + 'menu_LeftMenuItems', 'moveUploadedFile', 'moreHtmlStatus', 'pdf_build_address', diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index c192d5e6ac6..a54d5a7a358 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -688,9 +688,9 @@ function print_end_menu_array() * @param int $type_user 0=Menu for backoffice, 1=Menu for front office * @return int Nb of menu entries */ -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; +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, $hookmanager; //var_dump($tabMenu); @@ -1958,6 +1958,28 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM 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('menu_LeftMenuArray', $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 //var_dump($menu_array); /*$new_menu_array = array();