diff --git a/htdocs/core/class/menu.class.php b/htdocs/core/class/menu.class.php index 60bf6474031..06bc79804bf 100644 --- a/htdocs/core/class/menu.class.php +++ b/htdocs/core/class/menu.class.php @@ -120,7 +120,8 @@ class Menu $nb = 0; foreach ($this->liste as $val) { - if (!empty($val['enabled'])) $nb++; + //if (dol_eval($val['enabled'], 1)) $nb++; + if (!empty($val['enabled'])) $nb++; // $val['enabled'] is already evaluated to 0 or 1, no need for dol_eval() } return $nb; } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 0a15a1b5029..52a28b6d232 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -447,6 +447,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // Show personalized menus $menuArbo = new Menubase($db, 'eldy'); + $newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'eldy', $tabMenu); // Return tabMenu with only top entries $num = count($newTabMenu); @@ -455,34 +456,39 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = //var_dump($type_user.' '.$newTabMenu[$i]['url'].' '.$showmode.' '.$newTabMenu[$i]['perms']); $idsel = (empty($newTabMenu[$i]['mainmenu']) ? 'none' : $newTabMenu[$i]['mainmenu']); + $newTabMenu[$i]['url'] = make_substitutions($newTabMenu[$i]['url'], $substitarray); + + // url = url from host, shorturl = relative path into dolibarr sources + $url = $shorturl = $newTabMenu[$i]['url']; + if (!preg_match("/^(http:\/\/|https:\/\/)/i", $newTabMenu[$i]['url'])) // Do not change url content for external links + { + $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:''); + $shorturl = $url; + if (DOL_URL_ROOT) $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT, '/').'/', '', $shorturl); + } + $showmode = isVisibleToUserType($type_user, $newTabMenu[$i], $listofmodulesforexternal); if ($showmode == 1) { - $newTabMenu[$i]['url'] = make_substitutions($newTabMenu[$i]['url'], $substitarray); - - // url = url from host, shorturl = relative path into dolibarr sources - $url = $shorturl = $newTabMenu[$i]['url']; - if (!preg_match("/^(http:\/\/|https:\/\/)/i", $newTabMenu[$i]['url'])) // Do not change url content for external links - { - $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:''); - $shorturl = $url; - if (DOL_URL_ROOT) $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT, '/').'/', '', $shorturl); - } - // Define the class (top menu selected or not) if (!empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) $classname = 'class="tmenusel"'; elseif (!empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) $classname = 'class="tmenusel"'; else $classname = 'class="tmenu"'; - } elseif ($showmode == 2) $classname = 'class="tmenu"'; + } elseif ($showmode == 2) { + $classname = 'class="tmenu"'; + } - $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target'] ? $newTabMenu[$i]['target'] : $atarget), ($newTabMenu[$i]['mainmenu'] ? $newTabMenu[$i]['mainmenu'] : $newTabMenu[$i]['rowid']), ($newTabMenu[$i]['leftmenu'] ? $newTabMenu[$i]['leftmenu'] : ''), $newTabMenu[$i]['position'], $id, $idsel, $classname); + $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target'] ? $newTabMenu[$i]['target'] : $atarget), + ($newTabMenu[$i]['mainmenu'] ? $newTabMenu[$i]['mainmenu'] : $newTabMenu[$i]['rowid']), + ($newTabMenu[$i]['leftmenu'] ? $newTabMenu[$i]['leftmenu'] : ''), + $newTabMenu[$i]['position'], $id, $idsel, $classname); } // Sort on position @@ -517,7 +523,6 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = print "\n".''."\n"; print_start_menu_entry('companylogo', 'class="tmenu tmenucompanylogo nohover"', 1); - print ''."\n"; print_end_menu_entry(4); diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index 4006a24491d..c3e6a0bce05 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -147,7 +147,6 @@ class MenuManager if ($mode == 'top') print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $this->menu, 0); if ($mode == 'left') print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 0, $mode); } - if ($mode == 'topnb') { print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode); // no output diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index b9f630872ae..59aaf0ecc2c 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -31,8 +31,8 @@ if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled because need to do translations if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); -if (!defined('NOLOGIN')) define('NOLOGIN', 1); // File must be accessed by logon page so without login -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); // We need top menu content +if (!defined('NOLOGIN')) define('NOLOGIN', 1); // File must be accessed by logon page so without login. +//if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); // We load menu manager class (note that object loaded may have wrong content because NOLOGIN is set and some values depends on login) if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); @@ -55,6 +55,10 @@ if (empty($user->id) && !empty($_SESSION['dol_login'])) { $user->fetch('', $_SESSION['dol_login'], '', 1); $user->getrights(); + + // Reload menu now we have the good user (and we need the good menu to have ->showmenu('topnb') correct. + $menumanager = new MenuManager($db, empty($user->socid) ? 0 : 1); + $menumanager->loadMenu(); } @@ -190,6 +194,7 @@ $colortext = join(',', colorStringToArray($colortext)); $colortextlink = join(',', colorStringToArray($colortextlink)); $nbtopmenuentries = $menumanager->showmenu('topnb'); + if ($conf->browser->layout == 'phone') $nbtopmenuentries = max($nbtopmenuentries, 10); diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index d468eccf87d..dcfbc402927 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -56,6 +56,10 @@ if (empty($user->id) && !empty($_SESSION['dol_login'])) { $user->fetch('', $_SESSION['dol_login'], '', 1); $user->getrights(); + + // Reload menu now we have the good user (and we need the good menu to have ->showmenu('topnb') correct. + $menumanager = new MenuManager($db, empty($user->socid) ? 0 : 1); + $menumanager->loadMenu(); }