Fix: Activation of a module must works even when $user not defined (for installer).
This commit is contained in:
parent
39d05be28e
commit
8ed480df20
@ -20,7 +20,7 @@
|
||||
/**
|
||||
* \file htdocs/core/class/menubase.class.php
|
||||
* \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
|
||||
* \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
|
||||
* @return int <0 if KO, Id of record if OK
|
||||
*/
|
||||
function create($user)
|
||||
function create($user=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
/**
|
||||
* \file htdocs/includes/modules/DolibarrModules.class.php
|
||||
* \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
|
||||
* @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)
|
||||
*/
|
||||
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 ($reinitadminperms && ! empty($user->admin))
|
||||
if ($reinitadminperms)
|
||||
{
|
||||
$user->addrights($r_id);
|
||||
// We reload permissions
|
||||
$user->clearrights();
|
||||
$user->getrights();
|
||||
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);
|
||||
// We reload permissions
|
||||
$user->clearrights();
|
||||
$user->getrights();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1056,8 +1059,6 @@ class DolibarrModules
|
||||
*/
|
||||
function insert_menus()
|
||||
{
|
||||
global $user;
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/menubase.class.php");
|
||||
|
||||
$err=0;
|
||||
@ -1118,7 +1119,7 @@ class DolibarrModules
|
||||
|
||||
if (! $err)
|
||||
{
|
||||
$result=$menu->create($user);
|
||||
$result=$menu->create();
|
||||
if ($result > 0)
|
||||
{
|
||||
$this->menu[$key]['rowid']=$result;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user