From 9874529706d692b154afa65f1d18a5a7f8a5d305 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 May 2007 16:44:27 +0000 Subject: [PATCH] =?UTF-8?q?Debut=20d'impl=E9mentation=20des=20fonctions=20?= =?UTF-8?q?d'=E9dition=20du=20menu=20en=20standard.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/menus.php | 26 +++++++-- htdocs/admin/menus/index.php | 60 +++++++++++++-------- htdocs/admin/modules.php | 4 +- htdocs/conf/conf.class.php | 2 +- htdocs/includes/modules/modMenuDb.class.php | 55 ++++++++++--------- htdocs/includes/modules/modUser.class.php | 14 ++--- htdocs/langs/en_US/admin.lang | 3 ++ htdocs/langs/fr_FR/admin.lang | 3 ++ htdocs/user/perms.php | 4 +- 9 files changed, 109 insertions(+), 62 deletions(-) diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index 397b9bf0576..494023b4385 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -71,6 +71,21 @@ print_fiche_titre($langs->trans("Menus"),'','setup'); print $langs->trans("MenusDesc")."
\n"; print "
\n"; +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/menus.php"; +$head[$h][1] = $langs->trans("MenuHandlers"); +$head[$h][2] = 'handler'; +$h++; + +$head[$h][0] = DOL_URL_ROOT."/admin/menus/index.php"; +$head[$h][1] = $langs->trans("MenuAdmin"); +$head[$h][2] = 'editor'; +$h++; + +dolibarr_fiche_head($head, 'handler', $langs->trans("Menus")); + + if (isset($_GET["action"]) && $_GET["action"] == 'edit') { @@ -120,7 +135,7 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit') print ''; print ''; - print '
'; + print ''; } else { @@ -163,13 +178,18 @@ else print ''; print ''; +} +print ''; + + +if (! isset($_GET["action"]) || $_GET["action"] != 'edit') +{ print '
'; print ''.$langs->trans("Edit").''; print '
'; } - - + $db->close(); llxFooter('$Date$ - $Revision$'); diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index f1a5a7920c6..bb241a3af16 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -26,19 +26,18 @@ \version $Revision$ */ +require("./pre.inc.php"); - require("./pre.inc.php"); - - - - if (!$user->rights->menudb->creer) + +if (!$user->rights->menudb->creer && ! $user->admin) accessforbidden(); if (isset($_GET["action"]) && $_GET["action"] == 'up') { - $sql = "SELECT m.rowid, m.order FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".$_GET["menuId"]; + $sql = "SELECT m.rowid, m.order FROM ".MAIN_DB_PREFIX."menu as m"; + $sql.= " WHERE m.rowid = ".$_GET["menuId"]; $result = $db->query($sql); $num = $db->num_rows(); @@ -52,7 +51,9 @@ if (isset($_GET["action"]) && $_GET["action"] == 'up') $i++; } - $sql = "SELECT m.rowid, m.order FROM ".MAIN_DB_PREFIX."menu as m WHERE m.order = ".($precedent['order'] - 1)." AND m.level = -1"; + // Menu top + $sql = "SELECT m.rowid, m.order FROM ".MAIN_DB_PREFIX."menu as m"; + $sql.= " WHERE m.order = ".($precedent['order'] - 1)." AND m.type = 'top'"; $result = $db->query($sql); $num = $db->num_rows(); @@ -66,9 +67,13 @@ if (isset($_GET["action"]) && $_GET["action"] == 'up') $i++; } - $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m SET m.order = ".$suivant['order']." WHERE m.rowid = ".$precedent['rowid'].""; // Monte celui select + $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m"; + $sql.= " SET m.order = ".$suivant['order']; + $sql.= " WHERE m.rowid = ".$precedent['rowid'].""; // Monte celui select $db->query($sql); - $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m SET m.order = ".$precedent['order']." WHERE m.rowid = ".$suivant['rowid'].""; // Descend celui du dessus + $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m"; + $sql.= " SET m.order = ".$precedent['order']; + $sql.= " WHERE m.rowid = ".$suivant['rowid'].""; // Descend celui du dessus $db->query($sql); } @@ -89,7 +94,9 @@ if (isset($_GET["action"]) && $_GET["action"] == 'down') $i++; } - $sql = "SELECT m.rowid, m.order FROM ".MAIN_DB_PREFIX."menu as m WHERE m.order = ".($precedent['order'] + 1)." AND m.level = -1"; + $sql = "SELECT m.rowid, m.order"; + $sql.= " FROM ".MAIN_DB_PREFIX."menu as m"; + $sql.= " WHERE m.order = ".($precedent['order'] + 1)." AND type='top'"; $result = $db->query($sql); $num = $db->num_rows(); @@ -119,14 +126,27 @@ llxHeader(); -print_fiche_titre($langs->trans("Admin Menu"),'','setup'); - -print '
'; +print_fiche_titre($langs->trans("Menus"),'','setup'); + +print $langs->trans("MenusEditorDesc")."
\n"; +print "
\n"; + +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/menus.php"; +$head[$h][1] = $langs->trans("MenuHandlers"); +$head[$h][2] = 'handler'; +$h++; + +$head[$h][0] = DOL_URL_ROOT."/admin/menus/index.php"; +$head[$h][1] = $langs->trans("MenuAdmin"); +$head[$h][2] = 'editor'; +$h++; + +dolibarr_fiche_head($head, 'editor', $langs->trans("Menus")); if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') { - - $sql = "SELECT c.rowid, c.fk_constraint FROM ".MAIN_DB_PREFIX."menu_const as c WHERE c.fk_menu = ".$_GET['menuId']; $res = $db->query($sql); if ($res) @@ -355,9 +375,6 @@ if ($res) print ''; print ''; - print '
'; - - print ''; @@ -366,10 +383,9 @@ print '
'; print ''.$langs->trans("NewMenu").''; print '
'; - +$db->close(); - - - +llxFooter('$Date$ - $Revision$'); ?> + diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 5ae3edf056c..4c4736a79d5 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -337,7 +337,7 @@ foreach ($orders as $key => $value) if ($conf->global->$const_name) { // Module actif - if ($family == 'base') print $langs->trans("Required"); + if ($objMod->always_enabled) print $langs->trans("Required"); else print "numero."&action=reset&value=" . $modName . "&mode=" . $mode . "\">" . $langs->trans("Disable") . "\n"; if ($objMod->config_page_url) @@ -375,7 +375,7 @@ foreach ($orders as $key => $value) } else { - if ($family == 'base') + if ($objMod->always_enabled) { // Ne devrait pas arriver. } diff --git a/htdocs/conf/conf.class.php b/htdocs/conf/conf.class.php index 7ff3a7f2c52..bff30a9f886 100644 --- a/htdocs/conf/conf.class.php +++ b/htdocs/conf/conf.class.php @@ -251,7 +251,7 @@ class Conf $this->droitpret->dir_temp=DOL_DATA_ROOT."/droitpret/temp"; // Module menuDb - $this->menudb->enabled=defined("MAIN_MODULE_MENUDB")?MAIN_MODULE_MENUDB:0; + $this->menudb->enabled=1; // Module code barre $this->barcode->enabled=defined("MAIN_MODULE_BARCODE")?MAIN_MODULE_BARCODE:0; diff --git a/htdocs/includes/modules/modMenuDb.class.php b/htdocs/includes/modules/modMenuDb.class.php index 3cd433ae62d..7ae7f901400 100644 --- a/htdocs/includes/modules/modMenuDb.class.php +++ b/htdocs/includes/modules/modMenuDb.class.php @@ -47,43 +47,46 @@ class modMenuDb extends DolibarrModules function modMenuDb($DB) { $this->db = $DB ; - $this->id = 'menudb'; // Same value xxx than in file modXxx.class.php file + $this->id = 'menudb'; // Same value xxx than in file modXxx.class.php file $this->numero = 2300 ; - $this->family = "technic"; - $this->name = "Menu Db"; + $this->family = "base"; // Family for module (or "base" if core module) + $this->name = "Menus"; $this->description = "Administration des menus par base de données"; + + $this->revision = explode(' ','$Revision$'); $this->version = '1.1-beta'; // 'experimental' or 'dolibarr' or version + $this->const_name = 'MAIN_MODULE_MENUDB'; - $this->special = 1; + $this->special = 0; + $this->picto='group'; - // Dir - $this->dirs = array(); + // Dir + $this->dirs = array(); - // Dépendances - $this->depends = array(); - $this->requiredby = array(); + // Dépendances + $this->depends = array(); + $this->requiredby = array(); - // Constantes - $this->const = array(); + // Constantes + $this->const = array(); - // Boxes - $this->boxes = array(); + // Boxes + $this->boxes = array(); + + // Permissions + $this->rights = array(); + $this->rights_class = 'menudb'; + $this->rights_admin_allowed = 1; // Admin is always granted of permission (even when module is disabled) + $r=0; - // Permissions - $this->rights = array(); - $this->rights_class = 'menudb'; - - - $this->rights[2][0] = 2301; - $this->rights[2][1] = 'Créer/modifier les menus'; - $this->rights[2][2] = 'w'; - $this->rights[2][3] = 0; - $this->rights[2][4] = 'creer'; - - - + $r++; + $this->rights[$r][0] = 2301; + $this->rights[$r][1] = 'Configurer les menus'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'creer'; } diff --git a/htdocs/includes/modules/modUser.class.php b/htdocs/includes/modules/modUser.class.php index 368af3128a9..22d52bfa6ca 100644 --- a/htdocs/includes/modules/modUser.class.php +++ b/htdocs/includes/modules/modUser.class.php @@ -48,13 +48,14 @@ class modUser extends DolibarrModules function modUser($DB) { $this->db = $DB ; - $this->id = 'user'; // Same value xxx than in file modXxx.class.php file - $this->numero = 0 ; + $this->id = 'user'; // Same value xxx than in file modXxx.class.php file + $this->numero = 0; - $this->family = "base"; + $this->family = "base"; // Family for module (or "base" if core module) $this->name = "User"; $this->description = "Gestion des utilisateurs (requis)"; - + $this->always_enabled = 1; // Can't be disabled + $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; @@ -80,9 +81,10 @@ class modUser extends DolibarrModules $this->boxes = array(); // Permissions - $this->rights = array(); // L'admin bénéficie toujours des droits de ce module, actif ou non + $this->rights = array(); $this->rights_class = 'user'; - $r=0; + $this->rights_admin_allowed = 1; // Admin is always granted of permission (even when module is disabled) + $r=0; $r++; $this->rights[$r][0] = 251; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index f482da65b6c..2199a6fb089 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -51,6 +51,7 @@ Boxes=Boxes PositionByDefault=Default order Position=Order MenusDesc=Menus managers define content of the 2 menu bars (horizontal bar and vertical bar). +MenusEditorDesc=The menu editor allow you to change content of menus. System=System SystemInfo=System information SystemTools=System tools @@ -117,6 +118,8 @@ ModuleFamilyOther=Other ModuleFamilyTechnic=Tools or System Modules ModuleFamilyExperimental=Experimental modules ModuleFamilyFinancial=Financial Modules (Accountancy/Treasury) +MenuHandlers=Menu handlers +MenuAdmin=Menu editor # Modules Module0Name=Users & groups Module0Desc=Users and groups management diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 0a9b96a5e00..0054fddf809 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -52,6 +52,7 @@ Boxes=Bo PositionByDefault=Position par défaut Position=Ordre MenusDesc=Les gestionnaires de menu définissent le contenu des 2 barres de menus (la barre horizontale et la barre verticale). Il est possible de mettre un gestionnaire différent selon que l'utilisateur soit interne ou externe. +MenusEditorDesc=L'éditeur de menu permet de changer le contenu des menus. Il doit être utilisé avec prudence sous peine de mettre Dolibarr en situation instable nécéssitant une réinstallation pour retrouver un menu cohérent. System=Système SystemInfo=Infos Système SystemTools=Outils Système @@ -118,6 +119,8 @@ ModuleFamilyOther=Autre ModuleFamilyTechnic=Modules outils ou système ModuleFamilyExperimental=Modules expérimentaux (ne pas utiliser en production) ModuleFamilyFinancial=Modules financiers (Compta/trésorerie) +MenuHandlers=Gestionnaires menu +MenuAdmin=Edition menu # Modules Module0Name=Utilisateurs & groupes Module0Desc=Gestion des utilisateurs et groupes diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 3a5c0558598..369813fe76b 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -224,7 +224,7 @@ if ($result) $objMod=$modules[$obj->module]; $picto=($objMod->picto?$objMod->picto:'generic'); - if ($caneditperms && ($obj->module != 'user' || ! $fuser->admin)) + if ($caneditperms && (! $objMod->rights_admin_allowed || ! $fuser->admin)) { // On affiche ligne pour modifier droits print ''; @@ -245,7 +245,7 @@ if ($result) print ''.img_object('',$picto).' '.$objMod->getName(); print ''; - if ($fuser->admin && $obj->module == 'user') + if ($fuser->admin && $objMod->rights_admin_allowed) { // Permission own because admin if ($caneditperms)