diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index 397b9bf05769f287c570e76975874dc3673a3250..494023b4385567d36d292459644c9cb8a70c8e16 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")."<br>\n"; print "<br>\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 '<input class="button" type="submit" value="'.$langs->trans("Save").'">'; print '</center>'; - print '</form><br>'; + print '</form>'; } else { @@ -163,13 +178,18 @@ else print '</tr>'; print '</table>'; +} +print '</div>'; + + +if (! isset($_GET["action"]) || $_GET["action"] != 'edit') +{ print '<div class="tabsAction">'; print '<a class="tabAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Edit").'</a>'; print '</div>'; } - - + $db->close(); llxFooter('$Date$ - $Revision$'); diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index f1a5a7920c61c5a96fb8ce5fca65546eef502507..bb241a3af16227ca511ca01f90630fa877dd00d8 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 '<br>'; +print_fiche_titre($langs->trans("Menus"),'','setup'); -if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') -{ +print $langs->trans("MenusEditorDesc")."<br>\n"; +print "<br>\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 '</tr>'; print '</table>'; - print '<br>'; - - print '</div>'; @@ -366,10 +383,9 @@ print '<div class="tabsAction">'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/admin/menus/edit.php?menuId=0&action=create">'.$langs->trans("NewMenu").'</a>'; print '</div>'; - +$db->close(); - - - +llxFooter('$Date$ - $Revision$'); ?> + diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 5ae3edf056cfbe0490573a8c3a7539524cca7d0c..4c4736a79d5bfdeccd031a1037de5b003e21907e 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 "<a href=\"modules.php?id=".$objMod->numero."&action=reset&value=" . $modName . "&mode=" . $mode . "\">" . $langs->trans("Disable") . "</a></td>\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 7ff3a7f2c527dee30b573bc73e95f47bde5f62d7..bff30a9f886eefe997eaa52d4478064742691bfa 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 3cd433ae62de85518a2cbf66ab6f3c628a881a8e..7ae7f9014000ae2fc846541fec1577b0325c6dee 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 368af3128a9689b53f180ac6e3b21ca9bbbb3ac7..22d52bfa6cad5659ca7e1a1802526c7d840435af 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 f482da65b6ce845f81c8da51ae1ae5eefacaa008..2199a6fb0899f571612960bd25e89bbb0fe87e19 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 0a9b96a5e0021cb96d00738c5eab0b3288403e1a..0054fddf809f951f2931e4aea358dfc082a3d3b7 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 3a5c05585983868fbdc393dd1a32186265806b3e..369813fe76bb32897f19228d257eac0ef7f1319f 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 '<tr '. $bc[$var].'>'; @@ -245,7 +245,7 @@ if ($result) print '<td>'.img_object('',$picto).' '.$objMod->getName(); print '</td>'; - if ($fuser->admin && $obj->module == 'user') + if ($fuser->admin && $objMod->rights_admin_allowed) { // Permission own because admin if ($caneditperms)