Mutualize code in menu
This commit is contained in:
parent
e765f83644
commit
a0355cc9b1
415
htdocs/includes/menus/barre_top/eldy.lib.php
Normal file
415
htdocs/includes/menus/barre_top/eldy.lib.php
Normal file
@ -0,0 +1,415 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/includes/menus/barre_top/eldy.lib.php
|
||||
* \brief Library for file eldy menus
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function print_eldy_menu($db,$atarget,$hideifnotallowed)
|
||||
{
|
||||
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"]="";
|
||||
|
||||
|
||||
print '<table class="tmenu" summary="topmenu"><tr class="tmenu">';
|
||||
|
||||
// Home
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
$id='mainmenu_home'; $idsel='id="'.$id.'" ';
|
||||
print '<td class="tmenu" align="center">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/index.php?mainmenu=home&leftmenu="'.($atarget?" target=$atarget":"").'>'.$langs->trans("Home").'</a>';
|
||||
print '</td>';
|
||||
|
||||
|
||||
// Third parties
|
||||
if ($conf->societe->enabled || $conf->fournisseur->enabled)
|
||||
{
|
||||
$langs->load("companies");
|
||||
$langs->load("suppliers");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$id='mainmenu_companies'; $idsel='id="'.$id.'" ';
|
||||
if (($conf->societe->enabled && $user->rights->societe->lire)
|
||||
|| ($conf->fournisseur->enabled && $user->rights->fournisseur->lire))
|
||||
{
|
||||
print '<td class="tmenu" align="center">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/index.php?mainmenu=companies&leftmenu="'.($atarget?" target=$atarget":"").'>'.$langs->trans("ThirdParties").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("ThirdParties").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Products-Services
|
||||
if ($conf->produit->enabled || $conf->service->enabled)
|
||||
{
|
||||
$langs->load("products");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
$chaine="";
|
||||
if ($conf->produit->enabled) { $chaine.=$langs->trans("Products"); }
|
||||
if ($conf->produit->enabled && $conf->service->enabled) { $chaine.="/"; }
|
||||
if ($conf->service->enabled) { $chaine.=$langs->trans("Services"); }
|
||||
|
||||
$id='mainmenu_products'; $idsel='id="'.$id.'" ';
|
||||
if ($user->rights->produit->lire || $user->rights->service->lire)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/product/index.php?mainmenu=products&leftmenu="'.($atarget?" target=$atarget":"").'>'.$chaine.'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$chaine.'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Commercial
|
||||
if ($conf->societe->enabled)
|
||||
{
|
||||
$langs->load("commercial");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$id='mainmenu_commercial'; $idsel='id="'.$id.'" ';
|
||||
if($user->rights->societe->lire || $user->rights->societe->contact->lire)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/comm/index.php?mainmenu=commercial&leftmenu="'.($atarget?" target=$atarget":"").'>'.$langs->trans("Commercial").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("Commercial").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Financial
|
||||
if ($conf->compta->enabled || $conf->accounting->enabled || $conf->banque->enabled
|
||||
|| $conf->facture->enabled || $conf->deplacement->enabled)
|
||||
{
|
||||
$langs->load("compta");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$id='mainmenu_accountancy'; $idsel='id="'.$id.'" ';
|
||||
if ($user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire
|
||||
|| $user->rights->facture->lire || $user->rights->banque->lire)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/compta/index.php?mainmenu=accountancy&leftmenu="'.($atarget?" target=$atarget":"").'>'.$langs->trans("MenuFinancial").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("MenuFinancial").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Projects
|
||||
if ($conf->projet->enabled)
|
||||
{
|
||||
$langs->load("projects");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$id='mainmenu_project'; $idsel='id="'.$id.'" ';
|
||||
if ($user->rights->projet->lire)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/projet/index.php?mainmenu=project&leftmenu="'.($atarget?" target=$atarget":"").'>'.$langs->trans("Projects").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("Projects").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tools
|
||||
if ($conf->mailing->enabled || $conf->export->enabled || $conf->import->enabled || $conf->global->MAIN_MODULE_DOMAIN)
|
||||
{
|
||||
$langs->load("other");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$id='mainmenu_tools'; $idsel='id="'.$id.'" ';
|
||||
if ($user->rights->mailing->lire || $user->rights->bookmark->lire || $user->rights->export->lire || $user->rights->import->run)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/index.php?mainmenu=tools&leftmenu="'.($atarget?" target=$atarget":"").'>'.$langs->trans("Tools").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("Tools").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// OSCommerce 1
|
||||
if (! empty($conf->boutique->enabled))
|
||||
{
|
||||
$langs->load("shop");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "shop")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$id='mainmenu_shop'; $idsel='id="'.$id.'" ';
|
||||
print '<td class="tmenu">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/boutique/index.php?mainmenu=shop&leftmenu="'.($atarget?" target=$atarget":"").'>'.$langs->trans("OSCommerce").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// OSCommerce WS
|
||||
if (! empty($conf->oscommercews->enabled))
|
||||
{
|
||||
$langs->load("shop");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "shop")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$id='mainmenu_shop'; $idsel='id="'.$id.'" ';
|
||||
print '<td class="tmenu">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/oscommerce_ws/index.php?mainmenu=shop&leftmenu="'.($atarget?" target=$atarget":"").'>'.$langs->trans("OSCommerce").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Members
|
||||
if ($conf->adherent->enabled)
|
||||
{
|
||||
// $langs->load("members"); Added in main file
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$id='mainmenu_members'; $idsel='id="'.$id.'" ';
|
||||
if ($user->rights->adherent->lire)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/adherents/index.php?mainmenu=members&leftmenu="'.($atarget?" target=$atarget":"").'>'.$langs->trans("MenuMembers").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("MenuMembers").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Show personalized menus
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/menubase.class.php");
|
||||
|
||||
$menuArbo = new Menubase($db,'eldy','top');
|
||||
$tabMenu = $menuArbo->menuTopCharger($hideifnotallowed,$_SESSION['mainmenu'],'eldy');
|
||||
|
||||
for($i=0; $i<count($tabMenu); $i++)
|
||||
{
|
||||
if ($tabMenu[$i]['enabled'] == true)
|
||||
{
|
||||
$idsel=(empty($tabMenu[$i]['mainmenu'])?'none':$tabMenu[$i]['mainmenu']);
|
||||
$id='mainmenu_'.$idsel;
|
||||
if ($tabMenu[$i]['right'] == true) // Is allowed
|
||||
{
|
||||
if (preg_match("/^(http:\/\/|https:\/\/)/i",$tabMenu[$i]['url']))
|
||||
{
|
||||
$url = $tabMenu[$i]['url'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$url=DOL_URL_ROOT.$tabMenu[$i]['url'];
|
||||
if (! preg_match('/\?/',$url)) $url.='?';
|
||||
else $url.='&';
|
||||
if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url))
|
||||
{
|
||||
$url.='mainmenu='.$tabMenu[$i]['mainmenu'].'&leftmenu=&';
|
||||
}
|
||||
$url.="idmenu=".$tabMenu[$i]['rowid'];
|
||||
}
|
||||
|
||||
// Define the class (top menu selected or not)
|
||||
if (! empty($_SESSION['idmenu']) && $tabMenu[$i]['rowid'] == $_SESSION['idmenu']) $class='class="tmenusel"';
|
||||
else if (! empty($_SESSION['mainmenu']) && $tabMenu[$i]['mainmenu'] == $_SESSION['mainmenu']) $class='class="tmenusel"';
|
||||
else $class='class="tmenu"';
|
||||
|
||||
print '<td class="tmenu" id="mainmenu_'.$idsel.'">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a '.$class.' id="mainmenu_'.$idsel.'" href="'.$url.'"'.($tabMenu[$i]['atarget']?" target='".$tabMenu[$i]['atarget']."'":($atarget?" target=$atarget":"")).'>';
|
||||
print $tabMenu[$i]['titre'];
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu" id="mainmenu_'.$idsel.'">';
|
||||
print '<div class="'.$id.'"><span class="'.$id.'" id="'.$id.'"></span></div>';
|
||||
print '<a class="tmenudisabled" id="mainmenu_'.$idsel.'" href="#">'.$tabMenu[$i]['titre'].'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</tr></table>';
|
||||
print "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
@ -55,411 +55,9 @@ class MenuTop {
|
||||
*/
|
||||
function showmenu()
|
||||
{
|
||||
global $user,$conf,$langs,$dolibarr_main_db_name;;
|
||||
require_once(DOL_DOCUMENT_ROOT.'/includes/menus/barre_top/eldy.lib.php');
|
||||
|
||||
// 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"]="";
|
||||
|
||||
|
||||
print '<table class="tmenu" summary="topmenu"><tr class="tmenu">';
|
||||
|
||||
// Home
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
$idsel='id="mainmenu_home" ';
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/index.php?mainmenu=home&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("Home").'</a>';
|
||||
print '</td>';
|
||||
|
||||
|
||||
// Third parties
|
||||
if ($conf->societe->enabled || $conf->fournisseur->enabled)
|
||||
{
|
||||
$langs->load("companies");
|
||||
$langs->load("suppliers");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_companies" ';
|
||||
if (($conf->societe->enabled && $user->rights->societe->lire)
|
||||
|| ($conf->fournisseur->enabled && $user->rights->fournisseur->lire))
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/index.php?mainmenu=companies&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("ThirdParties").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("ThirdParties").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Products-Services
|
||||
if ($conf->produit->enabled || $conf->service->enabled)
|
||||
{
|
||||
$langs->load("products");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
$chaine="";
|
||||
if ($conf->produit->enabled) { $chaine.=$langs->trans("Products"); }
|
||||
if ($conf->produit->enabled && $conf->service->enabled) { $chaine.="/"; }
|
||||
if ($conf->service->enabled) { $chaine.=$langs->trans("Services"); }
|
||||
|
||||
$idsel='id="mainmenu_products" ';
|
||||
if ($user->rights->produit->lire || $user->rights->service->lire)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/product/index.php?mainmenu=products&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$chaine.'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$chaine.'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Commercial
|
||||
if ($conf->societe->enabled)
|
||||
{
|
||||
$langs->load("commercial");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_commercial" ';
|
||||
if($user->rights->societe->lire || $user->rights->societe->contact->lire)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/comm/index.php?mainmenu=commercial&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("Commercial").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("Commercial").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Financial
|
||||
if ($conf->compta->enabled || $conf->accounting->enabled || $conf->banque->enabled
|
||||
|| $conf->facture->enabled || $conf->deplacement->enabled)
|
||||
{
|
||||
$langs->load("compta");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_accountancy" ';
|
||||
if ($user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire
|
||||
|| $user->rights->facture->lire || $user->rights->banque->lire)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/compta/index.php?mainmenu=accountancy&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("MenuFinancial").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("MenuFinancial").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Projects
|
||||
if ($conf->projet->enabled)
|
||||
{
|
||||
$langs->load("projects");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_project" ';
|
||||
if ($user->rights->projet->lire)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/projet/index.php?mainmenu=project&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("Projects").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("Projects").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tools
|
||||
if ($conf->mailing->enabled || $conf->export->enabled || $conf->import->enabled || $conf->global->MAIN_MODULE_DOMAIN)
|
||||
{
|
||||
$langs->load("other");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_tools" ';
|
||||
if ($user->rights->mailing->lire || $user->rights->bookmark->lire || $user->rights->export->lire || $user->rights->import->run)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/index.php?mainmenu=tools&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("Tools").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("Tools").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Telephonie
|
||||
if (! empty($conf->telephonie->enabled) && $user->rights->telephonie->lire)
|
||||
{
|
||||
$class="";
|
||||
$path = DOL_URL_ROOT.'/telephonie/';
|
||||
if (preg_match("/^".preg_quote($path,'/')."/i",$_SERVER["PHP_SELF"]))
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_telephonie" ';
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/telephonie/index.php?mainmenu=telephonie"'.($this->atarget?" target=$this->atarget":"").'>Telephonie</a>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Energie
|
||||
if (! empty($conf->energie->enabled))
|
||||
{
|
||||
$langs->load("energy");
|
||||
$class="";
|
||||
$path = DOL_URL_ROOT.'/energie/';
|
||||
if (preg_match('/^'.preg_quote($path,'/').'/i',$_SERVER["PHP_SELF"]))
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_energie" ';
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/energie/index.php?mainmenu=energie"'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("Energy").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// OSCommerce 1
|
||||
if (! empty($conf->boutique->enabled))
|
||||
{
|
||||
$langs->load("shop");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "shop")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_shop" ';
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/boutique/index.php?mainmenu=shop&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("OSCommerce").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// OSCommerce WS
|
||||
if (! empty($conf->oscommercews->enabled))
|
||||
{
|
||||
$langs->load("shop");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "shop")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_shop" ';
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/oscommerce_ws/index.php?mainmenu=shop&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("OSCommerce").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Members
|
||||
if ($conf->adherent->enabled)
|
||||
{
|
||||
// $langs->load("members"); Added in main file
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_members" ';
|
||||
if ($user->rights->adherent->lire)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/adherents/index.php?mainmenu=members&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("MenuMembers").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("MenuMembers").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Show personalized menus
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/menubase.class.php");
|
||||
|
||||
$menuArbo = new Menubase($this->db,'eldy','top');
|
||||
$tabMenu = $menuArbo->menuTopCharger($this->hideifnotallowed,$_SESSION['mainmenu'],'eldy');
|
||||
|
||||
for($i=0; $i<count($tabMenu); $i++)
|
||||
{
|
||||
if ($tabMenu[$i]['enabled'] == true)
|
||||
{
|
||||
$idsel=(empty($tabMenu[$i]['mainmenu'])?'none':$tabMenu[$i]['mainmenu']);
|
||||
if ($tabMenu[$i]['right'] == true) // Is allowed
|
||||
{
|
||||
if (preg_match("/^(http:\/\/|https:\/\/)/i",$tabMenu[$i]['url']))
|
||||
{
|
||||
$url = $tabMenu[$i]['url'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$url=DOL_URL_ROOT.$tabMenu[$i]['url'];
|
||||
if (! preg_match('/\?/',$url)) $url.='?';
|
||||
else $url.='&';
|
||||
if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url))
|
||||
{
|
||||
$url.='mainmenu='.$tabMenu[$i]['mainmenu'].'&leftmenu=&';
|
||||
}
|
||||
$url.="idmenu=".$tabMenu[$i]['rowid'];
|
||||
}
|
||||
|
||||
// Define the class (top menu selected or not)
|
||||
if (! empty($_SESSION['idmenu']) && $tabMenu[$i]['rowid'] == $_SESSION['idmenu']) $class='class="tmenusel"';
|
||||
else if (! empty($_SESSION['mainmenu']) && $tabMenu[$i]['mainmenu'] == $_SESSION['mainmenu']) $class='class="tmenusel"';
|
||||
else $class='class="tmenu"';
|
||||
|
||||
print '<td class="tmenu" id="td_'.$idsel.'">';
|
||||
print '<span id="mainmenu_'.$idsel.'">';
|
||||
print '<a '.$class.' id="mainmenu_'.$idsel.'" href="'.$url.'"'.($tabMenu[$i]['atarget']?" target='".$tabMenu[$i]['atarget']."'":($this->atarget?" target=$this->atarget":"")).'>';
|
||||
print $tabMenu[$i]['titre'];
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu" id="td_'.$idsel.'">';
|
||||
print '<a class="tmenudisabled" id="mainmenu_'.$idsel.'" href="#">'.$tabMenu[$i]['titre'].'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</tr></table>';
|
||||
print "\n";
|
||||
print_eldy_menu($this->db,$this->atarget,$this->hideifnotallowed);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -55,408 +55,9 @@ class MenuTop {
|
||||
*/
|
||||
function showmenu()
|
||||
{
|
||||
global $user,$conf,$langs,$dolibarr_main_db_name;;
|
||||
require_once(DOL_DOCUMENT_ROOT.'/includes/menus/barre_top/eldy.lib.php');
|
||||
|
||||
// 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"]="";
|
||||
|
||||
|
||||
print '<table class="tmenu" summary="topmenu"><tr class="tmenu">';
|
||||
|
||||
// Home
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
$idsel='id="mainmenu_home" ';
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/index.php?mainmenu=home&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("Home").'</a>';
|
||||
print '</td>';
|
||||
|
||||
|
||||
// Third parties
|
||||
if ($conf->societe->enabled || $conf->fournisseur->enabled)
|
||||
{
|
||||
$langs->load("companies");
|
||||
$langs->load("suppliers");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_companies" ';
|
||||
if (($conf->societe->enabled && $user->rights->societe->lire)
|
||||
|| ($conf->fournisseur->enabled && $user->rights->fournisseur->lire))
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/index.php?mainmenu=companies&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("ThirdParties").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("ThirdParties").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Products-Services
|
||||
if ($conf->produit->enabled || $conf->service->enabled)
|
||||
{
|
||||
$langs->load("products");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
$chaine="";
|
||||
if ($conf->produit->enabled) { $chaine.=$langs->trans("Products"); }
|
||||
if ($conf->produit->enabled && $conf->service->enabled) { $chaine.="/"; }
|
||||
if ($conf->service->enabled) { $chaine.=$langs->trans("Services"); }
|
||||
|
||||
$idsel='id="mainmenu_products" ';
|
||||
if ($user->rights->produit->lire || $user->service->lire)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/product/index.php?mainmenu=products&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$chaine.'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$chaine.'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Commercial
|
||||
if ($conf->societe->enabled)
|
||||
{
|
||||
$langs->load("commercial");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_commercial" ';
|
||||
if($user->rights->societe->lire || $user->rights->societe->contact->lire)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/comm/index.php?mainmenu=commercial&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("Commercial").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("Commercial").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Financial
|
||||
if ($conf->compta->enabled || $conf->accounting->enabled || $conf->banque->enabled
|
||||
|| $conf->facture->enabled || $conf->deplacement->enabled)
|
||||
{
|
||||
$langs->load("compta");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_accountancy" ';
|
||||
if ($user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire
|
||||
|| $user->rights->facture->lire || $user->rights->banque->lire)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/compta/index.php?mainmenu=accountancy&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("MenuFinancial").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("MenuFinancial").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Projects
|
||||
if ($conf->projet->enabled)
|
||||
{
|
||||
$langs->load("projects");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_project" ';
|
||||
if ($user->rights->projet->lire)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/projet/index.php?mainmenu=project&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("Projects").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("Projects").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tools
|
||||
if ($conf->mailing->enabled || $conf->export->enabled || $conf->import->enabled || $conf->global->MAIN_MODULE_DOMAIN)
|
||||
{
|
||||
$langs->load("other");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_tools" ';
|
||||
if ($user->rights->mailing->lire || $user->rights->bookmark->lire || $user->rights->export->lire || $user->rights->import->run)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/index.php?mainmenu=tools&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("Tools").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("Tools").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Telephonie
|
||||
if (! empty($conf->telephonie->enabled) && $user->rights->telephonie->lire)
|
||||
{
|
||||
$class="";
|
||||
$path = DOL_URL_ROOT.'/telephonie/';
|
||||
if (preg_match('/^'.preg_quote($path,'/').'/i',$_SERVER["PHP_SELF"]))
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_telephonie" ';
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/telephonie/index.php?mainmenu=telephonie"'.($this->atarget?" target=$this->atarget":"").'>Telephonie</a>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Energie
|
||||
if (! empty($conf->energie->enabled))
|
||||
{
|
||||
$langs->load("energy");
|
||||
$class="";
|
||||
$path = DOL_URL_ROOT.'/energie/';
|
||||
if (preg_match('/^'.preg_quote($path,'/').'/i',$_SERVER["PHP_SELF"]))
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_energie" ';
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/energie/index.php?mainmenu=energie"'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("Energy").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// OSCommerce 1
|
||||
if (! empty($conf->boutique->enabled))
|
||||
{
|
||||
$langs->load("shop");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "shop")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_shop" ';
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/boutique/index.php?mainmenu=shop&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("OSCommerce").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// OSCommerce WS
|
||||
if (! empty($conf->oscommercews->enabled))
|
||||
{
|
||||
$langs->load("shop");
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "shop")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_shop" ';
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/oscommerce_ws/index.php?mainmenu=shop&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("OSCommerce").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Members
|
||||
if ($conf->adherent->enabled)
|
||||
{
|
||||
// $langs->load("members"); Added in main file
|
||||
|
||||
$class="";
|
||||
if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members")
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'class="tmenu"';
|
||||
}
|
||||
|
||||
$idsel='id="mainmenu_members" ';
|
||||
if ($user->rights->adherent->lire)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a '.$class.' '.$idsel.'href="'.DOL_URL_ROOT.'/adherents/index.php?mainmenu=members&leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("MenuMembers").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu">';
|
||||
print '<a class="tmenudisabled" '.$idsel.'href="#">'.$langs->trans("MenuMembers").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Affichage des menus personnalises
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/menubase.class.php");
|
||||
|
||||
$menuArbo = new Menubase($this->db,'eldy','top');
|
||||
$tabMenu = $menuArbo->menuTopCharger($this->hideifnotallowed,$_SESSION['mainmenu'],'eldy');
|
||||
|
||||
for($i=0; $i<count($tabMenu); $i++)
|
||||
{
|
||||
if ($tabMenu[$i]['enabled'] == true)
|
||||
{
|
||||
$idsel=(empty($tabMenu[$i]['mainmenu'])?'none':$tabMenu[$i]['mainmenu']);
|
||||
if ($tabMenu[$i]['right'] == true) // Is allowed
|
||||
{
|
||||
if (preg_match("/^(http:\/\/|https:\/\/)/i",$tabMenu[$i]['url']))
|
||||
{
|
||||
$url = $tabMenu[$i]['url'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$url=DOL_URL_ROOT.$tabMenu[$i]['url'];
|
||||
if (! preg_match('/\?/',$url)) $url.='?';
|
||||
else $url.='&';
|
||||
if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url))
|
||||
{
|
||||
$url.='mainmenu='.$tabMenu[$i]['mainmenu'].'&leftmenu=&';
|
||||
}
|
||||
$url.="idmenu=".$tabMenu[$i]['rowid'];
|
||||
}
|
||||
|
||||
// Define the class (top menu selected or not)
|
||||
if (! empty($_SESSION['idmenu']) && $tabMenu[$i]['rowid'] == $_SESSION['idmenu']) $class='class="tmenusel"';
|
||||
else if (! empty($_SESSION['mainmenu']) && $tabMenu[$i]['mainmenu'] == $_SESSION['mainmenu']) $class='class="tmenusel"';
|
||||
else $class='class="tmenu"';
|
||||
|
||||
print '<td class="tmenu" id="td_'.$idsel.'">';
|
||||
print '<a '.$class.' id="mainmenu_'.$idsel.'" href="'.$url.'"'.($tabMenu[$i]['atarget']?" target='".$tabMenu[$i]['atarget']."'":($this->atarget?" target=$this->atarget":"")).'>';
|
||||
print $tabMenu[$i]['titre'];
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->hideifnotallowed)
|
||||
{
|
||||
print '<td class="tmenu" id="td_'.$idsel.'">';
|
||||
print '<a class="tmenudisabled" id="mainmenu_'.$idsel.'" href="#">'.$tabMenu[$i]['titre'].'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</tr></table>';
|
||||
print_eldy_menu($this->db,$this->atarget,$this->hideifnotallowed);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user