Merge pull request #9357 from joseplluis/patch-3
FIX undefined rights_class on modules may lose setup when module disabled
This commit is contained in:
commit
8bd231adb0
@ -6,6 +6,7 @@
|
|||||||
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||||
|
* Copyright (C) 2018 Josep Lluís Amador <joseplluis@lliuretic.cat>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -1328,7 +1329,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
|||||||
|
|
||||||
// Search if cron entry already present
|
// Search if cron entry already present
|
||||||
$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."cronjob";
|
$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."cronjob";
|
||||||
$sql.= " WHERE module_name = '".$this->db->escape($this->rights_class)."'";
|
$sql.= " WHERE module_name = '".$this->db->escape(empty($this->rights_class)?strtolower($this->name):$this->rights_class)."'";
|
||||||
if ($class) $sql.= " AND classesname = '".$this->db->escape($class)."'";
|
if ($class) $sql.= " AND classesname = '".$this->db->escape($class)."'";
|
||||||
if ($objectname) $sql.= " AND objectname = '".$this->db->escape($objectname)."'";
|
if ($objectname) $sql.= " AND objectname = '".$this->db->escape($objectname)."'";
|
||||||
if ($method) $sql.= " AND methodename = '".$this->db->escape($method)."'";
|
if ($method) $sql.= " AND methodename = '".$this->db->escape($method)."'";
|
||||||
@ -1354,7 +1355,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
|||||||
if(is_int($status)){ $sql.= ' status,'; }
|
if(is_int($status)){ $sql.= ' status,'; }
|
||||||
$sql.= " entity, test)";
|
$sql.= " entity, test)";
|
||||||
$sql.= " VALUES (";
|
$sql.= " VALUES (";
|
||||||
$sql.= "'".$this->db->escape($this->rights_class)."', ";
|
$sql.= "'".$this->db->escape(empty($this->rights_class)?strtolower($this->name):$this->rights_class)."', ";
|
||||||
$sql.= "'".$this->db->idate($now)."', ";
|
$sql.= "'".$this->db->idate($now)."', ";
|
||||||
$sql.= ($datestart ? "'".$this->db->idate($datestart)."'" : "NULL").", ";
|
$sql.= ($datestart ? "'".$this->db->idate($datestart)."'" : "NULL").", ";
|
||||||
$sql.= ($dateend ? "'".$this->db->idate($dateend)."'" : "NULL").", ";
|
$sql.= ($dateend ? "'".$this->db->idate($dateend)."'" : "NULL").", ";
|
||||||
@ -1417,7 +1418,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
|||||||
if (is_array($this->cronjobs))
|
if (is_array($this->cronjobs))
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."cronjob";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."cronjob";
|
||||||
$sql.= " WHERE module_name = '".$this->db->escape($this->rights_class)."'";
|
$sql.= " WHERE module_name = '".$this->db->escape(empty($this->rights_class)?strtolower($this->name):$this->rights_class)."'";
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::delete_cronjobs", LOG_DEBUG);
|
dol_syslog(get_class($this)."::delete_cronjobs", LOG_DEBUG);
|
||||||
@ -1795,7 +1796,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
|||||||
$err=0;
|
$err=0;
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."rights_def";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."rights_def";
|
||||||
$sql.= " WHERE module = '".$this->db->escape($this->rights_class)."'";
|
$sql.= " WHERE module = '".$this->db->escape(empty($this->rights_class)?strtolower($this->name):$this->rights_class)."'";
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
dol_syslog(get_class($this)."::delete_permissions", LOG_DEBUG);
|
dol_syslog(get_class($this)."::delete_permissions", LOG_DEBUG);
|
||||||
if (! $this->db->query($sql))
|
if (! $this->db->query($sql))
|
||||||
@ -1833,7 +1834,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
|||||||
$menu->menu_handler='all';
|
$menu->menu_handler='all';
|
||||||
|
|
||||||
//$menu->module=strtolower($this->name); TODO When right_class will be same than module name
|
//$menu->module=strtolower($this->name); TODO When right_class will be same than module name
|
||||||
$menu->module=$this->rights_class;
|
$menu->module=empty($this->rights_class)?strtolower($this->name):$this->rights_class;
|
||||||
|
|
||||||
if (! $this->menu[$key]['fk_menu'])
|
if (! $this->menu[$key]['fk_menu'])
|
||||||
{
|
{
|
||||||
@ -1929,7 +1930,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
|||||||
$err=0;
|
$err=0;
|
||||||
|
|
||||||
//$module=strtolower($this->name); TODO When right_class will be same than module name
|
//$module=strtolower($this->name); TODO When right_class will be same than module name
|
||||||
$module=$this->rights_class;
|
$module=empty($this->rights_class)?strtolower($this->name):$this->rights_class;
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu";
|
||||||
$sql.= " WHERE module = '".$this->db->escape($module)."'";
|
$sql.= " WHERE module = '".$this->db->escape($module)."'";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user