Debut d'implmentation des fonctions d'dition du menu en standard.

This commit is contained in:
Laurent Destailleur 2007-05-07 16:44:27 +00:00
parent 0b8e4b707b
commit 9874529706
9 changed files with 109 additions and 62 deletions

View File

@ -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$');

View File

@ -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');
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&amp;action=create">'.$langs->trans("NewMenu").'</a>';
print '</div>';
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -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."&amp;action=reset&amp;value=" . $modName . "&amp;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.
}

View File

@ -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;

View File

@ -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';
}

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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)