Fix: Activation of a module must works even when $user not defined (for installer).

This commit is contained in:
Laurent Destailleur
2011-07-13 22:15:19 +00:00
parent 6efa2f87ca
commit c675e91a23

View File

@@ -24,7 +24,7 @@
/** /**
* \file htdocs/includes/modules/DolibarrModules.class.php * \file htdocs/includes/modules/DolibarrModules.class.php
* \brief Fichier de description et activation des modules Dolibarr * \brief Fichier de description et activation des modules Dolibarr
* \version $Id: DolibarrModules.class.php,v 1.160 2011/07/13 21:54:07 eldy Exp $ * \version $Id: DolibarrModules.class.php,v 1.161 2011/07/13 22:15:19 eldy Exp $
*/ */
@@ -926,7 +926,7 @@ class DolibarrModules
/** /**
* Insert permissions definitions related to the module into llx_rights_def * Insert permissions definitions related to the module into llx_rights_def
* @param $reinitadminperms If 1, we also grant them to admin user * @param $reinitadminperms If 1, we also grant them to all admin users
* @return int Number of error (0 if OK) * @return int Number of error (0 if OK)
*/ */
function insert_permissions($reinitadminperms=0) function insert_permissions($reinitadminperms=0)
@@ -1004,12 +1004,15 @@ class DolibarrModules
} }
// If we are into a logged session and we are an admin user, we take permission of new activated module // If we are into a logged session and we are an admin user, we take permission of new activated module
if ($reinitadminperms && ! empty($user->admin)) if ($reinitadminperms)
{ {
$user->addrights($r_id); if (! empty($user->admin)) // FIXME. We must loop on each admin records and make grant on each fuser object. We must removed global $user.
// We reload permissions {
$user->clearrights(); $user->addrights($r_id);
$user->getrights(); // We reload permissions
$user->clearrights();
$user->getrights();
}
} }
} }
} }
@@ -1056,8 +1059,6 @@ class DolibarrModules
*/ */
function insert_menus() function insert_menus()
{ {
global $user;
require_once(DOL_DOCUMENT_ROOT."/core/class/menubase.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/menubase.class.php");
$err=0; $err=0;
@@ -1118,7 +1119,7 @@ class DolibarrModules
if (! $err) if (! $err)
{ {
$result=$menu->create($user); $result=$menu->create();
if ($result > 0) if ($result > 0)
{ {
$this->menu[$key]['rowid']=$result; $this->menu[$key]['rowid']=$result;