diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php
index c135dce9ab8..4f927bdbd7e 100644
--- a/htdocs/admin/menus.php
+++ b/htdocs/admin/menus.php
@@ -21,7 +21,7 @@
/**
\file htdocs/admin/menus.php
- \ingroup core,menudb
+ \ingroup core
\brief Page de configuration des gestionnaires de menu
*/
diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php
index 80c7fb1e409..bb2c5dfba7a 100644
--- a/htdocs/admin/menus/edit.php
+++ b/htdocs/admin/menus/edit.php
@@ -21,7 +21,7 @@
/**
\file htdocs/admin/menus/edit.php
- \ingroup core,menudb
+ \ingroup core
\brief Edition des menus
*/
@@ -100,13 +100,13 @@ if (isset($_GET["action"]) && $_GET["action"] == 'add')
$error=0;
if (! $error && ! $_POST['menu_handler'])
{
- $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiest("MenuHandler")).'
';
+ $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("MenuHandler")).'
';
$_GET["action"] = 'create';
$error++;
}
if (! $error && ! $_POST['type'])
{
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiest("Type")).'
';
+ $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Type")).'
';
$_GET["action"] = 'create';
$error++;
}
@@ -128,6 +128,12 @@ if (isset($_GET["action"]) && $_GET["action"] == 'add')
$_GET["action"] = 'create';
$error++;
}
+ if (! $error && ! $_POST['menuId'] && $_POST['type'] == 'left')
+ {
+ $mesg=''.$langs->trans("ErrorLeftMenuMustHaveAParentId").'
';
+ $_GET["action"] = 'create';
+ $error++;
+ }
if (! $error)
{
$sql = "SELECT max(m.rowid) as maxId FROM ".MAIN_DB_PREFIX."menu as m";
diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php
index b870326d0df..ae2d2a54de6 100644
--- a/htdocs/admin/menus/index.php
+++ b/htdocs/admin/menus/index.php
@@ -21,7 +21,7 @@
/**
\file htdocs/admin/menus/index.php
- \ingroup core,menudb
+ \ingroup core
\brief Gestion des menus
*/
@@ -165,9 +165,8 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
}
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".$_GET['menuId'];
- $db->query($sql);
-
- if ($result == 0)
+ $resql=$db->query($sql);
+ if ($resql)
{
$db->commit();
diff --git a/htdocs/admin/menus/module_menudb.php b/htdocs/admin/menus/module_menudb.php
deleted file mode 100644
index a83f120ff46..00000000000
--- a/htdocs/admin/menus/module_menudb.php
+++ /dev/null
@@ -1,295 +0,0 @@
-
- *
- * 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/
- *
- * $Id$
- * $Source$
- */
-
-/**
- \file htdocs/includes/modules/menudb/modules_menudb.php
- \ingroup menudb
- \brief Fichier contenant la classe mère d'affichage des menus DB
- \version $Revision$
-*/
-
-/**
- \class MenuDb
- \brief Classe de gestion du menu DB
-*/
-class MenuDb
-{
- var $db;
- var $menu_handler;
- var $type;
- var $atarget;
-
- var $newmenu;
- var $mainmenu;
- var $leftmenu;
-
- function MenuDb($db,$menu_handler,$type)
- {
- $this->db = $db;
- $this->menu_handler = $menu_handler;
- $this->type = $type;
- }
-
- function menuCharger($mainmenu, $newmenu,$type_user, $leftmenu)
- {
-
- global $langs,$user, $conf;
-
- $this->mainmenu = $mainmenu;
- $this->newmenu = $newmenu;
- $this->leftmenu = $leftmenu;
-
- $sql = "SELECT m.rowid, m.titre, m.type";
- $sql.= " FROM " . MAIN_DB_PREFIX . "menu as m";
- $sql.= " WHERE m.mainmenu = '".$this->mainmenu."'";
- $sql.= " AND m.menu_handler= '".$this->menu_handler."'";
- $result = $this->db->query($sql);
- $menuTop = $this->db->fetch_object($result);
-
- $data[] = array ($menutop->rowid,-1,$this->mainmenu);
-
- $sql = "SELECT m.rowid, m.fk_menu, m.url, m.titre, m.langs, m.right, m.target, m.mainmenu, m.leftmenu";
- $sql.= " FROM " . MAIN_DB_PREFIX . "menu as m";
- $sql.= " WHERE m.menu_handler= '".$this->menu_handler."'";
- if($type_user == 0) $sql.= " AND m.user <> 1";
- else $sql.= " AND m.user > 0";
- $sql.= " ORDER BY m.order, m.rowid";
-
- $res = $this->db->query($sql);
- if ($res)
- {
- $num = $this->db->num_rows();
-
- $i = 1;
- while ($menu = $this->db->fetch_array($res)) {
- $langs->load($menu['langs']);
- $titre = $langs->trans($menu['titre']);
- $rights = $this->verifRights($menu['right']);
- $data[] = array (
- $menu['rowid'],
- $menu['fk_menu'],
- $menu['url'],
- $titre,
- $rights,
- $menu['target'],
- $menu['leftmenu']
- );
- $i++;
-
- }
-
- }
- else
- {
- dolibarr_print_error($this->db);
- }
-
- $this->recur($data, $menuTop->rowid, 1);
-
- return $this->newmenu;
-
- }
-
- function recur($tab, $pere, $rang) {
- $leftmenu = $this->leftmenu;
- //ballayage du tableau
- for ($x = 0; $x < count($tab); $x++) {
-
- //si un élément a pour père : $pere
- if ($tab[$x][1] == $pere) {
-
- //on affiche le menu
-
- if ($this->verifConstraint($tab[$x][0], $tab[$x][6], $tab[$x][7]) != 0) {
-
- if ($tab[$x][6]) {
-
- $leftmenuConstraint = false;
- $str = "if(" . $tab[$x][6] . ") \$leftmenuConstraint = true;";
-
- eval ($str);
- if ($leftmenuConstraint == true) {
- $this->newmenu->add_submenu(DOL_URL_ROOT . $tab[$x][2], $tab[$x][3], $rang -1, $tab[$x][4], $tab[$x][5]);
- $this->recur($tab, $tab[$x][0], $rang +1);
- }
- } else {
- $this->newmenu->add_submenu(DOL_URL_ROOT . $tab[$x][2], $tab[$x][3], $rang -1, $tab[$x][4], $tab[$x][5]);
- $this->recur($tab, $tab[$x][0], $rang +1);
- }
-
- }
- }
- }
- }
-
- function verifConstraint($rowid, $mainmenu = "", $leftmenu = "")
- {
- global $user, $conf, $user;
-
- $constraint = true;
-
- $sql = "SELECT c.rowid, c.action, mc.user";
- $sql.= " FROM " . MAIN_DB_PREFIX . "menu_constraint as c, " . MAIN_DB_PREFIX . "menu_const as mc";
- $sql.= " WHERE mc.fk_constraint = c.rowid AND (mc.user = 0 OR mc.user = 2) AND mc.fk_menu = '" . $rowid . "'";
-
- $result = $this->db->query($sql);
- if ($result)
- {
- //echo $sql;
- $num = $this->db->num_rows();
- $i = 0;
- while (($i < $num) && $constraint == true)
- {
- $obj = $this->db->fetch_object($result);
- $strconstraint = "if(!(" . $obj->action . ")) { \$constraint = false;}";
-
- eval ($strconstraint);
- $i++;
- }
- }
- else
- {
- dolibarr_print_error($this->db);
- }
-
- return $constraint;
- }
-
- function verifRights($strRights) {
-
- global $user,$conf,$user;
-
- if ($strRights != "") {
- $rights = true;
-
- $tab_rights = explode(" || ", $strRights);
- $i = 0;
- while (($i < count($tab_rights)) && ($rights == true)) {
- $str = "if(!(" . $strRights . ")) { \$rights = false;}";
- eval ($str);
- $i++;
- }
- } else
- $rights = true;
-
- return $rights;
- }
-
- function listeMainmenu()
- {
- $sql = "SELECT DISTINCT m.mainmenu";
- $sql.= " FROM " . MAIN_DB_PREFIX . "menu as m";
- $sql.= " WHERE m.menu_handler= '".$this->menu_handler."'";
-
- $res = $this->db->query($sql);
- if ($res) {
- $i = 0;
- while ($menu = $this->db->fetch_array($res)) {
- $overwritemenufor[$i] = $menu['mainmenu'];
- $i++;
- }
- }
- else
- {
- dolibarr_print_error($this->db);
- }
-
- return $overwritemenufor;
- }
-
-
- function menutopCharger($type_user,$mainmenu)
- {
- global $langs, $user, $conf;
-
- $sql = "SELECT m.rowid, m.mainmenu, m.titre, m.url, m.langs, m.right";
- $sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
- $sql.= " WHERE m.type = 'top'";
- $sql.= " AND m.menu_handler= '".$this->menu_handler."'";
- if($type_user == 0) $sql.= " AND m.user <> 1";
- else $sql.= " AND m.user > 0";
- $sql.= " ORDER BY m.order";
-
- $result = $this->db->query($sql);
- if ($result)
- {
- $numa = $this->db->num_rows();
-
- $a = 0;
- $b = 0;
- while ($a < $numa)
- {
- // Affichage entete menu
- $objm = $this->db->fetch_object($result);
-
- if ($this->verifConstraint($objm->rowid))
- {
- $langs->load($objm->langs);
-
- $class="";
- if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == $objm->mainmenu)
- {
- $class='id="sel"';
- }
- $chaine="";
-
- $right = true;
-
- if ($objm->right)
- {
- $str = "if(!(".$objm->right.")) \$right = false;";
- eval($str);
- }
-
- if(eregi("/",$objm->titre))
- {
- $tab_titre = explode("/",$objm->titre);
- $chaine = $langs->trans($tab_titre[0])."/".$langs->trans($tab_titre[1]);
- }
- else
- {
- $chaine = $langs->trans($objm->titre);
- }
-
- $tabMenu[$b]['titre'] = $chaine;
- $tabMenu[$b]['url'] = $objm->url;
- $tabMenu[$b]['atarget'] = $this->atarget;
- $tabMenu[$b]['class'] = $class;
- $tabMenu[$b]['right'] = $right;
-
- $b++;
-
- }
-
- $a++;
- }
- }
- else
- {
- dolibarr_print_error($this->db);
- }
-
- return $tabMenu;
-
- }
-}
-?>
diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php
index 50b1c9137a5..4085c3ec52f 100644
--- a/htdocs/admin/perms.php
+++ b/htdocs/admin/perms.php
@@ -22,7 +22,7 @@
/**
\file htdocs/admin/perms.php
- \ingroup core,menudb
+ \ingroup core
\brief Page d'administration/configuration des permissions par defaut
\version $Revision$
*/
diff --git a/htdocs/conf/conf.class.php b/htdocs/conf/conf.class.php
index 3466eb1a132..0031f9a8f07 100644
--- a/htdocs/conf/conf.class.php
+++ b/htdocs/conf/conf.class.php
@@ -254,9 +254,6 @@ class Conf
$this->droitpret->cat=defined('DROITPRET_MAIL')?DROITPRET_MAIL:'';
$this->droitpret->dir_temp=DOL_DATA_ROOT."/droitpret/temp";
- // Module menuDb
- $this->menudb->enabled=1;
-
// Module code barre
$this->barcode->enabled=defined("MAIN_MODULE_BARCODE")?MAIN_MODULE_BARCODE:0;
// Module categorie
diff --git a/htdocs/includes/menus/barre_left/auguria_backoffice.php b/htdocs/includes/menus/barre_left/auguria_backoffice.php
index 5b82682657a..c44446b07e0 100644
--- a/htdocs/includes/menus/barre_left/auguria_backoffice.php
+++ b/htdocs/includes/menus/barre_left/auguria_backoffice.php
@@ -55,14 +55,13 @@ class MenuLeft {
*/
function MenuLeft($db,&$menu_array)
{
-
- require_once(DOL_DOCUMENT_ROOT."/admin/menus/module_menudb.php");
+ require_once(DOL_DOCUMENT_ROOT."/lib/menubase.class.php");
$this->db=$db;
$this->menu_array=$menu_array;
$this->newmenu = new Menu();
- $this->menuArbo = new menudb($this->db,'auguria','left');
+ $this->menuArbo = new Menubase($this->db,'auguria','left');
$this->overwritemenufor = $this->menuArbo->listeMainmenu();
}
diff --git a/htdocs/includes/menus/barre_left/auguria_frontoffice.php b/htdocs/includes/menus/barre_left/auguria_frontoffice.php
index 9ec9548a3f8..1396a6fefb5 100644
--- a/htdocs/includes/menus/barre_left/auguria_frontoffice.php
+++ b/htdocs/includes/menus/barre_left/auguria_frontoffice.php
@@ -54,14 +54,14 @@ class MenuLeft {
*/
function MenuLeft($db,&$menu_array)
{
- require_once(DOL_DOCUMENT_ROOT."/admin/menus/module_menudb.php");
+ require_once(DOL_DOCUMENT_ROOT."/lib/menubase.class.php");
$this->db=$db;
$this->menu_array=$menu_array;
$this->newmenu = new Menu();
- $this->menuArbo = new menudb($this->db,'auguria','left');
+ $this->menuArbo = new Menubase($this->db,'auguria','left');
$this->overwritemenufor = $this->menuArbo->listeMainmenu();
}
diff --git a/htdocs/includes/menus/barre_top/auguria_backoffice.php b/htdocs/includes/menus/barre_top/auguria_backoffice.php
index afa8b3cc81f..0e331139e74 100644
--- a/htdocs/includes/menus/barre_top/auguria_backoffice.php
+++ b/htdocs/includes/menus/barre_top/auguria_backoffice.php
@@ -61,7 +61,7 @@ class MenuTop {
*/
function showmenu()
{
- require_once(DOL_DOCUMENT_ROOT."/admin/menus/module_menudb.php");
+ require_once(DOL_DOCUMENT_ROOT."/lib/menubase.class.php");
global $user,$conf,$langs,$dolibarr_main_db_name;;
@@ -85,7 +85,7 @@ class MenuTop {
}
- $menuArbo = new MenuDb($this->db,'auguria','top');
+ $menuArbo = new Menubase($this->db,'auguria','top');
$tabMenu = $menuArbo->menutopCharger(0,$_SESSION['mainmenu']);
print '';
diff --git a/htdocs/includes/menus/barre_top/auguria_frontoffice.php b/htdocs/includes/menus/barre_top/auguria_frontoffice.php
index 03ae937fa75..e59d986566e 100644
--- a/htdocs/includes/menus/barre_top/auguria_frontoffice.php
+++ b/htdocs/includes/menus/barre_top/auguria_frontoffice.php
@@ -61,7 +61,7 @@ class MenuTop {
*/
function showmenu()
{
- require_once(DOL_DOCUMENT_ROOT."/admin/menus/module_menudb.php");
+ require_once(DOL_DOCUMENT_ROOT."/lib/menubase.class.php");
global $user,$conf,$langs,$dolibarr_main_db_name;;
@@ -85,7 +85,7 @@ class MenuTop {
}
- $menuArbo = new menudb($this->db,'auguria','top');
+ $menuArbo = new Menubase($this->db,'auguria','top');
$tabMenu = $menuArbo->menutopCharger(1,$_SESSION['mainmenu']);
print '';
diff --git a/htdocs/includes/menus/barre_top/eldy_backoffice.php b/htdocs/includes/menus/barre_top/eldy_backoffice.php
index e2c550259bb..98acb0fdf4e 100644
--- a/htdocs/includes/menus/barre_top/eldy_backoffice.php
+++ b/htdocs/includes/menus/barre_top/eldy_backoffice.php
@@ -426,9 +426,9 @@ class MenuTop {
// Affichage des menus personnalises
- require_once(DOL_DOCUMENT_ROOT."/admin/menus/module_menudb.php");
+ require_once(DOL_DOCUMENT_ROOT."/lib/menubase.class.php");
- $menuArbo = new MenuDb($this->db,'eldy','top');
+ $menuArbo = new Menubase($this->db,'eldy','top');
$tabMenu = $menuArbo->menutopCharger(0,$_SESSION['mainmenu']);
for($i=0;$idb,'eldy','top');
+ $menuArbo = new Menubase($this->db,'eldy','top');
$tabMenu = $menuArbo->menutopCharger(0,$_SESSION['mainmenu']);
for($i=0;$idb,'eldy','top');
+ $menuArbo = new Menubase($this->db,'eldy','top');
$tabMenu = $menuArbo->menutopCharger(0,$_SESSION['mainmenu']);
for($i=0;$idb,'rodolphe','top');
+ $menuArbo = new Menubase($this->db,'rodolphe','top');
$tabMenu = $menuArbo->menutopCharger(0,$_SESSION['mainmenu']);
for($i=0;$isafe_mode is enabled on this PHP, check that Dolibarr php files owns to web server user (or group).
ErrorNoMailDefinedForThisUser=No mail defined for this user
ErrorFeatureNeedJavascript=This feature need javascript to be activated to work. Change this in setup - display.
-ErrorTopMenuMustHaveAParentWithId0=A menu of type 'Top' can't have a parent menu. Put 0 in parent menu or choose a menu of type 'Left'.
\ No newline at end of file
+ErrorTopMenuMustHaveAParentWithId0=A menu of type 'Top' can't have a parent menu. Put 0 in parent menu or choose a menu of type 'Left'.
+ErrorLeftMenuMustHaveAParentId=A menu of type 'Left' must have a parent id.
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang
index 0bb0abd63ea..633fdbe0b2a 100644
--- a/htdocs/langs/fr_FR/errors.lang
+++ b/htdocs/langs/fr_FR/errors.lang
@@ -18,4 +18,5 @@ ErrorFieldsRequired=Des champs obligatoires n'ont pas
ErrorFailedToCreateDir=Echec a la creation d'un repertoire. Verifiez que le user du serveur Web a bien les droits d'ecriture dans les repertoires documents de Dolibarr. Si le parametre safe_mode a été activé sur ce PHP, vérifier que les fichiers php dolibarr appartiennent à l'utilisateur du serveur Web.
ErrorNoMailDefinedForThisUser=EMail non defini pour cet utilisateur
ErrorFeatureNeedJavascript=Cette fonctionnalité a besoin de javascript activé pour fonctionner. Modifier dans configuration - affichage.
-ErrorTopMenuMustHaveAParentWithId0=Un menu de type 'Top' ne peut avoir de menu père. Mettre 0 dans l'id père ou choisir un menu de type 'Left'.
\ No newline at end of file
+ErrorTopMenuMustHaveAParentWithId0=Un menu de type 'Top' ne peut avoir de menu père. Mettre 0 dans l'id père ou choisir un menu de type 'Left'.
+ErrorLeftMenuMustHaveAParentId=Un menu de type 'Left' doit avoir un id de père.
\ No newline at end of file
diff --git a/htdocs/lib/menubase.class.php b/htdocs/lib/menubase.class.php
index 7e6b94531bb..2f817b470b7 100644
--- a/htdocs/lib/menubase.class.php
+++ b/htdocs/lib/menubase.class.php
@@ -53,16 +53,16 @@ class Menubase
var $user;
var $tms;
-
-
/**
* \brief Constructor
* \param DB Database handler
*/
- function Menubase($DB)
+ function Menubase($DB,$menu_handler='',$type='')
{
$this->db = $DB;
+ $this->menu_handler = $menu_handler;
+ $this->type = $type;
return 1;
}
@@ -344,5 +344,249 @@ class Menubase
$this->tms='';
}
+
+ function menuCharger($mainmenu, $newmenu, $type_user, $leftmenu)
+ {
+
+ global $langs,$user, $conf;
+
+ $this->mainmenu = $mainmenu;
+ $this->newmenu = $newmenu;
+ $this->leftmenu = $leftmenu;
+
+ $sql = "SELECT m.rowid, m.titre, m.type";
+ $sql.= " FROM " . MAIN_DB_PREFIX . "menu as m";
+ $sql.= " WHERE m.mainmenu = '".$this->mainmenu."'";
+ $sql.= " AND m.menu_handler= '".$this->menu_handler."'";
+ $result = $this->db->query($sql);
+ $menuTop = $this->db->fetch_object($result);
+
+ $data[] = array ($menutop->rowid,-1,$this->mainmenu);
+
+ $sql = "SELECT m.rowid, m.fk_menu, m.url, m.titre, m.langs, m.right, m.target, m.mainmenu, m.leftmenu";
+ $sql.= " FROM " . MAIN_DB_PREFIX . "menu as m";
+ $sql.= " WHERE m.menu_handler= '".$this->menu_handler."'";
+ if($type_user == 0) $sql.= " AND m.user <> 1";
+ else $sql.= " AND m.user > 0";
+ $sql.= " ORDER BY m.order, m.rowid";
+
+ $res = $this->db->query($sql);
+ if ($res)
+ {
+ $num = $this->db->num_rows();
+
+ $i = 1;
+ while ($menu = $this->db->fetch_array($res)) {
+ $langs->load($menu['langs']);
+ $titre = $langs->trans($menu['titre']);
+ $rights = $this->verifRights($menu['right']);
+ $data[] = array (
+ $menu['rowid'],
+ $menu['fk_menu'],
+ $menu['url'],
+ $titre,
+ $rights,
+ $menu['target'],
+ $menu['leftmenu']
+ );
+ $i++;
+
+ }
+
+ }
+ else
+ {
+ dolibarr_print_error($this->db);
+ }
+
+ $this->recur($data, $menuTop->rowid, 1);
+
+ return $this->newmenu;
+
+ }
+
+ function recur($tab, $pere, $rang) {
+ $leftmenu = $this->leftmenu;
+ //ballayage du tableau
+ for ($x = 0; $x < count($tab); $x++) {
+
+ //si un élément a pour père : $pere
+ if ($tab[$x][1] == $pere) {
+
+ //on affiche le menu
+
+ if ($this->verifConstraint($tab[$x][0], $tab[$x][6], $tab[$x][7]) != 0) {
+
+ if ($tab[$x][6]) {
+
+ $leftmenuConstraint = false;
+ $str = "if(" . $tab[$x][6] . ") \$leftmenuConstraint = true;";
+
+ eval ($str);
+ if ($leftmenuConstraint == true) {
+ $this->newmenu->add_submenu(DOL_URL_ROOT . $tab[$x][2], $tab[$x][3], $rang -1, $tab[$x][4], $tab[$x][5]);
+ $this->recur($tab, $tab[$x][0], $rang +1);
+ }
+ } else {
+ $this->newmenu->add_submenu(DOL_URL_ROOT . $tab[$x][2], $tab[$x][3], $rang -1, $tab[$x][4], $tab[$x][5]);
+ $this->recur($tab, $tab[$x][0], $rang +1);
+ }
+
+ }
+ }
+ }
+ }
+
+ function verifConstraint($rowid, $mainmenu = "", $leftmenu = "")
+ {
+ global $user, $conf, $user;
+
+ $constraint = true;
+
+ $sql = "SELECT c.rowid, c.action, mc.user";
+ $sql.= " FROM " . MAIN_DB_PREFIX . "menu_constraint as c, " . MAIN_DB_PREFIX . "menu_const as mc";
+ $sql.= " WHERE mc.fk_constraint = c.rowid AND (mc.user = 0 OR mc.user = 2) AND mc.fk_menu = '" . $rowid . "'";
+
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ //echo $sql;
+ $num = $this->db->num_rows();
+ $i = 0;
+ while (($i < $num) && $constraint == true)
+ {
+ $obj = $this->db->fetch_object($result);
+ $strconstraint = "if(!(" . $obj->action . ")) { \$constraint = false;}";
+
+ eval ($strconstraint);
+ $i++;
+ }
+ }
+ else
+ {
+ dolibarr_print_error($this->db);
+ }
+
+ return $constraint;
+ }
+
+ function verifRights($strRights) {
+
+ global $user,$conf,$user;
+
+ if ($strRights != "") {
+ $rights = true;
+
+ $tab_rights = explode(" || ", $strRights);
+ $i = 0;
+ while (($i < count($tab_rights)) && ($rights == true)) {
+ $str = "if(!(" . $strRights . ")) { \$rights = false;}";
+ eval ($str);
+ $i++;
+ }
+ } else
+ $rights = true;
+
+ return $rights;
+ }
+
+ function listeMainmenu()
+ {
+ $sql = "SELECT DISTINCT m.mainmenu";
+ $sql.= " FROM " . MAIN_DB_PREFIX . "menu as m";
+ $sql.= " WHERE m.menu_handler= '".$this->menu_handler."'";
+
+ $res = $this->db->query($sql);
+ if ($res) {
+ $i = 0;
+ while ($menu = $this->db->fetch_array($res)) {
+ $overwritemenufor[$i] = $menu['mainmenu'];
+ $i++;
+ }
+ }
+ else
+ {
+ dolibarr_print_error($this->db);
+ }
+
+ return $overwritemenufor;
+ }
+
+
+ function menutopCharger($type_user,$mainmenu)
+ {
+ global $langs, $user, $conf;
+
+ $sql = "SELECT m.rowid, m.mainmenu, m.titre, m.url, m.langs, m.right";
+ $sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
+ $sql.= " WHERE m.type = 'top'";
+ $sql.= " AND m.menu_handler= '".$this->menu_handler."'";
+ if($type_user == 0) $sql.= " AND m.user <> 1";
+ else $sql.= " AND m.user > 0";
+ $sql.= " ORDER BY m.order";
+
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ $numa = $this->db->num_rows();
+
+ $a = 0;
+ $b = 0;
+ while ($a < $numa)
+ {
+ // Affichage entete menu
+ $objm = $this->db->fetch_object($result);
+
+ if ($this->verifConstraint($objm->rowid))
+ {
+ $langs->load($objm->langs);
+
+ $class="";
+ if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == $objm->mainmenu)
+ {
+ $class='id="sel"';
+ }
+ $chaine="";
+
+ $right = true;
+
+ if ($objm->right)
+ {
+ $str = "if(!(".$objm->right.")) \$right = false;";
+ eval($str);
+ }
+
+ if(eregi("/",$objm->titre))
+ {
+ $tab_titre = explode("/",$objm->titre);
+ $chaine = $langs->trans($tab_titre[0])."/".$langs->trans($tab_titre[1]);
+ }
+ else
+ {
+ $chaine = $langs->trans($objm->titre);
+ }
+
+ $tabMenu[$b]['titre'] = $chaine;
+ $tabMenu[$b]['url'] = $objm->url;
+ $tabMenu[$b]['atarget'] = $this->atarget;
+ $tabMenu[$b]['class'] = $class;
+ $tabMenu[$b]['right'] = $right;
+
+ $b++;
+
+ }
+
+ $a++;
+ }
+ }
+ else
+ {
+ dolibarr_print_error($this->db);
+ }
+
+ return $tabMenu;
+
+ }
+
}
?>