/** * Core function to output top menu auguria * * @param DoliDB $db Database handler * @param string $atarget Target * @param int $type_user 0=Menu for backoffice, 1=Menu for front office * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) * @param array $menu Object Menu to return back list of menu entries * @param int $noout Disable output (Initialise &$menu only). * @return int 0 */ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 0) { global $user, $conf, $langs, $dolibarr_main_db_name; $mainmenu = $_SESSION["mainmenu"]; $leftmenu = $_SESSION["leftmenu"]; $id = 'mainmenu'; $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); // Show personalized menus $menuArbo = new Menubase($db, 'auguria'); $newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'auguria', $tabMenu); if (empty($noout)) { print_start_menu_array_auguria(); } $num = count($newTabMenu); for ($i = 0; $i < $num; $i++) { $idsel = empty($newTabMenu[$i]['mainmenu']) ? 'none' : $newTabMenu[$i]['mainmenu']; $showmode = dol_auguria_showmenu($type_user, $newTabMenu[$i], $listofmodulesforexternal); if ($showmode == 1) { $url = $shorturl = $newTabMenu[$i]['url']; if (!preg_match("/^(http:\\/\\/|https:\\/\\/)/i", $newTabMenu[$i]['url'])) { $tmp = explode('?', $newTabMenu[$i]['url'], 2); $url = $shorturl = $tmp[0]; $param = isset($tmp[1]) ? $tmp[1] : ''; if (!preg_match('/mainmenu/i', $param) || !preg_match('/leftmenu/i', $param)) { $param .= ($param ? '&' : '') . 'mainmenu=' . $newTabMenu[$i]['mainmenu'] . '&leftmenu='; } //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad $url = dol_buildpath($url, 1) . ($param ? '?' . $param : ''); $shorturl = $shorturl . ($param ? '?' . $param : ''); } $url = preg_replace('/__LOGIN__/', $user->login, $url); $shorturl = preg_replace('/__LOGIN__/', $user->login, $shorturl); $url = preg_replace('/__USERID__/', $user->id, $url); $shorturl = preg_replace('/__USERID__/', $user->id, $shorturl); // Define the class (top menu selected or not) if (!empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) { $classname = 'class="tmenusel"'; } else { if (!empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) { $classname = 'class="tmenusel"'; } else { $classname = 'class="tmenu"'; } } } else { if ($showmode == 2) { $classname = 'class="tmenu"'; } } if (empty($noout)) { print_start_menu_entry_auguria($idsel, $classname, $showmode); } if (empty($noout)) { print_text_menu_entry_auguria($newTabMenu[$i]['titre'], $showmode, $url, $id, $idsel, $classname, $newTabMenu[$i]['target'] ? $newTabMenu[$i]['target'] : $atarget); } if (empty($noout)) { print_end_menu_entry_auguria($showmode); } $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, $newTabMenu[$i]['target'] ? $newTabMenu[$i]['target'] : $atarget, $newTabMenu[$i]['mainmenu'] ? $newTabMenu[$i]['mainmenu'] : $newTabMenu[$i]['rowid'], ''); } $showmode = 1; if (empty($noout)) { print_start_menu_entry_auguria('', 'class="tmenuend"', $showmode); } if (empty($noout)) { print_end_menu_entry_auguria($showmode); } if (empty($noout)) { print_end_menu_array_auguria(); } print "\n"; return 0; }
/** * Core function to output top menu auguria * * @param $db * @param $atarget * @param $type_user 0=Internal,1=External,2=All */ function print_auguria_menu($db,$atarget,$type_user) { require_once(DOL_DOCUMENT_ROOT."/core/class/menubase.class.php"); global $user,$conf,$langs,$dolibarr_main_db_name; // On sauve en session le menu principal choisi if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; $_SESSION["leftmenuopened"]=""; $menuArbo = new Menubase($db,'auguria','top'); $newTabMenu = $menuArbo->menuTopCharger($_SESSION['mainmenu'], '', $type_user, 'auguria'); print_start_menu_array_auguria(); for($i=0; $i<count($newTabMenu); $i++) { if ($newTabMenu[$i]['enabled'] == true) { $idsel=(empty($newTabMenu[$i]['mainmenu'])?'none':$newTabMenu[$i]['mainmenu']); if ($newTabMenu[$i]['right'] == true) // Is allowed { // Define url if (preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url'])) { $url = $newTabMenu[$i]['url']; } else { $url=dol_buildpath($newTabMenu[$i]['url'],1); if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url)) { if (! preg_match('/\?/',$url)) $url.='?'; else $url.='&'; $url.='mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu='; } //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad } $url=preg_replace('/__LOGIN__/',$user->login,$url); // Define the class (top menu selected or not) if (! empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) $classname='class="tmenusel"'; else if (! empty($_SESSION['mainmenu']) && $newTabMenu[$i]['mainmenu'] == $_SESSION['mainmenu']) $classname='class="tmenusel"'; else $classname='class="tmenu"'; print_start_menu_entry_auguria($idsel); print '<div class="mainmenu '.$idsel.'"><span class="mainmenu_'.$idsel.'" id="mainmenuspan_'.$idsel.'"></span></div>'; print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($newTabMenu[$i]['atarget']?' target="'.$newTabMenu[$i]['atarget'].'"':($atarget?' target="'.$atarget.'"':'')).'>'; print_text_menu_entry_auguria($newTabMenu[$i]['titre']); print '</a>'; print_end_menu_entry_auguria(); } else if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) { if (! $type_user) { print_start_menu_entry_auguria($idsel); print '<div class="mainmenu '.$idsel.'"><span class="mainmenu_'.$idsel.'" id="mainmenuspan_'.$idsel.'"></span></div>'; print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'; print_text_menu_entry_auguria($newTabMenu[$i]['titre']); print '</a>'; print_end_menu_entry_auguria(); } } } } print_end_menu_array_auguria(); print "\n"; }