Qual: Start to clean how menu managers works.
This commit is contained in:
parent
8c4e13230b
commit
1224e79ee3
@ -49,8 +49,8 @@ $menu_handler_smartphone=preg_replace('/_frontoffice.php/i','',$menu_handler_sma
|
||||
|
||||
$menu_handler=$menu_handler_top;
|
||||
|
||||
if ($_REQUEST["handler_origine"]) $menu_handler=$_REQUEST["handler_origine"];
|
||||
if ($_REQUEST["menu_handler"]) $menu_handler=$_REQUEST["menu_handler"];
|
||||
if (GETPOST("handler_origine")) $menu_handler=GETPOST("handler_origine");
|
||||
if (GETPOST("menu_handler")) $menu_handler=GETPOST("menu_handler");
|
||||
|
||||
|
||||
|
||||
@ -173,7 +173,7 @@ if ($action == 'add')
|
||||
if (! $error)
|
||||
{
|
||||
$menu = new Menubase($db);
|
||||
$menu->menu_handler=$_POST['menu_handler'];
|
||||
$menu->menu_handler=preg_replace('/_menu$/','',$_POST['menu_handler']);
|
||||
$menu->type=$_POST['type'];
|
||||
$menu->titre=$_POST['titre'];
|
||||
$menu->url=$_POST['url'];
|
||||
|
||||
@ -54,12 +54,10 @@ $menu_handler_smartphone=preg_replace('/(_frontoffice\.php|_menu\.php)/i','',$me
|
||||
|
||||
$menu_handler=$menu_handler_top;
|
||||
|
||||
|
||||
if (GETPOST("handler_origine")) $menu_handler=GETPOST("handler_origine");
|
||||
if (GETPOST("menu_handler")) $menu_handler=GETPOST("menu_handler");
|
||||
|
||||
$menu_handler_to_search=preg_replace('/(_backoffice|_menu)?(\.php)?/i','',$menu_handler);
|
||||
$menu_handler_to_search=preg_replace('/(_frontoffice|_menu)?(\.php)?/i','',$menu_handler);
|
||||
$menu_handler_to_search=preg_replace('/(_backoffice|_frontoffice|_menu)?(\.php)?/i','',$menu_handler);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@ -391,12 +391,6 @@ class Menubase
|
||||
$mainmenu=$mymainmenu; // To export to dol_eval function
|
||||
$leftmenu=$myleftmenu; // To export to dol_eval function
|
||||
|
||||
// Load datas into tabMenu
|
||||
if (count($tabMenu) == 0)
|
||||
{
|
||||
$this->menuLoad($mainmenu, $leftmenu, $type_user, $menu_handler, $tabMenu);
|
||||
}
|
||||
|
||||
$newTabMenu=array();
|
||||
if (is_array($tabMenu))
|
||||
{
|
||||
@ -431,13 +425,6 @@ class Menubase
|
||||
$mainmenu=$mymainmenu; // To export to dol_eval function
|
||||
$leftmenu=$myleftmenu; // To export to dol_eval function
|
||||
|
||||
// Load datas from database into $tabMenu, later we will complete this->newmenu with values into $tabMenu
|
||||
if (count($tabMenu) == 0) // To avoid to read into database a second time
|
||||
{
|
||||
$this->menuLoad($mainmenu, $leftmenu, $type_user, $menu_handler, $tabMenu);
|
||||
}
|
||||
//var_dump($tabMenu); exit;
|
||||
|
||||
if (is_array($tabMenu))
|
||||
{
|
||||
$menutopid='';
|
||||
@ -451,11 +438,10 @@ class Menubase
|
||||
}
|
||||
}
|
||||
|
||||
// Now edit this->newmenu->list to add entries found into tabMenu that are childs of mainmenu claimed
|
||||
$this->recur($tabMenu, $menutopid, 1, $leftmenu);
|
||||
//var_dump($this->newmenu->liste);exit;
|
||||
// Now edit this->newmenu->list to add entries found into tabMenu that are childs of mainmenu claimed, using the fk_menu link (old method)
|
||||
$this->recur($tabMenu, $menutopid, 1);
|
||||
|
||||
// Update fk_menu when value is -1 (left menu added by modules with no top menu)
|
||||
// Now update this->newmenu->list when fk_menu value is -1 (left menu added by modules with no top menu)
|
||||
foreach($tabMenu as $key => $val)
|
||||
{
|
||||
//var_dump($tabMenu);
|
||||
@ -466,7 +452,7 @@ class Menubase
|
||||
|
||||
if (empty($val['fk_leftmenu']))
|
||||
{
|
||||
$this->newmenu->add($val['url'], $val['titre'], 0, $val['perms'], $val['target'], $val['mainmenu'], $val['leftmenu']);
|
||||
$this->newmenu->add($val['url'], $val['titre'], 0, $val['perms'], $val['target'], $val['mainmenu'], $val['leftmenu']); // TODO Add position
|
||||
//var_dump($this->newmenu->liste);
|
||||
}
|
||||
else
|
||||
@ -515,7 +501,7 @@ class Menubase
|
||||
* @param array &$tabMenu Array to store new entries found (in most cases, it's empty, but may be alreay filled)
|
||||
* @return int >0 if OK, <0 if KO
|
||||
*/
|
||||
private function menuLoad($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
|
||||
function menuLoad($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
|
||||
{
|
||||
global $langs, $user, $conf; // To export to dol_eval function
|
||||
global $mainmenu, $leftmenu; // To export to dol_eval function
|
||||
@ -651,9 +637,8 @@ class Menubase
|
||||
for ($x = 0; $x < $num; $x++)
|
||||
{
|
||||
//si un element a pour pere : $pere
|
||||
if ($tab[$x]['fk_menu'] == $pere && $tab[$x]['enabled'])
|
||||
if ( (($tab[$x]['fk_menu'] >= 0 && $tab[$x]['fk_menu'] == $pere)) && $tab[$x]['enabled'])
|
||||
{
|
||||
//print 'mainmenu='.$tab[$x]['mainmenu'];
|
||||
$this->newmenu->add($tab[$x]['url'], $tab[$x]['titre'], ($level-1), $tab[$x]['perms'], $tab[$x]['target'], $tab[$x]['mainmenu'], $tab[$x]['leftmenu']);
|
||||
$this->recur($tab, $tab[$x]['rowid'], ($level+1));
|
||||
}
|
||||
|
||||
@ -200,7 +200,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled || $conf->accounting->enabled', __HANDLER__, 'left', 2707__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/compta/journal/purchasesjournal.php?leftmenu=ca', 'PurchasesJournal', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__);
|
||||
-- Check deposit
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled && $conf->banque->enabled', __HANDLER__, 'left', 1711__+MAX_llx_menu__, 'accountancy', 'checks', 14__+MAX_llx_menu__, '/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank', 'MenuChequeDeposits', 0, 'bills', '$user->rights->facture->lire', '', 2, 9, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled && $conf->banque->enabled', __HANDLER__, 'left', 1712__+MAX_llx_menu__, 'accountancy', '', 1711__+MAX_llx_menu__, '/compta/paiement/cheque/fiche.php?leftmenu=checks&action=new', 'NewCheckDeposit', 1, 'bills', '$user->rights->facture->lire', '', 2, 0, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled && $conf->banque->enabled', __HANDLER__, 'left', 1712__+MAX_llx_menu__, 'accountancy', '', 1711__+MAX_llx_menu__, '/compta/paiement/cheque/fiche.php?leftmenu=checks&action=new', 'NewCheckDeposit', 1, 'compta', '$user->rights->facture->lire', '', 2, 0, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled && $conf->banque->enabled', __HANDLER__, 'left', 1713__+MAX_llx_menu__, 'accountancy', '', 1711__+MAX_llx_menu__, '/compta/paiement/cheque/liste.php?leftmenu=checks', 'List', 1, 'bills', '$user->rights->facture->lire', '', 2, 1, __ENTITY__);
|
||||
-- Withdrawal
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->prelevement->enabled', __HANDLER__, 'left', 2500__+MAX_llx_menu__, 'accountancy', 'withdraw', 14__+MAX_llx_menu__, '/compta/prelevement/index.php?leftmenu=withdraw&mainmenu=bank', 'StandingOrders', 0, 'withdrawals', '$user->rights->prelevement->bons->lire', '', 2, 9, __ENTITY__);
|
||||
|
||||
@ -30,17 +30,21 @@
|
||||
* @param string $atarget Target
|
||||
* @param int $type_user 0=Internal,1=External,2=All
|
||||
* @param string $limitmenuto To limit menu to a top or left menu value
|
||||
* @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty)
|
||||
* @return void
|
||||
*/
|
||||
function print_smartphone_menu($db,$atarget,$type_user,$limitmenuto)
|
||||
function print_smartphone_menu($db,$atarget,$type_user,$limitmenuto,&$tabMenu)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
|
||||
|
||||
global $user,$conf,$langs,$dolibarr_main_db_name;
|
||||
|
||||
$mainmenu=$_SESSION["mainmenu"];
|
||||
$leftmenu=$_SESSION["leftmenu"];
|
||||
|
||||
$submenus='';
|
||||
|
||||
$tabMenu=array();
|
||||
//$tabMenu=array();
|
||||
|
||||
$menutop = new Menubase($db,'smartphone');
|
||||
$menuleft = new Menubase($db,'smartphone');
|
||||
|
||||
@ -32,7 +32,9 @@ class MenuSmart
|
||||
var $atarget=""; // Valeur du target a utiliser dans les liens
|
||||
var $name="smartphone";
|
||||
|
||||
|
||||
var $tabMenu;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -41,7 +43,52 @@ class MenuSmart
|
||||
*/
|
||||
function __construct($db, $type_user)
|
||||
{
|
||||
$this->type_user=$type_user;
|
||||
$this->db=$db;
|
||||
|
||||
// On sauve en session le menu principal choisi
|
||||
if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"];
|
||||
if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"];
|
||||
|
||||
// Read mainmenu and leftmenu that define which menu to show
|
||||
if (isset($_GET["mainmenu"]))
|
||||
{
|
||||
// On sauve en session le menu principal choisi
|
||||
$mainmenu=$_GET["mainmenu"];
|
||||
$_SESSION["mainmenu"]=$mainmenu;
|
||||
$_SESSION["leftmenuopened"]="";
|
||||
}
|
||||
else
|
||||
{
|
||||
// On va le chercher en session si non defini par le lien
|
||||
$mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:'';
|
||||
}
|
||||
|
||||
if (isset($_GET["leftmenu"]))
|
||||
{
|
||||
// On sauve en session le menu principal choisi
|
||||
$leftmenu=$_GET["leftmenu"];
|
||||
$_SESSION["leftmenu"]=$leftmenu;
|
||||
|
||||
if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse
|
||||
{
|
||||
//$leftmenu="";
|
||||
$_SESSION["leftmenuopened"]="";
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION["leftmenuopened"]=$leftmenu;
|
||||
}
|
||||
} else {
|
||||
// On va le chercher en session si non defini par le lien
|
||||
$leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:'';
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
|
||||
$tabMenu=array();
|
||||
$menuArbo = new Menubase($db,'smartphone');
|
||||
$menuArbo->menuLoad($mainmenu, $leftmenu, $type_user, 'smartphone', $tabMenu);
|
||||
$this->tabMenu=$tabMenu;
|
||||
}
|
||||
|
||||
|
||||
@ -63,7 +110,7 @@ class MenuSmart
|
||||
$conf->global->MAIN_SEARCHFORM_CONTACT=0;
|
||||
}
|
||||
|
||||
print_smartphone_menu($this->db,$this->atarget,$this->hideifnotallowed,$mode);
|
||||
print_smartphone_menu($this->db,$this->atarget,$this->hideifnotallowed,$mode,$this->tabMenu);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
* \file htdocs/core/menus/standard/auguria.lib.php
|
||||
* \brief Library for file auguria menus
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
|
||||
|
||||
|
||||
|
||||
@ -30,22 +31,19 @@
|
||||
* @param DoliDB $db Database handler
|
||||
* @param string $atarget Target
|
||||
* @param int $type_user 0=Internal,1=External,2=All
|
||||
* @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty)
|
||||
* @return void
|
||||
*/
|
||||
function print_auguria_menu($db,$atarget,$type_user)
|
||||
function print_auguria_menu($db,$atarget,$type_user,&$tabMenu)
|
||||
{
|
||||
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"]="";
|
||||
|
||||
$mainmenu=$_SESSION["mainmenu"];
|
||||
$leftmenu=$_SESSION["leftmenu"];
|
||||
|
||||
$listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
|
||||
|
||||
$tabMenu=array();
|
||||
//$tabMenu=array();
|
||||
$menuArbo = new Menubase($db,'auguria');
|
||||
$newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'auguria',$tabMenu);
|
||||
|
||||
@ -177,45 +175,19 @@ function print_end_menu_array_auguria()
|
||||
* @param DoliDB $db Database handler
|
||||
* @param array $menu_array_before Table of menu entries to show before entries of menu handler
|
||||
* @param array $menu_array_after Table of menu entries to show after entries of menu handler
|
||||
* @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty)
|
||||
* @return void
|
||||
*/
|
||||
function print_left_auguria_menu($db,$menu_array_before,$menu_array_after)
|
||||
function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabMenu)
|
||||
{
|
||||
global $user,$conf,$langs,$dolibarr_main_db_name,$mysoc;
|
||||
|
||||
$overwritemenufor = array();
|
||||
$newmenu = new Menu();
|
||||
|
||||
// Read mainmenu and leftmenu that define which menu to show
|
||||
if (isset($_GET["mainmenu"])) {
|
||||
// On sauve en session le menu principal choisi
|
||||
$mainmenu=$_GET["mainmenu"];
|
||||
$_SESSION["mainmenu"]=$mainmenu;
|
||||
$_SESSION["leftmenuopened"]="";
|
||||
} else {
|
||||
// On va le chercher en session si non defini par le lien
|
||||
$mainmenu=$_SESSION["mainmenu"];
|
||||
}
|
||||
|
||||
if (isset($_GET["leftmenu"])) {
|
||||
// On sauve en session le menu principal choisi
|
||||
$leftmenu=$_GET["leftmenu"];
|
||||
$_SESSION["leftmenu"]=$leftmenu;
|
||||
if ($_SESSION["leftmenuopened"]==$leftmenu) {
|
||||
//$leftmenu="";
|
||||
$_SESSION["leftmenuopened"]="";
|
||||
}
|
||||
else {
|
||||
$_SESSION["leftmenuopened"]=$leftmenu;
|
||||
}
|
||||
} else {
|
||||
// On va le chercher en session si non defini par le lien
|
||||
$leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:'';
|
||||
}
|
||||
|
||||
//this->menu_array contains menu in pre.inc.php
|
||||
|
||||
|
||||
$mainmenu=$_SESSION["mainmenu"];
|
||||
$leftmenu=$_SESSION["leftmenu"];
|
||||
|
||||
// Show logo company
|
||||
if (! empty($conf->global->MAIN_SHOW_LOGO))
|
||||
{
|
||||
@ -235,35 +207,12 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after)
|
||||
}
|
||||
}
|
||||
|
||||
// Modules system tools
|
||||
// TODO Find a way to add parent menu only if child menu exists. For the moment, no ther method than hard coded methods.
|
||||
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled) || ! empty($conf->global->MAIN_MENU_ENABLE_MODULETOOLS))
|
||||
{
|
||||
if (empty($user->societe_id))
|
||||
{
|
||||
$newmenu->add("/admin/tools/index.php?mainmenu=home&leftmenu=modulesadmintools", $langs->trans("ModulesSystemTools"), 0, 1, '', $mainmenu, 'modulesadmintools');
|
||||
if ($leftmenu=="modulesadmintools" && $user->admin)
|
||||
{
|
||||
$langs->load("products");
|
||||
$newmenu->add("/product/admin/product_tools.php?mainmenu=home&leftmenu=modulesadmintools", $langs->trans("ProductVatMassChange"), 1, $user->admin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We update newmenu with entries found into database
|
||||
* --------------------------------------------------
|
||||
*/
|
||||
if ($mainmenu)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
|
||||
|
||||
$tabMenu=array();
|
||||
$menuArbo = new Menubase($db,'auguria');
|
||||
$newmenu = $menuArbo->menuLeftCharger($newmenu,$mainmenu,$leftmenu,($user->societe_id?1:0),'auguria',$tabMenu);
|
||||
//var_dump($newmenu);
|
||||
}
|
||||
|
||||
$menuArbo = new Menubase($db,'auguria');
|
||||
$newmenu = $menuArbo->menuLeftCharger($newmenu,$mainmenu,$leftmenu,($user->societe_id?1:0),'auguria',$tabMenu);
|
||||
|
||||
//var_dump($menu_array_before);exit;
|
||||
//var_dump($menu_array_after);exit;
|
||||
|
||||
@ -36,6 +36,8 @@ class MenuManager
|
||||
var $menu_array;
|
||||
var $menu_array_after;
|
||||
|
||||
var $tabMenu;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -45,8 +47,95 @@ class MenuManager
|
||||
*/
|
||||
function __construct($db, $type_user)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
|
||||
$this->type_user=$type_user;
|
||||
$this->db=$db;
|
||||
|
||||
// On sauve en session le menu principal choisi
|
||||
if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"];
|
||||
if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"];
|
||||
|
||||
// Read mainmenu and leftmenu that define which menu to show
|
||||
if (isset($_GET["mainmenu"]))
|
||||
{
|
||||
// On sauve en session le menu principal choisi
|
||||
$mainmenu=$_GET["mainmenu"];
|
||||
$_SESSION["mainmenu"]=$mainmenu;
|
||||
$_SESSION["leftmenuopened"]="";
|
||||
}
|
||||
else
|
||||
{
|
||||
// On va le chercher en session si non defini par le lien
|
||||
$mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:'';
|
||||
}
|
||||
|
||||
if (isset($_GET["leftmenu"]))
|
||||
{
|
||||
// On sauve en session le menu principal choisi
|
||||
$leftmenu=$_GET["leftmenu"];
|
||||
$_SESSION["leftmenu"]=$leftmenu;
|
||||
|
||||
if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse
|
||||
{
|
||||
//$leftmenu="";
|
||||
$_SESSION["leftmenuopened"]="";
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION["leftmenuopened"]=$leftmenu;
|
||||
}
|
||||
} else {
|
||||
// On va le chercher en session si non defini par le lien
|
||||
$leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:'';
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
|
||||
$tabMenu=array();
|
||||
$menuArbo = new Menubase($db,'auguria');
|
||||
$menuArbo->menuLoad($mainmenu, $leftmenu, $type_user, 'auguria', $tabMenu);
|
||||
|
||||
// Modules system tools
|
||||
// TODO Find a way to add parent menu only if child menu exists. For the moment, no other method than hard coded methods.
|
||||
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled) || ! empty($conf->global->MAIN_MENU_ENABLE_MODULETOOLS))
|
||||
{
|
||||
if (empty($user->societe_id))
|
||||
{
|
||||
//$newmenu->add("/admin/tools/index.php?mainmenu=home&leftmenu=modulesadmintools", $langs->trans("ModulesSystemTools"), 0, 1, '', 'home', 'modulesadmintools');
|
||||
if ($leftmenu=="modulesadmintools" && $user->admin)
|
||||
{
|
||||
$langs->load("products");
|
||||
array_unshift($tabMenu,array(
|
||||
'url'=>"/product/admin/product_tools.php?mainmenu=home&leftmenu=modulesadmintools",
|
||||
'titre'=>$langs->trans("ProductVatMassChange"),
|
||||
'enabled'=>($user->admin?true:false),
|
||||
'perms'=>($user->admin?true:false),
|
||||
'fk_mainmenu'=>'home',
|
||||
'fk_leftmenu'=>'modulesadmintools',
|
||||
'fk_menu'=>-1,
|
||||
'mainmenu'=>'home',
|
||||
'leftmenu'=>'modulesadmintools_massvat',
|
||||
'type'=>'left',
|
||||
'position'=>20
|
||||
));
|
||||
//$newmenu->add("/product/admin/product_tools.php?mainmenu=home&leftmenu=modulesadmintools", $langs->trans("ProductVatMassChange"), 1, $user->admin);
|
||||
}
|
||||
array_unshift($tabMenu,array(
|
||||
'url'=>"/admin/tools/index.php?mainmenu=home&leftmenu=modulesadmintools",
|
||||
'titre'=>$langs->trans("ModulesSystemTools"),
|
||||
'enabled'=>($user->admin?true:false),
|
||||
'perms'=>($user->admin?true:false),
|
||||
'fk_mainmenu'=>'home',
|
||||
'fk_menu'=>-1,
|
||||
'mainmenu'=>'home',
|
||||
'leftmenu'=>'modulesadmintools',
|
||||
'type'=>'left',
|
||||
'position'=>20
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$this->tabMenu=$tabMenu;
|
||||
}
|
||||
|
||||
|
||||
@ -69,8 +158,8 @@ class MenuManager
|
||||
}
|
||||
|
||||
$res='ErrorBadParameterForMode';
|
||||
if ($mode == 'top') $res=print_auguria_menu($this->db,$this->atarget,$this->type_user);
|
||||
if ($mode == 'left') $res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after);
|
||||
if ($mode == 'top') $res=print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu);
|
||||
if ($mode == 'left') $res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2010-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2012-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
@ -22,6 +22,7 @@
|
||||
* \file htdocs/core/menus/standard/eldy.lib.php
|
||||
* \brief Library for file eldy menus
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
|
||||
|
||||
|
||||
/**
|
||||
@ -30,18 +31,17 @@
|
||||
* @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)
|
||||
* @return void
|
||||
*/
|
||||
function print_eldy_menu($db,$atarget,$type_user)
|
||||
function print_eldy_menu($db,$atarget,$type_user,&$tabMenu)
|
||||
{
|
||||
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"]="";
|
||||
|
||||
$id='mainmenu';
|
||||
$mainmenu=$_SESSION["mainmenu"];
|
||||
$leftmenu=$_SESSION["leftmenu"];
|
||||
|
||||
$id='mainmenu';
|
||||
$listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
|
||||
|
||||
print_start_menu_array();
|
||||
@ -440,9 +440,6 @@ function print_eldy_menu($db,$atarget,$type_user)
|
||||
|
||||
|
||||
// Show personalized menus
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
|
||||
|
||||
$tabMenu=array();
|
||||
$menuArbo = new Menubase($db,'eldy');
|
||||
$newTabMenu = $menuArbo->menuTopCharger('','',$type_user,'eldy',$tabMenu); // Return tabMenu with only top entries
|
||||
|
||||
@ -566,49 +563,20 @@ function print_end_menu_array()
|
||||
/**
|
||||
* Core function to output left menu eldy
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param array $menu_array_before Table of menu entries to show before entries of menu handler
|
||||
* @param array $menu_array_after Table of menu entries to show after entries of menu handler
|
||||
* @param DoliDB $db Database handler
|
||||
* @param array $menu_array_before Table of menu entries to show before entries of menu handler
|
||||
* @param array $menu_array_after Table of menu entries to show after entries of menu handler
|
||||
* @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty)
|
||||
* @return void
|
||||
*/
|
||||
function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
|
||||
function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu)
|
||||
{
|
||||
global $user,$conf,$langs,$dolibarr_main_db_name,$mysoc;
|
||||
|
||||
// Read mainmenu and leftmenu that define which menu to show
|
||||
if (isset($_GET["mainmenu"]))
|
||||
{
|
||||
// On sauve en session le menu principal choisi
|
||||
$mainmenu=$_GET["mainmenu"];
|
||||
$_SESSION["mainmenu"]=$mainmenu;
|
||||
$_SESSION["leftmenuopened"]="";
|
||||
}
|
||||
else
|
||||
{
|
||||
// On va le chercher en session si non defini par le lien
|
||||
$mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:'';
|
||||
}
|
||||
|
||||
if (isset($_GET["leftmenu"]))
|
||||
{
|
||||
// On sauve en session le menu principal choisi
|
||||
$leftmenu=$_GET["leftmenu"];
|
||||
$_SESSION["leftmenu"]=$leftmenu;
|
||||
if ($_SESSION["leftmenuopened"]==$leftmenu)
|
||||
{
|
||||
//$leftmenu="";
|
||||
$_SESSION["leftmenuopened"]="";
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION["leftmenuopened"]=$leftmenu;
|
||||
}
|
||||
} else {
|
||||
// On va le chercher en session si non defini par le lien
|
||||
$leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:'';
|
||||
}
|
||||
|
||||
$newmenu = new Menu();
|
||||
|
||||
$mainmenu=$_SESSION["mainmenu"];
|
||||
$leftmenu=$_SESSION["leftmenu"];
|
||||
|
||||
// Show logo company
|
||||
if (! empty($conf->global->MAIN_SHOW_LOGO))
|
||||
@ -1359,9 +1327,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
|
||||
}
|
||||
|
||||
// Add personalized menus and modules menus
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
|
||||
|
||||
$tabMenu=array();
|
||||
$menuArbo = new Menubase($db,'eldy');
|
||||
$newmenu = $menuArbo->menuLeftCharger($newmenu,$mainmenu,$leftmenu,(empty($user->societe_id)?0:1),'eldy',$tabMenu);
|
||||
}
|
||||
|
||||
@ -35,6 +35,8 @@ class MenuManager
|
||||
var $menu_array;
|
||||
var $menu_array_after;
|
||||
|
||||
var $tabMenu;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -46,6 +48,50 @@ class MenuManager
|
||||
{
|
||||
$this->type_user=$type_user;
|
||||
$this->db=$db;
|
||||
|
||||
// On sauve en session le menu principal choisi
|
||||
if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"];
|
||||
if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"];
|
||||
|
||||
// Read mainmenu and leftmenu that define which menu to show
|
||||
if (isset($_GET["mainmenu"]))
|
||||
{
|
||||
// On sauve en session le menu principal choisi
|
||||
$mainmenu=$_GET["mainmenu"];
|
||||
$_SESSION["mainmenu"]=$mainmenu;
|
||||
$_SESSION["leftmenuopened"]="";
|
||||
}
|
||||
else
|
||||
{
|
||||
// On va le chercher en session si non defini par le lien
|
||||
$mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:'';
|
||||
}
|
||||
|
||||
if (isset($_GET["leftmenu"]))
|
||||
{
|
||||
// On sauve en session le menu principal choisi
|
||||
$leftmenu=$_GET["leftmenu"];
|
||||
$_SESSION["leftmenu"]=$leftmenu;
|
||||
|
||||
if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse
|
||||
{
|
||||
//$leftmenu="";
|
||||
$_SESSION["leftmenuopened"]="";
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION["leftmenuopened"]=$leftmenu;
|
||||
}
|
||||
} else {
|
||||
// On va le chercher en session si non defini par le lien
|
||||
$leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:'';
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
|
||||
$tabMenu=array();
|
||||
$menuArbo = new Menubase($db,'eldy');
|
||||
$menuArbo->menuLoad($mainmenu, $leftmenu, $type_user, 'eldy', $tabMenu);
|
||||
$this->tabMenu=$tabMenu;
|
||||
}
|
||||
|
||||
|
||||
@ -66,10 +112,10 @@ class MenuManager
|
||||
$conf->global->MAIN_SEARCHFORM_SOCIETE=0;
|
||||
$conf->global->MAIN_SEARCHFORM_CONTACT=0;
|
||||
}
|
||||
|
||||
|
||||
$res='ErrorBadParameterForMode';
|
||||
if ($mode == 'top') $res=print_eldy_menu($this->db,$this->atarget,$this->type_user);
|
||||
if ($mode == 'left') $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after);
|
||||
if ($mode == 'top') $res=print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu);
|
||||
if ($mode == 'left') $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
@ -68,7 +68,7 @@ if (preg_match('/^smartphone/',$conf->smart_menu) && ! empty($conf->browser->pho
|
||||
include_once DOL_DOCUMENT_ROOT ."/core/menus/smartphone/".$conf->smart_menu;
|
||||
}
|
||||
|
||||
$menusmart = new MenuSmart($db);
|
||||
$menusmart = new MenuSmart($db, $user->societe_id?1:0);
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/theme/phones/smartphone/tpl/menu.tpl.php';
|
||||
exit;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user