Fix: Activation of a module must works even when $user not defined (for installer).
This commit is contained in:
parent
597a99a518
commit
5485706bdc
@ -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;
|
||||
|
||||
|
||||
@ -28,10 +28,10 @@
|
||||
* \file htdocs/filefunc.inc.php
|
||||
* \ingroup core
|
||||
* \brief File that include conf.php file and functions.lib.php
|
||||
* \version $Id: filefunc.inc.php,v 1.17 2011/06/28 12:25:43 hregis Exp $
|
||||
* \version $Id: filefunc.inc.php,v 1.18 2011/07/13 21:19:58 eldy Exp $
|
||||
*/
|
||||
|
||||
define('DOL_VERSION','3.1.0-alpha'); // Also defined in htdocs/install/inc.php (Ex: x.y.z-alpha, x.y.z)
|
||||
define('DOL_VERSION','3.1.0-beta'); // Also defined in htdocs/install/inc.php (Ex: x.y.z-alpha, x.y.z)
|
||||
define('EURO',chr(128));
|
||||
|
||||
// Definition des constantes syslog
|
||||
|
||||
@ -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.159 2011/06/28 20:31:23 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)
|
||||
@ -955,7 +955,7 @@ class DolibarrModules
|
||||
{
|
||||
$r_id = $this->rights[$key][0];
|
||||
$r_desc = $this->rights[$key][1];
|
||||
$r_type = $this->rights[$key][2];
|
||||
$r_type = isset($this->rights[$key][2])?$this->rights[$key][2]:'';
|
||||
$r_def = $this->rights[$key][3];
|
||||
$r_perms = $this->rights[$key][4];
|
||||
$r_subperms = isset($this->rights[$key][5])?$this->rights[$key][5]:'';
|
||||
@ -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;
|
||||
|
||||
@ -22,10 +22,10 @@
|
||||
/** \file htdocs/install/inc.php
|
||||
* \ingroup core
|
||||
* \brief File that define environment for install pages
|
||||
* \version $Id: inc.php,v 1.134 2011/07/11 10:53:37 eldy Exp $
|
||||
* \version $Id: inc.php,v 1.135 2011/07/13 21:19:58 eldy Exp $
|
||||
*/
|
||||
|
||||
define('DOL_VERSION','3.1.0-alpha'); // Also defined in htdocs/master.inc.php (Ex: x.y.z-alpha, x.y.z)
|
||||
define('DOL_VERSION','3.1.0-beta'); // Also defined in htdocs/master.inc.php (Ex: x.y.z-alpha, x.y.z)
|
||||
|
||||
require_once('../core/class/translate.class.php');
|
||||
require_once('../lib/functions.lib.php');
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
/**
|
||||
* \file htdocs/lib/files.lib.php
|
||||
* \brief Library for file managing functions
|
||||
* \version $Id: files.lib.php,v 1.68 2011/07/11 06:23:22 hregis Exp $
|
||||
* \version $Id: files.lib.php,v 1.69 2011/07/13 21:33:38 eldy Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -590,12 +590,13 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
|
||||
* @param disableglob Disable usage of glob like *
|
||||
* @param nophperrors Disable all PHP output errors
|
||||
* @param notrigger Disable all triggers
|
||||
* @param triggercode Code of trigger
|
||||
* @param object Object for trigger
|
||||
* @return boolean True if file is deleted, False if error
|
||||
*/
|
||||
function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0)
|
||||
function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0,$triggercode='FILE_DELETE',$object=null)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
global $object;
|
||||
global $db, $conf, $user, $langs;
|
||||
|
||||
//print "x".$file." ".$disableglob;
|
||||
$ok=true;
|
||||
@ -611,12 +612,13 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0)
|
||||
dol_syslog("Removed file ".$filename,LOG_DEBUG);
|
||||
if (! $notrigger)
|
||||
{
|
||||
if (! is_object($object)) $object=(object) 'dummy';
|
||||
$object->src_file=$file;
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('FILE_DELETE',$object,$user,$langs,$conf);
|
||||
$result=$interface->run_triggers($triggercode,$object,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $errors=$interface->errors; }
|
||||
// Fin appel triggers
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user