From c18a8bef1b349d6db558d229b001f07045e27316 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Tue, 29 Jan 2019 19:44:59 +0100 Subject: [PATCH 1/3] Update eldy.lib.php Simplifying horizontal menu writing, it would simplify menu updates in the future. The menu table can be further simplified, it's in a 2nd step if @eldy confirms this restructuring. Already tested and it works. --- htdocs/core/menus/standard/eldy.lib.php | 584 +++++++++++++++--------- 1 file changed, 361 insertions(+), 223 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 1de907face7..ef1ce0c8d85 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -65,246 +65,384 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } - // Home - $showmode=1; - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='home'; - - $titlehome = $langs->trans("Home"); - if (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) $titlehome = '   '; - $menu->add('/index.php?mainmenu=home&leftmenu=home', $titlehome, 0, $showmode, $atarget, "home", '', 10, $id, $idsel, $classname); + // Home + $menu_arr[] = array( + 'name' => 'Home', + 'link' => '/index.php?mainmenu=home&leftmenu=home', + 'title' => (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)? '   ' : "Home") , + 'level' => 0, + 'enabled' => $showmode = 1, + 'target' => $atarget, + 'mainmenu' => "home", + 'leftmenu' => '', + 'position' => 10, + 'id' => $id, + 'idsel' => 'home', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home" ) ? 0 : 1 ), + 'loadLangs' => array(), + 'submenus' => array(), + ); // Members - $tmpentry = array( - 'enabled'=>(! empty($conf->adherent->enabled)), - 'perms'=>(! empty($user->rights->adherent->lire)), - 'module'=>'adherent', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='members'; + $menu_arr[] = array( + 'name' => 'Members', + 'link' => '/adherents/index.php?mainmenu=members&leftmenu=', + 'title' => "MenuMembers", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled' => (! empty($conf->adherent->enabled) ) , + 'perms' => (! empty($user->rights->adherent->lire) ), + 'module' => 'adherent', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "members", + 'leftmenu' => '', + 'position' => 18, + 'id' => $id, + 'idsel' => 'members', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members" ) ? 0 : 1 ), + 'loadLangs' => array(), + 'submenus' => array(), + ); - $menu->add('/adherents/index.php?mainmenu=members&leftmenu=', $langs->trans("MenuMembers"), 0, $showmode, $atarget, "members", '', 18, $id, $idsel, $classname); - } + // Third parties + $menu_arr[] = array( + 'name' => 'Companies', + 'link' => '/societe/index.php?mainmenu=companies&leftmenu=', + 'title' => "ThirdParties", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=> ( ( ! empty($conf->societe->enabled) && + ( empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) ) + ) + || ! empty($conf->fournisseur->enabled) + ), + 'perms'=> (! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), + 'module'=>'societe|fournisseur', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "companies", + 'leftmenu' => '', + 'position' => 20, + 'id' => $id, + 'idsel' => 'companies', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies" ) ? 0 : 1 ), + 'loadLangs' => array("companies","suppliers"), + 'submenus' => array(), + ); - // Third parties - $tmpentry = array( - 'enabled'=>(( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)), - 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), - 'module'=>'societe|fournisseur', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - // Load translation files required by the page - $langs->loadLangs(array("companies","suppliers")); + // Products-Services + $menu_arr[] = array( + 'name' => 'Products', + 'link' => '/product/index.php?mainmenu=products&leftmenu=', + 'title' => (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) + ? ( array("TMenuProducts" , " | " ,"TMenuServices") ) + : (! empty($conf->product->enabled)? "TMenuProducts" : "TMenuServices" ), + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=> ( ( ! empty($conf->societe->enabled) && + ( empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) ) + ) + || ! empty($conf->fournisseur->enabled) + ), + 'perms'=> (! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), + 'module'=>'product|service', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "products", + 'leftmenu' => '', + 'position' => 30, + 'id' => $id, + 'idsel' => 'products', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products" ) ? 0 : 1 ), + 'loadLangs' => array("products"), + 'submenus' => array(), + ); - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='companies'; - - $menu->add('/societe/index.php?mainmenu=companies&leftmenu=', $langs->trans("ThirdParties"), 0, $showmode, $atarget, "companies", '', 20, $id, $idsel, $classname); - } - - // Products-Services - $tmpentry = array( - 'enabled'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)), - 'perms'=>(! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)), - 'module'=>'product|service', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - $langs->load("products"); - - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='products'; - - $chaine=""; - if (! empty($conf->product->enabled)) { - $chaine.=$langs->trans("TMenuProducts"); - } - if (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) { - $chaine.=" | "; - } - if (! empty($conf->service->enabled)) { - $chaine.=$langs->trans("TMenuServices"); - } - - $menu->add('/product/index.php?mainmenu=products&leftmenu=', $chaine, 0, $showmode, $atarget, "products", '', 30, $id, $idsel, $classname); - } - - // Projects - $tmpentry=array('enabled'=>(! empty($conf->projet->enabled)), - 'perms'=>(! empty($user->rights->projet->lire)), - 'module'=>'projet'); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - $langs->load("projects"); - - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='project'; - - $title = $langs->trans("LeadsOrProjects"); // Leads and opportunities by default - $showmodel = $showmodep = $showmode; - if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { - $title = $langs->trans("Projects"); - $showmodel = 0; - } - if ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) { - $title = $langs->trans("Leads"); - $showmodep = 0; - } - - $menu->add('/projet/index.php?mainmenu=project&leftmenu=', $title, 0, $showmode, $atarget, "project", '', 35, $id, $idsel, $classname); - //$menu->add('/projet/index.php?mainmenu=project&leftmenu=&search_opp_status=openedopp', $langs->trans("ListLeads"), 0, $showmodel & $conf->global->PROJECT_USE_OPPORTUNITIES, $atarget, "project", '', 70, $id, $idsel, $classname); - //$menu->add('/projet/index.php?mainmenu=project&leftmenu=&search_opp_status=notopenedopp', $langs->trans("ListProjects"), 0, $showmodep, $atarget, "project", '', 70, $id, $idsel, $classname); - } + // Projects + $menu_arr[] = array( + 'name' => 'Projet', + 'link' => '/projet/index.php?mainmenu=project&leftmenu=', + 'title' => (empty($conf->global->PROJECT_USE_OPPORTUNITIES) || $conf->global->PROJECT_USE_OPPORTUNITIES == 2 ) + ? (($conf->global->PROJECT_USE_OPPORTUNITIES == 2)?"Leads":"Projects") + : "LeadsOrProjects", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=> ( ! empty($conf->projet->enabled) ? 1 : 0), + 'perms'=> (! empty($user->rights->projet->lire) ? 1 : 0), + 'module'=>'projet', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "project", + 'leftmenu' => '', + 'position' => 35, + 'id' => $id, + 'idsel' => 'project', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project" ) ? 0 : 1 ), + 'loadLangs' => array("projects"), + 'submenus' => array(), + ); // Commercial - $menuqualified=0; - if (! empty($conf->propal->enabled)) $menuqualified++; - if (! empty($conf->commande->enabled)) $menuqualified++; - if (! empty($conf->supplier_order->enabled)) $menuqualified++; - if (! empty($conf->supplier_proposal->enabled)) $menuqualified++; - if (! empty($conf->contrat->enabled)) $menuqualified++; - if (! empty($conf->ficheinter->enabled)) $menuqualified++; - $tmpentry = array( - 'enabled'=>$menuqualified, - 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->societe->contact->lire)), - 'module'=>'propal|commande|supplier_order|contrat|ficheinter', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - $langs->load("commercial"); + $menu_arr[] = array( + 'name' => 'Commercial', + 'link' => '/comm/index.php?mainmenu=commercial&leftmenu=', + 'title' => "Commercial", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=>(! empty($conf->propal->enabled) || + ! empty($conf->commande->enabled) || + ! empty($conf->supplier_order->enabled) || + ! empty($conf->supplier_proposal->enabled) || + ! empty($conf->contrat->enabled) || + ! empty($conf->ficheinter->enabled) + )?1:0, + 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->societe->contact->lire)), + 'module'=>'propal|commande|supplier_order|contrat|ficheinter', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "commercial", + 'leftmenu' => '', + 'position' => 40, + 'id' => $id, + 'idsel' => 'commercial', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial" ) ? 0 : 1 ), + 'loadLangs' => array("commercial"), + 'submenus' => array(), + ); - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='commercial'; - - $menu->add('/comm/index.php?mainmenu=commercial&leftmenu=', $langs->trans("Commercial"), 0, $showmode, $atarget, "commercial", "", 40, $id, $idsel, $classname); - } - - // Billing - Financial - $menuqualified=0; - if (! empty($conf->facture->enabled)) $menuqualified++; - if (! empty($conf->don->enabled)) $menuqualified++; - if (! empty($conf->tax->enabled)) $menuqualified++; - if (! empty($conf->salaries->enabled)) $menuqualified++; - if (! empty($conf->supplier_invoice->enabled)) $menuqualified++; - if (! empty($conf->loan->enabled)) $menuqualified++; - $tmpentry = array( - 'enabled'=>$menuqualified, - 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)), - 'module'=>'facture|supplier_invoice|don|tax|salaries|loan', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - $langs->load("compta"); - - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "billing") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='billing'; - - $menu->add('/compta/index.php?mainmenu=billing&leftmenu=', $langs->trans("MenuFinancial"), 0, $showmode, $atarget, "billing", '', 50, $id, $idsel, $classname); - } + // Billing - Financial + $menu_arr[] = array( + 'name' => 'Compta', + 'link' => '/compta/index.php?mainmenu=billing&leftmenu=', + 'title' => "MenuFinancial", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=>(! empty($conf->facture->enabled) || + ! empty($conf->don->enabled) || + ! empty($conf->tax->enabled) || + ! empty($conf->salaries->enabled) || + ! empty($conf->supplier_invoice->enabled) || + ! empty($conf->loan->enabled) + )?1:0, + 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->contact->lire) + || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) + || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)), + 'module'=>'facture|supplier_invoice|don|tax|salaries|loan', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "billing", + 'leftmenu' => '', + 'position' => 50, + 'id' => $id, + 'idsel' => 'billing', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "billing" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "billing" ) ? 0 : 1 ), + 'loadLangs' => array("compta"), + 'submenus' => array(), + ); // Bank - $tmpentry = array( - 'enabled'=>(! empty($conf->banque->enabled) || ! empty($conf->prelevement->enabled)), - 'perms'=>(! empty($user->rights->banque->lire) || ! empty($user->rights->prelevement->lire)), - 'module'=>'banque|prelevement', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - // Load translation files required by the page - $langs->loadLangs(array("compta","banks")); - - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='bank'; - - $menu->add('/compta/bank/list.php?mainmenu=bank&leftmenu=', $langs->trans("MenuBankCash"), 0, $showmode, $atarget, "bank", '', 52, $id, $idsel, $classname); - } + $menu_arr[] = array( + 'name' => 'Bank', + 'link' => '/compta/bank/list.php?mainmenu=bank&leftmenu=', + 'title' => "MenuBankCash", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=>(! empty($conf->banque->enabled) || ! empty($conf->prelevement->enabled)), + 'perms'=>(! empty($user->rights->banque->lire) || ! empty($user->rights->prelevement->lire)), + 'module'=>'banque|prelevement', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "bank", + 'leftmenu' => '', + 'position' => 52, + 'id' => $id, + 'idsel' => 'bank', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank" ) ? 0 : 1 ), + + 'loadLangs' => array("compta","banks"), + 'submenus' => array(), + ); // Accounting - $menuqualified=0; - if (! empty($conf->comptabilite->enabled)) $menuqualified++; - if (! empty($conf->accounting->enabled)) $menuqualified++; - if (! empty($conf->asset->enabled)) $menuqualified++; - $tmpentry = array( - 'enabled'=>$menuqualified, - 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->mouvements->lire) || ! empty($user->rights->asset->read)), - 'module'=>'comptabilite|accounting', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - $langs->load("compta"); - - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='accountancy'; - - $menu->add('/accountancy/index.php?mainmenu=accountancy&leftmenu=', $langs->trans("MenuAccountancy"), 0, $showmode, $atarget, "accountancy", '', 54, $id, $idsel, $classname); - } + $menu_arr[] = array( + 'name' => 'Accounting', + 'link' => '/accountancy/index.php?mainmenu=accountancy&leftmenu=', + 'title' => "MenuAccountancy", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=>(! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled) || ! empty($conf->asset->enabled)), + 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->mouvements->lire) || ! empty($user->rights->asset->read)), + 'comptabilite|accounting', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "accountancy", + 'leftmenu' => '', + 'position' => 54, + 'id' => $id, + 'idsel' => 'accountancy', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy" ) ? 0 : 1 ), + + 'loadLangs' => array("compta"), + 'submenus' => array(), + ); // HRM - $tmpentry = array( - 'enabled'=>(! empty($conf->hrm->enabled) || ! empty($conf->holiday->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)), - 'perms'=>(! empty($user->rights->hrm->employee->read) || ! empty($user->rights->holiday->write) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->expensereport->lire)), - 'module'=>'hrm|holiday|deplacement|expensereport', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - $langs->load("holiday"); - - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='hrm'; - - $menu->add('/hrm/index.php?mainmenu=hrm&leftmenu=', $langs->trans("HRM"), 0, $showmode, $atarget, "hrm", '', 80, $id, $idsel, $classname); - } + $menu_arr[] = array( + 'name' => 'HRM', + 'link' => '/hrm/index.php?mainmenu=hrm&leftmenu=', + 'title' => "HRM", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=>(! empty($conf->hrm->enabled) || ! empty($conf->holiday->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)), + 'perms'=>(! empty($user->rights->hrm->employee->read) || ! empty($user->rights->holiday->write) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->expensereport->lire)), + 'module'=>'hrm|holiday|deplacement|expensereport', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "hrm", + 'leftmenu' => '', + 'position' => 80, + 'id' => $id, + 'idsel' => 'hrm', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm" ) ? 0 : 1 ), + + 'loadLangs' => array("holiday"), + 'submenus' => array(), + ); // Tools - $tmpentry = array( - 'enabled'=>1, - 'perms'=>1, - 'module'=>'', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) + $menu_arr[] = array( + 'name' => 'Tools', + 'link' => '/core/tools.php?mainmenu=tools&leftmenu=', + 'title' => "Tools", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=>1, + 'perms'=>1, + 'module'=>'', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "tools", + 'leftmenu' => '', + 'position' => 90, + 'id' => $id, + 'idsel' => 'tools', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools" ) ? 0 : 1 ), + + 'loadLangs' => array("other"), + 'submenus' => array(), + ); + + // Add menus + foreach($menu_arr as $key => $smenu) { - $langs->load("other"); - - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='tools'; - - $menu->add('/core/tools.php?mainmenu=tools&leftmenu=', $langs->trans("Tools"), 0, $showmode, $atarget, "tools", '', 90, $id, $idsel, $classname); + $smenu = (object) $smenu; + + if( $smenu->enabled ) + { + if($langs->session) + { + $_SESSION['idmenu']=''; + } + + // Load Langue + if(! empty($smenu->loadLangs)) + { + $langs->loadLangs($smenu->loadLangs); + } + + // Trans title + $mtitle = ''; + if(is_array($smenu->title)) + { + foreach($smenu->title as $item) + { + $mtitle .= $langs->trans($item); + } + } + else + { + $mtitle = $langs->trans($smenu->title); + } + // Add item + $menu->add($smenu->link, $mtitle , $smenu->level, $smenu->enabled, $smenu->target, $smenu->mainmenu, $smenu->leftmenu, $smenu->position, $smenu->id, $smenu->idsel, $smenu->classname, $smenu->prefix); + } } // Show personalized menus From f3c725f40f0980ae588ce02bbd5afbeece10865e Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Tue, 29 Jan 2019 21:36:52 +0100 Subject: [PATCH 2/3] Update eldy.lib.php fix travis --- htdocs/core/menus/standard/eldy.lib.php | 72 ++++++++++++------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index ef1ce0c8d85..5226fb7d6cc 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -65,7 +65,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } - // Home + // Home $menu_arr[] = array( 'name' => 'Home', 'link' => '/index.php?mainmenu=home&leftmenu=home', @@ -94,7 +94,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( + $tmpentry = array( 'enabled' => (! empty($conf->adherent->enabled) ) , 'perms' => (! empty($user->rights->adherent->lire) ), 'module' => 'adherent', @@ -108,13 +108,13 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'id' => $id, 'idsel' => 'members', 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members" ) ? 'class="tmenusel"' : 'class="tmenu"', - 'prefix' => '', + 'prefix' => '', 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members" ) ? 0 : 1 ), 'loadLangs' => array(), 'submenus' => array(), ); - // Third parties + // Third parties $menu_arr[] = array( 'name' => 'Companies', 'link' => '/societe/index.php?mainmenu=companies&leftmenu=', @@ -123,10 +123,10 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( - 'enabled'=> ( ( ! empty($conf->societe->enabled) && + $tmpentry = array( + 'enabled'=> ( ( ! empty($conf->societe->enabled) && ( empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) ) - ) + ) || ! empty($conf->fournisseur->enabled) ), 'perms'=> (! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), @@ -147,21 +147,21 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'submenus' => array(), ); - // Products-Services + // Products-Services $menu_arr[] = array( 'name' => 'Products', 'link' => '/product/index.php?mainmenu=products&leftmenu=', - 'title' => (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) + 'title' => (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) ? ( array("TMenuProducts" , " | " ,"TMenuServices") ) : (! empty($conf->product->enabled)? "TMenuProducts" : "TMenuServices" ), 'level' => 0, 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( - 'enabled'=> ( ( ! empty($conf->societe->enabled) && + $tmpentry = array( + 'enabled'=> ( ( ! empty($conf->societe->enabled) && ( empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) ) - ) + ) || ! empty($conf->fournisseur->enabled) ), 'perms'=> (! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), @@ -182,18 +182,18 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'submenus' => array(), ); - // Projects + // Projects $menu_arr[] = array( 'name' => 'Projet', 'link' => '/projet/index.php?mainmenu=project&leftmenu=', - 'title' => (empty($conf->global->PROJECT_USE_OPPORTUNITIES) || $conf->global->PROJECT_USE_OPPORTUNITIES == 2 ) + 'title' => (empty($conf->global->PROJECT_USE_OPPORTUNITIES) || $conf->global->PROJECT_USE_OPPORTUNITIES == 2 ) ? (($conf->global->PROJECT_USE_OPPORTUNITIES == 2)?"Leads":"Projects") : "LeadsOrProjects", 'level' => 0, 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( + $tmpentry = array( 'enabled'=> ( ! empty($conf->projet->enabled) ? 1 : 0), 'perms'=> (! empty($user->rights->projet->lire) ? 1 : 0), 'module'=>'projet', @@ -222,13 +222,13 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( - 'enabled'=>(! empty($conf->propal->enabled) || - ! empty($conf->commande->enabled) || - ! empty($conf->supplier_order->enabled) || - ! empty($conf->supplier_proposal->enabled) || - ! empty($conf->contrat->enabled) || - ! empty($conf->ficheinter->enabled) + $tmpentry = array( + 'enabled'=>(! empty($conf->propal->enabled) || + ! empty($conf->commande->enabled) || + ! empty($conf->supplier_order->enabled) || + ! empty($conf->supplier_proposal->enabled) || + ! empty($conf->contrat->enabled) || + ! empty($conf->ficheinter->enabled) )?1:0, 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->societe->contact->lire)), 'module'=>'propal|commande|supplier_order|contrat|ficheinter', @@ -248,7 +248,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'submenus' => array(), ); - // Billing - Financial + // Billing - Financial $menu_arr[] = array( 'name' => 'Compta', 'link' => '/compta/index.php?mainmenu=billing&leftmenu=', @@ -257,16 +257,16 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( - 'enabled'=>(! empty($conf->facture->enabled) || - ! empty($conf->don->enabled) || - ! empty($conf->tax->enabled) || - ! empty($conf->salaries->enabled) || - ! empty($conf->supplier_invoice->enabled) || - ! empty($conf->loan->enabled) + $tmpentry = array( + 'enabled'=>(! empty($conf->facture->enabled) || + ! empty($conf->don->enabled) || + ! empty($conf->tax->enabled) || + ! empty($conf->salaries->enabled) || + ! empty($conf->supplier_invoice->enabled) || + ! empty($conf->loan->enabled) )?1:0, - 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->contact->lire) - || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) + 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->contact->lire) + || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)), 'module'=>'facture|supplier_invoice|don|tax|salaries|loan', ), @@ -294,7 +294,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( + $tmpentry = array( 'enabled'=>(! empty($conf->banque->enabled) || ! empty($conf->prelevement->enabled)), 'perms'=>(! empty($user->rights->banque->lire) || ! empty($user->rights->prelevement->lire)), 'module'=>'banque|prelevement', @@ -325,7 +325,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( + $tmpentry = array( 'enabled'=>(! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled) || ! empty($conf->asset->enabled)), 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->mouvements->lire) || ! empty($user->rights->asset->read)), 'comptabilite|accounting', @@ -356,7 +356,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( + $tmpentry = array( 'enabled'=>(! empty($conf->hrm->enabled) || ! empty($conf->holiday->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)), 'perms'=>(! empty($user->rights->hrm->employee->read) || ! empty($user->rights->holiday->write) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->expensereport->lire)), 'module'=>'hrm|holiday|deplacement|expensereport', @@ -387,7 +387,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( + $tmpentry = array( 'enabled'=>1, 'perms'=>1, 'module'=>'', From 84d2bcce4faa6bb07672f8649c08b1c0059d0bce Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Tue, 29 Jan 2019 22:08:18 +0100 Subject: [PATCH 3/3] Update eldy.lib.php Fix Travis --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 5226fb7d6cc..1da90af83e2 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -441,7 +441,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $mtitle = $langs->trans($smenu->title); } // Add item - $menu->add($smenu->link, $mtitle , $smenu->level, $smenu->enabled, $smenu->target, $smenu->mainmenu, $smenu->leftmenu, $smenu->position, $smenu->id, $smenu->idsel, $smenu->classname, $smenu->prefix); + $menu->add($smenu->link, $mtitle, $smenu->level, $smenu->enabled, $smenu->target, $smenu->mainmenu, $smenu->leftmenu, $smenu->position, $smenu->id, $smenu->idsel, $smenu->classname, $smenu->prefix); } }