From 58708b7cf02129da0a7ee5e3bba85ac72c31f3f5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 22 Oct 2011 11:56:04 +0200 Subject: [PATCH 1/3] Fix: hide php error message if dir not exist --- htdocs/admin/system/modules.php | 8 ++++---- htdocs/user/perms.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index d7f68fbe605..08bcd0329ed 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -1,7 +1,7 @@ - * Copyright (C) 2007 Rodolphe Quiedeville - * Copyright (C) 2010 Regis Houssin +/* Copyright (C) 2005-2009 Laurent Destailleur + * Copyright (C) 2007 Rodolphe Quiedeville + * Copyright (C) 2010-2011 Regis Houssin * * 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 @@ -74,7 +74,7 @@ foreach ($conf->file->dol_document_root as $type => $dirroot) // Load list of modules foreach($modulesdir as $dir) { - $handle=opendir($dir); + $handle=@opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle))!==false) diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 0ebbc059b96..618a9a560c4 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -150,7 +150,7 @@ foreach ($conf->file->dol_document_root as $type => $dirroot) foreach($modulesdir as $dir) { - $handle=opendir($dir); + $handle=@opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle))!==false) From 5a20fa8169c3481b99851791275304d4c03e8a92 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 22 Oct 2011 12:27:31 +0200 Subject: [PATCH 2/3] Fix: uniformize code --- htdocs/admin/perms.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index a62041acd48..c08f3522fff 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -120,15 +120,25 @@ foreach ($modulesdir as $dir) if ($modName) { - include_once($dir."/".$file); - $objMod = new $modName($db); - if ($objMod->rights_class) { + include_once($dir.$file); + $objMod = new $modName($db); - $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; - //print "modules[".$objMod->rights_class."]=$objMod;"; - } + $modules[$objMod->rights_class]=$objMod; + //print "modules[".$objMod->rights_class."]=$objMod;"; + } } } } From 9924b2f17da242cd3ed595b9e071fa53eb0abfbf Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 22 Oct 2011 19:26:25 +0800 Subject: [PATCH 3/3] Fix: use bad object --- htdocs/admin/perms.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index c08f3522fff..c9ed93052fe 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -147,7 +147,6 @@ foreach ($modulesdir as $dir) $db->commit(); - // Affiche lignes des permissions $sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; @@ -159,10 +158,11 @@ $sql.= " ORDER BY r.module, r.id"; $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - $var=True; - $old = ""; + $num = $db->num_rows($result); + $i = 0; + $var = True; + $oldmod = ""; + while ($i < $num) { $obj = $db->fetch_object($result); @@ -176,7 +176,7 @@ if ($result) // Check if permission we found is inside a module definition. If not, we discard it. $found=false; - foreach($objMod->rights as $key => $val) + foreach($modules[$obj->module]->rights as $key => $val) { $rights_class=$objMod->rights_class; if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms)) @@ -190,12 +190,13 @@ if ($result) $i++; continue; } - + // Break found, it's a new module to catch - if ($old <> $obj->module) + if ($oldmod <> $obj->module) { - $objMod=$modules[$obj->module]; - $picto=($objMod->picto?$objMod->picto:'generic'); + $oldmod = $obj->module; + $objMod = $modules[$obj->module]; + $picto = ($objMod->picto?$objMod->picto:'generic'); print ''; print ''.$langs->trans("Module").''; @@ -203,7 +204,6 @@ if ($result) print ''.$langs->trans("Default").''; print ' '; print "\n"; - $old = $obj->module; } $var=!$var;