Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2011-10-22 14:24:51 +02:00
commit fedafe5302
3 changed files with 33 additions and 23 deletions

View File

@ -120,15 +120,25 @@ foreach ($modulesdir as $dir)
if ($modName) if ($modName)
{ {
include_once($dir."/".$file); include_once($dir.$file);
$objMod = new $modName($db); $objMod = new $modName($db);
if ($objMod->rights_class) {
$ret=$objMod->insert_permissions(0); // Load all lang files of module
if (isset($objMod->langfiles) && is_array($objMod->langfiles))
{
foreach($objMod->langfiles as $domain)
{
$langs->load($domain);
}
}
// Load all permissions
if ($objMod->rights_class)
{
$ret=$objMod->insert_permissions(0);
$modules[$objMod->rights_class]=$objMod; $modules[$objMod->rights_class]=$objMod;
//print "modules[".$objMod->rights_class."]=$objMod;"; //print "modules[".$objMod->rights_class."]=$objMod;";
} }
} }
} }
} }
@ -137,7 +147,6 @@ foreach ($modulesdir as $dir)
$db->commit(); $db->commit();
// Affiche lignes des permissions // Affiche lignes des permissions
$sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault"; $sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault";
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r";
@ -149,10 +158,11 @@ $sql.= " ORDER BY r.module, r.id";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
$var=True; $var = True;
$old = ""; $oldmod = "";
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
@ -166,7 +176,7 @@ if ($result)
// Check if permission we found is inside a module definition. If not, we discard it. // Check if permission we found is inside a module definition. If not, we discard it.
$found=false; $found=false;
foreach($objMod->rights as $key => $val) foreach($modules[$obj->module]->rights as $key => $val)
{ {
$rights_class=$objMod->rights_class; $rights_class=$objMod->rights_class;
if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms)) if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms))
@ -182,10 +192,11 @@ if ($result)
} }
// Break found, it's a new module to catch // Break found, it's a new module to catch
if ($old <> $obj->module) if ($oldmod <> $obj->module)
{ {
$objMod=$modules[$obj->module]; $oldmod = $obj->module;
$picto=($objMod->picto?$objMod->picto:'generic'); $objMod = $modules[$obj->module];
$picto = ($objMod->picto?$objMod->picto:'generic');
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Module").'</td>'; print '<td>'.$langs->trans("Module").'</td>';
@ -193,7 +204,6 @@ if ($result)
print '<td align="center">'.$langs->trans("Default").'</td>'; print '<td align="center">'.$langs->trans("Default").'</td>';
print '<td align="center">&nbsp;</td>'; print '<td align="center">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
$old = $obj->module;
} }
$var=!$var; $var=!$var;

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -74,7 +74,7 @@ foreach ($conf->file->dol_document_root as $type => $dirroot)
// Load list of modules // Load list of modules
foreach($modulesdir as $dir) foreach($modulesdir as $dir)
{ {
$handle=opendir($dir); $handle=@opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)

View File

@ -150,7 +150,7 @@ foreach ($conf->file->dol_document_root as $type => $dirroot)
foreach($modulesdir as $dir) foreach($modulesdir as $dir)
{ {
$handle=opendir($dir); $handle=@opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)