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 39d05be28e
commit 8ed480df20
2 changed files with 13 additions and 12 deletions

View File

@ -20,7 +20,7 @@
/** /**
* \file htdocs/core/class/menubase.class.php * \file htdocs/core/class/menubase.class.php
* \ingroup core * \ingroup core
* \version $Id$ * \version $Id: menubase.class.php,v 1.25 2011/07/13 22:18:48 eldy Exp $
* \brief File of class to manage dynamic menu entries * \brief File of class to manage dynamic menu entries
* \remarks Initialy built by build_class_from_table on 2008-01-12 14:19 * \remarks Initialy built by build_class_from_table on 2008-01-12 14:19
*/ */
@ -78,7 +78,7 @@ class Menubase
* @param user User that create * @param user User that create
* @return int <0 if KO, Id of record if OK * @return int <0 if KO, Id of record if OK
*/ */
function create($user) function create($user=0)
{ {
global $conf, $langs; global $conf, $langs;

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,7 +1004,9 @@ 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)
{
if (! empty($user->admin)) // FIXME. We must loop on each admin records and make grant on each fuser object. We must removed global $user.
{ {
$user->addrights($r_id); $user->addrights($r_id);
// We reload permissions // We reload permissions
@ -1014,6 +1016,7 @@ class DolibarrModules
} }
} }
} }
}
else else
{ {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
@ -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;